Tutorial: Getting Started with ITK-SnAP

Welcome to SnAP! This guide will introduce you to the most commonly used features of the software. The tutorial is organized into eight sections, and requires about 60 minutes to complete.

Click the first link in te list below to begin the tutorial. You may also click one of the other links to jump to a specific section.

SNAP Tutorial. Section 1.

Section 1. Introduction.

This section explains the purpose of the SNAP tool, and describes the screen layout. This section is organized as a series of questions and answers about the general capabilities and structure of the SNAP tool. For brevity, only the most basic questions are answered here; more questions will be answered in later sections of the tutorial.

How is This Tutorial Organized?

This tutorial is a walk-through of a SNAP segmentation session. The information presented in this tutorial falls into the following categories:

How Do I Get and Run SNAP Under Microsoft Windows™?

On the Microsoft Windows™ platform, SNAP is distributed as a standalone program. It can be easily installed like any other program, and launched from the Microsoft Windows™ Start menu.

The SNAP self-installer is available for download at http://www.itksnap.org/download/snap

How Do I Get and Run SNAP as Part of ITK?

On all supported platforms, SNAP is distributed as a part if the Insight Toolkit InsightApplications directory. Obtaining, building and running SNAP as part of this distribution requires considerable knowledge of system administration and computer programming.

The directions on obtaining and installing SNAP are available at http://www.itksnap.org/download/snap

If SNAP has been installed on your system, consult your system administrator for instructions on starting it.

What Exactly Does SNAP Do?

SNAP provides a set of tools to make segmentation of volumetric data easier and faster. SNAP can be used in two different modes: manual segmetnation and semi-automatic segmentation. The manual mode is used for segmentation using hand contouring and for cleaning up the results of automatic segmentation. In the semi-automatic mode, a powerful level set segmentation algorithm is used to segment anatomical structures in three dimensions. This algorithm requires some guidance from the user, and SNAP provides an easy interface to provide such guidance.

What Kinds of Users is SNAP Designed for?

First and foremost, SNAP was designed for clinical users. A user who already uses a computer for image segmentation, and thus understands the fundamentals of three-dimensional medical imaging will be able to use SNAP after completing this tutorial. SNAP does not require a deep understanding of the underlying mathematics and computer science to use.

SNAP user interface also provides some controls designed specifically for expert users, who are familiar with the level set algorithms. In this tutorial, some sections are written for the expert users, and are optional.

What Kinds of Images Can SNAP Process?

SNAP can be used to segment a variety of three-dimensional images. The images have to be homogeneous, i.e., having a single intensity value per pixel. In other words, SNAP can be used with MRI, CT and PET images, but not with color cryosection or diffusion tensor images. SNAP reads a variety of image formats, including RAW, Analyze, GIPL and MetaImage.

How Does SNAP Represent Segmentation Results?

SNAP represents segmentation by assigning labels to pixels (voxels) in the input image. For instance, when segmenting a brain MRI, some of the pixels in the image may be assigned the label 'grey matter', others will be assigned the label 'lateral vetricle', etc. It is up to the user to come up with the list of labels to use in a particular segmentation task. Each voxel in the input image can only be assigned a single label. The output of SNAP is a volumetric image of labels.

In this tutorial, we will use the term grey image to refer to the three-dimensional input image, e.g., an MRI or a CT image. We will use the term label image to refer to the corresponding three-dimensional volume of labels.

What Are the Main Limitations of SNAP?

Since SNAP can only assign a single label to each pixel in the grey image, it can not be used for segmentation with sub-voxel accuracy.

What Are the Different Parts of the SNAP User Interface?

The picture below shows the SNAP user interface in manual segmentation mode.

Most of the SNAP window is occupied by four panels, three of which show orthogonal slices through an image, and the fourth, located at bottom left, shows the three-dimensional view of the segmentation. This tutorial will refer to these panels as slice panels and the 3D panel. Under each of these panels are located several blue buttons, which are used to interact with each panel individually.

The left portion of the SNAP window is occupied by a tall thin area called the control panel. At the top of the control panel is located a menu bar, which is used for saving and loading images, for setting options, and for accessing the help system. The rest of the control panel houses a variety of buttons, sliders and other controls, which appear and disappear depending on the current mode of operation. We will see how to use the control panel in the subsequent sections.

In addition to the main window shown above, several other windows will pop-up during the SNAP session. These windows are used to coordinate specific tasks, such as loading and saving images, or selecting parameters in the semi-automatic segmentation mode.

What Input Devices does SNAP Require?

SNAP requires the use of a mouse, trackball, or an equivalent input device. A three-button mouse with a scroll wheel is preferred, but is not necessary. If your input device does not have a right or a middle mouse button, use the following combinations keyboard mouse combinations:

What Additional Documentation is Available?

See the list of publications at http://itksnap.org/manual.php

SNAP Tutorial. Section 2.

Section 2. Loading a 3D Image File

Reading a three dimensional image is not as simple as opening a document in a word processor. To facilitate this process, SNAP offers a special wizard for loading images. This section of the tutorial will guide you through the different pages of this wizard. It will take 5 to 15 minutes to complete.


Step 1. Download an Example Image [recommended]

We strongly recommend that you use a set of images that we have provided as an example during this tutorial. A compressed file containing these images can be downloaded using the link shown below. Please note that the image can not be downloaded using the SNAP help viewer. Copy the link and open it in an external web browser.

http://www.itksnap.org/download/snap/files/MRI-crop.zip

Save the file MRI-crop.zip in a convenient directory. This file is a compressed archive, and can be opened using a decompression utility such as WinZip® on Windows or unzip on Unix. The archive contains the following files:

MRIcrop-orig.gipl An MRI image of a volunteer's brain
MRIcrop-seg.gipl An example segmentation of the MRI image done using SNAP.
MRIcrop-seg.label A file containing label descriptions for the segmentation

Please consult your system administrator if you need help with downloading and extracting the example images.


Step 2. Open the 'Load Image' Wizard.

Launch SNAP if you have not done so already.

Select File | Load Data | Greyscale Image using the menu bar located at the top left corner of the SNAP window, as shown in the picture below:

The wizard will appear, as shown below:


Step 3. Select the Image File.

There are three ways to specify the filename of the greyscale image. First, the filename can be typed into or pasted into the text box at the top of the wizard. Second, the 'Browse...' button can be used to locate the image file in your computer's file system. Finally, the 'History' button can be used to select a file that has been recently opened.

Click the 'Browse...' button. The following window will appear:

Notice that the file browser includes a 'Favorites' menu, which can be used to remember and quickly access frequently used directories.

We suggest you that for this tutorial you use the file MRIcrop-orig.gipl, which can be downloaded using the instructions given at the beginning of this section.

Use the file list to find and select an image, and press OK.

Once you select an image, its compete filename and image format will be displayed in the wizard, as illustrated below. SNAP tries to guess the format of the image file based on the file's extension. For some files, SNAP may not guess correctly, and you will need to select the correct format from the drop box.

Press the 'Next' button to continue to the next page of the wizard.

If you have selected to read an image in RAW file format (this is an advanced feature), please follow this link for additional information, before proceeding to the next subsection.


Step 4. Specify Image Orientation.

