Loading DeCA module

ANTs works with volumes, not 3D models. If you organize the original scans, and the landmarks that you created on the disk (not in the Slicer scene), you can create a volumetric template by using the Templates tab

I didn’t really have time to write a tutorial. There are some additional steps that are important to consider (e.g., selection of the initial template, or how to create one if there is no reference template). but give it a try as is, and if you think you find it useful, I can provide those points.

I will, because it looks good, and come back in touch
Best

Envoyé de mon iPhone

If I succeed, I will write a tutorial :grinning_face_with_smiling_eyes:

Envoyé de mon iPhone

Sounds good. Go ahead and proceed with using one of your actual samples as a reference. However, the more appropriate way would be to rigidly register all those samples into a common orientation (using groupwise tab), and average them at that space, and then use that to initialize the template building process.

That is not incorporated into the ANTsPY yet properly, but there is simple script that you can pretty much copy and edit the path to the rigidly aligned volumes, and paste it into the Python console in Slicer:

Sorry I can’t find such a display as this one:


I tried to copy, as suggested , the above script, and paste it in the console, but I got an error message : hereafter you’ll find the log

import slicer

import ants

import os

import time

Function to create a Slicer node from an ANTSImage

def nodeFromANTSImage(antsImage, name):

import ants

imageNode = slicer.mrmlScene.AddNewNodeByClass(‘vtkMRMLScalarVolumeNode’, name)

tempFilePath = os.path.join(

slicer.app.temporaryPath,

“tempImage_{0}.nii.gz”.format(time.time()),

)

ants.image_write(antsImage, tempFilePath)

storageNode = slicer.vtkMRMLVolumeArchetypeStorageNode()

storageNode.SetFileName(tempFilePath)

storageNode.ReadData(imageNode, True)

os.remove(tempFilePath)

return imageNode

Input directory of aligned images (such as from ANTs Registraion Groupwise Registration)

input_directory = “D:/ANTsData/MouseOutputs”

End pattern for selecting the transformed images from the input directory

filename_end_pattern = “transformed.nii.gz”

filePaths =

for file in os.listdir(input_directory):

if file.endswith(filename_end_pattern):

filePaths.append(os.path.join(input_directory, file))

averagedANTSImage = ants.math.average_images(filePaths)

averagedImageNode = nodeFromANTSImage(averagedANTSImage, “AverageImage”)

slicer.util.setSliceViewerLayers(background=averagedImageNode, fit=True)

Traceback (most recent call last):

File “”, line 2, in

ModuleNotFoundError: No module named ‘ants’

philippe pellerin
philippepellerin@me.com

What is the version of Slicer you are using and can you send a acreenshot of your antsRegistration module?

I have previously tried with 3 different issues, and each time I get this menu(attached). Before I answer your mail, I downloaded the issue 5.9.0-2025-09-20 released yesterday, and I have the good menu. I will try to use it and will let you know.
But, anyway, since the interest, for me, is to superpose the Normal skull with a skull of interest, only the models, with their edition and display abilities, are worthy, since the superposition of volume rendering is very difficult to read.
If you wish to have a look at my work, you may have a good idea by watching this tutorial on YouTube https://youtu.be/hJTWZDnqZ3k
I may, as well, share a folder with the Atlas if you like. I wonder whether the Slicer community could be interested.
Best regards, and, again, thanks for the nice tools that you provide. Best regards.

philippe pellerin

philippepellerin@me.com

I don’t understand. I had the good menu, then I restarted the application, and now it is back to the previous, incomplete menu!
this is a grab screen

philippe pellerin
philippepellerin@me.com

I got the right menu back when I disable the other extensions…

philippe pellerin
philippepellerin@me.com

Can you enable again the other extensions, start the application, and see what errors are in the Python console? It is possible that a previous error of another module prevented this one from being set up properly.

This is what I copy from the console:

Python 3.12.10 (main, Sep 21 2025, 23:13:54) [Clang 14.0.6 (https://github.com/tru/llvm-release-build 686807a176470032c208f27 on darwin

[VTK] Warning: In vtkSlicerTerminologiesModuleLogic.cxx, line 3351

[VTK] vtkSlicerTerminologiesModuleLogic (0x600000659400): LoadAnatomicContextFromFile is deprecated. Use LoadRegionContextFromFile instead.

philippe pellerin
philippepellerin@me.com

The problem is fixed when I disable the SlicerANTs extension

philippe pellerin
philippepellerin@me.com

This warning is harmless, it will not prevent anything.

Did you copy this with SlicerANTs enabled? There was nothing else?

Another error log in the console, if it could help

Python 3.12.10 (main, Sep 21 2025, 23:13:54) [Clang 14.0.6 (https://github.com/tru/llvm-release-build 686807a176470032c208f27 on darwin

Traceback (most recent call last):
File “/Applications/Slicer.app/Contents/Extensions-33957/SlicerANTsPy/lib/Slicer-5.9/qt-scripted-modules/ANTsRegistration.py”, line 341, in setup
self.ui.outputForwardTransformComboBox.connect(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: ‘’ object has no attribute ‘outputForwardTransformComboBox’. Did you mean: ‘outputTransformComboBox’?
Traceback (most recent call last):
File “/Applications/Slicer.app/Contents/Extensions-33957/SlicerANTsPy/lib/Slicer-5.9/qt-scripted-modules/ANTsRegistration.py”, line 522, in enter
self.initializeParameterNode()
File “/Applications/Slicer.app/Contents/Extensions-33957/SlicerANTsPy/lib/Slicer-5.9/qt-scripted-modules/ANTsRegistration.py”, line 564, in initializeParameterNode
self.setParameterNode(
File “/Applications/Slicer.app/Contents/Extensions-33957/SlicerANTsPy/lib/Slicer-5.9/qt-scripted-modules/ANTsRegistration.py”, line 605, in setParameterNode
self.updateGUIFromParameterNode()
File “/Applications/Slicer.app/Contents/Extensions-33957/SlicerANTsPy/lib/Slicer-5.9/qt-scripted-modules/ANTsRegistration.py”, line 630, in updateGUIFromParameterNode
self.ui.outputForwardTransformComboBox.setCurrentNode(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: ‘’ object has no attribute ‘outputForwardTransformComboBox’. Did you mean: ‘outputTransformComboBox’?

philippe pellerin
philippepellerin@me.com

What is the difference between SlicerAnts and SlicerAntsPy? They both contain a qt-scripted-module that is a file name antsregistration.py. I could see how that may mess up some loading module logic.

I am able to replicate the above mentioned traceback where it is getting confused of outputTransformComboBox from SlicerAnts and outputForwardTransformComboBox of SlicerAntsPy.

There is no reason to have AntsPy and Ants extensions simultaneously installed and I suspect thats the problem.

Antspy bring the full antspy package which is image quantification and segmentation libraries built on top of Ants. Ants extension only provides the AntsRegistration function.

While antspy does provide the same registration function we did not expose all possible parameters that one can possinbly pass to an ants registration call. So if the focus is single.pairwise registration, SlicerAnts extension is preferred.

If you need additional features such aa template building, groupwise, jacobian etc, you may use Antspy.

Having said that it might be good to have a check for ants extension checl in antspy and ask user to uninstall to use install antspy

@Sam_Horvath what do you think?

I built a template with ANTsPY. It worked fine, but the final result, even after iterations, is a bit blurred, and I can’t find my usual landmarks to orient the volume. Thus, for my research, going through skull segmentation and model creation is a better path to analysing craniofacial malformation. But thanks for suggesting this idea.

1 Like