I am asking for advice about the best way to segment a tooth from a fossil mandibular fragment. This is from a mCT scan of 1,554 slices. I want to segment enamel, dentine, pulp, and roots etc… but densities are extremely similar!
There is really no magical formulas to separate enamal, dentine pulp and roots if the intensities are very similar. Normally enamel should be easy, but you said this is a fossil so diagenesis would change that. You can try the NNInteractive, AI-based interactive segmentation, but you will probably first reduce the resolution of your dataset (probably by factor of 2).
Thank you. I am running on a Windows device with NVIDIA GPU, Quadro RTX 4000.
The setup instructions don’t seem to be working in Windows PowerShell:
PS C:\Users\Imaging Lab> cd /d %localappdata%
Set-Location : A positional parameter cannot be found that accepts argument '%localappdata%'.
At line:1 char:1
+ cd /d %localappdata%
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-Location], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
PS C:\Users\Imaging Lab> mkdir nninteractive-server
mkdir : An item with the specified name C:\Users\Imaging Lab\nninteractive-server already exists.
At line:1 char:1
+ mkdir nninteractive-server
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceExists: (C:\Users\Imagin...eractive-server:String) [New-Item], IOException
+ FullyQualifiedErrorId : DirectoryExist,Microsoft.PowerShell.Commands.NewItemCommand
PS C:\Users\Imaging Lab> cd nninteractive-server
PS C:\Users\Imaging Lab\nninteractive-server> pixi init .
Error: x pixi.toml already exists
PS C:\Users\Imaging Lab\nninteractive-server> pixi add python=3.12 pip
Added python=3.12
Added pip >=25.2,<26
PS C:\Users\Imaging Lab\nninteractive-server> cd .pixi\envs\default\Scripts
PS C:\Users\Imaging Lab\nninteractive-server\.pixi\envs\default\Scripts> pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip3 : The term 'pip3' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ pip3 install torch torchvision torchaudio --index-url https://downloa ...
+ ~~~~
+ CategoryInfo : ObjectNotFound: (pip3:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Suggestion [3,General]: The command pip3 was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\pip3". See "get-help about_Command_Precedence" for more details.
PS C:\Users\Imaging Lab\nninteractive-server\.pixi\envs\default\Scripts> cd /d %localappdata%\nninteractive-server\.pixi\envs\default\Scripts
Set-Location : A positional parameter cannot be found that accepts argument
'%localappdata%\nninteractive-server\.pixi\envs\default\Scripts'.
At line:1 char:1
+ cd /d %localappdata%\nninteractive-server\.pixi\envs\default\Scripts
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-Location], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
PS C:\Users\Imaging Lab\nninteractive-server\.pixi\envs\default\Scripts> pip install nninteractive-slicer-server
pip : The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ pip install nninteractive-slicer-server
+ ~~~
+ CategoryInfo : ObjectNotFound: (pip:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Suggestion [3,General]: The command pip was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\pip". See "get-help about_Command_Precedence" for more details.
PS C:\Users\Imaging Lab\nninteractive-server\.pixi\envs\default\Scripts> nninteractive-slicer-server --host 0.0.0.0 --port 1527
nninteractive-slicer-server : The term 'nninteractive-slicer-server' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At line:1 char:1
+ nninteractive-slicer-server --host 0.0.0.0 --port 1527
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (nninteractive-slicer-server:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Suggestion [3,General]: The command nninteractive-slicer-server was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\nninteractive-slicer-server". See "get-help about_Command_Precedence" for more details.
PS C:\Users\Imaging Lab\nninteractive-server\.pixi\envs\default\Scripts>
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.
C:\Users\Imaging Lab\AppData\Local\nninteractive-server\.pixi\envs\default\Scripts>
Does this mean my installed model checkpoint was trained for GPU (CUDA), but my current PyTorch install is CPU-only?
EDIT: I have forced a CUDA version in Terminal which now seems to have linked the server with the Slicer plug-in. Thank you!
One further issue, however, is the file size. I have cropped the volume to just one tooth on the mandible, I did not apply ResampleScalarVolume, as I was hesitant to reduce resolution too much. NNInteractive has failed at some stage:
[VTK] There is more than one file, use the vtkITKArchetypeImageSeriesReader instead
[Qt] ctkRangeWidget::setSingleStep( 100 ) is outside valid bounds
[Python] Segmentation failed.
[Python] Something has gone wrong with your request (Status code 500).
[VTK] vtkMRMLMarkupsNode::GetNthControlPointPositionStatus failed: control point 1 does not exist
Traceback (most recent call last):
File "C:/Users/Imaging Lab/AppData/Local/slicer.org/Slicer 5.8.1/slicer.org/Extensions-33241/NNInteractive/lib/Slicer-5.8/qt-scripted-modules/SlicerNNInteractive.py", line 642, in on_point_placed
self.point_prompt(xyz=xyz, positive_click=self.is_positive)
File "C:/Users/Imaging Lab/AppData/Local/slicer.org/Slicer 5.8.1/slicer.org/Extensions-33241/NNInteractive/lib/Slicer-5.8/qt-scripted-modules/SlicerNNInteractive.py", line 69, in inner
return func(self, *args, **kwargs)
File "C:/Users/Imaging Lab/AppData/Local/slicer.org/Slicer 5.8.1/slicer.org/Extensions-33241/NNInteractive/lib/Slicer-5.8/qt-scripted-modules/SlicerNNInteractive.py", line 651, in point_prompt
seg_response = self.request_to_server(
File "C:/Users/Imaging Lab/AppData/Local/slicer.org/Slicer 5.8.1/slicer.org/Extensions-33241/NNInteractive/lib/Slicer-5.8/qt-scripted-modules/SlicerNNInteractive.py", line 1144, in request_to_server
raise RuntimeError(f"Something has gone wrong with your request (Status code {status_code}).")
RuntimeError: Something has gone wrong with your request (Status code 500).
[Python] Segmentation failed.
[Python] Something has gone wrong with your request (Status code 500).
[VTK] Warning: In vtkSlicerCLIModuleLogic.cxx, line 2377
[VTK] vtkSlicerCLIModuleLogic (000001ECA648A420): Unable to delete temporary file C:/Users/Imaging Lab/AppData/Local/Temp/Slicer/BCJAAE_vtkMRMLScalarVolumeNodeD.nrrd
[Python] Segmentation failed.
[Python] Something has gone wrong with your request (Status code 500).
UPDATE: I have re-activated the server and URL and this has now worked, with some post-processing model cleaning. Unfortunately, as you mentioned, enamel and dentine densitites are too similar, but it has segmented from matrix rather well.
Best,
Tom