For steps on doing an exvivo recon, see the ExvivoRecon wiki.

Unpack Dicoms

(Finishes fairly quickly)

mksubjdirs <yourscan> (this command makes all the relevant freesurfer directories i.e. mri, surf, etc.)

Unpack dicoms from their location:

unpacksdcmdir -scanonly scan.log -src . -targ .

Convert Dicoms to mgz Files

(Finishes fairly quickly)

To convert multiple runs of single echo data to .mgz format:

foreach r (3 4 5 6 7)
mri_convert *-${r}-1.dcm  /path/where/you/want/yourscan_run${r}.mgz
end

Change the run numbers [i.e. (3 4 5 6 7)] to what is appropriate based on the number of runs collected (scan.log, created when unpacking, has this info).

For multiecho:

foreach e (0 1 2 3 4 5 6 7)
  mri_convert -nth ${e} *-000002-000001.dcm  /path/where/you/want/yourscan_run1_echo${e}.mgz 
  mri_convert -nth ${e} *-000003-000001.dcm  /path/where/you/want/yourscan_run1_echo${e}.mgz 
  mri_convert -nth ${e} *-000004-000001.dcm  /path/where/you/want/yourscan_run1_echo${e}.mgz
  mri_convert -nth ${e} *-000005-000001.dcm  /path/where/you/want/yourscan_run1_echo${e}.mgz
  mri_convert -nth ${e} *-000006-000001.dcm  /path/where/you/want/yourscan_run1_echo${e}.mgz
  mri_convert -nth ${e} *-000007-000001.dcm  /path/where/you/want/yourscan_run1_echo${e}.mgz
  mri_convert -nth ${e} *-000008-000001.dcm  /path/where/you/want/yourscan_run2_echo${e}.mgz
  mri_convert -nth ${e} *-000009-000001.dcm  /path/where/you/want/yourscan_run2_echo${e}.mgz
  mri_convert -nth ${e} *-000010-000001.dcm  /path/where/you/want/yourscan_run2_echo${e}.mgz
  mri_convert -nth ${e} *-000011-000001.dcm  /path/where/you/want/yourscan_run2_echo${e}.mgz
  mri_convert -nth ${e} *-000012-000001.dcm  /path/where/you/want/yourscan_run2_echo${e}.mgz
  mri_convert -nth ${e} *-000013-000001.dcm  /path/where/you/want/yourscan_run2_echo${e}.mgz
end

Change the echo numbers [i.e. (0 1 2 3 4 5 6 7)]. 0 represents the first echo. And add/delete a set of runs [run1, run2, etc.] for the amount of runs you did (see scan.log).

Average the Runs

(Takes hours sometimes depending on resolution, number of runs)

For single flip angle data:

mri_motion_correct2 -o yourscan_avg.mgz -wild yourscan_run*.mgz

Note: mri_motion_correct.fsl is another option to use instead of mri_motion_correct2 but it tends to fail on exvivo data (-Allison).

This will create an output file that ends with '_avg.mgz'. This file will be used for orientation.

For multiple flip angle data:

The script looks like this:

foreach fa (5 10 15 20 25 30)
pbsubmit -l nodes=1:opteron -c "mri_average -noconform mef${fa}_run*_echo*.mgz  mef${fa}_avg.mgz"; sleep 100
end

Run the script in seychelles.

./avg_runs_perFA.csh

Note: You can use mri_info on each run to find out the flip angle, if needed.

This will create output files that end with '_avg.mgz' for each flip angle (i.e. mef30_avg.mgz).

We average the runs and echoes for the flip angles ranging from 5 to 30. We do not average across flip angles. When we change the orientation later, we are orienting only the average of each flip angle.

Once the averages have been made, you want to load each average in scuba to check for any problems (artifacts, bad contrast, phase runs [should be obvious]). Any flip angle that has a problem could be excluded. Flip Angles with good contrast between wm and gm with no artifacts are used for the FA average to get the orig volume. It is also possible to look at the runs and echoes and exclude them if necessary.

scuba -v mef30_avg.mgz

Make Parameter Map for Averaged Volumes

Make parameter maps for the averaged volumes (uses averages to create T1 and PD maps and aligns images) in seychelles:

mkdir parameter_maps
pbsubmit -l nodes=1:opteron -c "mri_ms_fitparms mef*avg.mgz parameter_maps”

(Note: to do mri_ms_fitparms without the motion correct use -n 0 in your command.)

This will create:

PD.mgz   T1.mgz      vol0.lta  vol1.lta  vol2.lta  vol3.lta  vol4.lta
sse.mgz  T2star.mgz  vol0.mgz  vol1.mgz  vol2.mgz  vol3.mgz  vol4.mgz

If you choose the average volumes, average the flip angles (5 through 30) to make orig.mgz.

