So for local threshold effect, I would type in:
localThresholdEffect.setFeatureSize(6)
localThresholdEffect.setMinimumThreshold(250)
localThresholdEffect.setMaximumThreshold(1000)
Our code just takes in a point on a vertebra and runs local threshold from that point. We have already coded the taking in a point.
We are in the testing stage of the entire code now. To confirm, we are running it line by line in the python interactor. The GitHub code uses an apply function(which appears to be synonymous with run the algorithm). The parameters for apply are self and ijkPoints.
Whenever we run the apply function:â
apply(ijkPoints)
It says apply() missing 1 required positional argument: âijkPointsâ
Indeed, in case of this effect, which is derived from C++ effect, the syntax is slightly different, as effect refers to the C++ effect, and you need to call effect.self() to access the methods added in Python. So, a complete example:
I am sorry to bother you again. I copied all of the functions from the Local Threshold into the Python Interactor and created a segmentationNode around a pre-determined point. Then, I run this code:
segmentEditorWidget = slicer.modules.segmenteditor.widgetRepresentation().self().editor
segmentEditorWidget.setActiveEffectByName(âLocal Thresholdâ)
effect.setParameter(âMinimum Thresholdâ, 265)
effect.setParameter(âMaximum Thresholdâ, 1009)
effect = segmentEditorWidget.activeEffect()
ijkPoints = vtk.vtkPoints()
ijkPoints.InsertNextPoint(world[0], world[1], world[2]) ##world has the coordinates of the point
effect.self().apply(ijkPoints)
This gives me an error saying that âNone Typeâ has no attribute self. I feel like we have the necessary elements to the code(many thanks to your GitHub resources), but I just cannot get the code to actually work when run. Thank you
You can only select an effect if you selected a master volume and created a segment. See the examples.
Also note that the order of operations need to be fixed (effect = comes first) and that world coordinate is physical (RAS) coordinate and not IJK. You need to convert to RAS to IJK before inserting the point coordinates into ijkPoints.
The setActiveEffectByName line(and lines where we setParameters after it) still have errors regarding attributes and identifiers. Do you have any idea why @lassoan?