Dear @lassoan
Hello lassoan ,
I read this and this too. And I tried to extract HounsField Units and checked saved file when I clicked “Reload and Test” button.
These are result.csv and script code.
If you have import slicer in your module source code then you can access functions in slicer.util like this: slicer.util.getNode('someNode').
Note that getNode method is intended for testing and debugging only. In scripted modules you usually don’t know in advance the ID or name of the node that the user will choose, but you get the selected node from a MRML node selector widget.
You should get the input segmentationNode and masterVolumeNode from your node selectors - something like segmentationNode = self.ui.segmentationNodeSelector.currentNode().
You set the output labelmapVolumeNode correctly in the ...AddNewNodeByClass... line. The labelmapVolumeNode = slicer.util.getNode... line should be deleted.
We cannot review and comment on source code in screenshots. Could you upload your module (including all the files that the Extension Wizard generated) to github and post the link here?
I want to get the HU Values(x,y,z,HU) from Segment(via 3D Slicer Segmentation Editor’s output).
I tried debugging using VS Code, and I checked that labelmapVolumeNode had no value. And it is also true that we can’t find a way to check the volume and segment.
If you don’t mind, can you show me your source code?
Hello , @lassoan
How do I get the Hounsfield Unit Values for the Segment Volume that I made using SegmentEditor? I should like to have the benefit of your advice.
You can check my source code at here.
I occured this message "AttributeError : ‘MRMLCore.vtkMRMLScalarVolumeNode’ object has no attribute ‘GetSegmentation’ from this line “segmentationNode.GetSegmentation().GetNthSegmentID(0)” when I clicked the ‘Get HU Values’ button.
You can check ‘Get HU Values’ button’s all source at here.
The error message is truncated. Always copy-paste the entire error message text (in addition to that you can also attach screenshots but only if they contain more information than just a textbox).
The error message tells that you passed a volume node as an argument to Segment Statistics module, but it expected that argument to be a segmentation node instead.
@lassoan Thanks for reply.
This is full error message.
Traceback (most recent call last):
File “C:/Slicer_Module/HounsFiledUnit/src/HounsFieldUnit/HounsFieldUnit/HounsFieldUnit.py”, line 358, in onGetHUButton
segmentId = segmentationNode.GetSegmentation().GetNthSegmentID(0)
AttributeError: ‘MRMLCore.vtkMRMLScalarVolumeNode’ object has no attribute ‘GetSegmentation’
@lassoan
Hello, My code is here and you can check data I used in “data” directory.
After I input the sample directory’s data and occured coordinates(maybe x,y,z,hu) but HU(HounsField Unit) value is number one(1)…
I can’t understand why HU is 1. I think HU get coordinates(x,y,z) each HU values and these values are not same.
Can you review my code??
Thank you.