A volumetric image is a three-dimensional array of intensities. Every pixel in the image is referenced by three coordinates, x, y, and z, with z indicating the number of the slice to which the pixel belongs, y indicating the row in the slice, and x indicating the column. In order to display images correctly, SNAP needs to know the mapping between this x, y, z image coordiate system and the patient coordinate system. In other words, SNAP needs to know the mapping between directions x, y, z and the right-left, anterior-posterior or inferior-superior directions in the human body.

The orientation page of our wizard is used to specify this mapping, and it is shown below.

This page is used to specify the mapping between the patient coordinate system and the coordinate axes of the three-dimensional image. The orientation can be specified by (a) selecting one of the preset modes, (b) selecting 'Custom Orientation' in the preset drop box and assigning a patient direction to each image axis, or (c) by specifying a three-letter 'RAI' code.

RAI codes let you specify image orientation quickly. Each of the three letters in the code is an abbreviation for the direction in the patient coordinate system. For example, the code ASR means that the X axis corresponds to the anterior-posterior direction, the Y corresponds to the superior-inferior direction, and the Z corresponds to the right-left direction. The origin of the image is in the anterior-superior-right corner of the body.

For the image MRIcrop-orig.gipl, use the default orientation setting.

For other images, specify the appropriate setting. If you don't know the correct setting for your image, just use the default. You will still be able to use most of SNAP functionality.

Press the 'Next' button to continue.


Step 5. Review Image Information.

The last page of the wizard shows summary information about the loaded image.

Press the 'Finish' button to continue.

The wizard will disappear and the SNAP main window will display the image:


 

SNAP Tutorial. Section 3.

Section 3. Viewing the 3D Image.

This section shows you how to interact with a three-dimensional image in SNAP. It assumes that you have successfully loaded an image following the instructions in the previous section. This section requires approximately 10 minutes to complete.

Step 1. Examining the Control Panel.

After loading a grey image, SNAP puts itself into manual segmentation mode. The control panel for this mode is displayed to the right. It is divided into four sub-panels, which are labeled "IRIS Toolbox", "Tool Options", "Segmentation Label", and "3D Toolbox". The IRIS toolbox contains four buttons, which are used to select different modes of interaction with SNAP. These interaction modes are called tools for short. The contents of the tool options sub-panel depend on the tool that is currently selected in the IRIS toolbox. The segmentation label sub-panel is used to select the labels used for manual and automatic segmentation, and the 3D toolbox provides additional tools used to interact with the three-dimensional rendering of the segmented structures.

In this section of the tutorial you will learn how to use two of these tools in the IRIS toolbox: the crosshairs tool and the zoom/pan tool, which provide different ways to quickly navigate through the three-dimensional image.


Step 2. Viewing Orthogonal Slices.

Once you have successfully loaded an image, the SNAP main window should look like this:

Let's focus our attention on the three of the four dark windows that are displaying slices of the volumetric image (the fourth window is used for 3D display and will be discussed later). These three slice windows display three views of the image volume, in the orthogonal axial, coronal, and sagittal planes.

Notice that a scrollbar is located next to each slice window. Under each scrollbar is located a slice counter, which shows the index of the displayed slice and the total number of slices in the direction perpendicular to the slice.

Use the scrollbars to change the currently displayed slice in one of the three slice windows. If your mouse has a scroll wheel, you can use it to change the slice instead. Make sure that the mouse cursor is inside of the slice window that you want to interact with.

A key feature of SNAP is that the three slices are not viewed independently, but rather linked by a common cursor. As you manipulate the scroll bars, you will notice that the blue lines in the other two slice windows are moving. These blue lines indicate the intersection between orthogonal slices. As we will see shortly, the common cursor makes it easy to examine the volumetric image near any particular voxel.

Step 3. Navigating the Image in Crosshairs Mode

Crosshairs mode is used to quickly focus all three slide views onto a location in the image. When you click on one of the slices, the other two slices are adjusted so that the pixel where you clicked becomes the point of intersection of the three slices. Thus, you can easily examine the orthogonal views of the image in the neighborhood of any pixel.

Select the crosshairs tool in the IRIS toolbox (shown below)

Left-click on any one of the three slices. Watch how the other two slices change.

You can also hold down the left mouse button and move the mouse around the slice for faster navigation.

Remember that you can use the scroll wheel of your mouse to change the slice currently displayed in the slice window under the mouse. This lets you move around the image in three dimensions, without moving the mouse away from the slice window!

You will notice that the common cursor formed by the blue dashed lines always points to the same voxel in all three slice views. The grey level intensity of the voxel and the segmentation label corresponding to it are displayed in the tool options sub-panel of the control panel:

Since we have not done any segmentation yet, the segmentation label at every voxel has numeric value 0 and is called "Clear". The action of clicking on a voxel in the image to check its greylevel intentensity value is called probing. We will make use of probing later in this tutorial.

In other SNAP modes where the left mouse button is used for other tasks, you can still move the crosshairs by using the middle mouse button, or by holding the Alt key on the keyboard and using the left mouse button.

Step 4. Navigating the Image in Zoom/Pan Mode

While the crosshairs tool lets you move around the image, the zoom/pan tool allows you to zoom in on a particular region of a slice and to pan around when the whole slice does not fit into a slice window.

Select the zoom/pan tool in the IRIS toolbox (shown below)

Click and hold the right mouse button anywhere in one of the slice windows, and drag the mouse up to zoom into the slice. Drag the mouse down to zoom out.

Click and hold the left mouse button anywhere in one of the slice windows, and drag the mouse in any direction to pan around the image.

Click the Reset View button located below each slice window to restore the original zoom level, as illustrated below.

By default, SNAP lets you change the zoom in all three slice windows independently. However, it is often desireable to make sure that each of the three slices is displayed using the same zoom level. The tool options sub-panel, which is shown below, allows you to link the zoom level between the three slice views, as well as to specify zoom level explicitly.

Tick the "Zoom slices together" check-box in the tool options sub-panel. Try zooming in and out in one of the slice windows by dragging the mouse (as before). Notice how the other slices zoom in accordingly.

Type in the number 200 into the "Zoom %" text box, and press the Enter key. The slices will zoom to double the default zoom level.

Click the "Reset 2D views" button. The zoom level will return to default in all three slices.


When slices are zoomed together, the number of pixels on the computer screen corresponding to a unit of length in the space of the 3D image is the same in all three slice windows. When slices are zoomed independently, the a distance in image space may correspond to different distances in the slice windows.

Step 5. Adjusting Image Contrast (a.k.a. Windowing)

The MRI image that we have loaded in the last section of this tutorial has fairly low contrast. It is difficult to see some of the structures in the image. SNAP provides a windowing dialog for adjusting the mapping between intensities in the 3D image and the intensities of the displayed slices.

Select Options | Intensity Curve... using the menu bar. The windowing dialog will appear.

This dialog consists of a plot area on the left and several controls and buttons on the right. The plot area displays the current mapping between image intensities and display intensities as a think red line with four embedded yellow diamonds. These diamonds are called control points and can be used to change the shape of the mapping. Also, the plot area shows in blue the histogram of the intensities in the grey image. Notice that most of the intensities fall in the lower third of the intensity range. So, to improve the contrast, we will adjust the mapping accordingly.

Type the number 100 into the 'Window' text box, and press the Enter key.

