Calculating Simple Areas

I want to be able to calculate the area of total muscle on a single axial slice. When I run the segmentation statistics, it does give me “surface area” but I think it’s processing the entire CT scan instead of that single axial slice (it gives me a crazy high number). What is the best way to go about this?

1 Like

I wrote quick module a while back with lots of help from Andras and others on calculating the surface area of slices and plotting it - you should be able to extract the re-slicing and calculating part of this for your needs. (Or just use the plot data that comes out of it in the data table.)

There’s some extra stuff in there you probably don’t need that allows slicing along any axis. (Might be useful to you, though.)

Here is the gist with the module:

Hope this helps!


Thank you so much for sharing this amazing module!
Have one question here, when I opened the module, I went to the segmentation drop-down menu but it isn’t showing any of the existing segmentation and the plot button didn’t work. I tried to get to the documentation page to get help but the page is now 404 not found. Could you clarify with me how the segmentation drop-down menu works or is there any problem with my segmentation? Thank you so much for your help!
Also, sorry for replying to this old thread :’(

Probably you have labelmap volumes in the scene and not segmentation nodes. Right-click on the labelmap volume in Data module and choose “Convert labelmap to segmentation node”.

Thank you for your speedy reply! However, I discovered it is not because of labelmap volume, it is the correct volume type. However the segment quantification and plotchart generated by surface area plot is rather odd, it is not distinguishing the areas in different segments of the segmentation but rather a table with only slice number. the plotchart is simply blank. I have attached a screenshot

. Could you help me with that? Thank you so much!

Do you see any errors in the Python console? (Ctrl-3)

Thank you for getting back to me Andras!
Here’s the error code:

Traceback (most recent call last):
File “C:/Users/holly/Downloads/slicer addon/0492146f70ef0fc511b7b21410264481-3a9881a0d5539e75ae0b325436e304fd24b44fde/”, line 140, in onApplyButton, self.segmentationNode, self.direction)
File “C:/Users/holly/Downloads/slicer addon/0492146f70ef0fc511b7b21410264481-3a9881a0d5539e75ae0b325436e304fd24b44fde/”, line 209, in run
vimage = segmentationNode.GetBinaryLabelmapRepresentation(segmentID)
TypeError: GetBinaryLabelmapRepresentation() takes exactly 2 arguments (1 given)

I don’t know how to fix the lack of one argument, could you help me look into that?

Thank you

Slicer’s API has changed in recent preview releases (see migration guide).

To get binary labelmap representation, you need to create an image data object that will contain the result. To fix the issue, replace:

vimage = segmentationNode.GetBinaryLabelmapRepresentation(segmentID)

by this:

vimage = slicer.vtkOrientedImageData()
segmentationNode.GetBinaryLabelmapRepresentation(segmentId, vimage)

Hello. I made this adjustment to code and now the module will not even load. Is there a more recent edit that I need to make?

The code snippets above are no longer relevant:

  • You can now get surface area on a single slice by placing a closed curve and enabling “area” measurement.
  • You can measure cross sectional area of a segmentation along any world axis using “Segment cross-section area” module in Sandbox extension.