Time Series Data in Surface Space: Difference between revisions
No edit summary |
No edit summary |
||
| Line 43: | Line 43: | ||
done | done | ||
== Running the Script == | |||
A precondition of this script is that the data have been detrended following the [[Detrending_FreeSurfer_Data | procedure for detrending FreeSurfer data]]. A second precondition is that there should be a file called 'runs' in the bold/ directory. If you have followed the instructions for detrending your data, such a file should already exist. | A precondition of this script is that the data have been detrended following the [[Detrending_FreeSurfer_Data | procedure for detrending FreeSurfer data]]. A second precondition is that there should be a file called 'runs' in the bold/ directory. If you have followed the instructions for detrending your data, such a file should already exist. | ||
The script is run in a terminal by specifying the name of an annot file that can be found in the $SUBJECT_ID/label/ directory, a file pattern, followed by a list of subject IDs: | The script is run in a terminal by specifying the name of an annot file that can be found in the $SUBJECT_ID/label/ directory, a file pattern, followed by a list of subject IDs: | ||
gettimecourses.sh lausanne | gettimecourses.sh lausanne fmcpr.sm6.self FS_T1_501 | ||
This creates a series of output files ${sub}_?h_lausanne_${run}.detrend.wav.txt | This creates a series of output files ${sub}_?h_lausanne_${run}.detrend.wav.txt | ||
Revision as of 17:02, 4 May 2016
We can calculate mean time course vectors calculated across all voxels within regions defined in a FreeSurfer annotation (.annot) file. Though any annotation file can be used for this purpose, we have been working at the scale of the 1000 region Lausanne parcellation. A script exists, gettimecourses.sh, that will handle this:
gettimecourses.sh
#!/bin/bash
USAGE="Usage: gettimecourses.sh annot filepattern sub1 ... subN"
if [ "$#" == "0" ]; then
echo "$USAGE"
exit 1
fi
#first two parameters are is the annot files and filepatterns for the \
#.nii.gz time series to be detrended, up to the hemisphere indicator
#e.g., detrend.fmcpr.sm6.self.?h.nii.gz would use detrend.fmcpr.sm6.self as the filepattern
annot="$1"
shift
filepat="$1"
shift
#subjects
subs=( "$@" );
#hemispheres
hemis=( lh rh )
for sub in "${subs[@]}"; do
source_dir=${SUBJECTS_DIR}/${sub}/bold
if [ ! -d ${source_dir} ]; then
#The subject_id does not exist
echo "${source_dir} does not exist!"
else
cd ${source_dir}
readarray -t runs < runs
for hemi in "${hemis[@]}"; do
for r in "${runs[@]}"; do
mri_segstats \
--annot ${sub} ${hemi} ${annot} \
--i ${source_dir}/${r}/${filepat}.${hemi}.mgh \
--sum ${sub}_${hemi}_${seg}_${r}.${filepat}.sum.txt \
--avgwf ${sub}_${hemi}_${seg}_${r}.${filepat}.wav.txt
done
done
fi
done
Running the Script
A precondition of this script is that the data have been detrended following the procedure for detrending FreeSurfer data. A second precondition is that there should be a file called 'runs' in the bold/ directory. If you have followed the instructions for detrending your data, such a file should already exist.
The script is run in a terminal by specifying the name of an annot file that can be found in the $SUBJECT_ID/label/ directory, a file pattern, followed by a list of subject IDs:
gettimecourses.sh lausanne fmcpr.sm6.self FS_T1_501
This creates a series of output files ${sub}_?h_lausanne_${run}.detrend.wav.txt