Exercise: Segment a Brain Tumor
Overview
This exercise is based on the following Slicer tutorial: pdf
What is a meningioma?
- The most common type of primary brain tumor: ~30% of all brain tumors
- These tumors originate in the Meninges
- Three protective layers that surround and support the brain
- Dura, Arachnoid, and Pia mater
- Meningiomas grow out of the arachnoid (the middle layer of the meninges).
- Their growth can press against the brain or spinal cord and cause serious problems.
- Meningiomas are named by their location:
- e.g. Falcine meningiomas form in the falx, whereas parasagittal meningiomas form near the falx (The falx is a very thin layer of tissue between the two sides of the brain.)

Localization of intracranial meningiomas. Left: Axial view of meningiomas at the base of the skull. Right: Coronal view of meningiomas in the cranial dome, the falx cerebri, and intraventricular. For more information on meningiomas, click here. Image: University Department of Neurosurgery, Inselspital Bern.
What is gadolinium?
- Gadolinium (Gd) is a malleable and ductile rare-earth element
- It can be used as a contrast agent for MRI.
- When injected intravenously into the body, gadolinium enhances and improves the quality of the MRI images.
- This helps improve the visibility of inflammation, tumors, blood vessels, and—for some organs—blood supply.
- Gd is eliminated from the body through the kidneys.
How does Gadolinium improve contrast in MRIs?
- Gadolinium is paramagnetic at room temp
- helps with contrast by increasing nuclear spin relaxation rates
- Gd does not readily cross the blood-brain barrier
- But, brain tumors degrade the BBB, allowing Gd to penetrate
Required Extension
This exercise requires the following extensions:
- HDBrainExtraction.
- PyTorch (should be installed with TotalSegmentator Extension)
- SynthSeg
Be sure to install these extensions before continuing.
Load the Tumor datasets
- Select the
Sample Datasetmodule - Select MRBrainTumor1 and MRBrainTumor2
- Explore the volumes.
- Notice the tissue contrast in the brain.
Inspect Volume
Bring up the Data module ![]()
You should see two volumes:
- MRBrainTumor1
- MRBrainTumor2
Hover over the names of these volumes. Notice that you get some information on the volumes themselves.
Do the volumes have the same dimensions and voxel sizes?
No.
Volumes Module
Bring up the Volumes module 
The Volumes module gives you more detailed information on the volumes and allows you to change the display properties of the volumes.
What are the dimensions of the volume (Image Dimensions) and voxels (Image Spacing)? What is the Scalar type and Range?
- MRBrainTumor1
- Image Dimensions: 256 X 256 X 112
- Image Spacing: 0.94 X 0.94 X 1.4 mm
- Scalar Range: 0 to 695
- Scalar Type: short (16-bit)
- MRBrainTumor2
- Image Dimensions: 256 X 256 X 130
- Image Spacing: 0.94 X 0.94 X 1.2 mm
- Scalar Range: 0 to 986
- Scalar Type: short (16-bit)
Inspect the Tumors
Starting with MRBrainTumor1, find the tumor and get all three slice viewers aligned onto the tumor.
Then inspect Tumor 2.
The two volumes are MRIs of the same patient, taken at two different times. Here is what the radiologists reported:
Baseline radiologist's clinical impression (MRBrainTumor1):
- large falcine lesion is identified.
- measures 3.10 cm anteroposteriorly and 3.51 cm in height.
- enhances moderately on post gadolinium imaging.
Follow-up radiologist's clinical impression (MRBrainTumor2):
- left frontal lobe mass appears unchanged on all series.
- measures 3.3 x 3.2 cm in maximum dimension.
- enhances moderately on post gadolinium imaging.
Keep these reports in mind. Later, you will compare them with your own measurements.
Volume Render the Tumors
In this step, we will render the MRI volume in 3D and then use the crop tool to crop the volume down to the tumor.
- Bring up the Volume Rendering Module
- Set Volume: to
MRBrainTumor1 - Click open Eye Icon next to Volume to render

- Select the
MR-Defaultdisplay preset - Enable Crop and Display ROI
- In the 2D Viewers, drag the ROI so that it captures just the Tumor.
-
Make sure to scrub through the slices in all three planes to verify that you captured the tumor.

-
When you're done sizing the ROI, hide it by closing the eye next to "Display ROI".
- Adjust the display by sliding the Shift slider
Overlay Volumes

