Segment the patient’s vertebrae from a CT, on your own computer

ScolioSim can draw the model with the patient’s own vertebrae, taken from a segmentation of their CT. The segmentation is made with TotalSegmentator, an open tool from the University Hospital Basel. Installed on your computer from ScolioSim itself, on Windows, macOS or Linux, it takes a CT of any size, and the CT never leaves your computer.

TotalSegmentator is not a medical device, and neither is ScolioSim. The segmentation and its use are your responsibility, as with every other measurement you make in ScolioSim.

What your computer needs

The time it takes depends above all on the graphics card. TotalSegmentator uses an NVIDIA card (or the graphics of a Mac with Apple silicon); with anything else it runs on the processor, which works but is slow.

For reasonable timesIt still works
GraphicsNVIDIA card with 8 GB of memory or more, driver up to date; or a Mac with Apple silicon (M1 or later)None: the processor does the work, slowly
Memory (RAM)16 GB or moreLess, with the 3 mm model (--fast)
SystemWindows 10 or 11 (64-bit), Linux, or macOSIntel Macs: processor only, not tested
DiskAbout 15 GB free, for the programs and the model weights
InternetTo install it, and the first time it runs (it downloads the model weights once)

The authors of TotalSegmentator give these figures for their whole model, all 117 structures, on an NVIDIA RTX 3090: (TotalSegmentator)

CT size1.5 mm model: timeRAMGraphics memory3 mm model: timeRAMGraphics memory
512 × 512 × 2801 min 17 s7.6 GB6.1 GB34 s7.4 GB5.2 GB
512 × 512 × 4582 min 49 s10.6 GB8.5 GB53 s8.4 GB7.4 GB
512 × 512 × 8243 min 32 s11.8 GB11.4 GB1 min 23 s10.6 GB7.5 GB

ScolioSim asks only for the vertebrae from T1 to the sacrum, which in TotalSegmentator’s words “saves a lot of runtime and memory”. On the processor its authors advise exactly that, or the 3 mm model. (TotalSegmentator) On a laptop processor (Intel Core Ultra 9 185H, no NVIDIA card), with the weights already downloaded, we timed 2.3 min for a 512 × 512 × 336 series of 1 mm slices covering 34 cm (TotalSegmentator’s public example CT, resampled to that size) with the computer otherwise idle, and about 5 min with other programs keeping the processor busy. A CT from T1 to the sacrum is longer and takes longer.

On an NVIDIA RTX 4060 with 8 GB, a real lumbar spine CT of 1,437 slices 0.4 mm apart (57 cm) was segmented in 73 s, about 30 s of it prediction. The whole run took 2.9 min, from a study of more than 6,000 files: the rest is reading their headers, setting the series aside and converting it. The first time it took 5.3 min, because it also downloads the model weights (about 1.3 GB, once).

The simple way: the ScolioSim helper

Everything is done from ScolioSim itself, in X-rays, under The patient’s own vertebrae: installing TotalSegmentator, choosing the CT, segmenting it, correcting it, and removing it all when you no longer want it. A browser cannot install or start programs, so that part is done by a small helper that you install once. It works the same on Windows, macOS and Linux; only installing it differs.

Windows

  1. Get the ScolioSim helper from the Microsoft Store. It is free, installs for you alone, and the Store keeps it updated.
  2. Where the Store is blocked, as on many hospital computers, download the installer and open it instead: it installs without administrator rights, in about a minute. Windows may say Windows protected your PC, because the installer is not signed with a paid certificate: click More info and then Run anyway.
  3. Back in ScolioSim, click Connect to the helper. When Chrome asks whether the site may reach apps on this device, allow it: that is how the page talks to the helper.
  4. ScolioSim shows what your computer has and installs TotalSegmentator with one button. Then choose the CT (the CD folder or its ZIP): the page reads the headers, proposes the series and, once segmented, shows you the vertebrae to check. If two vertebrae come out mixed, or a piece sits in the wrong one, correct it there, slice by slice, before keeping them.

macOS

  1. Download the ScolioSim helper for Mac and open it: double-click the ZIP if the Mac has not unzipped it, then ScolioSim Helper Installer. It installs for you alone, without administrator rights, in a minute or two (it downloads its own small Python), with a window to start, one while it works and one at the end, as on Windows.
  2. The first time, macOS says it cannot verify the installer: the helper is free and not signed by Apple. Close that message, open System Settings, Privacy & Security, and near the bottom click Open Anyway beside ScolioSim Helper Installer; confirm it (macOS may ask for your Mac’s password).
  3. Back in ScolioSim, click Connect to the helper, and go on as on Windows (steps 3 and 4). The first time the page starts the helper again, after half an hour without use, the browser asks whether to open ScolioSim Helper: allow it.

