![]() | FreeSurfer & FSL
| ![]() |
Setup the necessary FreeSurfer environment variables.
tcsh users:
setenv FREESURFER_HOME <wherever>/freesurfer_alpha
setenv SUBJECTS_DIR <wherever>/subjects
source ${FREESURFER_HOME}/FreeSurferEnv.csh
Create subject directory structure.
mksubjdirs blobby
Orient the structural. Take the (analyze format) high resolution structural
and reorient it so that slices shows that its
orientation looks the same as here.
avwswapdim blobby_highres x -z y blobby_highres_reorient
slices blobby_highres_reorient
make sure that L-R is correct! (avwswapdim will warn you if you are
flipping L-R as well as rotating the image)
[Optional - can improve robustness of the early FreeSurfer
stages - use BET to brain-extract input image.]
bet blobby_highres_reorient blobby_highres_reorient_brain -f 0.4
(try 0.4 as this probably should be slightly liberal).
Convert MR data from AVW to COR format.
cd ${SUBJECTS_DIR}/blobby/mri/orig
mri_convert <wherever>/blobby_highres_reorient_brain.img .
or
mri_convert <wherever>/blobby_highres_reorient.img .
Initial processing (Talairaching, bias field correction,
skull stripping, segmentation, cutting, wm surface tesselation,
smoothing and inflation).
recon-all -stage1 -subjid blobby
[Optional - manual editing.]
tkmedit blobby wm lh.smoothwm -aux T1
Alt-C swaps between displaying wm and T1 images. In another terminal, run
tksurfer blobby lh inflated
in tksurfer click anywhere on the surface (such as within a topology
mistake), save the coordinates, then load these coordinates in tkmedit, turn on
tools->edit voxels and remove/add wm voxels with the right/middle
mouse buttons; finally save wm (main volume). Then do the right hemisphere:
tkmedit blobby wm rh.smoothwm -aux T1
and in the other terminal,
tksurfer blobby rh inflated
after again saving wm (main volume), rerun post-segmentation steps
recon-all -stage1 -subjid blobby
Automatic topology fixing.
recon-all -stage3 -subjid blobby
Final surface creation and standard spherical space warping.
recon-all -stage4a -subjid blobby
recon-all -stage4b -subjid blobby
Create an Analyze format version of the FreeSurfer-pre-processed
structural (this has a different field of view than the structural
that was input to FreeSurfer so does need to be created in order to
find the transform between the two spaces)
mri_convert ${SUBJECTS_DIR}/blobby/mri/T1 struc_fs_T1.img
Create registration transforms.
First register the
functional space (eg example_func) to the structural just created,
with FLIRT (probably set DOF=9, and as its orientation has changed
you probably need to set the FLIRT search space to the maximum;
Advanced->Search->Images: Incorrectly oriented), saving the
transform as (eg) func2struc.mat and then convert that to a FreeSurfer
transformation file:
tkregister2 --s blobby --mov example_func.img \
--fslreg func2struc.mat --reg func2struc.dat --noedit
Convert any lowres functional statistic image (eg
thresh_zstat1) to the FreeSurfer surface representation.
mri_vol2surf --src thresh_zstat1.img --src_type analyze --srcreg func2struc.dat \
--hemi lh --projfrac 0.5 --out ./thresh_zstat1-lh.w --out_type paint
mri_vol2surf --src thresh_zstat1.img --src_type analyze --srcreg func2struc.dat \
--hemi rh --projfrac 0.5 --out ./thresh_zstat1-rh.w --out_type paint
(this is creating output for each hemisphere; make sure you include the ./)
View in tksurfer by calling the qsurfer script.
qsurfer -stat thresh_zstat1 -subject blobby -hemi lh -old
qsurfer -stat thresh_zstat1 -subject blobby -hemi rh -old
[Optional: edit the qsurfer script to allow viewing of the sphere]
cp `which qsurfer` my_qsurfer
Edit my_qsurfer; change "set Surface = inflated" to "set Surface =
sphere" (can also view smoothwm, pial or sphere.reg)
./my_qsurfer -stat thresh_zstat1 -subject blobby -hemi lh -old
[Optional: view two non-overlapping thresholded stats images together] if
the second stats image is thresh_zstat2,
avwmaths thresh_zstat1 -sub thresh_zstat2 zdiff
mri_vol2surf --src zdiff.img --src_type analyze --srcreg func2struc.dat \
--hemi lh --projfrac 0.5 --out ./zdiff-lh.w --out_type paint
qsurfer -stat zdiff -subject blobby -hemi lh -old
Create the patch to flatten.
tksurfer blobby lh inflated
Load curvature file (e.g. lh.curv) with File->Curvature. Right
click before making a cut; this will clear previous points. This is
needed because it will string together all the previous places you
have clicked to make the cut. Left click on a line of points. Make the
points fairly close together; if they are too far appart, the cut
fails. After making your line of points, execute the cut by clicking
on the Cut icon (scissors with an open triangle for a line cut or
scissors with a closed triangle for a closed cut). Fill the
patch. Left click in the part of the surface that you want to form
your patch. Then hit the fill button (icon = filled triangle). This
will fill the patch with white. Save the patch through
File->Patch->SaveAs. Save it to something like lh.vis.patch
Flatten the patch.
cd ${SUBJECTS_DIR}/blobby/surf
mris_flatten -w 0 -distances 12 7 lh.vis.patch lh.vis.patch.flat
View the patch.
tksurfer blobby lh inflated
or
qsurfer -stat thresh_zstat1 -subject blobby -hemi lh -old
Then load the patch file lh.vis.patch.flat through File->Patch->Load.
Flatten each subject's highres structural
Transform all N subjects' relevant cope and varcope statistics images into
standard spherical space, but saved as Analyze format files.
mri_vol2surf --src cope1.img --src_type analyze \
--srcreg example_func2highres.dat --hemi lh \
--projfrac 0.5 --trgsubject ico --icoorder 7 \
--out ./cope1-ico-lh.img --out_type analyze4d
Do FEAT statistics on these "spherical standard space" files
(left and right hemispheres separately).
The easiest way (and
one which gives you a sanity results check) to find out what to do to
carry out group-stats is to do a standard (3D) higher-level FEAT
analysis, and extract the relevant design.* files from the resulting
.gfeat directory, whilst finding the command-line flame call from
report.log
Transform the results back onto one subject's inflated
space.
mri_surf2surf --srcsubject ico --srcsurfval groupz-cope1-ico-lh.img \
--src_type analyze4d \
--trgsubject blobby --trgsurfval ./groupz-cope1-blobby-lh.w \
--trg_type paint --hemi lh
qsurfer -stat z-cope1-blobby-group -hemi lh -subject blobby