Differences between revisions 8 and 9
Deletions are marked like this. Additions are marked like this.
Line 11: Line 11:
Output: dwi.nii, dwi.mghdti.bvecs, dwi.mghdti.bvals, dwi-ec.nii, lowb.nii, bvecs.dat, bvals.dat, eigvec[123].nii, eigvals.nii, tensor.nii, dwirvar.nii, ivc.nii, adc.nii, radialdiff.nii, vr.nii, ra.nii, fa.nii. Output: dwi.nii, dwi.mghdti.bvecs, dwi.mghdti.bvals, dwi-ec.nii, lowb.nii, bvecs.dat, bvals.dat, eigvec[123].nii, eigvals.nii, tensor.nii, dwirvar.nii, ivc.nii, adc.nii, radialdiff.nii, vr.nii, ra.nii, fa.nii, fa-tal.nii, register.dat.
Line 15: Line 15:
#!/bin/tcsh –ef
source $SUBJECTS_DIR/scripts/subjects.csh
 #!/bin/tcsh –ef
 #
Line 18: Line 18:
source subjects.csh

# Run dt_recon on all subjects
Line 20: Line 23:
  set outdir = $SUBJECTS_DIR/$subj/LZDiff <-----!!*****!!   set outdir = $TUTORIAL_DIR/$subj/dtrecon
Line 22: Line 25:
  set dicomfile = $SUBEJCTS_DIR/$subj/orig/*-1.dcm   set dicomfile = $TUTORIAL_DIR/$subj/orig/*-1.dcm
Line 41: Line 44:
#!/bin/tcsh -ef
source $SUBJECTS_DIR/scripts/subjects.csh
 #!/bin/tcsh -ef
 #
Line 44: Line 47:
source subjects.csh

# Loop through each subject
Line 46: Line 52:
  set outdir = $SUBJECTS_DIR/$subj/LZDiff <-----!!*****!!   set outdir = $TUTORIAL_DIR/$subj/dtrecon
Line 48: Line 54:
  # For each subject's wmparc and aparc+aseg volumes do...
Line 72: Line 79:
#!/bin/tcsh -ef
source $SUBJECTS_DIR/scripts/subjects.csh
 #!/bin/tcsh -ef
 #
Line 75: Line 82:
source subjects.csh

# Loop through each subject
Line 77: Line 87:
  set outdir = $SUBJECTS_DIR/$subj/LZDiff <-----!!*****!!   set outdir = $TUTORIAL_DIR/$subj/dtrecon
Line 79: Line 89:
  # Use wmparc2diff.mgz....
Line 101: Line 112:
#!/bin/tcsh -ef
source $SUBJECTS_DIR/scripts/subjects.csh
 #!/bin/tcsh -ef
 #

source subjects.csh
Line 105: Line 118:
set template = /autofs/cluster/con_001/users/lilla/CVS_atlas/buckner35rerun/avg35rerun/mri/norm.mgz <-----!!*****!! set template = $FREESURFER_HOME/subjects/cvs_avg35/mri/norm.mgz
Line 107: Line 120:
# Loop through each subject
Line 109: Line 123:
  set outdir = $SUBJECTS_DIR/$subj/LZDiff <-----!!*****!!   set outdir = $TUTORIAL_DIR/$subj/dtrecon
Line 112: Line 126:
  foreach vol (fa adc ivc) # Uncomment '(fa adc ivc)' and remove '(fa)' to run all three volumes through...
  foreach vol (fa) # (fa adc ivc)
Line 115: Line 130:
    set outvol = ${vol:r}.ANAT+CVS-to-avg35.v2v.mgz     set outvol = ${vol:r}.ANAT+CVS-to-avg35.mgz
Line 117: Line 132:
    set cmd = ( mri_vol2vol --targ $template --m3z $morph --noDefM3zPath --reg $outdir/register.dat --mov $vol\     set cmd = (mri_vol2vol --targ $template --m3z $morph --noDefM3zPath --reg $outdir/register.dat --mov $vol\
Line 138: Line 153:
set outdir = $SUBJECTS_DIR/diffusion_tutorial/GLM
set type = CVS-to-avg35 # alternatively could be TAL-to-avg35 or MNI-to-avg35
set prefix = fa-masked #alternatively could be adc-masked or ivc-masked
set inputfiles = ($outdir/../*/LZDiff/${prefix}.ANAT+${type}.v2v.mgz) <-----!!*****!!
 #!/bin/tcsh -ef
Line 143: Line 155:
set cmd = (mri_concat --i $inputfiles --o $outdir/GroupAnalysis.{$prefix}.${type}.Input.mgz) source subjects.csh

set outdir = $TUTORIAL_DIR/GLM
mkdir -p $outdir

# Assembling input for group analysis
set type = CVS-to-avg35 # alternatively could be 'TAL-to-avg35' or 'MNI-to-avg35'
set prefix = fa-masked #alternatively could be adc-masked or ivc-masked
set inputfiles = ()

foreach subj ($SUBJECTS)
  set inputfiles=($inputfiles $TUTORIAL_DIR/$subj/dtrecon/${prefix}.ANAT+${type}.mgz)
end

