Activations on 3D rendered brain

From NUTMEGwiki

Jump to: navigation, search

Contents

Creating skull-stripped MRI using BET

  • Add the following line to your .cshrc file in /home/username: setenv FSLOUTPUTTYPE ANALYZE
  • In a new terminal, go to the directory where the full MRI .img file is. For regular MRI: bet originalfile.img originalfile_noskull.img
  • Specific to non-human MRI, do the following instead: bet originalfile.img originalfile_noskull.img -v -r 40 -f 0.7
    • The -v just means some comments will get displayed as it works.
    • -r 40 means it starts off with a skull radius of roughly 40 mm.
    • -f 0.7 means a tradeoff of how much gets removed (too high removes too much brain, too low leaves too much skull.) Play around with this number for each scan, but 0.7 was a good number.
    • You can also use an option -g -0.2 or something like that, which controls if slices have different contrast at the bottom vs. the top. Didn't need it in most cases.

Exporting beamformer images to the Analyze format

For evoked fields

  • Open NUTMEG.
  • Display activation in viewer. Click Special -> save s_beam to Analyze. Give file some appropriate descriptive name, s_beam_name.img
  • While viewing the structural MRI (with or without activation overlaid), set mm to 0.0 0.0 0.0 See what the corresponding voxels are. Round them to the nearest integer (MRIcro only takes integers) and write down these values for later.
  • Close nutmeg.
  • Open SPM2
  • If you aren't sure you have your spm_defaults.m file set correct, type global defaults, then defaults.analyze and verify that defaults.analyze.flip=0
  • Click Display, and open the s_beam_name.img
  • Set mm to 0.0 0.0 0.0 . See what the corresponding voxels are. Round them to the nearest integer (MRIcro only takes integers) and write down these values for later.

For time-frequency beamformer and CTF SAM

  • Open your s_beam file with tv or nut_timef_viewer.
  • Choose the thresholding you want to use for export.
  • To export a single time window, choose the time point and the frequency band you want to export. Then click on menu Special-->Export Analyze Image.
  • To export multiple time windows for a movie (see below, chapter mri3dX), select the frequency band to export. Then, on the matlab command window, type nut_exportmultimg name, with name being any string describing your data.
  • If everything worked correctly, you should have one or several IMG and HDR files in the current directory.

DataViewer3D

  • DataViewer3D is the new hottness.
  • Detailed instructions forthcoming, but for now the procedure is similar to mri3dX and MRIcro (see below). Export functional image as Analyze format as described above. Then start DataViewer3D, load your structural image, then choose the exported Analyze image as the functional overlay.
  • Soon, there will be a button which takes care of this procedure and loads up DataViewer3D directly from NUTMEG's results viewer.
  • To render your activation onto pretty brains, use BET (installed onto the Linux command line by FSL or via the GUI of MRIcro/mri3dX) to brain segment your structural image. Alternatively, FreeSurfer can be used for potentially dazzling results, at the expense of hours of processing time and potentially pulled-out hair. Load the resulting brain-segmented image into DataViewer3D and render...

Overlaying NUTMEG activations onto 3D rendered brain in MRIcro

  • Open MRIcro (startmricro on Linux command line)
  • Open s_beam_*.img
  • Check the values in the origin (vxl) fields. If they are not equals to the values you recorded earlier in SPM2, type in the correct values, and save header.
  • Open *_noskull.img.
  • Make sure that the "size(mm)" values are all positive (sometimes the x field is negative) If it's negative, delete the minus sign, and Header -> save header and yes, overwrite the existing header.
  • Re-save origin fields if also not same as viewed in NUTMEG.
  • Add functional overlay to see if coregistered correctly. Overlay -> Load Functional Overlay Set the threshold to desired level. Scroll through MRI slices to ensure correct coregistration. If it's left-right flipped, you can flip the functional image by File -> Save As then click Flip Right/Left then save intel. This will save the functional with a new name xsbeam_*.img. Reload this overlay, and ensure correct coregistration.
  • Then, to optionally smooth the structural MRI: Etc-> Smooth Image buffer, then Etc -> Save image buffer to disk. This will save it as soriginalfile_noskull.img
  • Then make sure that the "origin" is not 0,0,0, but instead something that makes sense relative to the functional overlay so that they are coregistered (use spm, see below).
  • Then do Etc -> convert anisotropic to isotropic. This will save it as ssoriginalfile_noskull.img
  • If at any point it warns you that an image of that file name already exists, that means it didn't create the new img/hdr pair. It's okay to overwrite headers, but not images.

mri3dX

High quality 3D images

  • Type mri3dX on the Linux command line on a BIL computer. This opens a dialogue for the structural MRI (*.img file). There is a template MRI with excellent 3D rendering that works well for spatially normalized images in /netopt/mri3dX/bx/ch2.img. But you can use any structural MRI in the analyze format. Choose neuroaxial orientation. Leave the Talairach option unchecked. Click go.
  • If you use your own MRI, you must skull strip it with menu Seg-->Show Segment Manager-->FMRIB strip. This starts BET (see above). The 0.5 setting for FMRIB fact thres works in most cases, but you can try to modify it if necessary.
  • Load your functional image (*.img, export in nut_timef_viewer and nut_activation viewer as decribed above) by choosing Menu Fun-->Load Analyze Data.
  • Display 3D image by choosing menu Views-->3D render. This opens a new window. On the top right click b to remove the skull and reveal the brain. By clicking on p you can bring the brain to standard orientations. You can also rotate the brain freely by clicking on it with the right mouse button and moving the mouse. With the buttons rnd and sup, you can render the current settings. Click on Options-->Set total cutaway region to cut the brain and reveal deep regions. I recommend to first move the X2, Y2, and S2 rulers to the far right and remove the whole brain; then you can show the parts you want by playing around with all rulers.
  • Save your image in the bitmap (BMP) format by choosing menu File-->Save BMP.

Making Movies

  • You can export multiple BMP images with mri3dX, and then animate them with the convert program of ImageMagick.
  • You can manually save images of different time points.
  • Or you can run a script by choosing menu File-->ExecuteScript. You can create the scripts with any editor. Here is an example:
yourbmpfilename{
load_anal yourimgname01.img
load_anal yourimgname02.img
load_anal yourimgname03.img
}
  • To make a movie file, type, in the Linux terminal, convert -delay xx *.bmp moviename.mpg. The delay indicates the velocity of the movie (the longer the delay, the slower): delay = 100/samplingrate. If you have a beamformer time window shift of 50 ms, then your samplingrate is 20, and a delay of 5 will produce your animations more or less in real time.
  • The new movie can be viewed with any media player. On our Linux system, you can type mplayer -noaspect -loop 0 moviename.mpg.

More Information

For more detailed info, check out the official site of mri3dX: http://www.aston.ac.uk/lhs/staff/singhkd/mri3dX/mri3dX.jsp