Get Started with Medical Image Labeler
The Medical Image
Labeler app enables you to interactively label pixels in 2-D and 3-D medical
images. You can export labeled data as a
groundTruthMedical object to train semantic segmentation algorithms.
This tutorial provides an overview of the capabilities of the Medical Image Labeler and compares 2-D and 3-D image labeling.
Start New Labeling Session
Manage labeling in the Medical Image Labeler using app sessions. You can create a volume session to label 3-D image volumes or an image session to label 2-D images or series of images related by time. Within one session, you can import and label multiple image files. These might be repeat scans from one patient or scans from multiple patients with the same set of tissues, organs, or other regions of interest to label. Follow these steps to create a new labeling session.
Open the Medical Image Labeler app from the Apps tab on the MATLAB® toolstrip, under Image Processing and Computer Vision. You can also load the app by using the
On the app toolstrip, click New Session and select New Volume session (3-D) or New Image session (2-D).
You can also load a previous session by clicking Open Session.
Specify a session folder. You must specify the session folder upfront because the app automatically saves the label images as they are drawn. Therefore, the session folder must have access to enough memory to save all label images for the session. For more details, see the How Medical Image Labeler Manages Ground Truth Labels section.
Load Image Data
Load images from a file by clicking Import Data and then, under Data, selecting From File. The app supports loading these file formats:
Volume session — Single NIfTI, NRRD, or DICOM file, or a directory containing multiple DICOM files corresponding to one image volume.
Image session — Single NIfTI or DICOM file.
If you load a previous session, the app reopens the image data that was open when you closed the session.
Alternatively, you can load a
groundTruthMedical object created
programmatically or exported as a MAT file from a previous app session. You can import
groundTruthMedical object directly from a MAT file or from the
MATLAB workspace. Importing a
groundTruthMedical object loads
the image data, label data, and label definitions stored in the object into the app. For
example, import a
groundTruthMedical object to load partially labeled
data created outside the app or shared by a colleague. For more details about working on
a multi-person labeling team, see Collaborate on Multi-Labeler Medical Image Labeling Projects.
The Data Browser pane lists all of the image files that are loaded in the app. The app displays 3-D image data in the panes for the Transverse, Sagittal, and Coronal slice planes and a 3-D Volume pane. The app displays 2-D image data in the Slice pane.
For more details about viewing image volumes in the app, see Visualize 3-D Medical Image Data Using Medical Image Labeler.
Create Label Definitions
A label definition specifies the name, color, and order of each label assigned to the image.
You can create a label definition interactively in the app by clicking Create Label Definition in the Label Definitions pane. Optionally, you can assign a name for the label by clicking it, or change the color of the label by clicking the color square next to the label name.
Alternatively, you can import label definitions from a label definitions file or as
part of a
groundTruthMedical object. You can create a label definitions
file programmatically or load one exported from a previous app session. For more detail
about creating a label definitions file programmatically, see the
LabelDefinitions property of the
You must use the same label definitions across all images within a labeling session.
Label pixels using the tools in the Draw and Automate tabs.
You can manually draw labels using the Freehand, Assisted Freehand, Polygon, and Paintbrush tools.
You can add labels using semi-automated tools including Fill Region, Paint by Superpixels, and Trace Boundary. You can interpolate labeled regions between image frames or volume slices using the Auto Interpolate and Manually Interpolate tools.
|Fill Region||Flood fill label image or fill holes in label region.||
|Paint by Superpixels||Manually paint within an adjustable-sized grid of pixels. To use this tool, first select Paint Brush and then click Paint by Superpixels. Each superpixel contains a cluster of similar intensity values. Adjust the Superpixels Size to change the size of the superpixel grid.||
|Trace Boundary||Label connected regions that have similar intensity values. Select Trace Boundary in the app toolstrip, and then pause on a seed pixel or voxel in the region you want to label. The tool predicts the boundary of the region by including pixels or voxels with intensities that are similar to the current seed. Use the Threshold slider to adjust the similarity threshold used to predict the region boundary. Increasing the threshold includes a wider range of intensities above and below the seed value in the predicted region. Move your cursor to change the seed.||
The Automate tab contains built-in automation algorithms to refine existing labels or fully automate labeling. The app provides slice-based algorithms including Active Contours, Adaptive Threshold, Dilate, and Erode. In a volume session, the app additionally provides the Filter and Threshold, Smooth Edges, and Otsu's Threshold algorithms, which you can apply to all slices or to a specified slice range.
You can add a custom automation algorithm to use in the app. On the Automate tab, click Add Algorithm. Import an existing algorithm by selecting From File, or create a new algorithm using the provided function or class template.
See Label 2-D Ultrasound Series Using Medical Image Labeler for an example of labeling 2-D image data.
See Label 3-D Medical Image Using Medical Image Labeler for an example of labeling 3-D image data.
Export Labeling Results
You can export the
groundTruthMedical object and label definitions as
files to share with a colleague.
To export the
groundTruthMedicalobject as a MAT file, on the Home tab, click Export and, under Ground Truth, select To File.
To export the label definitions as a MAT file, on the Home tab, click Export and, under Label Definitions, select To File.
The actual pixel label data is stored in the
subfolder of the session folder. See How Medical Image Labeler Manages Ground Truth Labels for
How Medical Image Labeler Manages Ground Truth Labels
As you label images in the Medical Image Labeler app, the app automatically saves three sets of data in the session folder associated with the current app session.
groundTruthMedicalobject stored as a MAT file. The
groundTruthMedicalobject specifies the file locations of the unlabeled images and corresponding label images, as well as the name and color associated with each label.
A subfolder named
LabelData, which contains the label images.
Pixel label images created in an image session are saved in the
LabelDatafolder as MAT files. The MAT file stores the pixel labels as a
uint8array. You can read the label image into the MATLAB workspace by using the
Voxel label images created in a volume session are saved in the
LabelDatafolder as NIfTI files. The NIfTI file stores the voxel labels as a
uint8array. You can read the label images into the MATLAB workspace by using the
A subfolder named
AppData, which contains data about the app session stored as a MAT file.