Hi,
I have been following the diffusion analysis workflow on the freesurfer wiki. I am at the last stage before gorup analysis. I have registered the diffusion data to each individual subject’s T1 image. Now I am at the point where I want to register that to common space. I am working with a pediatric population and I would like to use the NIHPD atlas.
This is the script I used, trying out a couple of atlases. Question 1: Is it ok I use the nifti file for the atlas like that? 2. It worked, but when I view the registered images each of the planes are rotated counterclockwise, so if I were to try to visually check which template had best registration, I cannot tell because obviously they will not align properly. What would cause that rotation?
Here is my script:
#!/bin/tcsh -ef
# Source the subjects file which contains the list of subjects
source subjects.csh
# Define the interpolation method
set interp = trilin
# Define the templates
set templates = ( \
/opt/data/bin/TRIO_Y_NDC.nii \
/opt/data/bin/stealth_atlas_3to10.nii \
/opt/data/bin/stealth_atlas_11to18.nii \
/opt/data/bin/nihpd_sym_04.5-18.5_t1w.nii \
/opt/data/bin/nihpd_sym_13.0-18.5_t2w.nii \
/opt/data/bin/nihpd_sym_4to8_t2w_t88.nii \
/opt/data/bin/nihpd_sym_13to18_t2w_t88.nii \
)
# Loop through each subject
foreach subj ($SUBJECTS)
echo "Processing subject: $subj"
# Define the subject directory and output directory
set subjdir = $SUBJECTS_DIR/$subj
set atlas_dir = /opt/data/processed/cp/source/$subj/atlas
set outdir = /opt/data/processed/cp/source/$subj/outdir
# Ensure the subject directory exists
if (! -d $subjdir) then
echo "Subject directory $subjdir does not exist. Skipping subject $subj."
continue
endif
# Ensure the ATLAS directory exists
if (! -d $atlas_dir) mkdir -p $atlas_dir
# Define the path to the moving file
set mov_file = $subjdir/mri/orig.mgz
# Check if the moving file exists
if (! -f $mov_file) then
echo "Moving file $mov_file does not exist. Skipping subject $subj."
continue
endif
# Loop through each template for resampling
foreach template ($templates)
set template_base = `basename $template .nii`
echo "Processing template: $template"
# Define the paths to the m3z and output files for the current template
set m3z_file = $atlas_dir/fullMorph-to-${template_base}.m3z
set out_file = $atlas_dir/fullMorph-to-${template_base}.mgz
# Run the mri_vol2vol command to create the morph file if it doesn't exist
echo "Creating morph file: $m3z_file"
if (! -f $m3z_file) then
mri_vol2vol --mov $mov_file --targ $template --regheader --o $out_file --s $subj
if ($status != 0) then
echo "Error creating morph file $m3z_file. Skipping subject $subj."
continue
endif
endif
# Resample the fa-masked.mgz, adc-masked.mgz, and ivc-masked.mgz to common space
foreach vol (fa adc ivc)
set volfile = $outdir/${vol}-masked.mgz
if (! -f $volfile) then
echo "Volume file $volfile does not exist. Skipping volume $vol for subject $subj."
continue
endif
echo "Resampling volume: $volfile using template: $template"
set outvol = $outdir/${vol}-masked-to-${template_base}.mgz
echo "Output volume: $outvol"
set cmd = (mri_vol2vol --targ $template --noDefM3zPath --reg $outdir/register.dat --mov $volfile --o $outvol --interp $interp --no-save-reg)
echo $cmd
eval $cmd
end
end
end
#diffusion dti freesurfer #spatialnormalization registration #nihpd