My brain in many flavors
Below are some pictures of my own brain.
The images above were generated by freesurfer.
Below are some pictures of my own brain.
The images above were generated by freesurfer.
Assume CON14 is our subject ID and it is inside directory $SUBJECTS_DIR.
After the display window and the control panel pops up, try playing with the menus and buttons.
tkmedit for volume
tkmedit CON14 rawavg.mgz tkmedit CON14 rawavg.mgz lh.pial -aux-surface rh.pial File > Load Segmentation > (for "Load Volume") aparc+aseg.mgz (for "Load Color Table") FreeSurferColorLUT.txt
tksurfer for surface
tksurfer CON14 lh inflated tksurfer CON14 lh pial tksurfer CON14 rh pial File > Label > Import Annotation > (browse to) lh.aparc.annot
tkregister2 for check registration
tkregister2 --s CON14 --fstal
recon-all is a batch program and runs >30 steps. It easily takes 30 hours to finish one subject.
Use tkmedit CON14 T1.mgz and tksurfer CON14 lh inflated to visualize images. More about visualization with freesurfer.
Note: commands are in green. They are copied from the log files.
View images for every step here
Before you start, you need to put the structural images into certain directory hierarchy and set environment variable. Assume folder “structural” is where subjects’ structural images are. Under “structural”, you have folders “SUBJ1″, “SUBJ2″, “CON14″ etc for every subject. You will have to put your structural images to “structural/SUBJ1/mri/orig/001.mgz”. If you have multiple images for this subject, use “002.mgz” etc. (If you original file format is not mgz, check out how to convert image formats).
structural
|--SUBJ1
|--mri
|--orig
|--001.mgz
|--002.mgz
Then set environment variable in linux shell:
setenv SUBJECTS_DIR $PWD
cp CON14/mri/orig/001.mgz CON14/mri/rawavg.mgzmri_convert CON14/mri/rawavg.mgz CON14/mri/orig.mgz --conformmri_nu_correct.mni --i orig.mgz --o nu.mgz --n 2talairach_avi --i nu.mgz --xfm transforms/talairach.auto.xfmtkregister2 --s subjid --fstal. tkregister2 allows you to compare the orig volume against the talairach volume resampled into the orig space. Run “tkregister2 –help” for more information. Creates the files mri/transform/talairach.auto.xfm and talairach.xfm.mri_normalize -g 1 nu.mgz T1.mgzmri_em_register -skull nu.mgz /usr/local/freesurfer/average/RB_all_withskull_2008-03-26.gca transforms/talairach_with_skull.ltamri_em_register -mask brainmask.mgz nu.mgz /usr/local/freesurfer/average/RB_all_2008-03-26.gca transforms/talairach.ltamri_ca_normalize -mask brainmask.mgz nu.mgz /usr/local/freesurfer/average/RB_all_2008-03-26.gca transforms/talairach.lta norm.mgz
Further normalization, based on GCA model. Creates mri/norm.mgz.
mri_ca_register -align-after -nobigventricles -mask brainmask.mgz -T transforms/talairach.lta norm.mgz /usr/local/freesurfer/average/RB_all_2008-03-26.gca transforms/talairach.m3zmri_remove_neck -radius 25 nu.mgz transforms/talairach.m3z /usr/local/freesurfer/average/RB_all_2008-03-26.gca nu_noneck.mgzmri_em_register -skull -t transforms/talairach.lta nu_noneck.mgz /usr/local/freesurfer/average/RB_all_withskull_2008-03-26.gca transforms/talairach_with_skull.ltamri_ca_label -align -nobigventricles norm.mgz transforms/talairach.m3z /usr/local/freesurfer/average/RB_all_2008-03-26.gca aseg.auto_noCCseg.mgzmri_cc -aseg aseg.auto_noCCseg.mgz -o aseg.auto.mgz CON14mri_normalize -aseg aseg.mgz -mask brainmask.mgz norm.mgz brain.mgzmri_mask -T 5 brain.mgz brainmask.mgz brain.finalsurfs.mgzmri_segment brain.mgz wm.seg.mgzmri_edit_wm_with_aseg -keep-in wm.seg.mgz brain.mgz aseg.mgz wm.asegedit.mgzmri_pretess wm.asegedit.mgz wm norm.mgz wm.mgzmri_fill -a ../scripts/ponscc.cut.log -xform transforms/talairach.lta -segmentation aseg.auto_noCCseg.mgz wm.mgz filled.mgzmri_pretess ../mri/filled.mgz 255 ../mri/norm.mgz ../mri/filled-pretess255.mgzmri_tessellate ../mri/filled-pretess255.mgz 255 ../surf/lh.orig.nofixmris_extract_main_component ../surf/lh.orig.nofix ../surf/lh.orig.nofixmris_smooth -nw ../surf/lh.orig.nofix ../surf/lh.smoothwm.nofixmris_inflate -no-save-sulc ../surf/lh.smoothwm.nofix ../surf/lh.inflated.nofixmris_sphere -q ../surf/lh.inflated.nofix ../surf/lh.qsphere.nofixmris_fix_topology -mgz -sphere qsphere.nofix -ga CON14 lhmris_euler_number ../surf/lh.origmris_remove_intersection ../surf/lh.orig ../surf/lh.origmris_make_surfaces -noaparc -mgz -T1 brain.finalsurfs CON14 lhmris_calc -o lh.area.mid lh.area add lh.area.pialmris_calc -o lh.area.mid lh.area.mid div 2mris_calc -o lh.volume lh.area.mid mul lh.thickness] Cortical Ribbon Mask (-<no>cortribbon)mris_smooth -n 3 -nw ../surf/lh.white ../surf/lh.smoothwmmris_inflate ../surf/lh.smoothwm ../surf/lh.inflatedmris_curvature -thresh .999 -n -a 5 -w -distances 10 10 ../surf/lh.inflatedmris_sphere ../surf/lh.inflated ../surf/lh.spheremris_register -curv ../surf/lh.sphere /usr/local/freesurfer/average/lh.average.curvature.filled.buckner40.tif ../surf/lh.sphere.regmrisp_paint -a 5 /usr/local/freesurfer/average/lh.average.curvature.filled.buckner40.tif#6 ../surf/lh.sphere.reg ../surf/lh.avg_curvCheck out recon-all manual in freesurfer wiki.
[this post is under frequent updating]
Retinotopy analysis consists two parts, one on high resolution structural images (segmentation, inflation, cut, etc), the other on functional images.
structural
Before you start, you need to put the structural images into certain directory hierarchy and set environment variable. Assume folder “structural” is where subjects’ structural images are. Under “structural”, you have folders “SUBJ1″, “SUBJ2″, “CON14″ etc for every subject. You will have to put your structural images to “structural/SUBJ1/mri/orig/001.mgz”. If you have multiple images for this subject, use “002.mgz” etc. (If you original file format is not mgz, check out how to convert image formats).
structural
|--SUBJ1
|--mri
|--orig
|--001.mgz
|--002.mgz
Then set environment variable in linux shell:
setenv SUBJECTS_DIR $PWD
recon-all -all -subjid CON14tksurfer CON14 lh inflated


