# HD\_BET does not work in latest Slicer Preview Release

**URL:** <https://discourse.slicer.org/t/hd-bet-does-not-work-in-latest-slicer-preview-release/30583>\
**Category:** Development\
**Created:** [July 13, 2023, 1:24pm UTC](https://discourse.slicer.org/t/hd-bet-does-not-work-in-latest-slicer-preview-release/30583 "2023-07-13T13:24:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Muhammed\_Fatih\_Talu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muhammed_fatih_talu/32/14646_2.png) [@Muhammed\_Fatih\_Talu](https://discourse.slicer.org/u/Muhammed_Fatih_Talu)\
**Post date:** [July 13, 2023, 1:24pm UTC](https://discourse.slicer.org/t/hd-bet-does-not-work-in-latest-slicer-preview-release/30583/1 "2023-07-13T13:24:58Z")

</div>

While the code below works without any errors in the stable version, it gives an error in the preview version.

```auto
import HDBrainExtractionTool             
        
HDBetLogic = HDBrainExtractionTool.HDBrainExtractionToolLogic()                            
        
brainNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLScalarVolumeNode')        
brainSegNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLSegmentationNode')
HDBetLogic.process(masterVolumeNode,brainNode ,brainSegNode ,0)
slicer.util.setSliceViewerLayers(background=brainNode)

```

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/b/bbfdf42c0a39df88ec8f9b5a8771f376a5fd5cf5.png)

```auto
  File "C:/ProgramData/slicer.org/Slicer5.3.0/slicer.org/Extensions-31866/HDBrainExtraction/lib/Slicer-5.3/qt-scripted-modules/HDBrainExtractionTool.py", line 346, in process
    from HD_BET.run import run_hd_bet
ModuleNotFoundError: No module named 'HD_BET'

```

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 13, 2023, 1:57pm UTC](https://discourse.slicer.org/t/hd-bet-does-not-work-in-latest-slicer-preview-release/30583/2 "2023-07-13T13:57:46Z")

</div>

Please post the exact error.

Also, it could help to post a fully reproducible example that someone can easily paste into the python console to reproduce what you are seeing. E.g. us the sample data methods to load data, etc.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 16, 2023, 1:42am UTC](https://discourse.slicer.org/t/hd-bet-does-not-work-in-latest-slicer-preview-release/30583/3 "2023-07-16T01:42:28Z")

</div>

@Muhammed_Fatih_Talu You need to install prerequisite packages (pytorch and hd\_bet). You can do that by running the module once using the GUI. If you install and run the module from script, make sure you call `HDBetLogic.setupPythonRequirements()` before `HDBetLogic.process(...)`.

---

<div class="post-metadata">

**Author:** ![cnaehle](https://avatars.discourse-cdn.com/v4/letter/c/8baadc/32.png) [@cnaehle](https://discourse.slicer.org/u/cnaehle)\
**Post date:** [January 18, 2025, 10:20pm UTC](https://discourse.slicer.org/t/hd-bet-does-not-work-in-latest-slicer-preview-release/30583/4 "2025-01-18T22:20:49Z")

</div>

Hi,  
I am running into similar issue:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/7/37741aa3aa09a890caa98413b47d9372e6833461.jpeg)

Traceback (most recent call last):  
File “/Applications/Slicer.app/Contents/bin/Python/slicer/util.py”, line 3255, in tryWithErrorDisplay  
yield  
File “/Applications/Slicer.app/Contents/Extensions-32448/HDBrainExtraction/lib/Slicer-5.6/qt-scripted-modules/HDBrainExtractionTool.py”, line 237, in onApplyButton  
self.logic.process(self.ui.inputVolumeSelector.currentNode(), self.ui.outputVolumeSelector.currentNode(),  
File “/Applications/Slicer.app/Contents/Extensions-32448/HDBrainExtraction/lib/Slicer-5.6/qt-scripted-modules/HDBrainExtractionTool.py”, line 346, in process  
from HD\_BET.run import run\_hd\_bet  
ModuleNotFoundError: No module named ‘HD\_BET.run’

Now, PyTorch is installed, but how do I do add the suggested hd\_bet package?

Help is appreciated…

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [January 20, 2025, 2:52am UTC](https://discourse.slicer.org/t/hd-bet-does-not-work-in-latest-slicer-preview-release/30583/5 "2025-01-20T02:52:15Z")

</div>

The Slicer HDBrainExtension currently specifies to use the latest code of the HD\_BET Python package, but the developer has refactored the code resulting in API compatibility issues. I have written up the following GitHub issue to track the work associated with updating the Slicer extension to use an older version of HD\_BET that would be compatible.

cc: @lassoan

> <https://github.com/lassoan/SlicerHDBrainExtraction/issues/2>
>
> This extension has broken following the developer of HD\_BET refactoring the code… as part of creating a HD\_BETv2 version. This occurred in https://github.com/MIC-DKFZ/HD-BET/commit/27414b2ef60167bce8a5ae5a1a34e8b02bb2d7d6 where \`nnunetv2\` became a new dependency along as requiring Python 3.10+.
> 
> The issue was originally discovered by a user that posted on the Slicer discourse forum. See https://discourse.slicer.org/t/hd-bet-does-not-work-in-latest-slicer-preview-release/30583/4.
> \`\`\`
> Traceback (most recent call last):
> File “/Applications/Slicer.app/Contents/bin/Python/slicer/util.py”, line 3255, in tryWithErrorDisplay
> yield
> File “/Applications/Slicer.app/Contents/Extensions-32448/HDBrainExtraction/lib/Slicer-5.6/qt-scripted-modules/HDBrainExtractionTool.py”, line 237, in onApplyButton
> self.logic.process(self.ui.inputVolumeSelector.currentNode(), self.ui.outputVolumeSelector.currentNode(),
> File “/Applications/Slicer.app/Contents/Extensions-32448/HDBrainExtraction/lib/Slicer-5.6/qt-scripted-modules/HDBrainExtractionTool.py”, line 346, in process
> from HD\_BET.run import run\_hd\_bet
> ModuleNotFoundError: No module named ‘HD\_BET.run’
> \`\`\`
> 
> The following code that installs HD\_BET
> https://github.com/lassoan/SlicerHDBrainExtraction/blob/71a4f021c8f200e88707cf411445848858bde2d4/HDBrainExtractionTool/HDBrainExtractionTool.py#L285
> could be updated to https://github.com/MIC-DKFZ/HD-BET/archive/0dcab33233e991b9f7a7cb33052b164eb50062bd.zip which was a version 1.1 commit just prior to the refactoring for version 2. I have opened a separate issue https://github.com/lassoan/SlicerHDBrainExtraction/issues/3 for making things compatible with version 2.
