Mri binarize: Difference between revisions

From CCN Wiki
Jump to navigation Jump to search
(Created page with "If you have data from different time points, as with the booth data, and want to make comparisons of ROI's across time points you'll want to be looking at the same voxels. Her...")
 
No edit summary
 
(31 intermediate revisions by 5 users not shown)
Line 1: Line 1:
If you have data from different time points, as with the booth data, and want to make comparisons of ROI's across time points you'll want to be looking at the same voxels. Here seems to be the way to do that freesurfer.
* '''This approach has been abandoned -- Check [http://ccnlab.psy.buffalo.edu/wiki/index.php/Working_with_ROIs_(Freesurfer) this] out instead.'''


At this point you should have conducted group stats (glm) and pulled out whatever ROI's of interest. Now you'll convert your group average .annot label file
If you have data from different time points, as with the booth data, and want to make comparisons of ROI's across time points you'll want to be looking at the same voxels. Here's how to do that with freesurfer.
 
At this point you should have conducted group stats (mri_glmfit) and pulled out whatever ROI's are of interest. Now you'll need to convert your group average .annot label file
to a volume, so that we can use the binarize function.
to a volume, so that we can use the binarize function.


For T1 & T2
For T1 & T2
  mri_label2vol --annot T1_rh.200functional_subclusters.annot --temp f.nii --o rh.T1_200funclust.mgz --subject fsaverage --hemi rh --reg reg.2mm.mni152.dat
  mri_label2vol --annot rh.T1_200functional_subclusters.annot --temp T1.mgz --o rh.T1_200funclust.mgz --subject fsaverage --hemi rh --reg reg.mni152.2mm.dat
  mri_label2vol --annot T1_lh.200functional_subclusters.annot --temp f.nii --o lh.T1_200funclust.mgz --subject fsaverage --hemi lh --reg reg.2mm.mni152.dat
  mri_label2vol --annot lh.T1_200functional_subclusters.annot --temp T1.mgz --o lh.T1_200funclust.mgz --subject fsaverage --hemi lh --reg reg.mni152.2mm.dat
mri_label2vol --annot T2_rh.200functional_subclusters.annot --temp f.nii --o rh.T2_200funclust.mgz --subject fsaverage --hemi rh --reg reg.2mm.mni152.dat
mri_label2vol --annot T2_lh.200functional_subclusters.annot --temp f.nii --o lh.T2_200funclust.mgz --subject fsaverage --hemi lh --reg reg.2mm.mni152.dat


mri_label2vol --annot rh.T2_200functional_subclusters.annot --temp T1.mgz --o rh.T2_200funclust.mgz --subject fsaverage --hemi rh --reg reg.mni152.2mm.dat
mri_label2vol --annot lh.T2_200functional_subclusters.annot --temp T1.mgz --o lh.T2_200funclust.mgz --subject fsaverage --hemi lh --reg reg.mni152.2mm.dat


Now that you have volumes, that mri_binarize function will produce 3 volumes with significant voxels set to 1 (or whatever value specified). One with sig. voxels in A but not B, one with sig. voxels in B but not A, and one with overlapping sig. voxels in both A and B.  
Questions: Use fsaverage's T1.mgz as a template, vs the orig.mgz, and from /mri or /mri.2mm?  Registery reg.mni152.2mm.dat vs. reg.2mm.mni152.dat ??
 
 
Now that you have volumes, use the mri_binarize function to set voxels of min values (0.1 seems to grab all voxels) to 1 for T1 and 2 for T2 (specified by binval).


For Left and Right Hemi
For Left and Right Hemi
  mri_binarize
  mri_binarize --i lh.T1_200funclust.mgz --min 0.1 --binval 1 --o lh.T1_bin.mgz
  mri_binarize
  mri_binarize --i lh.T2_200funclust.mgz --min 0.1 --binval 2 --o lh.T2_bin.mgz
   
 
mri_binarize --i rh.T1_200funclust.mgz --min 0.1 --binval 1 --o rh.T1_bin.mgz
mri_binarize --i rh.T2_200funclust.mgz --min 0.1 --binval 2 --o rh.T2_bin.mgz
 
 
Use fscalc to add T1 and T2 for left and right hemi's. This will cause voxels only in T1 to be one, only in T2 to
be 2, and voxels in both to be 3.
fscalc lh.T1_bin.mgz add lh.T2_bin.mgz --o lh.T1andT2.mgz
  fscalc rh.T1_bin.mgz add rh.T2_bin.mgz --o rh.T1andT2.mgz


Then we convert our new volumes back to label files.
The venn diagram is cool, but for the analysis you want the voxels that are coded as 3. When converting the volume
back to a label file, use mri_cor2label and specify labelid as 3.
  mri_cor2label
  mri_cor2label
--i lh.T1andT2.mgz
--id 3
--l lh.T1_T2_200subclust.annot
--surf fsaverage lh
  mri_cor2label
  mri_cor2label
--i rh.T1andT2.mgz
--id 3
--l rh.T1_T2_200subclust.annot
--surf fsaverage rh
This also has options for writing label volume in file and interpreting input volume as surface overlay, which may be more appropriate?




