OSGM Script: Difference between revisions
Line 9: | Line 9: | ||
HEMIS=( lh rh ) #Which hemispheres are you analyzing? Possible choices are [lh | rh | mni305] | HEMIS=( lh rh ) #Which hemispheres are you analyzing? Possible choices are [lh | rh | mni305] | ||
ANALYSES=( LDT.fsaverage.sm4.down ) #Name of the analysis directory created by mkanalysis-sess | ANALYSES=( LDT.fsaverage.sm4.down ) #Name of the analysis directory created by mkanalysis-sess | ||
CONTRASTS=( task w-v-pw hi-v-lo ) #Names of all contrasts you're interested in | CONTRASTS=( <span style="color:red">task</span> w-v-pw hi-v-lo ) #Names of all contrasts you're interested in | ||
for hemi in "${HEMIS[@]}" | for hemi in "${HEMIS[@]}" |
Revision as of 12:26, 28 September 2017
A BASH script can be written to take the tedium out of running group level analyses for multiple contrasts.
Example Script
Below is a script I wrote to run mri_glmfit and mri_glmfit-sim on a set of 3 contrasts. It accomplishes this by executing the commands within a nested loop.
#!/bin/bash
SUBJECTS_DIR=`pwd`
RFXDIR=RFX #This is the name of the directory into which the group-level analyses will go
HEMIS=( lh rh ) #Which hemispheres are you analyzing? Possible choices are [lh | rh | mni305]
ANALYSES=( LDT.fsaverage.sm4.down ) #Name of the analysis directory created by mkanalysis-sess
CONTRASTS=( task w-v-pw hi-v-lo ) #Names of all contrasts you're interested in
for hemi in "${HEMIS[@]}"
do
for anls in "${ANALYSES[@]}"
do
#the analysis directory contains each contrast directory
ANDIR=${SUBJECTS_DIR}/${RFXDIR}/${anls}.${hemi}
#move to analysis directory for the first time
cd ${ANDIR}
for con in "${CONTRASTS[@]}"
do
cd ${con}
pwd
mri_glmfit --y ces.nii.gz --wls cesvar.nii.gz --osgm \
--surface fsaverage ${hemi} --glmdir glm.wls --nii.gz
#correct for multiple comparisons
mri_glmfit-sim --glmdir glm.wls --cache 2 pos --cwpvalthresh .025
cd ${ANDIR} #go back to the analysis directory
done
done
done
This script ran mri_glmfit on the fsaverage surface for each hemisphere/surface appearing in the HEMIS array. The output volumes go into the glmdir (in this case a directory called glm.wls) and will be saved as gzipped .nii files. The script also did cluster size thresholding using a cached Monte Carlo simulation with uncorrected .01 ("cache 2", or p=10E-02) p-values for positive t-scores. The thresholding was corrected by dividing .05 by 2, the total number of surfaces examined. A more clever way would be to determine the cwpvalthresh by calling the Unix bc function to calculate it according to the size of the HEMIS array.
What values do I use for ANALYSES and CONTRASTS?
The above script runs in nested for-loops that iterate through each entry in the ANALYSES and CONTRASTS arrays. The script comments tell you what these array values represent, but you might not be clear what the correct values should be.
Analyses
When you ran mkanalysis-sess in your SUBJECTS_DIR
, 1, 2 or 3 directories were created, and will be sitting along-side your individual participant directories. These will have names like my_analysis.lh, my_analysis.rh, and my_analysis.mni305. In this case, your ANALYSES array declaration should read like:
ANALYSES=( my_analysis )
Where you omit the part of the directory name that indicates the surface/space (lh/rh/mni305). It is our usual practice to use analysis folder names that give some indication of the nature of the processing that was done, and the surface that was used (self or fsaverage). In the above script, the analysis folder is called LDT.fsaverage.sm4.down because it used par-files called LDT, used the fsaverage surface for the first-level analysis, and the data used a 4mm smoothing kernel and were slice-time corrected in the down direction.
Contrasts
In the analysis directory will be a series of .mat files: one for each contrast you defined using mkcontrast-sess. Your matrix of contrast names should be the names of each of these contrasts you would like to see at the group level -- just omit the .mat part of the filename.