|
Size: 4049
Comment:
|
Size: 5104
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 4: | Line 4: |
| Be sure to source FreeSurfer before trying to run any of the following scripts. | |
| Line 5: | Line 6: |
| Be sure to source FreeSurfer before trying to run any of the following scripts. | === subjects.csh === Use this script to set the 'SUBJECTS_DIR' and 'TUTORIAL_DIR' parameters, as well as assigning variouos subject data sub-sets (normal subjects, lesioned subjects, both groups). The 'TUTORIAL_DATA' represents the file path of where the tutorial data is being stored. |
| Line 7: | Line 9: |
| subjects.csh | {{{ #!/bin/tcsh -ef |
| Line 9: | Line 12: |
| DiffPreproc.csh | setenv SUBJECTS_DIR $TUTORIAL_DATA/diffusion_recon setenv TUTORIAL_DIR $TUTORIAL_DATA/diffusion_tutorial |
| Line 11: | Line 15: |
| 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. | |
| Line 13: | Line 16: |
| ---- {{{#!/bin/tcsh –ef source $SUBJECTS_DIR/scripts/subjects.csh |
set SUBJECTS = (Diff001 Diff002 Diff003 Diff004 Diff005 Diff006 Diff007 Diff008 Diff009 Diff010) set LESION_SUBJECTS = (LDiff006 LDiff007 LDiff008 LDiff009 LDiff010) set SUBJECTS_AND_LESION_SUBJECTS = (Diff001 Diff002 Diff003 Diff004 Diff005 LDiff006 LDiff007 LDiff008 LDiff009 LDiff010) }}} |
| Line 17: | Line 21: |
| === DiffPreproc.csh === {{{ #!/bin/tcsh –ef # source subjects.csh # Run dt_recon on all subjects |
|
| Line 19: | Line 31: |
| set outdir = $SUBJECTS_DIR/$subj/LZDiff <-----!!*****!! | set outdir = $TUTORIAL_DIR/$subj/dtrecon |
| Line 21: | Line 33: |
| set dicomfile = $SUBEJCTS_DIR/$subj/orig/*-1.dcm | set dicomfile = $TUTORIAL_DIR/$subj/orig/*-1.dcm |
| Line 27: | Line 39: |
| ---- | |
| Line 29: | Line 40: |
| 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 32: | Line 44: |
| === AlignAnat2Diff.csh === {{{ #!/bin/tcsh -ef # |
|
| Line 33: | Line 49: |
| source subjects.csh | |
| Line 34: | Line 51: |
| AlignAnat2Diff.csh Outputs: wmparc2diff.mgz, aparc+aseg2diff.mgz ---- {{{#!/bin/tcsh -ef source $SUBJECTS_DIR/scripts/subjects.csh |
# Loop through each subject |
| Line 44: | Line 54: |
| set outdir = $SUBJECTS_DIR/$subj/LZDiff <-----!!*****!! | set outdir = $TUTORIAL_DIR/$subj/dtrecon |
| Line 46: | Line 56: |
| # For each subject's wmparc and aparc+aseg volumes do... | |
| Line 57: | Line 68: |
| ---- | |
| Line 59: | Line 69: |
| Output: wmparc2diff.mgz, aparc+aseg2diff.mgz. | |
| Line 62: | Line 73: |
| === DiffMasking.csh === {{{ #!/bin/tcsh -ef # |
|
| Line 63: | Line 78: |
| source subjects.csh | |
| Line 64: | Line 80: |
| DiffMasking.csh Outputs: fa-masked.mgz, adc-masked.mgz, ivc-masked.mgz ---- {{{#!/bin/tcsh -ef source $SUBJECTS_DIR/scripts/subjects.csh |
# Loop through each subject |
| Line 74: | Line 83: |
| set outdir = $SUBJECTS_DIR/$subj/LZDiff <-----!!*****!! | set outdir = $TUTORIAL_DIR/$subj/dtrecon |
| Line 76: | Line 85: |
| # Use wmparc2diff.mgz.... | |
| Line 85: | Line 95: |
| ---- |
Output: fa-masked.mgz, adc-masked.mgz, ivc-masked.mgz. |
| Line 90: | Line 99: |
| === AlignAnatCVSToAvg.csh === {{{ #!/bin/tcsh -ef # |
|
| Line 91: | Line 104: |
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_DIR/scripts/subjects.csh |
source subjects.csh |
| Line 101: | Line 107: |
| 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 103: | Line 109: |
| # Loop through each subject | |
| Line 105: | Line 112: |
| set outdir = $SUBJECTS_DIR/$subj/LZDiff <-----!!*****!! | set outdir = $TUTORIAL_DIR/$subj/dtrecon |
| Line 108: | Line 115: |
| 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 111: | Line 119: |
| set outvol = ${vol:r}.ANAT+CVS-to-avg35.v2v.mgz | set outvol = ${vol:r}.ANAT+CVS-to-avg35.mgz |
| Line 113: | Line 121: |
| 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 121: | Line 129: |
| ---- |
Output: fa.ANAT+CVS-to-avg35.v2v.mgz, adc.ANAT+CVS-to-avg35.v2v.mgz, ivc.ANAT+CVS-to-avg35.v2v.mgz. |
| Line 126: | Line 133: |
| === GroupAnalysis.csh === {{{ #!/bin/tcsh -ef |
|
| Line 127: | Line 137: |
| source subjects.csh | |
| Line 128: | Line 139: |
| GroupAnalysis.csh | set outdir = $TUTORIAL_DIR/GLM mkdir -p $outdir |
| Line 130: | Line 142: |
| 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 | # 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 = () |
| Line 132: | Line 147: |
| ---- {{{ 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) <-----!!*****!! |
foreach subj ($SUBJECTS) set inputfiles=($inputfiles $TUTORIAL_DIR/$subj/dtrecon/${prefix}.ANAT+${type}.mgz) end |
| Line 139: | Line 151: |
| set cmd = (mri_concat --i $inputfiles --o $outdir/GroupAnalysis.{$prefix}.${type}.Input.mgz) | set cmd = (mri_concat --i $inputfiles --o $outdir/GroupAnalysis.${prefix}.${type}.Input.mgz) |
| Line 143: | Line 155: |
| # Create average of the input images for visualization | |
| Line 147: | Line 160: |
| 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\ |
| Line 152: | Line 165: |
| ---- | Output: 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. ||Return to [[FsTutorial/Diffusion|Diffusion]] || |
Return to Diffusion |
Be sure to source FreeSurfer before trying to run any of the following scripts.
subjects.csh
Use this script to set the 'SUBJECTS_DIR' and 'TUTORIAL_DIR' parameters, as well as assigning variouos subject data sub-sets (normal subjects, lesioned subjects, both groups). The 'TUTORIAL_DATA' represents the file path of where the tutorial data is being stored.
setenv SUBJECTS_DIR $TUTORIAL_DATA/diffusion_recon setenv TUTORIAL_DIR $TUTORIAL_DATA/diffusion_tutorial set SUBJECTS = (Diff001 Diff002 Diff003 Diff004 Diff005 Diff006 Diff007 Diff008 Diff009 Diff010) set LESION_SUBJECTS = (LDiff006 LDiff007 LDiff008 LDiff009 LDiff010) set SUBJECTS_AND_LESION_SUBJECTS = (Diff001 Diff002 Diff003 Diff004 Diff005 LDiff006 LDiff007 LDiff008 LDiff009 LDiff010)
DiffPreproc.csh
#!/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
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.
Return to Diffusion |
AlignAnat2Diff.csh
#!/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
endOutput: wmparc2diff.mgz, aparc+aseg2diff.mgz.
Return to Diffusion |
DiffMasking.csh
#!/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
endOutput: fa-masked.mgz, adc-masked.mgz, ivc-masked.mgz.
Return to Diffusion |
AlignAnatCVSToAvg.csh
#!/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
endOutput: fa.ANAT+CVS-to-avg35.v2v.mgz, adc.ANAT+CVS-to-avg35.v2v.mgz, ivc.ANAT+CVS-to-avg35.v2v.mgz.
Return to Diffusion |
GroupAnalysis.csh
#!/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 $cmdOutput: 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.
Return to Diffusion |