Notice how the red line changes, and the displayed slices change contrast. You can also directly manipulate the curve by moving the control points.

Move the mouse over one of the yellow control points, hold down the left mouse button and move the mouse to update the mapping

The number shown in the text box labeled 'Level' is the image intenisty of the leftmost control point. The number shown in the text box labeled 'Window' is the difference between the rightmost and leftmost control points. The slider 'Control Points' allows you to change the number of the control points, increasing the control over the shape of the mapping curve.


Press the 'Close' button to close the dialog

Step 6. [Optional] Adjusting Slice Display Order.

By default, SNAP shows the axial slice in the upper left, the sagittal in the upper right, and the coronal slice in the lower right. You can change the order of the display using the 'Display Options' dialog.

Select Options | Display Options... using the menu bar. The display options dialog will appear.

Choose the 'Layout' tab.

Experiment with selecting different display configurations.

Press 'Apply' to put the selected configuration into effect.

Press 'Close' to close the dialog.

Step 7. [Optional] Adjusting Display Apperance.

You can adjust the appearance of certain elements of the SNAP User Interface. This is useful if you are preparing a manuscript or a presentation and want to make sure that elements such as crosshairs are clearly visible.

Select Options | Display Options... using the menu bar. The display options dialog will appear.

Choose the 'Appearance' tab.

Choose one of the available user inteface elements and adjust its color, line thickness, etc.

Press 'Apply' to make changes.

Press 'Reset' to restore default settings.

Press 'Close' to close the dialog.

SNAP Tutorial. Section 4.

Section 4. Manual Segmentation

This section describes how SNAP can be used for manual segmentation. You will learn about working with segmentation labels, painting regions ontwo-dimensional slices of the image, and saving and loading segmentation results. This section requires approximately 10 minutes to complete.

Step 1. About Segmentation and Segmentation Labels

To segment an anatomical structure in SNAP means to assign a label to each voxel in the structure. A label is a number between 0 and 255. Associated with each label is a name and a set of display settings, such as the color used to display the label. For example, we can associate the name 'cuadate' and the color red with the label 3. When you first load a grey image into SNAP, the special label 0 is assigned to each voxel in the image. This label is associated with the name 'Clear' and means that a pixel has not been segmented yet.


Step 2. Create a Few Labels

When you first load SNAP, it creates a default set of six labels, with names 'Label 1' through 'Label 6'. Before starting segmentation, we will edit these labels, assigning them meaningful names and colors.

The SNAP control panel contains a sub-panel that is used to interact with segmentation labels. It is shown below.

At the top of this sub-panel are two drop-down boxes. The first box is used to select the label that is currently used for manual and automatic segmentation. The second box is used to select the label or labels that are affected by the segmentation. We will see how to use these drop boxes a few steps below. Below the drop-boxes is located a button called 'Edit Labels...', which is used to associate names and colors with label numbers.

Press the 'Edit labels...' button. The following window will appear.

This label editor can be used to modify information associated with each label and to add new labels. The left pane of the editor lists the labels that are currently available. The right pane is used to modify the label currently selected in the list. You can change the color in which the label appears in SNAP, the name associated with the label, and the transparency of the label.

Change the description text box to 'Caudate'

Change the color associated with the label to light green

Press the 'Close Window' button to apply the changes and close the window

The following additional information is associated with each label:

Opacity: A label can be made to appear partially transparent when it is displayed in the 3D window. This is useful when one structure, such as the skull, obstructs the view of another.

Visibility: A label can be hidden from display, either in the 3D window or in all windows. Like transparency, this can be used to hide obstructing structures. Additionally, you can tell SNAP to apply manual and automatic segmentation only to voxels with labels that are not hidden. Thus, by hiding a label, it is possible to prevent various segmentation operations from affecting it.



Step 3. Load Labels from a File

If you have downloaded an image archive, as recommended in Section 2, Step 1, then you can load a set of segmentation labels from a file.

Select File | Load Data | Label Descriptions... using the menu bar. A dialog will appear.

Use the 'Browse...' button to locate and select the file MRIcrop-seg.label

Load this file by pressing the Ok button.

The file contains a dozen or so labels for describing brain anatomy. If you open the label editor, it should look like this:


You can create your own label files. Just use the label editor to change existing labels and to add new labels, and then select File | Save Data | Label Descriptions... from the menu bar.


Every time you work with an image, SNAP remembers all sorts of information about your session, and restores this information next time that you open the image. The list of labels is part of the information that SNAP remembers.



Step 4. Segment the Caudate Nucleus

In the step, we will manually segment the caudate nucleus. This step assumes that you are working with the image MRIcrop-orig.gipl, as recommended in Section 2, Step 1.

Make sure that the 'Segmentation Label' subpanel looks like this:

This means that we are going to apply the label called 'caduates' to the voxels that we segment. The 'draw over all labels' settings means that segmentation will override all labels that have already been assigned to voxels.

Enter the crosshairs mode.

Position the crosshairs in such a way that the right caudate nucleus (shown below) is visible in all three slices.

Now we are ready to begin manual slice-by-slice segmentation.

Select the polygon tool in the IRIS toolbox (shown below)

The polygon tool is used to paint closed polygons on top of the axial, sagittal and coronal slice windows. These polygons are then filled with the currently selected label. By painting polygons slice by slice, a whole 3D structure can be selected.

Click the left mouse button somewhere on the boundary of the right caudate.

Continue clicking the left button along a sequence of points along the boundary.

Click the right mouse button to close the polygon (i.e., to connect the first an the last vertices).

The green rectangle around the polygon indicates that all of the vertices are currently selected. Selected vertices can be moved by clicking and dragging the left mouse button. Let's select some vertices and move them:

Use the mouse to draw a box around some of the vertices in the polygon (to draw the box, click and hold the left mouse button near the upper left part of the slice window, drag the mouse towards the lower right corner and release the button once the box contains two or more vertices).

Click and hold the left mouse button inside the green box and drag it to move the selected vertices.

In addition to selecting vertices and moving them, you can use the buttons located under each slice window to manipulate the polygon. Use the 'delete' button to delete the currently selected vertices from the polygon. Use the 'insert' button to insert new vertices between adjacent pairs of selected vertices.

Edit the polygon by selecting, moving, deleting and inserting vertices until you are satisfied with it.

Use the 'accept' button to fill the polygon with the segmentation label 'caudates'.

Once you have clicked 'accept', the voxels inside of the polygon are assigned the currently selected segmentation label.

If you are not satisfied with your result and want to erase it, you can do so by changing the active drawing label to the 'Clear' label, and painting a polygon on top of the part of the segmentation that you want to erase. When you press 'accept', the voxels withing this polygon will be assigned the clear label.

SNAP remembers the last polygon that you used and lets you paste it. This makes segmenting a structure faster.

Move to the next slice in the slice window where you just painted (using the scroll bar or the mouse wheel).

Press the 'paste' button to recall the last accepted polygon.

Edit the pasted polygon by selecting and moving vertices, and accept it when satisfied.

So, by moving from slice to slice, pasting, editing and accepting polygons you can quickly segment the caudate. Notice that as you accept polygons in one of the slice windows, it becomes visible in the other slice windows as a line of voxels. SNAP is unique in letting you view and edit the segmentation in all three orthogonal slice windows at once.

