Beauchamp:MRI Data Analysis: Difference between revisions

From OpenWetWare
Jump to navigationJump to search
Line 55: Line 55:
Manual mask
Manual mask


==MEG and MRI==
[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]==MEG and MRI==
Download and install MNE
Download and install MNE
Go to http://www.nmr.mgh.harvard.edu/martinos/userinfo/data/MNE_register/index.php
Go to http://www.nmr.mgh.harvard.edu/martinos/userinfo/data/MNE_register/index.php

Revision as of 13:13, 22 April 2008

Brain picture
Beauchamp Lab Notebook






  1. Internal Wiki (UTHSC-H Only)

MRI

  1. Motion and Distortion Correction
  2. Autism Data
  3. Group analysis with Matlab ANOVAN

Creating Average Time Series

There are three basic steps:

1) Create a mask file

2) Using an AND operation, combine the activation map with the mask file to select only active voxels within the mask

3) Apply the final mask to the deconvolved impulse response function to create time series for each ROI in a subject

4) Move the time series into Excel (or Matlab) to calculate mean and statistics across subjects

In more detail: 1) Create a mask file This can be done in an automated way using pre-defined anatomical ROIs, such as the Zilles Anatomy Toolbox atlas that is included with AFNI or the FreeSurfer parcellation included with SUMA. Manual mask creation can be done with 3dclust (or 3dmerge -1clust_order) to find clusters of active voxels. Or, ROIs can be manually drawn using the Draw Dataset plug-in in AFNI or the Draw ROI tool in SUMA.

To use the drawing tool in SUMA, select Tools, Draw ROI. Click on the Right Mouse Button to draw an outline. When done, click the Join button. The outline will change color. Click in the middle of the ROI to fill it in. The inside of the ROI should change color. Click the Undo button if something goes wrong. If something goes really wrong, just quit the window or SUMA and try again. Once you are happy with the ROI, click Finish. The outline should get thinner.

Draw another ROI and hit Join to close. Then change the number in the Value window, perhaps to the next highest number (e.g. from 1 to 2, from 2 to 3) to differentiate the new ROI from the old ROI. (The label value is optional but it may be useful in switching between ROIs).

When finished drawing All ROIs and you wish to save them, change the "THIS" button to "ALL" to save ALL ROIs. Use the appropriate format (1D or NIML).

The ROIs should be drawn separately for each hemisphere, and then converted to the volume:

3dSurf2Vol -spec /Volumes/data9/surfaces/barker_kathryn/AX/SUMA/both.spec -surf_A rh.smoothwm.asc -grid_parent AXv6dec+orig -sv AX_SurfVol_Alnd_Exp+orig -map_func max -prefix S1lhROIv5 -sdata_1D S1ROIRH.1D.roi

3dSurf2Vol -spec /Volumes/data9/surfaces/barker_kathryn/AX/SUMA/both.spec -surf_A lh.smoothwm.asc -grid_parent AXv6dec+orig -sv AX_SurfVol_Alnd_Exp+orig -map_func max -prefix S1lhROIv6 -sdata_1D S1LH.1D.roi


These volumes are usually combined with the functional dataset so that only active voxels within the drawn ROI are considered.

3dcalc -prefix AXS1 -a S1lhROIv5+orig -b S1lhROIv6+orig -c82 AXv6dec+orig -d109 AXv6dec+orig \ -expr "step(a+b)*step(c-8.4)*(1*step(d-2) + 2*step(-2-d))"

This dataset can then be used to create average timeseries.


Manual mask

[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]==MEG and MRI== Download and install MNE Go to http://www.nmr.mgh.harvard.edu/martinos/userinfo/data/MNE_register/index.php and register. After registering you will be emailed a login password. The webpage makes it seem that an email is sent immediately, but in my experience it took over an hour. After you receive your password login and download the software, also available is the manual and installation instructions. Following steps C.1 - C.2.3 should do it, unless your computer doesn't already have fink on it, in which case follow the instructions available on the internal wiki to install fink. One step you'll have to change, C.1.2 instructs you to type "tar zxvf <filename>", however they seem to longer be using gzip format files, so instead change that to "tar -xvf <filename>".


Run MNE GUI (mne_analyze)

Save a label file format for label file is like this

 # Label from mne_analyze
 2358
 16 -39.8716 -10.9534 17.9286 0
 62 -40.1451 7.47006 5.60055 0
 etc.

Try to create a similar label file in SUMA


two ways: 1) Manually drawing an ROI (ctrl-d in SUMA)

2) 3dVol2Surf

Both MNE and AFNI analysis will need to use the EXACT SAME surface because otherwise the node numbering will be different and the ROIs will not correspond.


Here is a possible way to do this, according to Ziad Saad.


Manually drew an ROI in SUMA, wrote it out to test.1D.roi

 ROI2dataset -prefix test2 -of 1D -input test.1D.roi

This creates a SPARSE dataset where there are only values for some nodes. To create a FULL dataset more similar to a FreeSurfer label file, we must first determine how many nodes are in the original surface e.g.

 more lh.pial.asc

133265 266526

Then, we use the command

 ROI2dataset -prefix test3 -pad_to_node 133264 -input test.1D.roi

This creates a file with one column, zeros for most nodes and a value for the nodes that were drawn on.

However, a label file is in this format:

  1. !ascii label , from subject

124029 0 -8.057 -103.564 3.861 0.000000 1 -8.412 -103.675 3.858 0.000000


1) Create an ROI containing all nodes using 3dVol2Surf -oob or -oob OR draw an ROI, use ROI2dataset to convert to a file with all nodes


2) cat or 1dcat this file with the original surface file (containing the x,y,z co-ordinates of the nodes)

3) Use convertdset to select only those nodes with a value at the nodes

May also have to use SurfToSurf to convert from the fMRI surface (where the label file was created on) to the MEG surface (created separately so it has a different number of nodes).

SurfToSurf -i MEGSurface.asc -i fMRISurface.asc -output_params Data -data LeftMT.ROI.1D


Interpolate ROI file onto another surface file and save as a freesurfer label file

1) Copy the .roi file along with the suface of the hemisphere for that subject into your working folder.

-The original surface file should use the following naming convention: [hemishpere].inflated-MRI.asc

ex: lh.inflated-MRI.asc

NOTE: See Converting to asc Format about converting a surface file to a .asc file

2) Make sure that new surface file for that hemisphere also exists in that folder in the proper freesurfer format (lh.inflated.asc)

3) Set your environment by defining the following 3 variables in the command line where hem is either lh or rh, area is the area of interest, and roi is the name of the .roi file:

setenv hem lh
setenv area mt
setenv roi Left_MT.1D.roi


4) Run the following commands from a command line in the proper working directory:

SurfToSurf -i $hem.inflated-MRI.asc -i $hem.inflated.asc  -prefix $area -node_indices "$roi"'[0]' -output_params NearestNode
1dcat $area.1D'[1]' $area.1D'[1]' $area.1D'[1]' $area.1D'[1]' $area.1D'[1]' > $area-$hem
wc $area-$hem > temp_node
echo "#! " $area > temp_1
echo `1dcat temp_node'[0]'` > temp_2
cat  temp_1 temp_2 $area-$hem > $area-$hem.label
rm -f temp_node
rm -f temp_1
rm -f temp_2
rm -f $area.1D
rm -f $area-$hem

or you can also save the above commands as a file with #!/bin/csh at the very top of the file (save as "batch") and call all of the commands using a single command: csh batch