New extension: HDBrainExtraction for AI-based skull stripping

A new AI-based tool - HDBrainExtracion extension - is added to 3D Slicer for skull stripping (blanking out region outside the brain in MRI images). The model is trained on a large set of images and proven to be more robust than many other similar tools.

The extension is built by packaging the HD-BET model provided by DKFZ (Heidelberg, Germany). This extension can serve as a good example for others who intend to distribute their AI models via 3D Slicer.


This is a very instructive and well-written extension, thank you @lassoan. Do you have any information on how HD-BET trained their skull stripping model in detail? The cited paper remains a bit unclear here. It would be interesting to have similar tissue stripping AI-based modules for other organs.

1 Like

I don’t have any more information other than what they described in their paper. You may contact the authors at the email provided in the paper or by submitting an issue in their GitHub repository for more details.

Short feedback: Works great on a Windows 11 GTX 1060 laptop, but I needed to start Slicer in Admin mode to install the PyTorch extension upon the first run. Processing took about 5 min to complete (Device=auto), so it is probably not using the GPU yet.

1 Like

Thanks for the feedback. What indicated that installing as admin user was necessary?

I’ve noticed that failed Pytorch installs may prevent proper installation. You may consider trying to reinstall Slicer from scratch (deleting the Slicer install folder completely) to see if it makes Slicer’s pytorch find the GPU.

Also make sure that in your NVIDIA settings Slicer is configured to use the GPU.

I install HDBrainExtraction, it asks to install PyTorch too, I agree, then I restart and run the extension the first time and get:

1 Like

This exception was solved by applying this commit

to the PyTorch utility module. Then the install runs normally, but unfortunately, it does not detect CUDA yet on my two systems. Using Slicer in Admin mode was mandatory, otherwise, the PyTorch Util was throwing exceptions.


Very good performance on my desktop (RTX 3070 Ti): 20 s rendering time

CUDA seems to be available on that system.



Thanks for the additional information.

If you encounter any issues then always try to update the extensions in the latest Slicer Stable Release, or install the latest Slicer Preview Release (extension updates are not available for preview releases).

1 Like

HDBrainExtraction is useful for non-volumetric T1 images?

I would expect that the module only works for images that contains many slices and cover the full brain, but you can try it on síngle-slice images, too.

If you find that it does not work then you can train a new network specifically for síngle-slice images. You should be able to automatically generate training data from full-brain data sets.

This is great… do you know if there is a way to hack the Pytorch installation to swap it to use the Metal-backend that is now available for M1/M2 processors?

Wet use light-the-torch to install pytorch. Check out its documentation for ARM architecture compatibility. Note that Slicer runs on ARM macs through Rosetta emulation, which might complicate things a bit further.

1 Like