SAMM (Segment Any Medical Model): A 3D Slicer Integration to SAM

Yihao Liu, Jiaming Zhang, Zhangcong She, Amir Kheradmand, Mehran Armand

Abstract

The Segment Anything Model (SAM) is a new image segmentation tool trained with the largest available segmentation dataset. The model has demonstrated that, with prompts, it can create high-quality masks for general images. However, the performance of the model on medical images requires further validation. To assist with the development, assessment, and application of SAM on medical images, we introduce Segment Any Medical Model (SAMM), an extension of SAM on 3D Slicer - an image processing and visualization software extensively used by the medical imaging community. This open-source extension to 3D Slicer and its demonstrations are posted on GitHub. SAMM achieves 0.6-second latency of a complete cycle and can infer image masks in nearly real-time.

Introduction

Medical image segmentation—the process of isolating specific organs, tumors, or anatomical structures—is a cornerstone of modern radiology and surgery planning. Traditionally, this requires AI models meticulously fine-tuned on specific datasets (e.g., a model trained only on "liver CTs"). These models often struggle with "domain gaps," failing when faced with different imaging hardware or patient variations.

While the Segment Anything Model (SAM) revolutionized general computer vision by segmenting almost any object without specific training, its utility in the medical field remained gated. Medical images are often 3D volumes (DICOM/NIfTI) with low signal-to-noise ratios and complex coordinate systems, making it difficult for clinicians to apply a "general-purpose" model like SAM to their specialized workflows. SAMM bridges this gap, providing a user-friendly interface for the medical community to test and validate SAM’s potential within the gold-standard 3D Slicer environment.

Methods and System Architecture

The SAMM framework utilizes a dual-component architecture designed to minimize latency and maximize usability for clinicians. It consists of a SAM Server and a Slicer-IPP (Interactive Prompt Plugin).

The dual-component architecture of SAMM, connecting 3D Slicer to a dedicated SAM Server.

The SAM Server

This backend loads the pretrained SAM model. To ensure speed, it computes the "image embeddings" (the heavy mathematical representation of the image) for an entire 3D volume once. These are stored in RAM, allowing subsequent user interactions to be nearly instantaneous. By decoupling the encoder—the most computationally expensive part of SAM—from the interactive loop, the system avoids re-calculating the embedding for every user click.

Slicer-IPP and Communication

The frontend plugin for 3D Slicer handles the conversion of 3D world coordinates (RAS: Right, Anterior, Superior) into the 2D pixel coordinates (IJK) required by the model. To prevent lag, the system uses ZeroMQ for messaging and Numpy memory mapping for data transfer, bypassing the overhead of traditional file-saving methods. Users place "fiducial points" (green for "include," red for "exclude") on a slice, which are transmitted to the server to generate a mask in real-time.

Key Results and Evaluation

The system was evaluated using standard sample datasets provided by 3D Slicer, including Computed Tomography (CT), Magnetic Resonance Imaging (MRI), and Ultrasound (US). These datasets represent a variety of anatomical structures, allowing for a robust test of SAM's "zero-shot" performance.

Zero-shot segmentation results across MRI, CT, and Ultrasound modalities using point-based prompts.

Performance Metrics

  • Latency: The system achieves a complete cycle (from prompt to mask display) in approximately 0.612 seconds.
  • Preprocessing Speed: For a 352 × 352 × 240 MRI volume, computing all necessary embeddings takes about 162.9 seconds. While this is a one-time initialization cost, it enables sub-second interaction thereafter.
  • Qualitative Success: As shown in the visual results, SAMM successfully segments diverse structures across CT, MRI, and Ultrasound without any fine-tuning of the underlying SA-1B pre-trained model. This suggests that the fundamental "edges" and "shapes" learned by foundation models are surprisingly universal.

Discussion and Future Work

SAMM demonstrates that workflow integration is key; for AI to be useful in medicine, it must live where the data lives. Integrating SAM into 3D Slicer allows researchers to use existing medical visualization tools immediately after segmentation.

However, limitations remain. The system's timing is unstable during the first 5 seconds of the initialization phase. Furthermore, while point-based prompting is effective, future iterations could include bounding boxes or text-based prompts. Most importantly, while SAMM makes it easier to use SAM, the model's clinical accuracy still requires rigorous validation by medical professionals before use in diagnostic settings. Future work may involve using SAMM as a "smart initialization" tool for more specialized medical AI frameworks like MONAI.

Summary updated

Abstract

The Segment Anything Model (SAM) is a new image segmentation tool trained with the largest available segmentation dataset. The model has demonstrated that, with prompts, it can create high-quality masks for general images. However, the performance of the model on medical images requires further validation. To assist with the development, assessment, and application of SAM on medical images, we introduce Segment Any Medical Model (SAMM), an extension of SAM on 3D Slicer - an image processing and visualization software extensively used by the medical imaging community. This open-source extension to 3D Slicer and its demonstrations are posted on GitHub (https://github.com/bingogome/samm). SAMM achieves 0.6-second latency of a complete cycle and can infer image masks in nearly real-time.
BibTeX
@misc{liu2023samm,
  author = {Yihao Liu and Jiaming Zhang and Zhangcong She and Amir Kheradmand and Mehran Armand},
  title = {{SAMM (Segment Any Medical Model): A 3D Slicer Integration to SAM}},
  year = {2023},
  eprint = {2304.05622},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2304.05622},
}
Figure