And, finally apply the new annot file to each subject
Now you can check the .annot files by importing them in tksurfer with fsaverage.  -- Error, vertex index out of range, leading me to believe there is an error with the reg file I picked, or that I should use the surface overlay option in mri_cor2label..  More on this later.


For Left and Right Hemi
 
  mri_surf2surf
And, finally apply the new annot file to each subject, for Left and Right Hemi (to run this template as is, you'll have to move the new .annot files into the fsaverage label folder)
  mri_surf2surf \
--srcsubject fsaverage \
--trgsubject FS_T1_501 \
--hemi lh \
--sval-annot $SUBJECTS_DIR/fsaverage/label/lh.T1_T2_200subclust.annot \
--tval $SUBJECTS_DIR/FS_T1_501/label/lh.T1_T2_200subclust.annot
 
mri_surf2surf \
--srcsubject fsaverage \
--trgsubject FS_T1_501 \
--hemi rh \
--sval-annot $SUBJECTS_DIR/fsaverage/label/rh.T1_T2_200subclust.annot \
--tval $SUBJECTS_DIR/FS_T1_501/label/rh.T1_T2_200subclust.annot

Latest revision as of 15:13, 13 July 2017

  • This approach has been abandoned -- Check this out instead.

If you have data from different time points, as with the booth data, and want to make comparisons of ROI's across time points you'll want to be looking at the same voxels. Here's how to do that with freesurfer.

At this point you should have conducted group stats (mri_glmfit) and pulled out whatever ROI's are of interest. Now you'll need to convert your group average .annot label file to a volume, so that we can use the binarize function.

For T1 & T2

mri_label2vol --annot rh.T1_200functional_subclusters.annot --temp T1.mgz --o rh.T1_200funclust.mgz --subject fsaverage --hemi rh --reg reg.mni152.2mm.dat
mri_label2vol --annot lh.T1_200functional_subclusters.annot --temp T1.mgz --o lh.T1_200funclust.mgz --subject fsaverage --hemi lh --reg reg.mni152.2mm.dat
mri_label2vol --annot rh.T2_200functional_subclusters.annot --temp T1.mgz --o rh.T2_200funclust.mgz --subject fsaverage --hemi rh --reg reg.mni152.2mm.dat
mri_label2vol --annot lh.T2_200functional_subclusters.annot --temp T1.mgz --o lh.T2_200funclust.mgz --subject fsaverage --hemi lh --reg reg.mni152.2mm.dat

Questions: Use fsaverage's T1.mgz as a template, vs the orig.mgz, and from /mri or /mri.2mm? Registery reg.mni152.2mm.dat vs. reg.2mm.mni152.dat ??


Now that you have volumes, use the mri_binarize function to set voxels of min values (0.1 seems to grab all voxels) to 1 for T1 and 2 for T2 (specified by binval).

For Left and Right Hemi

mri_binarize --i lh.T1_200funclust.mgz --min 0.1 --binval 1 --o lh.T1_bin.mgz
mri_binarize --i lh.T2_200funclust.mgz --min 0.1 --binval 2 --o lh.T2_bin.mgz
mri_binarize --i rh.T1_200funclust.mgz --min 0.1 --binval 1 --o rh.T1_bin.mgz
mri_binarize --i rh.T2_200funclust.mgz --min 0.1 --binval 2 --o rh.T2_bin.mgz


Use fscalc to add T1 and T2 for left and right hemi's. This will cause voxels only in T1 to be one, only in T2 to be 2, and voxels in both to be 3.

fscalc lh.T1_bin.mgz add lh.T2_bin.mgz --o lh.T1andT2.mgz 
fscalc rh.T1_bin.mgz add rh.T2_bin.mgz --o rh.T1andT2.mgz 

The venn diagram is cool, but for the analysis you want the voxels that are coded as 3. When converting the volume back to a label file, use mri_cor2label and specify labelid as 3.

mri_cor2label
--i lh.T1andT2.mgz
--id 3
--l lh.T1_T2_200subclust.annot
--surf fsaverage lh
mri_cor2label
--i rh.T1andT2.mgz
--id 3
--l rh.T1_T2_200subclust.annot
--surf fsaverage rh

This also has options for writing label volume in file and interpreting input volume as surface overlay, which may be more appropriate?


Now you can check the .annot files by importing them in tksurfer with fsaverage. -- Error, vertex index out of range, leading me to believe there is an error with the reg file I picked, or that I should use the surface overlay option in mri_cor2label.. More on this later.


And, finally apply the new annot file to each subject, for Left and Right Hemi (to run this template as is, you'll have to move the new .annot files into the fsaverage label folder)

mri_surf2surf \
--srcsubject fsaverage \
--trgsubject FS_T1_501 \
--hemi lh \
--sval-annot $SUBJECTS_DIR/fsaverage/label/lh.T1_T2_200subclust.annot \
--tval $SUBJECTS_DIR/FS_T1_501/label/lh.T1_T2_200subclust.annot
mri_surf2surf \
--srcsubject fsaverage \
--trgsubject FS_T1_501 \
--hemi rh \
--sval-annot $SUBJECTS_DIR/fsaverage/label/rh.T1_T2_200subclust.annot \
--tval $SUBJECTS_DIR/FS_T1_501/label/rh.T1_T2_200subclust.annot