Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation shape is not the same as the original image shape #57

Open
melaniezhang opened this issue Feb 9, 2024 · 0 comments
Open

Comments

@melaniezhang
Copy link

This is what I'm trying:

# read individual segments from dicom file via pydicom_seg
dcm = pydicom.dcmread(dicom_filename)
print(dcm.pixel_array.shape)

# Use a SegmentReader to iterate through all the segments
reader = pydicom_seg.SegmentReader()
result = reader.read(dcm)

segmentations = []
for segment_number in result.available_segments:
    print(segment_number)
    image_data = result.segment_data(segment_number)  # directly available
    image = result.segment_image(segment_number)  # lazy construction
    print(sitk.GetArrayFromImage(image).shape)
    segmentations.append(image)

The original dicom image pixel array's shape is (440, 512, 512).

However the individual segment shapes are (114, 512, 512); strange.

Is there a way to read the segments where the shape of the original image is preserved?

I need this because I'm trying to combine all the segments back to a numpy array, and save it in a different format like .nii.gz, where I need the dimensions of the combined output to be the same as the original dicom input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant