/
Manual editing using tkmedit (FreeSurfer v6.0 and below)

Attention: Confluence is not suitable for the storage of highly confidential data. Please ensure that any data classified as Highly Protected is stored using a more secure platform.
If you have any questions, please refer to the University's data classification guide or contact ict.askcyber@sydney.edu.au

Manual editing using tkmedit (FreeSurfer v6.0 and below)

This section is ONLY relevant for the manual editing step. For full pre-processing steps, refer back to here.

 

Below is a previous guide from James - Note it uses the older versions of FreeSurfer (v6.0 and below).

For FreeSurver v7.0 and above, click here for instructions on how to use freeview to make manual edits.

 

MANUAL EDITING

  1. Make sure you have freesurfer set up correctly and that your subjects directory is correct e.g. SUBJECTS_DIR=/Users/Lucie/Desktop/hpc/Lucie/T1/. See "Setting up freesurfer" for more details. Confirm freesurfer is set up correctly by opening a new terminal window and comparing to Figure B. below. 

Figure B. Terminal window showing correctly set up freesurfer environment.

  1. Run:

tkmedit FTD### brainmask.mgz lh.white –aux T1.mgz –aux-surface rh.white

This will open up two windows. Figure C. shows the main editor window. Here, the red line is outlining the pial surface and the yellow and green lines are outlining the wm surface. This command loads two volumes: the brainmask (currently being edited as shown by the asterisks surrounding the name) as well as the unedited T1 (the auxiliary volume, shown by the parentheses surrounding the name). You can switch between these two by pressing Control+1 or 2.

Figure D. Tkmedit Toolbox window.

*Use the two buttons circled in green to switch between the main and aux volumes. You can also switch between these two by pressing Control + 1 or 2.

**Select the button circled in Red to edit the main volume and the button circled in Blue to add control points.

***the MOP buttons circled in yellow show/hide the red, green or yellow lines.

****The CHS buttons circled in yellow change the view from coronal to horizontal to sagittal view.

***** The magnifying glass + and – is to zoom and you move through the slices using the -/+ buttons to the left of this, or by using the up and down keys on your keyboard.

 

EDITING THE PIAL SURFACE

 

  1. BEFORE MAKING EDITS TO THE PIAL SURFACE – select Tools → Configure brush info → increase the radius to 2 → and change the shape to circle,→ press ok. Make sure the button circled in Red above is selected and enlarge the brain screen to size you like.

  2. Scroll through all 200 slices to look for anywhere that the red line includes within it something that is not brain. Right click to delete voxels and use the scroll button on the mouse to add voxels (but you will not use this during pial edits).

  3. See below for examples of typical locations where sections of non-brain have been included in the pial volume. These will have to be erased. 



See below for examples of typical locations where sections of non-brain have been included in the pial volume. These will have to be erased.

Figure E. Examples of sections of non-brain being included in the pial volume.



Conventions for Pial edits:  

  1. We do not make any edits to the part of the medial temporal lobe circled below (see Example A.).

  2. Once the midbrain is connected to the rest of the brain (see Example B.) we STOP editing the area at the bottom of the brain (can still make edits to the rest of the surface of the brain e.g. cortex).

  3. Do not edit out the cerebellum if it is included (see Example C).

Example A. Sections of medial temporal lobe that are ignored.

Example B. Point at which midbrain connects. From this point, do not edit the bottom of the temporal region.

Example C. Cerebellum is included in the pial volume but is not edited.

Example A. Sections of medial temporal lobe that are ignored.

Example B. Point at which midbrain connects. From this point, do not edit the bottom of the temporal region.

Example C. Cerebellum is included in the pial volume but is not edited.



 

ADDING CONTROL POINTS

When editing the brainmask.mgz volume (e.g. during pial edits) you may need to add control points where a piece of brain has not been included (see examples below). To do this you will need to change the cursor to the button circled in blue (see sidebar) and then add control points by pressing the scroll button (these will come up as little green crosses). 

You must save control points separatelyFile → save control points.



Example A. Control points needed.

Example B. Control points added.   