[Optional] Continue segmenting the caudate in all three slice windows until you are satisfied with the result.

Press the 'update mesh' button located below the 3D view window to see the segmented structure in three dimensions.

You can learn a lot more about interacting with the 3D window in a later section.


Step 5. [Optional] Save your work

SNAP saves segmentation results as images. Each voxel in this image contains a number between 0 and 255, which indicates the segmentation label assigned to the voxel. Segmentation images can be saved in a variety of image formats and can be read by other programs.

Select File | Save Data | Segmentation Data... using the menu bar. A dialog will appear.

The dialog asks you for the file name of the image that will be saved. You can type in a filename, use the 'Browse' button to search for an appropriate location on your computer, or you can use the 'History' button to enter up a recently used file name.

Supply a filename to the wizard using the 'Browse' button.

Once you select an image, its compete filename and image format will be displayed in the wizard, as illustrated below. SNAP tries to guess the format of the image file based on the file's extension. For some files, SNAP may not guess correctly, and you will need to select the correct format from the drop box

.

Press 'Save' to save the segmentation.

 

SNAP Tutorial. Section 5.

Section 5. Introduction to Automatic Segmentation.

Step 1. Snake Evolution and Velocities

This section of the tutorial introduces the basic concepts behind the automatic segmentation component of SNAP. There are no action items in this section, just an explanation of the theory and terminology that must be understood to use SNAP effectively. All examples in this section will be made using two-dimensional images. The concepts, however, extend to three dimensions in a straight forward way.

The methodology behind SNAP is called snake evolution. The term snake is used to refer to a closed curve (or surface in 3D) that represents a segmentation. In snake evolution methods, the snake evolves from a very rough estimate of the anatomical structure of interest to a very close approximation of the structure, as illustrated in the figure below.

The red curve is this figure is called the snake. It starts out initialized as a small circle inside of the ventricle, and over time it grows, or evolves, to take shape of the ventricle. So how does it do that?

The snake evolution is governed by a mathematical equation that describes the velocity of every point on the snake at any particular time. The velocity of each point depends (1) on the shape of the snake and (2) on the intensities of the image in the neighborhood of the point. Here is an illustration of some of the velocities that can act on the snake:

In this picture, velocities acting on some of the points are shown as blue and yellow arrows. The velocity vectors always point in the direction perpendicular to the snake. The yellow velocities depend on image properties: they are stronger in the regions of the image where the intensity is homogeneous and weaker where there are edges (discontinuities) in image intensity. By making the snake expands much slower at image edges than at homogeneous regions, we force the snake to assume to form of these regions. The blue velocities depend on the shape of the snake: they are longer at points where the snake is more curved and shorter where the snake is more straight. By applying higher inward velocities at places where the snake is sharp, we cause it to maintain a smooth shape.

The movement of a point on the snake is determined by the sum of the velocities at that point. The figure below shows how the snake evolves under the effect of velocities. The dashed outline represents the snake at the next time interval.

When interacting with the SNAP automatic segmentation mode, the user needs to specify three things:

  1. How will the image intensities affect the image-dependant velocities acting on the snake?
  2. Which types of velocities, and in which proportion, will drive snake evolution?
  3. What form will the initial snake take?

In the following three subsections, we will address these three questions correspondingly.


Step 2. Feature Images

As mentioned above, some of the velocities that drive snake evolution depend on the image intensities. In SNAP, this dependency is represented by the so-called feature image . The feature image is computed by applying a particular function uniformly to the entire image. Image dependent velocities are proportional to the value of the feature image.

Image-dependent snake propagation velocities are proportional to the value of the feature image.

SNAP defines two distinct ways to compute feature images. The first causes the snake to slow down near edges, or discontinuities, of intensity. The second causes the snake to attract to boundaries of regions of uniform intensity. It is very important to understand the effect of the feature image on snake evolution because the proper construction of the feature image is the one most important step in getting a good segmentation.

We will begin by examining the edge feature image, an example of which is shown below:

The edge feature function takes values between zero and one. It is close to zero at strong edges in the image, and it is close to one in regions of uniform intensity. The value of the feature image at a pixel is independent of the intensity level of the input image; it only depends on the differences in intensity between neighboring pixels.

The edge-based feature image is computed using the following pipeline:

  1. The image is smoothed, i.e., blurred using a Gaussian filter.
  2. The gradient magnitude of the image is computed. Gradient magnitude of an image describes how much neighboring pixels differ in intensity.
  3. The gradient magnitude is remapped to the range 0 to 1, with large values of gradient magnitude mapping to 0 and small values mapping to 1.
greylevel image
blurred image
grad. magnitude
edge feature image

The steps of the pipeline are illustrated by the images above. As a user, you have the option to change the amount of blurring that is done. The more blurring is performed, the less likely are the subtle edges in the image to affect the segmentation. You also have control over the function used to remap the gradient magnitude image into the feature image. This lets you increase or decrease the contrast of the feature image. You will learn how to construct the edge feature image in a later section of the tutorial.

Now, let's examine the so called region competition feature images. Region competition is based on thresholding the image intensities, i.e., classifying them into background and foreground intensities. Based on the user's specifications, a range of intensities is designated as foreground, or object intensities.The intensities outside of the range are defined as background. A feature image is constructed by assigning values near 1.0 to foreground intensities, assigning values near -1.0 to background intensities, and assigning values close to zero to intensitues that are on the borderline between foreground and background. This is illustrated below: the left picture shows the histogram of the intensities in the greylevel image. The intensities between 45 and 63 are chosen as foreground, the rest as background. The function plotted in picture on the right maps the intensities between 45 and 63 to positive values, and it maps the rest of the intensities to the negative values.

The feature image resulting from this operation is shown below. The caudate appears as a bright region with positive values of the feature, and the surrounding structures appear dark.

Unlike the edge feature image whose values are non-negative, the region competition feature image takes both positive and negative values. This means that the image-dependent velocities acting on the snake act outward in places where the feature image is positive (i.e., inside the structure of interest), and they act inward in places where the feature image is negative. These velocities are illustrated below.

These velocities force the snake to fit the boundary of the foreground region. Here is an example of snake evolution using the region competition feature function. The snake is initialized both inside and outside of the caudate nucleus. After a few iterations, however, it fits the boundary caudate by shrinking in the background region and growing in the foreground region.

Note that in this image we show the interior of the snake, rather than its boundary, as was shown in an earlier illustration. This is how the snake is actually visualized in SNAP.


Step 3. Types of Velocities for Snake Evolution

In this subsection we will discuss in more detail the different types of velocities for image propagation. There are three types of velocities that can be applied in SNAP to drive snake evolution.

  1. Propagation velocity
  2. Curvature velocity
  3. Advection velocity

Let us examine each velocity type in more detail.

Propagation Velocity

This is the most common velocity used in SNAP. It is proportional to the value of the feature image. The constant of proportionality can be set to be positive, in which case positive values of the feature image cause this velocity to point outwards, or negative, in which case positive values of the feature image cause this velocity to point inwards. In a homogeneous region of the feature image, the propagation velocity is constant and causes the snake to expand (or contract) at a unit speed.

Curvature Velocity

