Friday, June 18, 2010

Freesurfer on Macaque

There are hardly any good tutorials or references on how one could generate a freesurfer surface using freesurfer. There are many problems to following the standard human analysis that simply does not work well for the macaque brain. Below is a work-in-progress tutorial on how to generate freesurfer surfaces. This tutorial requires FSL and it's associated tools, as well as a working installation of freesurfer. The easiest way of getting all this is to download the VirtualBox image of FreeSurfer from the MGH website and voila!

Anyways, here goes the rough draft:

1. You should have a high-contrast, low noise MPRAGE of your monkey's brain. We typically use 0.35 mm isotropic voxel resolution, and scan between 9 to 12 times (each scan runs for 15 minutes) to generate a good mean image.

2. You should also aquire a T2 image while you acquire your MPRAGEs, as this will make skull extraction (a BIG deal with monkeys) much easier.

3. You must get your images in the orientation that FSL likes (nifti files, with very particular dimension ordering). You can use fslswapdim function for this. If you are converting dicoms from the scanner to nifti's using the mri_convert command (from the FreeSurfer distribution), make sure to pass the "--sphinx" argument to it. After this, run

fslswapdim inputvol.nii LR PA IS outputvol.nii

to correct the dimension directions as FSL likes it. Check with fsl_view.

4. If the images are properly aligned, you can now use the FSL Brain Extraction Tool (BET) to rip out the brain. Here, you can pass the T2 image for a much better skull stripping. Alternatively (haven't tried it, but in theory should work), you can generate a brain mask using the T2 by thresholding it, then filling the volume and cutting the brain out of the hi-res anatomical with this.

5. Once you have a nice clean skull-stripped brain, you'll have to correct for the non-uniform intensity across the image. This can be achieved easily by FreeSurfer's implementation of the MNI's N3 correction tool. Apply this using "mri_nu_correct", as follows:

mri_nu_correct --i skulStrippedBrain.nii --o skull_stripped_nu.nii --distance 24

The distance factor may need to be adjusted, depending on what type of coil you used, and how big your monkey is, etc. Increasing the distance factor makes the program look for lower-frequency modulations of the intensity, whereas smaller numbers (better for phased-array coils) look for higher spatial frequency modulations.

6. You can then use the FSL FAST tool to segment your volume into white, gray, and csf. Output the white matter image for FreeSurfer, and leave the rest alone.

7. Make a new subject directory in keeping with the FreeSurfer system by using mksubjdirs.

8. Now comes the fun part: FreeSurfer wants 1mm isotropic voxels, but your images are 0.35 mm iso, so if you ask FreeSurfer to work with them, it will have to downsample them to 1mm. That's no fun, so we play a trick.

8a. Start Matlab. Make sure to download the NIFTI toolbox from the NIFTI website. Using load_nii, load the image you want to prep, like this:

nii = load_nii('mynifti.nii');

Make sure the nifti file is not compress (not "niil.gz"). Then modify nii.hdr.pixeldim to reflect 1 mm voxel ( = [1 1 1 1 0 0 0], or just replace the 0.35 in the size vector by 1's).

nii.hdr.pixeldim = [1 1 1 1 0 0 0];

Now save the volume, keeping track of what you did:

save_nii(nii, 'newNiftiName.nii');

8b. Finally, convert to MGZ format, and make sure to tell it to CONFORM:

mri_convert -c invol_fake1mm.nii outvol_fake1mm.mgz

Now, do this for all your volumes. Then they'll be ready for FreeSurfer.

9. Fill in your white matter surface:
9a. load in tkmedit, like this:

tkmedit -f /directory/brain.mgz

9b. In tkmedit, make note of the VOXEL coordinates (bottom left of window, top row) for the corpus calosum and the pons.

9c. Go back to the command prompt and exceute the following on the white matter image:

mri_fill -CV 192 172 214 -PV 192 249 194 /subj/mri/wm/wm.mgz ../filled/filled.mgz

where CV and PV reflect the corpus callosum VOXEL coordinates, and PV that of the pons.

9d. Check the results in tkmedit. Should be cute.

10. Now, we follow the recon-all dev table, which uses mri_pretess as follows:

mri_pretess ../filled/filled.mgz 255 ../brain/nu.mgz ../filled-pretess255.mgz

Then,

mri_tessellate ../filled-pretess255.mgz 255 ../lh.orig.nofix

Then,

mris_extract_main_component ../lh.orig.nofix ../lh.orig.nofix

mris_smooth -nw ../lh.orig.nofix ../lh.smoothwm.nofix

mris_inflate -no-save-sulc ../lh.smoothwm.nofix ../lh.inflated.nofix

mris_sphere -q ../lh.inflated.nofix ../lh.qsphere.nofix

And now, repeat this for the righ hemisphere (rh.orig)

3 Comments:

Blogger Unknown said...

I used this a lot - v helpful. I'd never used FS before. It took 6 weeks, but finally got great surfaces.

I got nowhere with the scripts on the freesurfer wiki. these simple steps form an indispensable bedrock.

If like me you have high res exvivo data, and an MTR rather than T1/T2 then it is very important to nuke the crap out of it with nu_correct at a small distance before you do anything else.

there are other ways. More principled ways. But that works.

I removed everything pons down manually in mango, inc the entire cerebellum. that helps a lot.

I found that if you want a surface free of defects (and that still looks like monkey white matter), you will want to make sure it is in LPI orientation and and the midline exactly orthogonal to the floor.

with exvivo data you have no CSF as such. mris_make_surfaces will make a good pial surface eventually. you just have to hustle it with the undocumented parameters for CSF peaks and others.

February 4, 2012 at 10:06 AM  
Blogger Unknown said...

I used this a lot - v helpful. I'd never used FS before. It took 6 weeks, but finally got great surfaces.

I got nowhere with the scripts on the freesurfer wiki. these simple steps form an indispensable bedrock.

If like me you have high res exvivo data, and an MTR rather than T1/T2 then it is very important to nuke the crap out of it with nu_correct at a small distance before you do anything else.

there are other ways. More principled ways. But that works.

I removed everything pons down manually in mango, inc the entire cerebellum. that helps a lot.

I found that if you want a surface free of defects (and that still looks like monkey white matter), you will want to make sure it is in LPI orientation and and the midline exactly orthogonal to the floor.

with exvivo data you have no CSF as such. mris_make_surfaces will make a good pial surface eventually. you just have to hustle it with the undocumented parameters for CSF peaks and others.

February 4, 2012 at 10:09 AM  
Blogger Unknown said...

Thanks for this helpful step-by-step guide. I'm not normally an MRI analyst so I'm not very versed in its ins and outs.

I've followed it through and I've come to the final /...qsphere.nofix file. How can I now view the final product? tksurfer?

-Steven

June 19, 2014 at 5:41 PM  

Post a Comment

<< Home