I am currently trying to program a script that will automate thresholding of scalar volumes then compute the DSC values of these segmentations when compared with previously manually segmented ones. While the coding for Threshold worked seamlessly with CLI, I have been struggling to figure out the parameters for DiceComputation (the extension).
The script runs beautifully in Slicer from Command Line, but then gives me a NoneType object attribute error because the parameter name is clearly wrong and cannot associate with the value I give it in the code. I am convinced it is only a parameter naming problem as all of my other code works well.
When checking the documentation online, I couldn’t find any of the attribute names. Therefore, I have been mostly guessing them based on what I know from other CLI parameters in different modules. I have also tried looking for the original source code of DiceComputation both on GitHub as well as from my own computer after installing the module. However, while I had no luck for the former, I only found .so (compiled Shared Object files) on my computer in its directory.
If anyone knows what the parameters are or have worked in CLI for DiceComputation before, please let me know. All tips and tricks are warmly welcomed. I don’t know, but perhaps DiceComputation doesn’t have the capabilities for CLI?
This is a loadable module, not a CLI. However, computing the Dice coefficient is implemented in the logic for the module, and so should be easily accessible through python. See: Help with Accessing Module Logic in Python Scripted Modules
Note that Dice metric is a very poor metric for comparing segmentations. The main issue that the value has no absolute meaning - 99% value may be unacceptably low and a 80% value may be perfectly good, depending on the shape of the compared segments. Instead, I would recommend to use Hausdorff distance as a metric. Both Dice and Hausdorff distance metrics are computed by Segment Comparison module (available in SlicerRT extension).