mris_flatten -w 0 -distances 20 7 lh.occip.patch.3d lh.occip.patch.flatfunctional
Under SUBJ01, create a file called “subjectname” with one line string “SUBJ1″ — assuming “SUBJ1″ is this subject’s name under “structural” folder. This file is to link this subject’s functional and structural data.
Create file sessid under retinotopy. In this file each line is the folder’s name for each subject.
retinotopy
|--sessid
|--SUBJ01
|--subjectname
|--bold
|--001
|--f.nii
|--rtopy.par
|--002
|--f.nii
|--rtopy.par
Please refer to freesurfer’s wiki for detailed explanation. And the following diagram is very helpful:

In rtopy.par file, write two lines
stimtype eccen
direction pos
or
stimtype polar
direction neg
mkanalysis-sess.new -a rtopy -TR 2 -designtype retinotopy -paradigm rtopy.par -funcstem fmcsm5 -ncycles 8
Note: ncycles is the number of periods in each run of either ecc or mm. For example, if you have 10 steps going from a small circle to a big circle in ecc, and repeat this for 4 times, then ncycles=4.preproc-sess -sf sessid -fwhm 5preproc-sess -s SUBJ01 -fwhm 5tkregister-sess -sf sessid -regheaderfslregister-sess -sf sessidsfa-sess -a rtopy -sf sessidsliceview-sess -sf sessid -a rtopy -c eccen -map h -slice mossliceview-sess -sf sessid -a rtopy -c polar -map h -slice mospaint-sess -a rtopy -sf sessidsurf-sess -sf sessid -a rtopy -retinotopy fieldsign -flat
surf-sess -sf sessid -a rtopy -retinotopy eccen -flat
surf-sess -sf sessid -a rtopy -retinotopy polar -flat
surf-sess -sf sessid -a rtopy -c polar -flatFor single file to single file conversion, you usually use mri_convert of freesurfer. For example
mri_convert x.img y.nii
Other options would be LONI Debabeler or MRICro.
Here are some special cases:
multiple 3D ANALYZE to a single 4D Nifti: mri_concat
mri_concat is a program of freesurfer. Assume the original image files are f001.img, f002.img … etc. The output file is f.nii.
mri_concat f???.img --o f.nii
You can also use FSL’s fslmerge to achieve the same thing (but pay attention to your fsl environment setting for default output format).
multiple DICOM to other format
To convert DICOM files to other format, use mri_convert
mri_convert I0001.dcm T1.mgz
If you have a bunch of DICOM files (slices) for a single brain, you only need to input the 1st one as the argument of mri_convert.
Another way is to use SPM’s DICOM import. In the end you get ANALYZE files.
GE 7 file to ANALYZE or Nifti: makevols and makenifti
.7 files are functional images produced by GE scanners in Stanford. You use makevols to convert.
makevols E*P*.7 I rename I.V I_ I.V*
You will get a bunch of .img/.hdr files.
To make a Nifti file, you run
makenifti Efilename outfilename
The output is a single nii file (outfilename.nii).
Note: If you rename the .7 files, you might not get makevols to work. For example, if you rename P06144.7 to P06144_mer1.7, makevols doesn’t work (only produces a lot .hdr files but not .img files).
makevols and makenifti are written by Dr. Gary Glover at Stanford University. Here you can download the two programs.
Check out here to see how to convert images with different number of bytes per voxel.