- Use the Slice controllers to overlay the volume.
- Foreground:
MRBrainTumor2 - Background:
MRBrainTumor1
- Foreground:
- Change the transparency between the 2 volumes to 50%
- Are the volumes aligned?
Register the Volumes
In the previous step, we saw that the two brains (from the same human) are not aligned. This is due to the fact that the MRIs were captured at two separate time points and the subject wasn't precisely positioned in the same location in the machine. In this step, we will register the brains, which means we will align their positions.
Under the Registration Modules Menu, choose the "General Registration (BRAINs)"
Change the following settings:
- Fixed Image Volume:
MRBrainTumor1 - Moving Image Volume:
MRBrainTumor2 - Slicer Linear Transform: Create New Linear Transform
- Output Image Volume: Create new volume as "MRBT2mvd"
- Initialize Transform Mode:
useMomentsAlign - Registration Phases:
Rigid (6 DOF) - Click apply. Should take about 1 minute.

Check registration
In the Volumes Module, change the colormap of the newly created "MRBT2mvd" volume to a different color like shades of magenta (CoolShade3) or inverse gray
Use the Slice controllers to overlay Tumor1 with MRBT2mvd.
- Foreground:
MRBrainTumor1 - Background:
MRBT2mvd - Adjust LUT for MRBT2mvd (so it's not so overexposed)
- Set transparency to 50%
Are they aligned?
Yes? Good.
SAVE YOUR WORK!
Segmentation
Next, we'll segment the tumors using the segmentation tool.
Segment Tumor1
We will use the Grow-from-seeds method to segment the Tumor in the MRBrainTumor1 volume. First, though, we need to segment three orthogonal sections from the tumor (and sample the background).
2D Slice Viewers
- Find the largest cross-section of the tumor in the Sagittal viewer (yellow viewer).
- Ensure that the slice includes some of the bright white meninges layer as well.
- Align 2D viewers (Hold the shift button and hover the mouse) so all three viewers are aligned with the Yellow viewer
- Compare with the image below for an example of how the 2D viewers (in the 4up layout) should look (but without any green label yet)
Segment Editor
Bring up the Segment Editor and use the following settings:
- Segmentation: Rename new segmentation as
SegTumor1
- Source Volume: Set to
MRBrainTumor1 - Add a new segment called
Tumor1 - Add another segment called
Not_Tumor

Threshold

The threshold tool allows you to select a range of intensities to segment. Here, we will use the threshold tool for masking.
- Bring up the threshold tool to set the masking range
- Move the cursor over to the center of the tumor cross-section in one of the slice viewers
- Notice that the cursor has the icon of the Threshold tool in one corner
- Click and hold on the center of the tumor
- A yellow circle will appear. As you drag, the circle gets larger
- Drag to the edge of the tumor to capture the intensities in that tumor
- Release the mouse button
- Notice that you have just set the Threshold Range in the Threshold module.

- Adjust the range to 125-500 if needed
- The flashing color in the slice viewers indicates what will be segmented if you were to click
Apply(but don't do that) - Click on the
Use for maskingbutton.- This will restrict the paint tool to only paint voxels with an intensity that falls in the intensity range (125-500)
Paint Tool

After clicking on the Use for masking button, Slicer should have automatically switched over to the paint tool. If not, do so now by clicking on the paint tool button.
In the Masking settings of the paint tool, the "Editable intensity range" should now be turned on:

Now when you paint, you will only be able to paint inside the tumor and other bright areas, like the meninges, where the intensities fall inside of the editable intensity range.
Go ahead and paint the three orthogonal slices of the tumor, as follows:

Next, in the Paint tool, change the masking to the following settings:

Notice that we have un-checked the "Editable Intensity range". With these settings, you will be unable to overwrite the tumor labels you have already drawn, but you should be able to paint everywhere else.
Select the "Not_Tumor" label in the segmentations table and paint the background surrounding the tumors, as follows:

Grow-From-Seeds

- Select the "Tumor1" label in the segmentations table and then bring up the Grow From Seeds tool
- Use the following Masking settings:
- Editable Area:
Everywhere - Modify other Segments:
Overwrite all
- Editable Area:
- Click on the
Initializebutton - Scrub through the slices and ensure that the two labels are properly labeled. If not, use the paint tool to correct any label errors, making sure you select the right segmentation in the segmentation table before painting
- Click
Applyand wait. - Enjoy segmented tumor (Be sure the Show 3D button is selected in the segment editor tool)
- Clean-up tumor noise using the Smoothing tool
- Enjoy a freshly segmented tumor!

SAVE YOUR WORK!
Tumor2
Ok, repeat the segmentation for Tumor2, with the following changes:
- Create a New Segmentation as
SegTumor2 - Change the Source Volume to
MRBT2mvd - Add a new segment called
Tumor2. Change the color of this segment to Blue (or a different color from the original tumor)

Final Comparison
Go to the Data Module. You should see the following in your Node list:
- MRBrainTumor1 (Volume)
- MRBrainTumor2 (Volume)
- Slicer Linear Transform (LinearTransform)
- MRBT2mvd (Volume)
- SegTumor1 (Segmentation)
- Tumor1 (Segment)
- SegTumor2 (Segmentation)
- Tumor2 (Segment)
Review how slicer organizes the data.
- Each Segmentation contains segments that are specific to a volume (MRBrainTumor1 or MRBT2mvd, in this case)
- Click on MRBrainTumor1
- Notice how other items in the Data table light up - these are connected to Tumor1 in some fashion
- Hover over one of the segments (like Tumor1). After a beat, you get information about that segment: >Segment - ID, Segment_1, Representations: Binary labelmap, Closed Surface, Color: (128, 174, 128)
- Compare that information to the information that you get for the volumes, like "MRBrainTumor1" >Volume (Dimensions: 256 X 256 X 112 Spacing: 0.938 x 0.938 x 1.42mm )
Review Segments
- Display only the MRBrainTumor1 volume to slice viewers (add to the background). Hide any other volumes
- Display the Tumor1 segment and the Tumor2 segment by opening the eye icons in the Data hierarchy
- Compare their dimensions. Do they look the same size?

Measure the Tumors
So, have the tumors changed in size? In this step, you measure each tumor by hand. Later, in MATLAB, you will import these measurements and calculate the volume, the overlap (Dice), and the surface distance of the two tumor segmentations.
Manually Measure Tumor With Ruler
You can measure objects in Slicer using the Markups tools, which includes a points list, line, angle, curve, closed curve, plane, ROI etc. To reveal the Markups toolbar, click on the Markups Toggle Button ![]()

Switch to the Markups module to keep track of your markup measurements.

Measure the tumor using the Line tool
- Scrub the viewers so that you see the widest aspect of the tumor in each view.
- Select the Line Markup tool (the second button from the left)
- Measure the tumor by clicking on one side of the tumor and then on the other side
- Each time you click, Slicer adds a control point (red dot) to the viewer
- Slicer measures the distance between two sequential control points.
- Be consistent how you make your measurements
- Be sure to measure all three anatomical axes of the tumors: A-P, L-R, S-I
- Make sure that you measure across the widest part of the tumors in each plane.
Making Multiple Sequential Line Measurements
You can make several measurements at the same time by turning on the "Place Multiple Control Points" setting. In the Markups tool bar, bring up the Place Control Points menu by clicking on the triangle next to this icon:

Now when you are done with one line measurement, you can go on to the next. Double-click the last control point when you are done. If you accidentally get an extra measurement point in the Markups table, just delete that measurement.
Label and Organize each measurement
- As you measure each length, an entry will be added into the Markups table, prefaced by an "L" (for length)
- Double-click on that name and rename it to indicate tumor number and Anatomical Axes, e.g.
T1-LR- Use exactly these six names:
T1-AP,T1-LR,T1-SI,T2-AP,T2-LR, andT2-SI. Slicer saves each line in a file with the same name (e.g.T1-LR.mrk.json), and the MATLAB live script uses these names to import your measurements
- Use exactly these six names:
- Also, for each measurement, under the Display:Advanced tab, uncheck
Properties Labelto remove text from the slices - When you are ready to Measure the second tumor, hide all of the first tumor markups by closing the eye icons for each measurement in the Markups table
- Finally, when you have made all of your measurements, create a new folder in the Markups module called Line Measurements and drag all of your measurements into this folder
You should end up with something that looks like this:

How do your measurements compare with the radiologists' impressions?
Compare your measurements of Tumor1 with the baseline impression, and your measurements of Tumor2 with the follow-up impression (see Inspect the Tumors). Did the tumor change in size?
Skull Stripping
In this step, we will remove the skulls from the volumes using the HD Brain Extraction tool. This is not strictly necessary to segment the tumors but it does highlight a cool new technique.
Select the HD Brain Extraction tool from the Modules/Segmentation Menu

And set:
- Input volume to
MRBrainTumor1 - Skull-stripped volume to
Create New Volume - Brain Segmentation to
Create New Segmentation
- Click Apply.
- You may get a notice that PyTorch will be installed. Just wait...
Eventually, you should get something awesome, like the following:

If HD Brain Extraction hangs or fails: skull stripping and SynthSeg in MATLAB
You can do this step and the SynthSeg step in MATLAB instead, with the live script Skull Stripping and SynthSeg in MATLAB (SynthSeg_Tumor_MATLAB.m). You don't need Python or any Slicer extension.
- Open the live script in MATLAB, choose your project folder, and run each section. The live script starts from
MRBrainTumor1, and runs SynthSeg once to find both the brain and its structures - It saves four files in your project folder:
MRBT1stripped.nrrd,MRBT1SkullStrip.seg.nrrd,MRBT1stripped_synthseg_v2.seg.nrrd, andMRBT1stripped_volumes.csv - Drag
MRBT1stripped.nrrdandMRBT1SkullStrip.seg.nrrdinto Slicer. They open as the volumeMRBT1stripped(use it wherever this page saysMRBrainTumor1 stripped) and the segmentationMRBT1SkullStrip, with the segment "brain" - Continue with Review Stripping Results, and skip the SynthSeg section: you already have its files
Review Stripping Results
Switch to the Data Module and notice that:
- There is a new Volume: "MRBrainTumor1 stripped"
- A new segmentation node has been added called
MRBT1SkullStripand it contains one segment: "brain"
Go to the Segment Editor and turn on the 3D view to see the brain in 3D
SAVE YOUR WORK!!!!
SynthSeg
SynthSeg is a deep learning model that segments the brain into about 30 structures, such as the cerebral cortex, the white matter, the ventricles, and the hippocampus. It was trained on healthy brains, so let's see what it does with a tumor.
Bring up the SynthSeg module and set:
- Input Volume:
MRBrainTumor1 stripped - Model:
SynthSeg 2.0 - Click Run Segmentation. This can take a few minutes.
If SynthSeg fails the first time
The first time you run SynthSeg, Slicer installs the Python packages that SynthSeg needs. These packages may not work until Slicer restarts, so the first run can fail or crash. If that happens:
- Save your work
- Restart Slicer and reload your scene
- Run SynthSeg again
If it still fails, run SynthSeg in MATLAB instead (see below).
SynthSeg in MATLAB
If the SynthSeg extension doesn't work on your computer, you can run the same model (SynthSeg 2.0) in MATLAB, with the live script Skull Stripping and SynthSeg in MATLAB (SynthSeg_Tumor_MATLAB.m). You don't need Python or any Slicer extension.
- Save the skull-stripped volume (
MRBrainTumor1 stripped) in your project folder asMRBT1stripped.nrrd(see Save the files). The live script finds it, and only runs SynthSeg - Open the live script in MATLAB, choose your project folder, and run each section
The live script saves MRBT1stripped_synthseg_v2.seg.nrrd and MRBT1stripped_volumes.csv in your project folder, with the names that the SLCR3 live script expects. To see the segmentation in Slicer, drag MRBT1stripped_synthseg_v2.seg.nrrd into Slicer. Then skip to Save Your Files for MATLAB.

SynthSeg output showing the right cerebral cortex, the left cerebral white matter, and the tumors
Scrub through the slices. Is there any segmentation at the tumors?
SynthSeg creates a new segmentation node, with one segment per brain structure. It also calculates the volume of each structure, and saves them in a CSV file (MRBT1stripped_volumes.csv) when the segmentation is done. You will use this file in MATLAB.
SAVE YOUR WORK!
Save Your Files for MATLAB
In the MATLAB live script (SLCR3 Tumor Comparisons), you will analyze your segmentations and measurements. To get ready, merge your segmentations into one node, and save your files with the names that the live script expects.
Merge the segmentations
The live script loads the brain and both tumors from a single segmentation node. As in the CTA Cardio exercise, we copy segments from one node to another:
- Bring up the Segmentations module
- Set the Active segmentation to
MRBT1SkullStrip(the node with the "brain" segment) - Open the Copy/move segments tab
- On the right-hand side, select
SegTumor1, select theTumor1segment, and click the<+button to copy it intoMRBT1SkullStrip - Repeat for the
Tumor2segment inSegTumor2 MRBT1SkullStripshould now contain three segments: brain, Tumor1, and Tumor2- In the Data module, rename
MRBT1SkullStriptoMerged Segmentations
Because the tumors are inside the brain (and overlap each other), Slicer stores each segment in its own layer. You will learn how to handle these layers in MATLAB.
Save the files
Click the Save button and save your files into your project folder. In the File Name column, make sure that these files have these names:
| Data | File name |
|---|---|
Skull-stripped volume (MRBrainTumor1 stripped) |
MRBT1stripped.nrrd |
| Merged segmentation (brain, Tumor1, Tumor2) | Merged Segmentations.seg.nrrd |
| Line measurements | T1-AP.mrk.json, T1-LR.mrk.json, T1-SI.mrk.json, T2-AP.mrk.json, T2-LR.mrk.json, T2-SI.mrk.json |
| SynthSeg segmentation | MRBT1stripped_synthseg_v2.seg.nrrd |
| SynthSeg volumes (created by SynthSeg; copy it into your project folder if it isn't there already) | MRBT1stripped_volumes.csv |
Tip
You can edit a file name by double-clicking it in the File Name column of the Save dialog. The line measurements are saved with the names that you gave them in the Markups module.
Challenge
How would you create this scene?

Volume Rendering with Tumors
- Turn on Tumor Segmentations in 3D view
- Turn on coronal slice view in 3D
- Render the Stripped Skull volume
- Crop the volume along the interhemispheric fissure
- Make sure your tumor model is visible