Segmentations oblique to the acquisition plane of the source data are not yet supported

Issue #49 resolved
Jun Xian created an issue

Hello,

I was trying to run MONAILabel inference on a dicom scan, the inference runs smoothly without errors, but the output segmentation was not displayed on the viewer. In the console log, this error appeared.

Initially i thought this would be a simple fix by changing the ImageOrientationPatient, rounding it to 1 and 0’s. But that doesn’t seem to work.

I have also opened an issue on monailabel’s repo: https://github.com/Project-MONAI/MONAILabel/issues/1336#issuecomment-1622914349

Comments (13)

  1. Mo Alsad

    Hi Jun,

    Do the ImageOrientationPatient values are the same for all the frames in the DICOM dataset?

    Kind regards,

    Mo

  2. Jun Xian reporter

    Hello Mo,

    ImageOrientationPatient stays constant throughout the entire scan

    ImagePositionPatient values are not the same

    Example:
    First slice

    Next slice

    Next slice

  3. Jun Xian reporter

    Anyway i have attached the dicom file in this zip folder here.

    The segmentation output in nifti format here
    The segmentation output in dcm format converted through 3D Slicer here

    This is CQ296 from CQ500 dataset, nifti converted to dicom files through 3D Slicer here

  4. Jun Xian Tan

    Hello Mo, were you able to reproduce this error? I have been editing different tags and their values and I cant seem to find a workaround.

  5. Jun Xian reporter

    I was modifying some dicom tags, trying to make it work, these are the dicom tags which i have edited on my end:

    # Calculate the direction cosines for the image orientation
    direction_cosines = reference_file.ImageOrientationPatient
    row_cosine = [float(direction_cosines[0]), float(direction_cosines[1]), float(direction_cosines[2])]
    column_cosine = [float(direction_cosines[3]), float(direction_cosines[4]), float(direction_cosines[5])]
    
    for i, ds in enumerate(dicom_files):
        # Calculate the new ImagePositionPatient values using the slice number and direction cosines
        new_position = [(i + 1) * row_cosine[j] + ds.ImagePositionPatient[j] * column_cosine[j] for j in range(3)]
        # Update the ImagePositionPatient values for the current DICOM file
        ds.ImagePositionPatient = new_position
        # To ensure order of slices 
        ds.ImagePositionPatient[2] = ds.InstanceNumber
    
        ds.ImageOrientationPatient = [1,0,0,0,1,0]
        ds.ImageType = ['ORIGINAL', 'PRIMARY', 'AXIAL']
        ds.PatientOrientation = ['L', 'P']
    

    I haven’t tested it out on more scans yet, would anyone be able to confirm that this is one of the way to solve the oblique issue?

  6. Jun Xian Tan

    So i figured the main issue was just the dicom metadata being corrupted / bad so some kind of editing was required. We can close this issue

  7. Log in to comment