Back to TroubleshootingData
A segmentation is a volume whose values represent an index of an anatomical structure or label to which the corresponding voxel in the main anatomical volume belongs. The structures are listed in a lookup table. This table also specifies the colors the structures should appear in, and is more commonly called a color table.
Both a volume and a color table must be loaded to view a segmentation. A segmentation data file is treated the same as a normal anatomical volume, so it can be a COR- volume or any other supported file type. The color table assigns a name and color to each index. You can load both items by choosing File->Load Segmentation.... You can also control-right click the Segmentation button on the toolbar.
You can create a new segmentation with the File->New Segmentation... command. You will still need to specify a color table for tkmedit to use.
You can import a surface annotation with the File->Import Surface Annotation as Segmentation... command. A surface annotation is a segmentation of the surface, so that every vertex in the surface has an associated label. TkMedit will look up the corresponding voxel for each vertex and assign the label value to that voxel in a new segmentation.
Like the anatomical volumes, TkMedit can have a Main or Aux segmentation. Each can have its own color table. To load Aux segmentations use the commands in File->Aux Segmentation. As with the anatomical volumes, only the Main segmentation volume can be edited.
Segmentations are drawn as a colored overlay in the Display Window. The colors are defined in the color lookup table file specified at load time. The opacity of the overlay can be configured in the dialog box brought up by choosing View->Configure..., Segmentation Display... or by control-left clicking on the Segmentation button on the toolbar. The overlay can be hidden by unchecking View->Segmentation Overlay or by clicking the Segmentation button on the toolbar. You can toggle between the Main and Aux segmentations with the View->Aux Segmentation Overlay command.
If the Segmentation Label Volume Count option in the View menu is checked, when the Edit Segmentation tool is active and the left button is used to set the cursor, TkMedit will count the number of contiguous voxels in the label clicked and display the result in the Cursor Information area in the Tools Window. This operation may take anywhere from a second to minutes depending on the size of the area clicked, so be aware that TkMedit may seem unresponsive for this length of time after setting the cursor with this option activated.
You can select a segmentation label, adding to the current selection, by placing the cursor on a label and choosing Tools->Segmentation->Select Main Segmentation Label At Cursor, or the corresponding command for the Aux segementation. This goes through the entire segmentation volume and finds all voxels of the same segmentation value as the one at the cursor, and adds them to the selection.
A segmentation can be edited with the Edit Segmentation tool, which can be activated by pushing the button on the Main Toolbar, by choosing Tools->Edit Segmentation, or by pressing the 'g' key.
By clicking with button 2 with this tool, you can 'paint' a label in the segmentation. The color used can be set in the dialog box brought up by choosing Tools->Configure Segmentation Brush.... This tool is a brush tool, so it uses the global brush settings available in Tools->Configure Brush Shape... and in the Reconstruction Toolbar. To 'erase' a label you have added, you must re-paint the original segmentation that it was.
If you are working on the aseg.mgz and plan to save your edits as aseg.mgz, to "erase" something you added in error you right click on the Edit Segmentation button and the Segmentation Brush Info window will pop up. From the list of structures, choose the one that the area you edited was originally. For example, if you were adding Thalamus on top of Left Cerebral White Matter and what to delete the Thalamus label, choose Left Cerebral White Matter and use the 2nd mouse button to draw over the Thalamus voxels you want to remove.
If you are creating a segmentation and not saving it as aseg.mgz, you probably want to choose 0 Unknown from the Segmentation Brush Info list to "erase" segmentation you have added.
The painting function is similar to the Edit Voxels tool: the clicked voxel, and those around it depending on the brush radius, are set to the value specified in the Configure Segmentation Brush dialog. Clicking on a voxel with button 2 and the control and shift key held down will set the current painting color to the color of the clicked voxel. Edits can be undone with the Edit->Undo Last Edit menu item.
A flood fill is also available, activated by shift-clicking mouse button 2 or 3. This tool fills areas with values equal to or similar to the voxel clicked. It looks for contiguous areas in the source volume to fill in the segmentation with the selected color. It is configured in the Configure Segmentation Brush dialog. It has parameters for 3D, the source volume, fuzziness, distance.
Source Volume: Specifies which volume to use when looking for similar voxels, so that the Main, Aux, or segmentation volume can be used to look for regions. You can use this to fill an area in the segmentation volume based on voxel values in the anatomical volume. Fuzziness: Determines the level of similarity to consider when finding adjacent voxels to select. If it is 0, only contiguous voxels with exactly the same value as the voxel clicked will be set. If it is greater than 0, this is the maximum value difference from the clicked voxel that a contiguous voxel can have to be considered in the same region. Distance: Determines the maximum size of the region to fill from the clicked voxel. If it is 0, there will be no distance limit. 3D: Determines if the fill is in-plane only or will fill in three dimensions.
A fill can be undone with the Edit->Undo Last Edit menu item.
To save changes to a segmentation, choose File->Save Segmentation to overwrite the original segmentation volume or File->Save Segmentation As... to specify a new volume, such as an .mgh or .mgz volume, or an empty directory in which to save a COR volume.
After you have saved all of your edits, you could recreate the final surfaces with the command:
recon-all -autorecon2-noaseg -subjid <Subj_ID>
Do not run this command if you are conducting the tutorial! This step will take a long time and there is no need to run it for the tutorial purposes.