AIM-Harvard / foundation-cancer-image-biomarker

Code and evaluation repository for the paper
https://aim-harvard.github.io/foundation-cancer-image-biomarker/
MIT License
75 stars 9 forks source link

AssertionError: Invalid coordinates: min_d >= max_d #300

Closed wafaequo closed 3 months ago

wafaequo commented 3 months ago

I downloaded the SPIE-AAPM Lung CT Challenge data and converted the images from DICOM to nii using the following code: https://github.com/rordenlab/dcm2niix.

The coordinates of the nodule are given in pixels and I converted it to physical coordinate space using .get_zooms() from the metadata of each image.

I still keep getting the following errors (depending on the image I choose) when running visualize_seed_point: AssertionError: Invalid coordinates: min_d >= max_d AssertionError: Invalid coordinates: min_h >= max_h

What am I doing wrong?

surajpaib commented 3 months ago

Hi @wafaequo

I'm not very familiar with nibabel as I mostly use SimpleITK for my image loading purposes. I'm assuming there might be a mismatch between the orientation provided by nibabel coordinates and the ones expected by FMCIB.

Could you test the same workflow with SimpleITK and let me know if it works?


import SimpleITK as sitk

# Load the image
image_path = 'path/to/your/image.nii'  # Replace with your image file path
image = sitk.ReadImage(image_path)

# Convert image coordinates (i, j, k) to physical coordinates (x, y, z)
def image_to_physical(image_coords):
    return image.TransformIndexToPhysicalPoint(image_coords)

# Example image coordinates
image_coords = (100, 150, 75) 

# Convert to physical coordinates
physical_coords = image_to_physical(image_coords)
print(f"Physical coordinates: {physical_coords}")
surajpaib commented 3 months ago

Alternatively, if you can share a image coordinate, the image itself and your current physical coordinate, I can test it myself and let you know how to modify.

wafaequo commented 3 months ago

@surajpaib Hello, I just tried the provided code and it worked!! Thank you very much for the fast reply 👍🏽