If you prefer not to download anything, the same installation is done by this line, pasted in Terminal (in Applications, Utilities), and then macOS asks nothing; ScolioSim shows it too, with a button to copy it:

curl -fsSL https://scoliosim.com/segment/helper-install.sh | sh

On a Mac with Apple silicon (M1 or later) TotalSegmentator uses its graphics, and where they cannot manage a step, the processor takes over. On an Intel Mac it runs on the processor, and it has not been tested there. To update the helper, open the installer again (or paste the line again): TotalSegmentator stays installed.

Linux

  1. Open a terminal (Ctrl+Alt+T on most desktops), paste the same line and press Enter. It installs the helper for you alone, in a minute or two, without administrator rights and without asking for a password, and starts it. When it says it is done, close the window.
  2. Back in ScolioSim, click Connect to the helper, and go on as on Windows (steps 3 and 4).

On Linux TotalSegmentator uses an NVIDIA card if there is one, and the processor if not. To update the helper, paste the same line again.

On every system

The helper listens only on your own computer (address 127.0.0.1) and answers only the ScolioSim site. The CT goes from the browser to the helper inside the same computer; nothing of it reaches a server. It stops by itself after half an hour without use, and ScolioSim starts it again when needed. It works in Chrome and Edge on a desktop computer; Safari may not let a web page reach it. To remove it: Uninstall the helper in ScolioSim, which removes TotalSegmentator, its model weights and its Python too. On Windows it is also in Settings, Apps, ScolioSim Helper; on a Mac or Linux, in Terminal, sh ~/Library/Application\ Support/ScolioSim/Helper/uninstall.sh (macOS) or sh ~/.local/share/scoliosim/helper/uninstall.sh (Linux). Its code can be read before installing it: scoliosim_helper.py, worker.py and, for macOS and Linux, helper-install.sh.

With a command (Windows, macOS, Linux)

For those who prefer to work in a terminal, without the helper: the result is a file that you bring into ScolioSim yourself.

Windows

Open PowerShell (Start menu, type PowerShell) and paste this line. It needs no administrator rights.

irm https://scoliosim.com/segment/install.ps1 | iex

From the Command Prompt (cmd) instead, this one:

powershell -ExecutionPolicy Bypass -c "irm https://scoliosim.com/segment/install.ps1 | iex"

macOS and Linux

Open Terminal and paste this line.

curl -fsSL https://scoliosim.com/segment/install.sh | sh

The installer, which you can read before running it (install.ps1, install.sh, scoliosim_segment.py):

Segment a CT

On Windows, drop the CT folder or ZIP on ScolioSim - segment a CT on the desktop. Anywhere, in a terminal: scoliosim-segment, a space, and drag the folder or ZIP onto the window.

Give it the CT as it came: the CD, the folder exported from the viewer, or the ZIP, whatever its size and however many series it holds. It reads only the headers, says which series it found, picks one, copies only that one aside and segments it. The result is one file, …-vertebrae.nii.gz, written beside the CT (or in Documents/ScolioSim segmentations when that place cannot be written to, as on a CD). Load it in ScolioSim, in X-rays, under The patient’s own vertebrae.

Which series it takes, and why

A CT study usually holds several series: the scout, reconstructions with a bone kernel and with a soft-tissue kernel, thin and thick slices, coronal and sagittal reformats. The vertebrae need one, and the program picks it with these rules, printing the list and the reason each series was left out:

To see the list without segmenting, add --list. To take another series, add --series and its number in the list, for example scoliosim-segment D:\ --series 3.

The CT itself is best when it shows the whole spine, from T1 to the sacrum: ScolioSim only has the patient’s vertebrae that the CT shows, and draws the rest with its reference models.

Other options

Privacy

The CT is read and segmented on your computer, and nothing of it is sent anywhere, to ScolioSim or anyone else. The only things downloaded are the programs, while installing, and the model weights, once, from the TotalSegmentator releases on GitHub. TotalSegmentator sends anonymous usage statistics by default (no images, no patient data); the ScolioSim program turns them off. (TotalSegmentator)

The result file holds only the label map: no name or data of the patient.

If something goes wrong

Measure, plan and simulate on your own radiographs, in the browser. Nothing about a patient or a case is stored on a server.

Open ScolioSim — free

References

  1. Wasserthal J, Breit HC, Meyer MT, et al. (2023). TotalSegmentator: robust segmentation of 104 anatomic structures in CT images. Radiol Artif Intell 5(5):e230024. doi:10.1148/ryai.230024. Code, figures and licence (Apache-2.0; the task used here is open for any use): github.com/wasserth/TotalSegmentator.