Unpack Dicoms
(Finishes fairly quickly)
mksubjdirs <yourscan> (this command makes all the relevant freesurfer directories i.e. mri, surf, etc.)
Login to seychelles, source the dev environment of freesurfer.
From the dicom directory, unpack the data:
cd dicom pbsubmit -f -m <your username> -l nodes=1:opteron -c "unpacksdcmdir -scanonly scan.log -src . -targ ."
Convert Dicoms to mgz Files
(Finishes fairly quickly)
For single echo:
foreach r (3 4 5 6 7) pbsubmit -l nodes=1:opteron -c "mri_convert *-${r}-1.dcm /path/where/you/want/yourscan_run${r}.mgz" ; sleep 40 end
Edit the script to apply to this subject. Change the run numbers [i.e. (3 4 5 6 7)]- see the unpack.log in the dicom dir for the run numbers. Do not use the run numbers for the localizers. Run the script from your dicom directory in seychelles.
./convert_dicoms.csh
For multiecho:
foreach e (0 1 2 3 4 5 6 7) pbsubmit -l nodes=1:opteron -c "mri_convert -nth ${e} *-000002-000001.dcm /path/where/you/want/yourscan_run1_echo${e}.mgz" ; sleep 40 pbsubmit -l nodes=1:opteron -c "mri_convert -nth ${e} *-000003-000001.dcm /path/where/you/want/yourscan_run1_echo${e}.mgz" ; sleep 40 pbsubmit -l nodes=1:opteron -c "mri_convert -nth ${e} *-000004-000001.dcm /path/where/you/want/yourscan_run1_echo${e}.mgz" ; sleep 40 pbsubmit -l nodes=1:opteron -c "mri_convert -nth ${e} *-000005-000001.dcm /path/where/you/want/yourscan_run1_echo${e}.mgz" ; sleep 40 pbsubmit -l nodes=1:opteron -c "mri_convert -nth ${e} *-000006-000001.dcm /path/where/you/want/yourscan_run1_echo${e}.mgz" ; sleep 40 pbsubmit -l nodes=1:opteron -c "mri_convert -nth ${e} *-000007-000001.dcm /path/where/you/want/yourscan_run1_echo${e}.mgz" ; sleep 40 pbsubmit -l nodes=1:opteron -c "mri_convert -nth ${e} *-000008-000001.dcm /path/where/you/want/yourscan_run2_echo${e}.mgz" ; sleep 40 pbsubmit -l nodes=1:opteron -c "mri_convert -nth ${e} *-000009-000001.dcm /path/where/you/want/yourscan_run2_echo${e}.mgz" ; sleep 40 pbsubmit -l nodes=1:opteron -c "mri_convert -nth ${e} *-000010-000001.dcm /path/where/you/want/yourscan_run2_echo${e}.mgz" ; sleep 40 pbsubmit -l nodes=1:opteron -c "mri_convert -nth ${e} *-000011-000001.dcm /path/where/you/want/yourscan_run2_echo${e}.mgz" ; sleep 40 pbsubmit -l nodes=1:opteron -c "mri_convert -nth ${e} *-000012-000001.dcm /path/where/you/want/yourscan_run2_echo${e}.mgz" ; sleep 40 pbsubmit -l nodes=1:opteron -c "mri_convert -nth ${e} *-000013-000001.dcm /path/where/you/want/yourscan_run2_echo${e}.mgz" ; sleep 40 end
Edit the script to apply to this subject. Change the echo numbers [i.e. (0 1 2 3 4 5 6 7)]. You will know the echo #s from your scan protocol (sometimes it is in the name of the scan). For the numbers in the script, always start with 0 such as in the example above which was an 8 echo scan. Change the flip angles [i.e. the "30" in mef30] so you have a list of flip angles used for each run. And add/delete a set of runs [run1, run2, etc.] for the amount of runs you did (see unpack.log). Then run the script from your dicom directory in seychelles.
./convert_lowresdicoms.csh
This will take awhile to submit the jobs.
Average the Runs
(Takes hours sometimes depending on resolution, number of runs)
For single flip angle data:
pbsubmit -l nodes=1:opteron -c "mri_motion_correct2 -o yourscan_avg.mgz -wild yourscan_run*.mgz"
In seychelles:
./avg_runs.csh
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
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.
#acl AdminGroup:read,write,delete,revert All:
Index
Contents
Project
The following processing guidelines apply to the majority of ex-vivo data collected for Bruce Fischl. For guidelines on data collection for all these projects, see ExvivoDataCollection. For other information on exvivo projects and data processing see ExvivoProjects.
High Resolution Scan
Collect single echo FLASH data with one flip angle, 120-150um (7T bay5). See this page to soon be put here for information on scanning procedures.
Data Location
The main directory is here:
/autofs/space/rock_004/users/hires
All data should be symlinked to the main directory.
However, this is a list of partitions with hires data on them:
/autofs/space/tensor_007/users/hires /autofs/space/tensor_020/users/hires (No more space available) /autofs/space/tensor_021/users/hires /autofs/space/tensor_018/users/hires
Transfer Dicoms from Bourget
(Takes hours sometimes depending on resolution, number of runs)
Before transferring the dicoms, create a directory for your subject's data in one of the hires partitions that still has space:
mkdir <subjid_hemi_structure>
Create a link between the directory you created and the main hires directory (if necessary):
cd /autofs/space/rock_004/users/hires/<subjid_hemi> ln -s <path/to/subjid_hemi_structure> .
Note: If this brain has never been scanned before, you will have to first create a main subject directory for that brain that lists the subject ID and hemisphere. For example, /autofs/space/rock_004/users/hires/I26_RH. Within this main subject directory, a directory for each scan session is made.
Use findsession to locate the dicoms on BOURGET and then copy it to the directory you created.
findsession <name you used to register subject on scanner> cd /autofs/space/rock_004/users/hires/<subjid_hemi>/<subjid_hemi_structure> cp -r <directory given by findsession> .
Once the data has finished copying, rename the folder created 'dicom'. For example:
mv TrioTim-18001-20071025-182700-785000 dicom
Unpack Dicoms
(Finishes fairly quickly)
Login to seychelles, source the dev environment of freesurfer and set your SUBJECTS_DIR to the directory you created.
From the dicom directory, unpack the data:
cd $SUBJECTS_DIR/dicom pbsubmit -f -m <your username> -q captain -l nodes=1:opteron -c "unpacksdcmdir -scanonly scan.log -src . -targ ."
Convert Dicoms to mgz Files
(Finishes fairly quickly)
After the dicoms are unpacked, we need to convert them to .mgz files. The script used to do this will put the .mgz files in a directory you need to create:
cd $SUBJECTS_DIR mkdir mri mkdir mri/flash
Copy the convert_dicoms script from the scripts dir in the main directory to this subject's dicom directory:
cp /autofs/space/rock_004/users/hires/scripts/convert_dicoms.csh $SUBJECTS_DIR/dicom
The script will look like this:
foreach r (3 4 5 6 7) pbsubmit -q captain -l nodes=1:opteron -c "mri_convert *-${r}-1.dcm ../mri/flash/flash20_MT_100um_run${r}.mgz" ; sleep 40 end
Edit the script to apply to this subject. Change the run numbers [i.e. (3 4 5 6 7)]- see the unpack.log in the dicom dir for the run numbers. Do not use the run numbers for the localizers. Change the flip angle [i.e. the "20" in flash20], the region of interest [i.e. MT], and the resolution [i.e. 100um]. Then run the script from your dicom directory in seychelles.
./convert_dicoms.csh
Average the Runs
(Takes hours sometimes depending on resolution, number of runs)
After all dicoms have been converted to .mgz files, we will average all the runs. The runs [i.e. flash20_MT_100um_run6.mgz] are now located in your flash directory.
cd ../mri/flash
For single flip angle data:
If you did not scan mulitiple flip angles, copy this script to your flash directory:
/autofs/space/rock_004/users/hires/scripts/avg_runs.csh
The script will look like this:
pbsubmit -q captain -l nodes=1:opteron -c "mri_motion_correct2 -o flash20_MT_100um_avg.mgz -wild flash20_MT_100um_run*.mgz"
Edit the script for the correct flip angles, region of interest, and resolution (as described above) and run it from your flash directory in seychelles.
./avg_runs.csh
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 in the flash directory that ends with '_avg.mgz'. This file will be used for orientation.
If you need to average the runs for multiple flip angles, see below under Low Resolution Scan.
Orient the Volume
Change the group permissions so others on the project have access to the data:
cd /autofs/space/rock_004/users/hires/ /usr/pubsw/bin/setgrp -c <group> <subjid_hemi_structure>
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.
cd <subjid_hemi_structure>/mri/flash orient_mri --volume flash_MT_150um_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. flash_MT_150um_avg_ras.mgz) within the flash directory.
Note: orient_mri in freesurfer dev seems to have problems, so use freesurfer stable orient_mri instead.
Intensity Normalize Volume
In some cases, you may need to add control points to the white matter in order to get better intensity normalization.
Open the volume in scuba:
scuba -v flash_MT_150um_avg.mgz
In the Tools Panel, choose Markers and set the limit to 1,000. Middle click to add control points well into the white matter on every other slice. Save control points as control.dat in flash dir. Then run:
mri_normalize -sigma 30 -noconform -fonly control.dat -n 1 -no1d flash20_MT_100um_avg_ras.mgz flash20_MT_100um_avg_ras_norm.mgz
Make Label
Make a directory to save the labels (it should be outside of the mri dir):
cd <subjid_hemi_structure> mkdir label cd mri/flash
Open the volume in scuba:
scuba -v flash_MT_150um_avg.mgz
Have Jean look at EC and advise on how far anterior it starts and how far posterior it ends. Draw the label using the ROI tool in scuba. You want to use a fairly large brush (Tools Panel -> Circle -> Edit Radius) to cover most of EC although it isn't necessary to cover all of it. Do not go into the white matter. Save the label as:
?h.highres_area28.label
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 flash_MT_150um_avg.mgz rh.highres_area28.mnc mv rh.highres_area28.mnc <subjid_hemi_recon>/mri/transforms/rh.highres_area28.mnc cd <subjid_hemi_recon>/mri mri_convert orig.mgz orig.mnc mv orig.mnc transforms/orig.mnc cd transforms
Make sure you have enough space before attempting to register or else you will lose all your work:
register -rgb orig.mnc rh.highres_area28.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 colum 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: ?h.lowres_area28.tags Then hit Enter and then click the button that says Save Tags. Do the same for the Transform calling it ?h.highres_area28.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.
Map Label from High Res Volume onto Low Res Volume
Map Label to Surface
Low Resolution Scan
Collect multi echo (8 echoes) FLASH 1mm isotropic data for flip angles of 30, 25, 20, 15, 10 and 5 degrees (1.5T bay2).
Data Location
The recon directory is here:
/autofs/space/rock_004/users/hires/recons
All data should be symlinked to the recon directory and the main directory (rock/4).
Transfer Dicoms from Bourget
Before transferring the dicoms, create a directory for your subject's data in one of the recon partitions that still has space:
mksubjdirs <subjid_hemi_recon> (this command makes all the relevant freesurfer directories i.e. mri, surf, etc.) cd <subjid_hemi_recon>/mri mkdir flash
Locate dicoms on BOURGET and copy them to the mri directory.
findsession <name you used to register subject on scanner> cd /autofs/space/rock_004/users/hires/recons/<subjid_hemi_recon>/mri cp -r <directory given by findsession> .
Rename the transferred dicom directory to 'dicom'.
Create a link between the directory you created and the recon directory. Also create a link between the directory you created and the main directory for this hemi that is in rock/4/users/hires.
cd /autofs/space/rock_004/users/hires/recons/<subjid_hemi_recon> ln -s <path/to/subjid_hemi_recon> . cd /autofs/space/rock_004/users/hires/<subjid_hemi> ln -s <path/to/subjid_hemi_recon> .
Unpack Dicoms
Login to seychelles, source the dev environment of freesurfer and set your SUBJECTS_DIR to the recon directory (/autofs/space/rock_004/users/hires/recons).
From the dicom directory, unpack the data:
cd $SUBJECTS_DIR/<subjid_hemi_recon>/mri/dicom pbsubmit -f -m <your username> -q captain -l nodes=1:opteron -c "unpacksdcmdir -scanonly scan.log -src . -targ ."
Convert Dicoms to mgz Files
After the dicoms are unpacked, we need to convert them to .mgz files.
Copy the convert_dicoms script from the scripts dir in the main directory to this subject's dicom directory:
cp /autofs/space/rock_004/users/hires/scripts/convert_lowresdicoms.csh $SUBJECTS_DIR/dicom
The script will look like this:
foreach e (0 1 2 3 4 5 6 7) pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000002-000001.dcm ../mri/flash/mef30_run1_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000003-000001.dcm ../mri/flash/mef25_run1_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000004-000001.dcm ../mri/flash/mef20_run1_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000005-000001.dcm ../mri/flash/mef15_run1_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000006-000001.dcm ../mri/flash/mef10_run1_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000007-000001.dcm ../mri/flash/mef5_run1_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000008-000001.dcm ../mri/flash/mef30_run2_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000009-000001.dcm ../mri/flash/mef25_run2_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000010-000001.dcm ../mri/flash/mef20_run2_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000011-000001.dcm ../mri/flash/mef15_run2_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000012-000001.dcm ../mri/flash/mef10_run2_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000013-000001.dcm ../mri/flash/mef5_run2_echo${e}.mgz" ; sleep 40 end
Edit the script to apply to this subject. Change the echo numbers [i.e. (0 1 2 3 4 5 6 7)]. You will know the echo #s from your scan protocol (sometimes it is in the name of the scan). For the numbers in the script, always start with 0 such as in the example above which was an 8 echo scan. Change the flip angles [i.e. the "30" in mef30] so you have a list of flip angles used for each run. And add/delete a set of runs [run1, run2, etc.] for the amount of runs you did (see unpack.log). Then run the script from your dicom directory in seychelles.
./convert_lowresdicoms.csh
This will take awhile to submit the jobs.
Average the Echoes for each Flip Angle
After all dicoms have been converted to .mgz files, we will average all the echoes for each flip angle. The echoes [i.e. mef5_run2_echo6.mgz] are now located in your flash directory.
cd ../mri/flash
In this dir you should see something like this for each flip angle:
mef10_run1_echo1.mgz mef10_run2_echo1.mgz mef10_run1_echo2.mgz mef10_run2_echo2.mgz mef10_run1_echo3.mgz mef10_run2_echo3.mgz mef10_run1_echo4.mgz mef10_run2_echo4.mgz mef10_run1_echo5.mgz mef10_run2_echo5.mgz mef10_run1_echo6.mgz mef10_run2_echo6.mgz mef10_run1_echo7.mgz mef10_run2_echo7.mgz
For multiple flip angle data:
If you scanned multiple flip angles, you will want to copy the following script to your flash directory ($SUBJECTS_DIR/mri/flash):
/autofs/space/rock_004/users/hires/scripts/avg_runs_perFA.csh
The script looks like this:
foreach fa (5 10 15 20 25 30) pbsubmit -q captain -l nodes=1:opteron -c "mri_average -noconform mef${fa}_run*_echo*.mgz mef${fa}_avg.mgz"; sleep 100 end
Run the script from your flash directory 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 in the flash directory 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”
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 to make orig, 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.
Contents
Project
The following processing guidelines apply to the majority of ex-vivo data collected for Bruce Fischl. For guidelines on data collection for all these projects, see ExvivoDataCollection. For other information on exvivo projects and data processing see ExvivoProjects.
High Resolution Scan
Collect single echo FLASH data with one flip angle, 120-150um (7T bay5). See this page to soon be put here for information on scanning procedures.
Data Location
The main directory is here:
/autofs/space/rock_004/users/hires
All data should be symlinked to the main directory.
However, this is a list of partitions with hires data on them:
/autofs/space/tensor_007/users/hires /autofs/space/tensor_020/users/hires (No more space available) /autofs/space/tensor_021/users/hires /autofs/space/tensor_018/users/hires
Transfer Dicoms from Bourget
(Takes hours sometimes depending on resolution, number of runs)
Before transferring the dicoms, create a directory for your subject's data in one of the hires partitions that still has space:
mkdir <subjid_hemi_structure>
Create a link between the directory you created and the main hires directory (if necessary):
cd /autofs/space/rock_004/users/hires/<subjid_hemi> ln -s <path/to/subjid_hemi_structure> .
Note: If this brain has never been scanned before, you will have to first create a main subject directory for that brain that lists the subject ID and hemisphere. For example, /autofs/space/rock_004/users/hires/I26_RH. Within this main subject directory, a directory for each scan session is made.
Use findsession to locate the dicoms on BOURGET and then copy it to the directory you created.
findsession <name you used to register subject on scanner> cd /autofs/space/rock_004/users/hires/<subjid_hemi>/<subjid_hemi_structure> cp -r <directory given by findsession> .
Once the data has finished copying, rename the folder created 'dicom'. For example:
mv TrioTim-18001-20071025-182700-785000 dicom
Unpack Dicoms
(Finishes fairly quickly)
Login to seychelles, source the dev environment of freesurfer and set your SUBJECTS_DIR to the directory you created.
From the dicom directory, unpack the data:
cd $SUBJECTS_DIR/dicom pbsubmit -f -m <your username> -q captain -l nodes=1:opteron -c "unpacksdcmdir -scanonly scan.log -src . -targ ."
Convert Dicoms to mgz Files
(Finishes fairly quickly)
After the dicoms are unpacked, we need to convert them to .mgz files. The script used to do this will put the .mgz files in a directory you need to create:
cd $SUBJECTS_DIR mkdir mri mkdir mri/flash
Copy the convert_dicoms script from the scripts dir in the main directory to this subject's dicom directory:
cp /autofs/space/rock_004/users/hires/scripts/convert_dicoms.csh $SUBJECTS_DIR/dicom
The script will look like this:
foreach r (3 4 5 6 7) pbsubmit -q captain -l nodes=1:opteron -c "mri_convert *-${r}-1.dcm ../mri/flash/flash20_MT_100um_run${r}.mgz" ; sleep 40 end
Edit the script to apply to this subject. Change the run numbers [i.e. (3 4 5 6 7)]- see the unpack.log in the dicom dir for the run numbers. Do not use the run numbers for the localizers. Change the flip angle [i.e. the "20" in flash20], the region of interest [i.e. MT], and the resolution [i.e. 100um]. Then run the script from your dicom directory in seychelles.
./convert_dicoms.csh
Average the Runs
(Takes hours sometimes depending on resolution, number of runs)
After all dicoms have been converted to .mgz files, we will average all the runs. The runs [i.e. flash20_MT_100um_run6.mgz] are now located in your flash directory.
cd ../mri/flash
For single flip angle data:
If you did not scan mulitiple flip angles, copy this script to your flash directory:
/autofs/space/rock_004/users/hires/scripts/avg_runs.csh
The script will look like this:
pbsubmit -q captain -l nodes=1:opteron -c "mri_motion_correct2 -o flash20_MT_100um_avg.mgz -wild flash20_MT_100um_run*.mgz"
Edit the script for the correct flip angles, region of interest, and resolution (as described above) and run it from your flash directory in seychelles.
./avg_runs.csh
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 in the flash directory that ends with '_avg.mgz'. This file will be used for orientation.
If you need to average the runs for multiple flip angles, see below under Low Resolution Scan.
Orient the Volume
Change the group permissions so others on the project have access to the data:
cd /autofs/space/rock_004/users/hires/ /usr/pubsw/bin/setgrp -c <group> <subjid_hemi_structure>
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.
cd <subjid_hemi_structure>/mri/flash orient_mri --volume flash_MT_150um_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. flash_MT_150um_avg_ras.mgz) within the flash directory.
Note: orient_mri in freesurfer dev seems to have problems, so use freesurfer stable orient_mri instead.
Intensity Normalize Volume
In some cases, you may need to add control points to the white matter in order to get better intensity normalization.
Open the volume in scuba:
scuba -v flash_MT_150um_avg.mgz
In the Tools Panel, choose Markers and set the limit to 1,000. Middle click to add control points well into the white matter on every other slice. Save control points as control.dat in flash dir. Then run:
mri_normalize -sigma 30 -noconform -fonly control.dat -n 1 -no1d flash20_MT_100um_avg_ras.mgz flash20_MT_100um_avg_ras_norm.mgz
Make Label
Make a directory to save the labels (it should be outside of the mri dir):
cd <subjid_hemi_structure> mkdir label cd mri/flash
Open the volume in scuba:
scuba -v flash_MT_150um_avg.mgz
Have Jean look at EC and advise on how far anterior it starts and how far posterior it ends. Draw the label using the ROI tool in scuba. You want to use a fairly large brush (Tools Panel -> Circle -> Edit Radius) to cover most of EC although it isn't necessary to cover all of it. Do not go into the white matter. Save the label as:
?h.highres_area28.label
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 flash_MT_150um_avg.mgz rh.highres_area28.mnc mv rh.highres_area28.mnc <subjid_hemi_recon>/mri/transforms/rh.highres_area28.mnc cd <subjid_hemi_recon>/mri mri_convert orig.mgz orig.mnc mv orig.mnc transforms/orig.mnc cd transforms
Make sure you have enough space before attempting to register or else you will lose all your work:
register -rgb orig.mnc rh.highres_area28.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 colum 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: ?h.lowres_area28.tags Then hit Enter and then click the button that says Save Tags. Do the same for the Transform calling it ?h.highres_area28.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.
Map Label from High Res Volume onto Low Res Volume
Map Label to Surface
Low Resolution Scan
Collect multi echo (8 echoes) FLASH 1mm isotropic data for flip angles of 30, 25, 20, 15, 10 and 5 degrees (1.5T bay2).
Data Location
The recon directory is here:
/autofs/space/rock_004/users/hires/recons
All data should be symlinked to the recon directory and the main directory (rock/4).
Transfer Dicoms from Bourget
Before transferring the dicoms, create a directory for your subject's data in one of the recon partitions that still has space:
mksubjdirs <subjid_hemi_recon> (this command makes all the relevant freesurfer directories i.e. mri, surf, etc.) cd <subjid_hemi_recon>/mri mkdir flash
Locate dicoms on BOURGET and copy them to the mri directory.
findsession <name you used to register subject on scanner> cd /autofs/space/rock_004/users/hires/recons/<subjid_hemi_recon>/mri cp -r <directory given by findsession> .
Rename the transferred dicom directory to 'dicom'.
Create a link between the directory you created and the recon directory. Also create a link between the directory you created and the main directory for this hemi that is in rock/4/users/hires.
cd /autofs/space/rock_004/users/hires/recons/<subjid_hemi_recon> ln -s <path/to/subjid_hemi_recon> . cd /autofs/space/rock_004/users/hires/<subjid_hemi> ln -s <path/to/subjid_hemi_recon> .
Unpack Dicoms
Login to seychelles, source the dev environment of freesurfer and set your SUBJECTS_DIR to the recon directory (/autofs/space/rock_004/users/hires/recons).
From the dicom directory, unpack the data:
cd $SUBJECTS_DIR/<subjid_hemi_recon>/mri/dicom pbsubmit -f -m <your username> -q captain -l nodes=1:opteron -c "unpacksdcmdir -scanonly scan.log -src . -targ ."
Convert Dicoms to mgz Files
After the dicoms are unpacked, we need to convert them to .mgz files.
Copy the convert_dicoms script from the scripts dir in the main directory to this subject's dicom directory:
cp /autofs/space/rock_004/users/hires/scripts/convert_lowresdicoms.csh $SUBJECTS_DIR/dicom
The script will look like this:
foreach e (0 1 2 3 4 5 6 7) pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000002-000001.dcm ../mri/flash/mef30_run1_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000003-000001.dcm ../mri/flash/mef25_run1_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000004-000001.dcm ../mri/flash/mef20_run1_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000005-000001.dcm ../mri/flash/mef15_run1_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000006-000001.dcm ../mri/flash/mef10_run1_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000007-000001.dcm ../mri/flash/mef5_run1_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000008-000001.dcm ../mri/flash/mef30_run2_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000009-000001.dcm ../mri/flash/mef25_run2_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000010-000001.dcm ../mri/flash/mef20_run2_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000011-000001.dcm ../mri/flash/mef15_run2_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000012-000001.dcm ../mri/flash/mef10_run2_echo${e}.mgz" ; sleep 40 pbsubmit -q captain -l nodes=1:opteron -c "mri_convert -nth ${e} *-000013-000001.dcm ../mri/flash/mef5_run2_echo${e}.mgz" ; sleep 40 end
Edit the script to apply to this subject. Change the echo numbers [i.e. (0 1 2 3 4 5 6 7)]. You will know the echo #s from your scan protocol (sometimes it is in the name of the scan). For the numbers in the script, always start with 0 such as in the example above which was an 8 echo scan. Change the flip angles [i.e. the "30" in mef30] so you have a list of flip angles used for each run. And add/delete a set of runs [run1, run2, etc.] for the amount of runs you did (see unpack.log). Then run the script from your dicom directory in seychelles.
./convert_lowresdicoms.csh
This will take awhile to submit the jobs.
Average the Echoes for each Flip Angle
After all dicoms have been converted to .mgz files, we will average all the echoes for each flip angle. The echoes [i.e. mef5_run2_echo6.mgz] are now located in your flash directory.
cd ../mri/flash
In this dir you should see something like this for each flip angle:
mef10_run1_echo1.mgz mef10_run2_echo1.mgz mef10_run1_echo2.mgz mef10_run2_echo2.mgz mef10_run1_echo3.mgz mef10_run2_echo3.mgz mef10_run1_echo4.mgz mef10_run2_echo4.mgz mef10_run1_echo5.mgz mef10_run2_echo5.mgz mef10_run1_echo6.mgz mef10_run2_echo6.mgz mef10_run1_echo7.mgz mef10_run2_echo7.mgz
For multiple flip angle data:
If you scanned multiple flip angles, you will want to copy the following script to your flash directory ($SUBJECTS_DIR/mri/flash):
/autofs/space/rock_004/users/hires/scripts/avg_runs_perFA.csh
The script looks like this:
foreach fa (5 10 15 20 25 30) pbsubmit -q captain -l nodes=1:opteron -c "mri_average -noconform mef${fa}_run*_echo*.mgz mef${fa}_avg.mgz"; sleep 100 end
Run the script from your flash directory 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 in the flash directory 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 the subjects' mri/flash dir in seychelles:
cd <subjid_hemi_recon>/mri mkdir parameter_maps cd flash pbsubmit -q captain -l nodes=1:opteron -c "mri_ms_fitparms mef*avg.mgz ../parameter_maps”
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
Copy the mef${fa}_avg.mgz files from the flash dir to the mri dir (we make copies because they will be reoriented and conformed later on):
cd <subjid_hemi_recon>/mri/flash cp mef??_avg.mgz ../ {*Note: ?? is for 2 digits [30] and ? is for 5} cp mef?_avg.mgz ../
Sometimes the PD looks better than the multiple flip angle data so we can use the PD as our orig.mgz. Also, Jean sometimes uses the volumes created here for her research.
Change the group permissions so others on the project have access to the data (should do this also when done with all processing):
cd /autofs/space/rock_004/users/hires/recon /usr/pubsw/bin/setgrp -c <group> <subjid_hemi_recon>
Choose Orig Volume
The orig.mgz is used to register the lowres to the hires and to superimpose the highres label onto the lowres volumes.
For the orig.mgz, you want to choose a volume with even wm intensities and good gm/wm contrast to make orig.mgz. Look at the parameter_maps (<subjid_hemi_recon>/mri/parameter_maps) to find a volume with even wm intensities and good wm and gm contrast. Also look at the mef{fa}_avg.mgz volumes in mri dir to see if the volumes look good. Then choose between the averages and the parameter maps which is the appropriate orig.mgz volume. Niranjini says it is usually PD.mgz.
If you choose the average volumes, average the flip angles (5 through 30) to make orig.mgz.
pbsubmit -q captain -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.
cp <volume choosing as orig> <subjid_hemi_recon>/mri/orig.mgz
Orient the Volume
If you open the orig.mgz in tkmedit, you will see that the orientations of the brain (ie. coronal, sagittal, and horizontal) do not correspond to the orientation buttons in tkmedit. We need to change these orientations so they correspond to the correct RAS coordinates.
Open the volume with orient_mri.
orient_mri --volume orig.mgz
See the orient_mri wiki page for directions on its use. Save the oriented volume with _ras added to the end (i.e. orig_ras.mgz).
Note: Make sure you check which hemisphere you are looking at so you can make sure the surface is on the correct side of the midline (right or left). Finding the temporal lobe is a good way of figuring out how the volume must be rotated.
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.