Example C. After running Autorecon2 with control points, sections of brain are now included.

Example A. Control points needed.

Example B. Control points added.   

Example C. After running Autorecon2 with control points, sections of brain are now included.



Example A. demonstrates a situation where control points would be needed. Enter control points along the middle of the brain tissue you want freesurfer to include (Example B). Once you re-run autorecon2 with control points the volume should change to now include the part you have added (Example C).

*NOTE: Make sure you have added and run all necessary control points changes before moving on to edit the WM volume, as adding control points will revert any changes you have made to the WM volume. 

EDITING THE WHITE MATTER VOLUME

 

  1. Before editing the white matter volume, you must load it by changing the aux volume to wm.mgz through File → aux volume → load aux volume → click Browse → scroll to the very bottom of Files (on the right) and select wm.mgz → OK → OK. Now, you will note that you will only be able to view the brainmask and white matter volumes (instead of the original T1).

  2. To make edits the aux volume (white matter), you need to FIRST change the brushTools → configure brush info → change Target to Aux volume, increase as desired (larger is often easier) → change the shape to circle → close. As with the pial edits, make sure the button with the paintbrush and square is selected in the toolbox.

  3. Edit the white matter volume by filling any gaps in the white matter (see example A. and B.) as deleting any additional white matter pixels which are outside the Red pial volume line (see Examples C. and D.).

  4. To save changes to white matter, select File → aux volume → save aux volume. 

//Add examples of gaps in white matter, as well as points where the white matter is outside the pial volume



BEFORE CLOSING TKMEDIT

  1. Remember to save main volume, aux volume and cp points separately!

  2. If multiple people are making changes to the same scan simultaneously, there may be an issue with permissions.



RE-RUNNING FREESURFER SCRIPTS

  1. After manual edits have been made, re-run AutoRecon2+3 steps using either: Autorecon2-wm.sh (if you have made edits to pial, wm or both) or Autorecon2-cp.sh (if you have added control points).

    bash submit.sh Autorecon2-wm.sh # or # bash submit.sh Autorecon2-cp.sh
  2. If you have added control points, do not make changes to the white matter. Wait until you are happy with the control points (potentially running Autorecon2-cp.sh multiple times), then edit the white matter and run Autorecon2-wm separately.



***CONTINUE REPEATING THIS PROCESS UNTIL YOU ARE HAPPY WITH BOTH THE BRAINMASK AND WHITE MATTER VOLUMES****



ONCE MANUAL EDITS ARE COMPLETE

  1. Surface Check: Open tkmedit as if you were doing manual edits (we will use this later). Then, open a new terminal window and enter the command below.  Here we are looking at a 3D construction of each hemisphere to check for any problems (i.e. spikes or holes).

  2. Change the rotation from 90 to 30 degrees, then use the rotation arrows above to rotate the brain to check the whole surface (See Figure G. in sidebar). 

  3. If there is a spot you want to check, double click on it (which will make a little blue dot) then hit the save button circled in red. Go to the tkmedit tool box and click the folder with the + sign (appears like the button circled in green) to open the saved location in the tkmedit window we opened earlier. It will place the small red cross on the exact spot you saved on the inflated version. You may need to scroll back and forth through the slices to find the exact location. 

  4. This step is a final quality check. We want to use the surface check to highlight any locations where we have potentially missed a section of brain that is not included or a section of non-brain that has been included.

  5. Address issues found by doing more manual edits and rerunning autorecon2/3 as above. 

  6. NOTE: There will always be a spike on either hemisphere where the optic nerve enters the brain. This spike is ignored. 

  7. Once you have done this for the left hemisphere, repeat the process for the right: 

 

Last pre-processing step

Continue with pre-processing step - qcache (outlined in the main section of manual pre-processing steps here).

 

Related content

FreeSurfer
More like this
Preprocessing Scripts
Preprocessing Scripts
Read with this
Pre-processing
Pre-processing
More like this
Group Analysis (baseline)
Group Analysis (baseline)
More like this
Longitudinal Analysis
Longitudinal Analysis
More like this
Analysis
More like this