Steve, thanks for reply.
First, I was excited and examined the log file (as below).
I thought I could find the step-by-step python codes of the process done in the log file.
However, the log file unfortunately did not have detailed content.
[DEBUG][Qt] 13.03.2022 21:36:02 [] (unknown:0) - Switch to module: "ProbeVolumeWithModel"
[DEBUG][Qt] 13.03.2022 21:36:20 [] (unknown:0) - Found CommandLine Module, target is C:/ProgramData/NA-MIC/Slicer 4.13.0-2022-02-11/bin/../lib/Slicer-4.13/cli-modules/ProbeVolumeWithModel.exe
[DEBUG][Qt] 13.03.2022 21:36:20 [] (unknown:0) - ModuleType: CommandLineModule
[DEBUG][Qt] 13.03.2022 21:36:22 [] (unknown:0) - Probe Volume With Model command line:
C:/ProgramData/NA-MIC/Slicer 4.13.0-2022-02-11/bin/../lib/Slicer-4.13/cli-modules/ProbeVolumeWithModel.exe --outputArrayName NRRDImage C:/Users/Administrator/AppData/Local/Temp/19/Slicer/BIBHG_vtkMRMLScalarVolumeNodeE.nrrd C:/Users/Administrator/AppData/Local/Temp/19/Slicer/BIBHG_vtkMRMLModelNodeE.vtk C:/Users/Administrator/AppData/Local/Temp/19/Slicer/BIBHG_vtkMRMLModelNodeF.vtk
[DEBUG][Qt] 13.03.2022 21:36:24 [] (unknown:0) - Probe Volume With Model standard output:
Done reading the file C:/Users/Administrator/AppData/Local/Temp/19/Slicer/BIBHG_vtkMRMLScalarVolumeNodeE.nrrd
[DEBUG][Qt] 13.03.2022 21:36:24 [] (unknown:0) - Probe Volume With Model completed without errors
Yes, this is expected - the ProbeVolumeWithModel module is a C++ command line module so when you run it from the GUI your widget selections are converted into command line arguments. To call the same module from python you need to make sure your command has all the same arguments of the right types. Both ways of running the module will log the command line in the log.
I solved the problem.
I was not getting the correct ID of InputModelNode.
instead of slicer.mrmlScene.GetFirstNodeByClass(“vtkMRMLModelNode”),
I used slicer.mrmlScene.GetFirstNodeByName(“InputModel”).
It runs perfect
Thanks every body.
Image slices are displayed in 3D views as model nodes, therefore the first 3 model nodes are typically these slice plane nodes.
@pieper what do you think about adding a flag to GetFirstNodeByName method to include/exclude hidden nodes and by default make hidden nodes excluded? This would change the behavior of the method by default, but since this is a high-level convenience function, the expected behavior is probably to not consider hidden nodes.
Yes, those convenience methods (also getNode in python) seem to regularly lead to some confusion; making them behave better could help. Maybe in slicer.util we should provide a pickNode method that pops up a gui node combo box and use that in the script repository instead of teaching people to use the less reliable methods.