Skip to content

This repository contains the code for the SAMSEG.

Notifications You must be signed in to change notification settings

freesurfer/samseg

Repository files navigation

SAMSEG

This repository is under construction. Please look at the main repository in the meantime.

TODO: Add segmentation image(s)?

Sequence Adaptive Multimodal SEGmentation (SAMSEG) is a tool to robustly segment dozens of brain structures from head MRI scans without preprocessing. The characteristic property of SAMSEG is that it accepts multi-contrast MRI data without prior assumptions on the specific type of scanner or pulse sequences used. Dedicated versions to handle longitudinal data, or to segment white matter lesions in multiple sclerosis (MS) patients are also available.

TODO: The description above does not include the subregions module. Fix this.

Build Status

Linux Windows MacOS
Build Status Build Status Build Status

Getting Started

SAMSEG runs on 64bit Windows, Linux, and MacOS machines. Please visit the official SAMSEG Wiki and subregions Wiki for instructions.

Most of the functionalities of SAMSEG do not require FreeSurfer to be installed on your system, except:

  • longitudinal registration preprocessing;
  • subregions module.

Installing from source (on *nix)

  1. Clone project: git clone https://github.com/freesurfer/samseg.git

  2. Get the submodules: git submodule init git submodule update

Note that when you switch between branches with different submodule versions (such as dev and itk_update), you can call git checkout <branch> --recurse-submodules to have the submodules automatically updated.

  1. Create a virtual environment using, e.g., conda: conda create -n samseg python=3.9

  2. Activate the virtual environment: conda activate samseg

  3. Install correct compilers for ITK v.4.13.2 conda install -c conda-forge gcc==10.4 gxx==10.4

  4. Create the ITK build directory mkdir ITK-build cd ITK-build

  5. Export compilers installed with conda: export CC=<your_conda_path>/envs/samseg/bin/x86_64-conda_cos6-linux-gnu-gcc export CXX=<your_conda_path>/envs/samseg/bin/x86_64-conda_cos6-linux-gnu-g++

  6. Run CMAKE: cmake -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ITK-install ../ITK

  7. Install: make install cd..

  8. Install in development mode (.[test] installs pytest, use just . if you don't want to run tests) ITK_DIR=ITK-install python -m pip install --editable .[test]

  9. If you want to build wheels call ITK_DIR=ITK-install python -m pip wheel . -w ./dist --no-deps

  10. If you're developing and want to run the tests call (in the root of the git repository): pytest samseg

References

If you use these tools in your analysis, please cite: