Hello! We have finished our code and tested it manually through the Python interactor. Now, we are attempting to run it through a module, so it is just a click of the button. In the testing class in our python file, do we actually copy and paste our algorithm into the class or do you somehow use the logic?
Also, when assigning inputVolume, is there a way to assign inputVolume to your current selected volume?
To run the module test, you should call the logic methods from the test class.
Do you mean that you would like to get image that is displayed in the slice views? You can use something like this:
layoutManager = slicer.app.layoutManager()
# Use first background volume node in any of the displayed layouts
for layoutName in layoutManager.sliceViewNames():
compositeNode = self.getCompositeNode(layoutName)
If you want the user to be able to select input/output nodes from the GUI, you could add qMRMLNodeComboBox to the module widget.
If you want to let the users select their own inputs/outputs, you should use this approach:
Logic method should perform the actual segmentation and accept arguments for all of the inputs and outputs. In the test class you can download the sample data (CTA-cardio) and call the logic method that performs the segmentation.
Okay, we will begin working on the qMRMLNodeComboBox. Thank you so much!
I have attached the test_VertebraSegmentation1 file if you have any suggestions. We believe this is what the module runs we click reload and test. Lines 17-66 perform the actual segmentation. When we copy them into the python interactor in slicer, our desired result works(given a fiducial point has been marked on a vertebra).
The help is much appreciated! We will add in the qMRMLNodeComboBox so the user can select their own input Volume.
We tried to reload and test and we got an error while running. We put down two fiducial points to test our code but we got an error saying that it “could not find nodes in the scene by name or id ‘F’” (our fiducials were called ‘F’). How can we fix this error @Sunderlandkyl?
We have done the tutorial and gone through old modules. We are very appreciative of everyone’s help. We have our code, lines 17-66 in the link two topics above. This code works perfectly when copied and pasted into the python interactor. We just don’t know how to translate that to the testing function in the testing class in our module.
We think it should be easy since we have the code, we just don’t/understand the tutorial on how to transition it.
I have just re-read through the tutorial. My understanding is that we put our chunk of code that runs the algorithm(for reference, it is lines 17-66 in the GitHub link above) in the logic class of our python text. I do not know where in the logic class we actually put it though.
Then we run the testing function in the testing class of our python text using the onApplyButton function that takes in some parameters. Is there anything we are missing? We are very confused by the whole process as it is our first time coding.
Thank you very much for the help. We still have one issue where the fiducials dissapear every time we run and we get an error saying that there is no node with id (‘F’) (the name of our fiducial). How can we fix this problem?
In addition, the CTA-Cardio scan that we download deltes every time we run so there is no final volume and nothing in the subject hierarchy. This contributes to the fiducial issue above so I was wondering why this happens and what can I do to fix this?