Hi, I encountered a problem where if these lines are included in the code, the module cannot be loaded through extension wizard:
# Check if binary labelmap is valid
if binary_labelmap.GetNumberOfPoints() > 0:
# Count the non-zero voxels in the binary labelmap
volume_pixels = 0
data = vtk.util.numpy_support.vtk_to_numpy(binary_labelmap.GetPointData().GetScalars())
volume_pixels = (data > 0).sum()
# Assuming you know the spacing of the labelmap to convert to volume in cm³
spacing = binary_labelmap.GetSpacing()
volume_cm3 = volume_pixels * spacing[0] * spacing[1] * spacing[2] / 1000.0 # Convert mm³ to cm³
# Get the segment name
segment_name = segmentation.GetSegment(segment_id).GetName()
segment_volumes[segment_id] = (segment_name, volume_cm3)
total_volume += volume_cm3
print(f"{segment_name} volume = {volume_cm3:.3f} cm³, {volume_cm3}")
After I press select extension and select the correct folder, the extension editor shows the files in the directory, but I don’t get a popup for adding modules.
I have tested with ARM and Intel Macs and both had the same issues, however it worked fine on windows devices.
The only way I found to add the module is by deleting these lines, and the problem persists if they are only commented out.
Thanks in advance for any help!