User Tools

Site Tools


mirecc:mireccanat:first_seg

FIRST Segmentation

Assuming you've already converted your data into nifti, and flipped to LAS, the following code will run all of the available segmentations with FIRST.

  • its also possible to run individual regions
run FIRST
 
run_first_all INPUT_T1 BOUNDARY_CORRECTION_THRESH OUT_PREFIX 
ex: /code/run_first_all T1_flip 3 12345 
##the run_first_all script in the /code/ directory has been changed to use a brainmask 

The boundary correction threshold is a zscore of how strict your want FIRST to be concerning the borders of your ROIs.

  • all ROIs are run individually, so this threshold will not remove overlapping ROIs.
  • FIRST will run all subcortical regions individually, then merge them into a single 4D file.
  • The 1st image in the file contains all segmentations with corresponding label values.
  • The overlap has been labeled by adding the values from the individual regions together (ex: region A = 10, region B = 11 … overlap = 21)

:mirecc:mireccanat:mirecc_first_seg.jpg —-

re-create FIRST boundary corrected ROIs

the boundary corrected ROIs need to be regenerated from the remaining first VTK meshes.

#!/bin/bash 
 
SUBJ=$1 
FIRSTDIR=/path/to/first/segmentations/$SUBJ/firstSeg 
OUTDIR=~/path/to/put/regenerated/segmentations/$SUBJ 
 
######for first volumes 
for region in R_Amyg L_Amyg R_Accu L_Accu R_Hipp L_Hipp R_Caud L_Caud; do 
##recreate the individual first volumes from remaining VTK 
first_utils --meshToVol -i $FIRSTDIR/T1_flip -m $FIRSTDIR/${SUBJ:9}-${region}_first.vtk -o ${OUTDIR}/tmp_${region} 
 
##boundary correct the volumes using the same correction originally used while running FIRST 
first_utils --singleBoundaryCorr -i ${OUTDIR}/tmp_${region} -r $FIRSTDIR/T1_flip -p 4 -o ${OUTDIR}/tmp_${region}_corr4 
done 
 
##create ROIs, by adding the L and R together (optional) 
##here the R will always equal 2 because the mask has been multiplied by 2 before adding the the L side 
fslmaths ${OUTDIR}/tmp_R_Amyg_corr4 -mul 2 -add ${OUTDIR}/tmp_L_Amyg_corr4 $OUTDIR/amyg_first 
fslmaths ${OUTDIR}/tmp_R_Accu_corr4 -mul 2 -add ${OUTDIR}/tmp_L_Accu_corr4 $OUTDIR/accu_first 
fslmaths ${OUTDIR}/tmp_R_Caud_corr4 -mul 2 -add ${OUTDIR}/tmp_L_Caud_corr4 $OUTDIR/caud_first 
fslmaths ${OUTDIR}/tmp_R_Hipp_corr4 -mul 2 -add ${OUTDIR}/tmp_L_Hipp_corr4 $OUTDIR/hipp_first 
 
##remove the temporary files written above 
rm ${OUTDIR}/tmp_* 
measure volumes
  • since we know that the L always = 1, and the R always = 2 (from the above code), volumes can be measure with the fslstats command.
  • this can be done via the command line, or in script form
##creates and empty txt file 
touch $OUTDIR/first_vols.txt 
for input in amyg_first hipp_first accu_first caud_first; do 
echo "$OUTDIR/$input L" >> $OUTDIR/first_vols.txt 
fslstats $OUTDIR/$input -u 1.1 -V >> $OUTDIR/first_vols.txt 
echo "$OUTDIR/$input R" >> $OUTDIR/first_vols.txt 
fslstats $OUTDIR/$input -l 1.1 -V >> $OUTDIR/first_vols.txt 
done 
mirecc/mireccanat/first_seg.txt · Last modified: 2014/08/04 16:03 (external edit)