This velocity is used to control the shape of the evolving snake, and it can sometimes prevent the snake from leaking into adjacent structures. The curvature velocity acts inwards and is approximately proportional to the curvature of the snake at the point. Sharp corners in the snake's boundary have high curvature, while points where the snake is straight have low curvature. The effect of curvature velocity is to slow down the snake evolution at places of high curvature, effectively smoothing out the sharp corners that may otherwise be formed.

Advection Velocity

The advection velocity is the most difficult of the three velocities to visualize, but it is very important because it can have a dramatic effect on the quality of the segmentation. The advection velocity is used only in conjunstion with the edge feature image; it is not used with the region competition feature image. In qualitative terms, it causes the snake to slow down or stop as it approaches edges in the greyscale image. More precisely, the velocity is defined by the dot product of the unit vector perpendicular to the snake and the gradient vector of the feature image. That means that when the snake is parallel to an image edges and close to it, the advection force acting inwards on the snake is greatest. The illustration below shows the gradient vectors of the feature image and the corresponding advection velocities.


Step 4. Snake Initialization

As mentioned, the snake can be initialized very roughtly, using a circular bubble. More than one bubble can be used to initialize the snake. As the snake evolves, its disconnected components may merge together, as illustrated by the sequence of images below.

The following rule is improtant for proper snake initialization :

When using the edge feature image, make sure that the initialization is fully contained in the anatomical structure that you want to segment, since the snake propagates outwars only.

When using the region competition feature image, the initialization may lie outside of the structure of interest, since the snake propagates both inward and outward.

 


Step 5. Summary

One does not need to fully understand the mathematical theory behind snake evolution in order to use it in SNAP. Basically, a snake is a closed curve or collection of closed curves in 2D, and a closed surface or collection of closed surfaces in 3D. Snake evolvution is described by the sum of different types of velocities that act on each point of the snake in the direction perpendicular to the snake. Some of these velocities are image dependant, while others depend on the shape of the snake. The image dependant velocities are defined in terms of the feature image, to which they are proportional. SNAP can create two types of feature images, one based on edges in the input image, the other based on regions of uniform intensity. SNAP supports three types of velocities: the image dependent propagation velocity, the shape dependent curvature velocity and the image dependent advection velocity.

In order to perform an automatic segmentation in SNAP, the user needs to (1) choose the type, edge or region, of the feature image to be used, (2) select the parameters used to compute the feature image, (3), initialize the snake using spherical bubbles, and (4) choose the relative weights of the different types of velocities that drive snake evolution. The following two sections of the tutorial describe how these tasks are performed through the SNAP user interface.

SNAP Tutorial. Section 6.

Section 6. Automatic Segmentation using Region Competition Snakes

