Gradient Anisotropic Diffusion itk filter in my .py extension

Operating system: w10
Slicer version: 4.11

I’m trying to include in my in-house Extension the possibility to generate a filtered version of a selected volume using Gradient Anisotropic Diffusion itk filter. The parameters (conductance, iterations…) would be fixed in my .py, with no GUI, so my unique outcome after pushing the “Start” button would be generate the new filtered volume.
I followed this notebook ( 300_Segmentation_Overview ) but the arguments seems to fail.

Coul you please help me?

Please provide the code that you are running and the error message you get.

Alternatively, since these ITK filters are \available in CLI modules (“Curvature Anisotropic Diffusion” and “Gradient Anisotropic Diffusion” modules), you can perform this filtering from Python as described here.

Thank you for your quick response!
I tried what you put forward above using these lines:
outputVolume = slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLScalarVolumeNode”)

        parameters = {}
        parameters["inputVolume"] = inputVolume.GetID()
        parameters["outputVolume"] = outputVolume.GetID()
        parameters["useImageSpacing"] = True
        parameters["conductance"] = 0.9
        parameters["numberOfIterations"] = 7
        parameters["timeStep"] = 0.0625

        cliNode =, None, parameters)

The output volume is created but as Invalid Volume, with no spatial information. Should I clone the input and then apply the filter? I’m not sure in which step it is the trouble.

Thank you!

You need to use runSync or wait for the execution to complete. See details at the link in my previous post.