set cmd = (mri_concat --i $inputfiles --o $outdir/GroupAnalysis.${prefix}.${type}.Input.mgz)
Line 147: Line 173:
# Create average of the input images for visualization
Line 151: Line 178:
set cmd = ( mri_glmfit --y $outdir/GroupAnalysis.{$prefix}.${type}.Input.mgz --fsgd group_analysis.fsgd\ set cmd = (mri_glmfit --y $outdir/GroupAnalysis.{$prefix}.${type}.Input.mgz --fsgd group_analysis.fsgd\

Return to Diffusion

Be sure to source FreeSurfer before trying to run any of the following scripts.

subjects.csh

DiffPreproc.csh

Output: dwi.nii, dwi.mghdti.bvecs, dwi.mghdti.bvals, dwi-ec.nii, lowb.nii, bvecs.dat, bvals.dat, eigvec[123].nii, eigvals.nii, tensor.nii, dwirvar.nii, ivc.nii, adc.nii, radialdiff.nii, vr.nii, ra.nii, fa.nii, fa-tal.nii, register.dat.


 #!/bin/tcsh –ef
 #

source subjects.csh

# Run dt_recon on all subjects
foreach subj ($SUBJECTS)
  echo $subj
  set outdir = $TUTORIAL_DIR/$subj/dtrecon
  mkdir -p $outdir
  set dicomfile = $TUTORIAL_DIR/$subj/orig/*-1.dcm
  set cmd = (dt_recon --i $dicomfile --s $subj --o $outdir)
  echo $cmd
  eval $cmd
end


Return to Diffusion

AlignAnat2Diff.csh

Outputs: wmparc2diff.mgz, aparc+aseg2diff.mgz


 #!/bin/tcsh -ef
 #

source subjects.csh

# Loop through each subject
foreach subj ($SUBJECTS)
  echo $subj
  set outdir = $TUTORIAL_DIR/$subj/dtrecon

  # For each subject's wmparc and aparc+aseg volumes do...
  foreach vol (wmparc aparc+aseg)
    set vol = $SUBJECTS_DIR/$subj/mri/$vol.mgz
    set vol2diff = ${vol:r}2diff.mgz
    set cmd = (mri_vol2vol --mov $outdir/lowb.nii --targ $vol --inv --interp nearest\
               --o $vol2diff --reg $outdir/register.dat --no-save-reg)
    echo $cmd
    eval $cmd
  end

end


Return to Diffusion

DiffMasking.csh

Outputs: fa-masked.mgz, adc-masked.mgz, ivc-masked.mgz


 #!/bin/tcsh -ef
 #

source subjects.csh

# Loop through each subject
foreach subj ($SUBJECTS)
  echo $subj
  set outdir = $TUTORIAL_DIR/$subj/dtrecon

  # Use wmparc2diff.mgz....
  foreach vol (fa adc ivc)
    set cmd = (mri_mask $outdir/$vol.nii $SUBJECTS_DIR/$subj/mri/wmparc2diff.mgz\
               $outdir/${vol}-masked.mgz)
    echo $cmd
    eval $cmd
  end

end


Return to Diffusion

AlignAnatCVSToAvg.csh

Outputs: fa.ANAT+CVS-to-avg35.v2v.mgz, adc.ANAT+CVS-to-avg35.v2v.mgz, ivc.ANAT+CVS-to-avg35.v2v.mgz


 #!/bin/tcsh -ef
 #

source subjects.csh

set interp = trilin
set template = $FREESURFER_HOME/subjects/cvs_avg35/mri/norm.mgz

# Loop through each subject
foreach subj ($SUBJECTS)
  echo $subj
  set outdir = $TUTORIAL_DIR/$subj/dtrecon
  set morph = $SUBJECTS_DIR/$subj/cvs/fullCVSmorph-to-avg35template.m3z <-----!!*****!!

# Uncomment '(fa adc ivc)' and remove '(fa)' to run all three volumes through...
  foreach vol (fa) # (fa adc ivc)
    set vol = $outdir/${vol}-masked.mgz  # any volume in diffusion space (i.e. fa.nii or adc.nii)
    echo $vol
    set outvol = ${vol:r}.ANAT+CVS-to-avg35.mgz
    echo $outvol
    set cmd = (mri_vol2vol --targ $template --m3z $morph --noDefM3zPath --reg $outdir/register.dat --mov $vol\
                --o $outvol --interp $interp --no-save-reg )
    echo $cmd
    eval $cmd
  end

end


Return to Diffusion

GroupAnalysis.csh

Outputs: gender_age.fa-masked.CVS-to-avg35.glmdir, dof.dat, mri_glmfit.log, y.fsgd, X.mat, contrast/Xg.dat, contrast/rstd.mgz, contrast/rvar.mgz, contrast/beta.mgz, contrast/fwhm.dat, contrast/sar1.mgz, contrast/mask.mgz


 #!/bin/tcsh -ef

source subjects.csh

set outdir = $TUTORIAL_DIR/GLM
mkdir -p $outdir

# Assembling input for group analysis
set type = CVS-to-avg35    # alternatively could be 'TAL-to-avg35' or 'MNI-to-avg35'
set prefix = fa-masked     #alternatively could be adc-masked or ivc-masked
set inputfiles = ()

foreach subj ($SUBJECTS)
  set inputfiles=($inputfiles $TUTORIAL_DIR/$subj/dtrecon/${prefix}.ANAT+${type}.mgz)
end

set cmd = (mri_concat --i $inputfiles --o $outdir/GroupAnalysis.${prefix}.${type}.Input.mgz)
echo $cmd
eval $cmd

# Create average of the input images for visualization
set cmd = (mri_average $inputfiles $outdir/Average.{$prefix}.${type}.Input.mgz)
echo $cmd
eval $cmd

set cmd = (mri_glmfit --y $outdir/GroupAnalysis.{$prefix}.${type}.Input.mgz --fsgd group_analysis.fsgd\
            dods --C contrast.mtx --glmdir $outdir/gender_age.{$prefix}.${type}.glmdir --mgz)
echo $cmd
eval $cmd


FsTutorial/Diffusion/DTIscripts (last edited 2017-03-21 10:59:57 by AllisonMoreau)