This section gives step by step instructions on segmenting an image using the region competition snake (in last section's terminology, snake evolution that uses the region feature image). This section assumes that you are working with the image MRIcrop-orig.gipl, as recommended in Section 2, Step 1. We will segment the caudate nucleus and the ventricles in this image. This section also assumes that you are using the label file MRIcrop-seg.label.

You can, however, follow the general directions of this section using a different image, but you will have to use your own judgement in selecting various parameters.


Step 1. Discard the Previous Segmentation.

In Section 4, we have created a manual segmentation. In order to perform the segmentation automatically, we will discard the manual segmetnation. This involves reloading the greyscale image.

Select File | Load Data | Greyscale Image.

Use the History button to select the image loaded most recently.

Step through the rest of the wizard, as descibed in Section 2.



Step 2. Select the Label to Use for Automatic Segmentation

We will be segmenting the caudate nucleus. We have to make sure that the appropriate combination of the current drawing label and background (draw over) label is selected.

Make sure that the label "caudates" is selected as the current drawing label

Make sure that "All Labels" is selected in the Draw over drop-down box.

The draw over label functions the same way in automatic segmentation as in manual segmentation. It lets you apply the results of automatic segmentation to all labels, to all visible labels, to the clear label, or to a particular label. This gives you a lot of creative control when segmenting multiple structures. For instance, to segment a structure that is embedded inside another structure, you can first segment the outer structure with label A and then segment the inner structure with label B and with the draw-over label set to A.



Step 3. Select the Region of Interest using the Snake Interaction Mode.

The automatic segmentation component of SNAP requires a lot of computer resources. Both the amount of memory and the time required to compete a segmentation can be reduces by selecting a sub-region of the image on which to perform segmentation. In this step, we will select a subregion of the image that contains the caudate nucleus.

Make sure that the slice is fully visible in each the slice windows by pressing the Reset View buttons underneath the slice windows.


Select the snake tool in the IRIS toolbox (shown below)

As you select the snake tool, a pink-colored dashed selection box will appear at the border of the each slice in the slice windows, as shown below:

The selection box displays the region of interest that will be used in automatic segmentation. The use of word region here should not be confused with region competition. The region of interest is a rectalinear box, while the regions in region competition are of arbitrary shape and are defined by uniform intensity. We will now adjust the region of interest by dragging the sides of the selection box

In one of the slices position the mouse cursor near one of the corners of the selection box

Hold down the left mouse button and drag the mouse towards the center of the image. The size of the box will be adjusted as you move the mouse.

As you are dragging the selection box, its edges change color from red to yellow.

Using all three slice windows, adjust the selection box to include the left and right caudate nuclei. Try to simulate the selection box in the picture below.

If the selection box disappears in one of the slice windows, that means that the crosshairs position is outside of the selection box. You can adjust the crosshairs position in one of the adjacent slices.

The crosshair position can be adjusted in this mode using the left mouse button as usual. However, you will need to click a few pixels away from the selection box to move the crosshairs.

Notice that the tool options control subpanel contains two buttons: Reset Region and Segment 3D. The former is used to reset the region of interest to the entire image. The second is used to enter the automatic segmentaiton mode of SNAP.

Once you have adjusted the region of interest, press the Segment 3D button.



Step 4. Familiarize Yourself with the Automatic Segmentation Mode.

When you press the Segment 3D button, the SnAP user interface changes considerably.

Let's look at some of the new elements that have appeared:

  1. The slice windows have fewer buttons and only show the region of interest selected in the previous step.
  2. The IRIS toolbar has been replaced by a smaller toolbar containing only two buttons. These buttons are used to change the crosshairs position and to zoom and pan around the region of interest. The buttons are used in the same way as in the manual SNAP mode that you are used to, except that fewer options for setting zoom are provided.
  3. A large panel labeled "Segmentation Pipeline" appears underneath the new toolbar. This panel contains the 'wizard ' used for controlling automatic segmentation. We will work with this wizard extensively in this section.
  4. A button labeled Cancel Segmentation appears at the bottom of the control panel. You can use this button at any time to return to abort the automatic segmentation and return to the manual SNAP mode.
  5. A pair of buttons appear underneath the 3D window. These buttons have the same functionality as the similar looking buttons in the 3D toolbox in the manual mode.

If the image slices appear washed out, i.e., have low contrast, use the Intensity Curve window to change the contrast as described in Section 3.



Step 4. Construct a Region Competition Feature Image.

Recall the concept of edge and region competition feature images from the last section.In this step we will construct a region competition feature image appropriate for segmenting the caudate nuclei.

First let's tell SnAP which type of the feature image we will be using:

Select the option Intensity Regions in the section A of the Segmentation Pipeline Wizard.

Now, let's estimate the range of intensities to which the voxels in the caudate nucleus belong.

Move the crosshairs around the caudate nuclei. Look at the values of the grey level intensity, which is reported in a box labeled "Grey" underneath the toolbar.

You will find that the intensities in the caudate range between the high 40's and low 60's. This information is improtant for contructing the feature image.

Press the button labeled Preprocess Image... This button is used to construct the feature image. The following window will appear

This window is used to specify the mapping between the greyscale image intensities and the values of the feature image, which fall into the range between -1 and 1.

In the Intensity Region Filter window

  1. Set the threshold direction to Below and Above.
  2. Set the lower threshold to 48.
  3. Set the upper threshold to 63
  4. Set the smoothness to 1.7

After you use the mouse to click on and move the knobs that are used to change the threshold and smoothness values, you can use the left and right arrow keys to move these knobs one value at a time.

As soon as you change some of the parameters, the SnAP slice windows will display the feature image instead of the grey image. As you change the parameters, the slice windows are updated immideately. If you uncheck the Preview result checkbox, the slice windows will only reflect the values of the parameters when you press the Apply button.

Our goal in setting the parameters is to make sure that the voxels inside of fthe caudate nuclei are assigned positive values in the feature image, and that the voxels outside of it are assigned negative values. There are two ways to check that this happens:

Move the crosshairs around in the slice windows (the intensity region filter window will remain on top). Look at the values of the feature image, which are reported in a box labeled "Preproc" underneath the toolbar.

or

Check the Combined Display check box. The greylevel image is shown again, but the pixels where the feature image is positive are painted over with the color of the current segmentation label, as shown below. This is an easy way to make sure that the pixels in the caudate have a positive feature image value.

Uncheck Combined Display check box to see the feature image again.

The smoothness value determines the steepness of the mapping curve. It does not affect the sign of the feature function at any particular voxel, but it does have an effect on the smoothness of the snake evolution.

When you are satisfied with the feature image, press Okay to compute the feature image at all voxels and close the intensity region filter window.

SnAP lets you save and load feature images. Just use the appropriate menu items in the File menu. You can also load feature images by pressing the Load from File... button in the segmentation pipeline wizard.


Voxels in feature images are saved as floating point numbers, so some applications may not be able to load the saved images. You can not save feature images in GIPL format because if does not support floating point voxels. The Meta format is recommended.

We are now almost done with the first step of the Segmentation Pipeline Wizard.

Press the Next button in the Segmentation Pipeline Wizard to proceed to the next step.


Step 5. Initialize the Snake with Bubbles

The Segmentation Pipeline Wizard should be displaying "Step 2 od 3", as shown below.

This step of the wizard is used to position spherical bubbles to that initialize the snake, as described in the previous section.

Move the crosshairs such that the crosshairs position is inside of the right caudate nucleus in all three slice windows.

Press the Add Bubble button to place a bubble at the crosshairs position.

Use the Radius slider to change the radius of the bubble.

After adding a bubble, the SnAP window should look like this:

Place one more bubble inside the right caudate and place two bubbles inside the left caudate.

The result should look something like this:

To remove a bubble, select it in the list of bubbles underneath the Radius slider and press the Remove bubble button.

Finally,

Press the Next button in the Segmentation Pipeline Wizard to proceed to the next step.

As an alternative to using bubbles, you can use manual segmentation to initialize the snake. Before starting automatic segmentation, create a manual segmentation as described in Section 4 using the same label that you wish to use for snake segmentation. The manual segmentation will be used as the snake initialization, and you would not have to add any bubbles.



Step 6. Run the Snake Evolution

The Segmentation Pipeline Wizard should be displaying "Step 3 od 3", as shown below.

This wizard page allows you to set the parameters for snake evolution, and it allows you to control the snake using VCR-style controls.

Press Set Parameters... to open the snake parameter window.

The Snake Parameters window is shown below. This window consists of two parts. On the left is a control panel used to specify various parameters, mainly the weights of the propagation, curvature, and advection forces that were discussed in Section 5. These velocities are displayed using a fixed feature image, and not the feature image that you are working with. Nevertheless, this image is useful for understanding the relative contribution of the forces to snake evolution

The red curve for which the velocities are shown can be changed using the mouse. Left-click once in one of the four windows showing the curve and yellow 'control points' will appear. Move the control points by dragging using with the left mouse button. Try moving the curve and see how the foces change.

The snake parameter window also lets you save snake evolution parameter settings to a file and to load them from a file.


Change the curvature velocity weight to from 0.20 to 0.15

Press Accept to close the window


The Mathematical Mode tab of the Snake Parameters Window shows mathematical expression for the partial differential equation that drives the snake evolution, and allows you to set the parameters directly as constants in this equation.

You can also choose to display the experimental equation, which contains more terms and gives you more control over snake evolution.


The Advanced Mode tab of the Snake Parameters Window is discussed in the section on Tips and Tricks. It can be used to speed up large segmentations.

Now that we've set the snake parameters, we are ready to run the snake evolution. Notice the VCR-style controls located in the Segmentation Pipeline Wizard.

These controls have the following functionality:

Underneath the VCR buttons is a control that allows you to set the size of the step used in snake evolution. The larger the step value, the fewer times will the user interface be updated as the snake evolves. For small segmentations, it is advisable to leave the step size at 1. Next to the step size dropbox is a display that shows the current iteration.

Press the Step button several times to run the snake for a few iterations

Press the Run button once and watch the snake fill up the caudates.

Press the Stop button when the caudates have been filled up

Press the Rewind button if you want to restart.

To see the segmentation result in 3D, you can press the Update Mesh button underneath the 3D window, or you can select the Update Continuously checkbox.

Warning! Selecting Update Continuously will degrade segmentation performace significantly, possibly by orders of magnitude!

The result of the segmentation should look something like this.


Step 7. Finalize the Segmentation

The final step in the automatic segmentation process is to return to the SNAP manual segmentation mode, incorporating the segmentation results with other structures that have been previously segmented.

Press the Finish button in the Segmentation Pipeline Wizard

The Segmentation Pipeline Wizard will disappear, and the layout of the SNAP control panel will return to normal.

[Optional] Save your segmentation as described in Section 4.



Step 8. Use the 3D Tools to Edit the Segmentation Results

In this step we will postprocess the results of the segmentation using 3D tools.

Press the Update Mesh button below the 3D window to render the results


Now, let us examine the different tools available in the 3D Toolbox, which is shown below.

The toolbox contains four tools. Top to bottom, left to right, they are

Let's begin by examining the 3D trackball tool:

Select the 3D Trackball Tool

Press and hold the left mouse button and move the mouse to rotate the 3D view.

Press and hold the right mouse button and move the mouse up or down to zoom in and out in the 3D view

Press and hold the middle mouse button and move the mouse to pan in the 3D view.

Now try the 3D crosshair tool:

Select the 3D Crosshair Tool

Position the mouse over any point on the caudates and click the left mouse button. The crosshair position will move to the selected point and the slices shown in the slice windows will be changed.

Now, something more complex. We will use the 3D scalpel tool to assign different labels to the left and right caudate nuclei.

Use the Edit Labels button to add two new labels called 'left caudate' and 'right caudate' with different colors (for information on editing labels, see Section 3).


Select 'right caudate' as the current drawing label, and select 'caudates' (the label used for automatic segmentation) as the label to draw over, as shown below.

The 3D scalpel tool works by partitioning the space into two regions separated by a plane. The segmentation labels on one side of the plane are replaced by the current drawing label, as long as they agree with the current setting of the draw over label. In order to use the scalpel tool, we need to first rotate the 3D view such that a line can be drawn between the two caudates.

Use the 3D Trackball tool to rotate the 3D view in such a way that the caudates can be separated by an imaginary line, as shown below.

Now, we will use the 3D scalpel tool to actually draw a line in place of the imaginary line

Select the 3D Scalpel Tool

Click the left mouse button at one end of the imaginary line separating the caudates

Move the mouse around the 3D window. You will see a white line indicating where the 'cut' will be made, and an arrow indicating which half of the space will be relabeled.

Click the left mouse button again at the other end of the imaginary line

The result of this operation should look like this:

If you are not satisfied with the 'cut', press the Reset View button and try again.


Otherwise, press the Accept button to repaint one of the caudates with the active drawing label and press the Update Mesh to see the result in 3D.

The 3D scalpel is a very powerful tool for editing segmentation results. Using the clear label as the active drawing label, you can erase parts of the segmentation that have leaked outside of the caudates.


Step 9. [Optional] Segment the Ventricles

Use the procedure outlined in the steps above to segment the ventricles in the image. You will need to use the Above threshold direction setting when creating the feature image.

The result should look like this

SNAP Tutorial. Section 7.

Section 7. Segmentation Using Edge Based Snakes

This section assumes that the reader has competed the region competition based segmentation tasks in the previous section. The instructions offered in this section are less detailed than previous sections, since the reader would have gained sufficient experience using the tool in the preceding sections.

Step 1. Prepare SNAP for Edge-Based Ventricle Segmentation

The first task in this section is to use edge-based snakes to segment the ventricles in our image. In this step we will perform the preliminary tasks: clearing the previous segmentation, selecting the appropriate label and entering SNAP mode.

Discard the previous segmentation. Refer to Step 1 in Section 6 for instructions.


Set 'Ventricles' as the active drawing label and set the Draw Over mode to 'All labels'. Refer to Step 2 in Section 6 for instructions.


Select the snake tool in the IRIS toolbox

Position the 3D selection box to include the ventricles

Press the Segment 3D to enter the automatic segmentation mode.

The above tasks are described in Step 3 in Section 6


Step 2. Computing the Edge-Based Feature Image

At this point, you should be in the automatic segmentation mode of SNAP, on step 1 of the segmentation pipeline

In this step we will compute the feature image that assigns near-zero values to the pixels close to intensity edges in the grey image and assigns values close to one to regions of uniform intensity

First let's tell SnAP which type of the feature image we will be using:

Select the option Image Edges in the section A of the Segmentation Pipeline Wizard.


Press the button labeled Preprocess Image.... The Image Edge Filter window will appear:

This window is used to specify how intensity edges are used in constructing the feature image (this construction was outlined in Section 5, Step 2). There are three parameters that you can set in this window: scale of Gaussian blurring, edge contrast and edge mapping exponent.

The scale of Gaussian blurring describes how much the greyscale image is blurred before the edges in the image are calculated. At small values of the blurring scale all of the edges in the image will be used in constructing the feature image, which can lead to a prevalence of noisy edges, i.e., intensity discontinuities that do not correspond to boundaries between anatomical structures. For the larger blurring scales, only the most prevalent intensity edges become visible in the feature image, but fine-scale qualities of edges become lost. The selection of the blurring scale is a careful process where a tradeoff is made between too much noise and too little detail. Luckily, the edges between the ventricles and the surrounding tissues are very conspicuous and 'survive' a significant amount of blurring.

The other two parameters, the edge contrast and edge mapping exponent, determine the shape of the curve shown in the above window. This curve is used to map edge stregth to feature image values. The steeper the curve, the greater the contrast between flat regions and edges. Remember that the speed of snake propagation at a point is proportional to the value of the feature image at that point.

On a fast computer it is advisable to check the Preview result checkbox in order to receive live feedback as you change the parameters in the Image Edge Filter window.


Set the 'Scale of Gaussian Blurring' to 0.6

Set the 'Edge Contrast' value to 0.030

Keep the 'Edge Mapping Exponent' value at 2.0

Press Okay to compute the feature image

After this step, the SNAP window should look like this:

Step 3. Snake Initialization

In this step we will initialize the snake using bubbles which will grow to assume the shape of the vertricles. When initializing edge based snakes, it is improtant to keep the bubbles entirely within the structure that we are interested in segmenting. Bubble placement for region-competition based feature images was described in Section 6, Step 4..

Press the Next buttor to proceed to the next stage of automatic segmentation: 'Step 2. Snake Initialization'


Set the bubble radius to 3

Place four bubbles inside of the lateral ventricles in the axial view, as illustrated below:


Step 4. Setting Snake Parameters and Segmentation

In this step we will experiment with the parameters used for edge-based segmentation.

Press the Next buttor to proceed to the next stage of automatic segmentation: 'Step 3. Segmentation'

Press the Set Parameters... button to bring up the parameter selection window.


We will begin by experimenting with snake evolution with the advection force turned off. You will see how without this force the snake is likely to 'leak' pas the boundaries of the ventricles

Set the 'Balloon Force' to 1.0

Set the 'Curvature Force' to 0.2

Set the 'Advection Force' to 0.0

Accept the new parameter settings.


Run the snake evolution using the button with the 'Play' (triangle) symbol

As the snake leaks past the boundaries of the ventricles, press the button with the 'Stop' (square) symbol


The leaking occurs because the balloon force acts outwards with a strength proportional to the value of the feature image. Since the feature image is positive, the balloon force never stops acting, so the snake never stops growing. Luckily, the advection force can be used to get the snake to stop. The advection force acts inwards when the snake crosses an edge and keeps the snake from expanding further

Rewind the segmentation using the button with the Rewind (pair of triangles facing left) symbol.

Bring up the parameter selection window

Set the advection force to 5.0 and press Accept

Run the snake evolution again, stopping it after a 1000 iterations or so.

This time the snake does not leak!

Step 5. Further Experiments

Experiment with different values of the ballon, curvature and advection forces. What are the values ideal for segmenting the ventricles?


Try recomputing the feature image using different parameters, such as a smaller scale of Gaussian blurring. You should be able to get a better segmentation than before.


By now you have mastered the most important features of SNAP!

Experiment with segmenting other structures in the brain. For example, it's possible to segment the caudates using edge-based snakes. Even the hippocampus can be partially segmented, but extensive manual post-processing will be necessary.


SNAP Tutorial. Section 8.

Section 8. Computing Volumes and Statistics

This brief section describes how to use SNAP to calculate volumes of the segmented structures, as well as the statistics of the image intensity for each structure. This section will take under 5 minutes to complete.

Step 1. Load an image and an existing segmentation

We will begin by loading the image that we have been working with all along. You may already have this image loaded, in which case, reloading the image will clear the results of your previous segmentations.

Load image MRIcrop-orig.gipl as described in Section 2

The completed segmentation for this image is located in the same directory as the image itself and is called MRIcrop-seg.gipl

Select File | Load Data | Segmentation Data to bring up the image input wizard.
Use the wizard to load the image MRIcrop-seg.gipl
Press the Update Mesh button in the 3D window panel to render the segmentation in 3D.


Step 2. Compute Volumes and Statistics

In the previous step, you have loaded a segmentation that includes several structures. Now, you will create a file that contains the following information about each structure:

Select File | Save Data | Volumes & Statistics .

Specify a filename with a .txt extension and press Ok.

The volumes and statistics will be saved in a text file that you specify. The contents of this file are displayed below. The file can be imported into various spreadsheet applications.

##########################################################
# SNAP Voxel Count File
# File format:
# LABEL: ID / NUMBER / VOLUME / MEAN / SD
# Fields:
#    LABEL         Label description
#    ID            The numerical id of the label
#    NUMBER        Number of voxels that have that label
#    VOLUME        Volume of those voxels in cubic mm
#    MEAN          Mean intensity of those voxels
#    SD            Standard deviation of those voxels
##########################################################
vent-lat                                :    1 /      18138 /      18138 /    22.0791 /    6.70728
vent-3rd                                :    2 /       2633 /       2633 /     25.763 /    6.36361
vent-4th                                :    3 /       4775 /       4775 /    25.4262 /    6.60467
hippo-R                                 :    4 /       2250 /       2250 /    55.6178 /    4.47806
hippo-L                                 :    5 /       2548 /       2548 /    52.6429 /    4.15063
vent-temp                               :    6 /       1047 /       1047 /    23.5244 /    7.34334
caudates                                :    7 /       7661 /       7661 /    56.3759 /    3.92178
corpus-callosum                         :    8 /      16841 /      16841 /    69.2177 /    6.05497
SNAP Tutorial. Section 9.

Section 9. Tips and Tricks

This section contains a list of loosely organized list of SNAP features that can make it a more powerful tool than it may appear at first look. Click below to jump to a specific tip:

  1. Displaying image information
  2. Focusing on a Single Slice View
  3. Another Way to Initialize Segmentations
  4. Automatic Segmentation of Anisotropic Images
  5. Advanced Parameter Settings
  6. Large Segmentations in SNAP

Displaying Image Information

SNAP includes an image information window that can be brought up at any time. The window displays dimensions of the image, voxel size, current cursor location and other useful information.

Select File | Image Info ...

Focusing on a Single Slice View

When performing manual segmentation, it may be useful to dedicate a larger area of the screen to a single slice of the 3D image. SNAP allows you to replace the standard four-view layout (three slice views and a 3D view) with a single-view layout.

Click on the plus button ( ) in one of the four views to expand that view.

Click on the plus button ( ) in the expanded view to collapse the view and display the other three views.

Another Way to Initialize Segmentations

In this tutorial, automatic segmentations were initialized using 'bubbles'. There is an other way to initialize segmentation. Whenever you enter the automatic segmentation mode with some label X as the current drawing label, all the pixels already labelled X will be passed on to the automatic segmentation mode as initialization pixels. Therefore, you can use the results of one segmentation attempt to initialize another. You can also use manual segmentation tools to construct the snake initialization.

Automatic Segmentation of Anisotropic Images

The snake evolution algorithms used in SNAP are poorly suited for non-isotropic images, especially wen anisotropy is great, e.g., when pixels have size 1x1x3 or 1x1x5, which is quite common in medical images. The option to resample an image has been added to SNAP especially for dealing with such images

Before entering the automatic segmentation mode, you have an option to resample the region of interest passed on to automatic segmentation. Just check the box 'Resample Region' before pressing the Segment 3D button.

After you press Segment 3D, the Region Resampling window will appear:

You can use this window to change the dimensions of the pixels that will be passed on to SNAP's automatic segmentation mode. For instance, if the input image has 1x1x5 pixels, you can have SNAP replace each pixel by 5 isotropic ones, as shown above. Be aware, however, that supersampling an image in this way increases memory usage (fivefold in this case), and should be done only for small regions of interest. A more conservative option is to resample 1x1x5 pixels to 2x2x2 pixels.

The automatic segmentation will be performed on the resampled image, and the results will be resampled back to the resolution of the original, anisotropic image.

You can choose between cubic, linear, and nearest neighbor interpolation modes. Cubic produces the best quality resampled images, but is slow. Nearest neighbor interpolation is fast but results in greatest distortion. Cubic interpolaion is recommended in most cases.

Advanced Parameter Settings

The 'Advanced' tab of the snake parameter setting window is shown below:

This tab allows you to change the algorithm used for snake propagation. At the time of this writing, the default Sparse Field Level Set Algorithm is the most efficient option. The Narrow Band Level Set Algorithm is a little slower and some small differences in the results of the two methods have been detected. The Narrow Band algorithm is more robust with respect to increasing the segmentation time step (see next paragraph). The Dense Level Set Algorithm is included purely for experimental purposes. It is orders of maginitude slower that the other two options.

This tab also allows you to override the default time step used in snake propagation. The default setting is to use the so-called optimal time step: the largest time step that allows some mathematical guarantees on the segmentation error to be established. In practice, it is possible to use a larger time step value, resulting in proportionally faster segmentations, but at a cost of (sometimes unpredictable) error. We recommend overriding the optimal step when doing rough segmentations on large regions of interest.

The experimental noise reduction option can be used in conjunction with overriding the optimal time step. For very large speedups, it may reduce the error accumulation. We recommend to leave the noise reduction setting at zero.

Large Segmentations in SNAP

You may have noticed that the speed of segmentation in SNAP is roughly proportional to the size of the structure you are segmenting. If that were always the case, it would take a very long time to segment large structures such as the whole of the brain white matter or gray matter. Luckily, SNAP provides a couple of ways to speed up large segmentations.

The first way is to take advantage of the option to resample the region of interest when entering the automatic segmentation mode. The details on such resampling are given in the Tip on Automatic Segmentation of Anisotropic Images.For example, if the original image has 1mm cube pixels and you resample it to 2x2x2 resolution, you will reduce the amount of memory needed for segmentation by eightfold and will speedup the segmentation by an eightfold as well. The gains in speed come, of course, at the price of accuracy. However, you can use subsampling to get a 'quick and dirty' segmentation and then use that segmentation as an initialization to another segmentation, this time without resampling. See the Tip on Another Way to Initialize Segmentations for more details on using segmentation results for initialization of subsequent segmentations.

The second way to speed up segmentations is to override the default time step used for snake propagation. See the Tip on Advanced Parameter Settings for details.

Using the Spray Paint 3D Tool for Landmark Placement

The manual mode of SNAP includes the 3D spray paint tool .

This tool is used to mark points on the surface of the 3D rendering of the segmentation results with the active drawing label. Simply select this tool, position the mouse over a rendered segmentation results (e.g., ventricles, as shown below), and press the left mouse button. Tiny bubbles will appear on the surface of the segmented structure under the mouse. You can move the mouse while pressing the left mouse button. Press the Accept button to relabel the pixels corresponding to these bubbles with the active drawing label, or press the Reset View to discard the spray painted bubbles.

Spray painting is useful for assigning unique labels to specific anatomical landmarks. It can also be used for tracing curves on the surface of anatomical structures, e.g., for rough tracing of the sulci or gyri.