pbsubmit -l nodes=1:opteron -c "mri_average -noconform mef5_avg.mgz mef10_avg.mgz mef15_avg.mgz mef20_avg.mgz mef25_avg.mgz mef30_avg.mgz orig.mgz"

The tag -noconform must be used whenever working with the averages before they are oriented.

Orient the Volume

Since the brain is not put in the scanner in the expected direction (i.e. head first supine), it must be oriented to the correct radiological orientation.

Open the average volume with orient_mri.

orient_mri --volume yourscan_avg.mgz

See the orient_mri wiki page for directions on its use. Save the oriented volume with _ras added to the end (i.e. yourscan_avg_ras.mgz).

Note: orient_mri in freesurfer dev seems to have problems, so use freesurfer stable orient_mri instead.

Copy RAS Coordinates to all Volumes

The script will look like this:

#Copies new RAS oriented orig to each FA volume and renames it blah_ras.mgz. And then conforms it to 256 256 256 matrix and renames them all blah_ras_conf.mgz
foreach fa (5 10 15 20 25 30)
mri_copy_params mef${fa}_avg.mgz orig_ras.mgz mef${fa}_avg_ras.mgz
mri_convert -c  mef${fa}_avg_ras.mgz  mef${fa}_avg_ras_conf.mgz
end

#No longer need the non-conformed oriented averages so remove them and rename the conformed ones blah_avg.mgz
rm mef??_avg_ras.mgz
rm mef?_avg_ras.mgz

foreach fa (5 10 15 20 25 30)
mv mef${fa}_avg_ras_conf.mgz mef${fa}_avg.mgz 
end

#Conforms orig that was oriented into 256 256 256 matrix now that we are done copying it.
mri_convert -c  orig_ras.mgz  orig.mgz
mv orig_ras.mgz orig_ras_noconf.mgz

Edit the script if necessary. This script will copy the new RAS oriented orig information to each FA volume and then conform them and the orig to 256x256x256 matrix. Output will be orig.mgz and the orig_ras.mgz will be renamed orig_ras_noconf.mgz to indicate it is the oriented but nonconformed version.

{{{
./copy_ras_params.csh

Register High Res Volume to Low Res Volume

Beforing registering the volumes, they need to be converted to mnc files and the hires.mnc needs to be moved to the hemi's recon directory:

mri_convert lowres.mgz lowres.mnc
mri_convert hires.mgz hires.mnc

Make sure you have enough space before attempting to register or else you will lose all your work:

register -rgb lowres.mnc hires.mnc

Register will open. You can change the colors of the images. The image on the left is the low res and you can choose the Gray button underneath it to change the color to gray. The image in the middle column is the high res volume. Choose the Hot button to make it orange. Use the slider above the color buttons to adjust the contrast. You can zoom in on each image by hitting Shift and scrolling with the middle button. You can move the image by hitting Shift and clicking the left mouse button.

Before placing tags, choose the button on the left menu that says Transform Type and choose the option that says Full Affine 12 Parameter and hit close. Do this any time you open register.

You want to scroll through the slices (use middle button to scroll) and find your region of interest. You want to place about 6 tags around the ROI in all different directions (anterior, posterior, inferior, superior, ventral, lateral). Each tag should be placed in the same location in the low res as the high res. After all tags are placed, the 2 volumes should be transformed and registered to each other so that the label drawn on the high res volume will fit in the right place on the low res volume.

To place tags you left click on a location in the low res volume and then left click on the same location on the high res volume (the 2 volumes are likely to be oriented a different way so will have to find the matching orientation and figure out how it compares to the other). Then right click over the place you put the last tag to register the two. To delete a tag, look on the bottom left of the screen and click on the last Dst: box (which will be the last tag you made) and click on Delete Tag on the left menu.

The right column will show you the 2 volumes on top of each other and you can check if your ROI is lining up. Use the slider underneath this column to switch between the 2 volumes to see how well they line up.

When placing tags, try to find an area with good contrast. Check all 3 orientations of a volume to the 3 orientations of the other volume to make sure at least 2 are looking the same. Since the brain is scanned on different occasions, they may not line up exactly the same and you can't just trust one orientation when placing tags.

When done, in the box in the left menu above Save Tags, click on it and start typing the name you want to save the tags under: namethis.tags Then hit Enter and then click the button that says Save Tags. Do the same for the Transform calling it namethis.xfm

If opening volumes in register at a later time and need to load tags, do the same as you would if saving the tags but hit load tags instead.

Making a mask

You can use make a mask of the brain to get rid of the bag and plp by using the mri_threshold command. To determine the appropriate thresholds click around until you find a min and a max. The -u flag is used to set an upper threshold and you can create a lower threshold with no flag at all so for example to threshold an orig volume at 400 to 3900 you would run the following two commands.

mri_threshold orig.mgz 390 lower.mgz
mri_threshold -u lower.mgz 3900 mask.mgz