AttributeError: 'vtkSlicerMarkupsModuleMRMLPython.vtkMRMLMarkupsClo' object has no attribute 'GetImageData'

Hi, I’m new to Slicer (version 5.8.1 on Windows 11 Pro) and would like to calculate radiomics features from native 2D DICOM images. I’m trying this code in the Python-Slicer terminal:

import slicer
import numpy as np
import SimpleITK as sitk
from radiomics import featureextractor
def calculate_2d_radiomics(image_node, segmentation_node, label_value=1, force_2d=True, force_2d_dimension=0):
extractor = featureextractor.RadiomicsFeatureExtractor()
extractor.settings[‘label’] = label_value
extractor.settings[‘force2D’] = force_2d
extractor.settings[‘force2Ddimension’] = force_2d_dimension
image_sitk = sitk.GetImageFromArray(slicer.util.arrayFromVolume(image_node))
segmentation_sitk = sitk.GetImageFromArray(slicer.util.arrayFromVolume(segmentation_node))

segmentation_sitk = sitk.Cast(segmentation_sitk, sitk.sitkUInt8)
try:
results = extractor.execute(image_sitk, segmentation_sitk)
return results
except Exception as e:
print(f"Error during feature extraction: {e}“)
return None

image_node = slicer.util.getNode(“DCM_IMG”)
segmentation_node = slicer.util.getNode(“SEG_IMG”)

if image_node and segmentation_node:
radiomics_results = calculate_2d_radiomics(image_node, segmentation_node, label_value=1, force_2d=True, force_2d_dimension=0)
if radiomics_results:
for key, value in radiomics_results.items():
if key.startswith(‘original’):
print(f”{key}: {value}")
else:
print(“Error: Please load an image and segmentation with specified names.”)

I’m getting this error:

AttributeError: ‘vtkSlicerMarkupsModuleMRMLPython.vtkMRMLMarkupsClo’ object has no attribute ‘GetImageData’

I’ve also tried different ROI segmentations: “closed curve,” “ROI,” etc.

Do you have some suggestions?
Thanks in advance for your help.

What is happening is that your code is trying to call GetImageData on a node type that is not an image (a closed curve markups node).

You need to make sure you’re using the proper data types for your calculation. I’d suggest that you read on segmentations in Slicer a bit, because from your last sentence it seems that you are confusing various node types with segmentations.

Also next time please format the code you paste as code, because it is very hard to read Python code without indentation. Thanks!

Sorry, maybe I didn’t express myself clearly. I tried both the Segmentation and ROI tools. In the meantime, I’ve solved the problem. I get radiomic features from a 2D image (for example, just an MRI slide) but not from native 2D scintigraphy scans. The error is this:

ValueError: Image/Mask geometry mismatch. Potential fix: increase tolerance using geometryTolerance, see Documentation:Usage:Customizing the Extraction:Settings:geometryTolerance for more information

I read that this problem could be solved with “correctMask: True”, but it doesn’t work for me.

Do you have any suggestions? Thanks a lot!