Time Series Data in MNI Space: Difference between revisions
No edit summary |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
Thanks to Cary for sorting this out. It appears that the process for obtaining mean time series from the mni305 volumes generated by '''preproc-sess''' is very similar to that for [[Time_Series_Data_in_Surface_Space | time series in surface space]] | Thanks to Cary for sorting this out. It appears that the process for obtaining mean time series from the mni305 volumes generated by '''preproc-sess''' is very similar to that for [[Time_Series_Data_in_Surface_Space | time series in surface space]] | ||
After the data have been [[Detrending_FreeSurfer_Data | detrended]], <code>mri_segstats</code> can be called on the detrended volume to extract the average waveform within each of the labeled segments | After the data have been [[Detrending_FreeSurfer_Data | detrended]], <code>mri_segstats</code> can be called on the detrended volume to extract the average waveform within each of the labeled segments. | ||
#Assume ${sub} contains the subject ID | #Assume ${sub} contains the subject ID | ||
Line 13: | Line 13: | ||
This will generate a *.wav.txt file in the current working directory with t=timepoints rows and s=43 columns (1 per segment). | This will generate a *.wav.txt file in the current working directory with t=timepoints rows and s=43 columns (1 per segment). | ||
The following is a script which will automate the process for just the MNI space files. The commands below have been incorporated into the more general gettimecourses.sh scripts, so the code below is appropriate for when surface space data have already been extracted and you wish to go back and get the subcortical data. | |||
'''getmnitimecourses.sh''' | '''getmnitimecourses.sh''' | ||
Line 57: | Line 59: | ||
fi | fi | ||
done | done | ||
=Working with ROIs= | |||
The above code extracts mean time series for all voxels in each labeled region in the aseg.mgz file. However, it is possible to use a masked subcortical segmentation file, which you can [[Working_with_Subcortical_ROIs_(Freesurfer) | create]]. You would use the created mask file in place of the aseg.mgz file in the above example. |
Latest revision as of 14:55, 20 September 2020
Thanks to Cary for sorting this out. It appears that the process for obtaining mean time series from the mni305 volumes generated by preproc-sess is very similar to that for time series in surface space
After the data have been detrended, mri_segstats
can be called on the detrended volume to extract the average waveform within each of the labeled segments.
#Assume ${sub} contains the subject ID #Assume ${r} contains the run number #Assume ${FILEPAT} contains the name of the detrended volume: FILEPAT=fmcpr.siemens.sm7.mni305.2mm.mgh mri_segstats --seg /usr/local/freesurfer/5.3.0/subjects/fsaverage/mri.2mm/aseg.mgz --i ${sub}/bold/${r}/${FILEPAT} \ --ctab /usr/local/freesurfer/5.3.0/FreeSurferColorLUT.txt \ --sum ${sub}/bold/${r}/sum_subcort.txt \ --avgwf ${sub}_${r}.${FILEPAT}.wav.txt
This will generate a *.wav.txt file in the current working directory with t=timepoints rows and s=43 columns (1 per segment).
The following is a script which will automate the process for just the MNI space files. The commands below have been incorporated into the more general gettimecourses.sh scripts, so the code below is appropriate for when surface space data have already been extracted and you wish to go back and get the subcortical data.
getmnitimecourses.sh
#!/bin/bash USAGE="Usage: getmnitimecourses.sh 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., fmcpr.sm6.self.?h.nii.gz would use fmcpr.sm6.self as the filepattern 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 if [ -n "${r}" ]; then mri_segstats \ --seg /usr/local/freesurfer/5.3.0/subjects/fsaverage/mri.2mm/aseg.mgz \ --i ${source_dir}/${r}/${filepat} \ --sum ${sub}_${hemi}_${annot}_${r}.${filepat}.sum.txt \ --ctab /usr/local/freesurfer/5.3.0/FreeSurferColorLUT.txt \ --avgwf ${sub}_${hemi}_${annot}_${r}.${filepat}.wav.txt fi done done fi done
Working with ROIs
The above code extracts mean time series for all voxels in each labeled region in the aseg.mgz file. However, it is possible to use a masked subcortical segmentation file, which you can create. You would use the created mask file in place of the aseg.mgz file in the above example.