Skip to content
New issue

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

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

Already on GitHub? # to your account

There is something wrong about the ProstateX-0142 Finding 3 geometry #9

Open
enliden1 opened this issue Apr 8, 2021 · 11 comments
Open
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@enliden1
Copy link

enliden1 commented Apr 8, 2021

Hi!
Regarding the ADC mask for ProstateX-0142:
Finding3 (ProstateX-0142-Finding3-ep2d_diff_tra_DYNDIST_ADC0_ROI.nii) geometry does not correspond to Finding1, Finding2 or the DICOM file:

  • Finding1 and 2 geometry : (84, 128, 19)
  • Finding3 geometry: (384, 384, 21)

Also, the ADC masks array is "flipped" corresponding to the DICOM array for every patients -->
Mask: (84, 128, 19), DICOM: (128, 84, 19)
I'm applying transpose to the ADC mask array, so both array geometry corresponds to each other.

@rcuocolo
Copy link
Owner

rcuocolo commented Apr 9, 2021

Thank you for letting me know. I will look into it as soon as possible.

@rcuocolo
Copy link
Owner

Sorry for the wait. The mask of finding3 for the ADC map in patient 0142 should now be fixed. I can confirm the issue of the "flipped" arrays for ADC as well, if you have already scripted a fix, can I ask you to perform a pull request and upload the corrected files (including the new mask for patient 0142). This would be of great help in speeding up the fix.

@enliden1
Copy link
Author

Thank you for the confirmation. I'll upload my project in a couple of months, and could perform a pull request then. For now i've only adjusted the bounding box, not the mask.

@rcuocolo
Copy link
Owner

The issues with ADC maps are probably due to the process used to annotate lesions. DICOM files were first converted to the NII format using dcm2niix, segmented on ITKSNAP, then flipped back to the DICOM geometry using nibabel and numpy (flipping along the Y axis if I remember correctly).
At visual inspection on ITKSNAP these ROIs appear to be correctly positioned, but at closer inspection the issue with array orientation is present.
As a stopgap solution, I will upload the NII masks (not flipped) as they are surely correctly matched with the PROSTATEx files if converted to NII format using dcm2niix. If you could provide correctly reoriented masks with a future pull request, it would be greatly appreciated as currently I am pretty swamped and don't have much time to work on this issue actively.

@rcuocolo rcuocolo added bug Something isn't working help wanted Extra attention is needed labels Apr 29, 2021
@rcuocolo rcuocolo pinned this issue Apr 29, 2021
@rcuocolo
Copy link
Owner

I have updated the repository and readme with the masks for the NIFTI files. These provide a valid workaround for this issue (after converting the original DICOMs to NIFTI files using dcm2niix), and could be useful to fix the issue in and of itself.

@wassname
Copy link
Contributor

wassname commented Jun 3, 2021

I believe that you can reverse what dcm2niix did with

  • mask.transpose((1, 0, 2))[::-1, :, ::-1]
    • swapping x and y
    • reversing order on x (was y) and z

Here's an image of proof of concept with the image that enliden1 mentioned:

image

code

P.S. for people attempting to use dcm2nii, the exact command I used was:

dcm2niix -z y -v y -a y -o nii -f %i_%s ./dicom/train/downloads/PROSTATEx/, this gives unique names and matches the PROSTATEx_masks for nii files.

@rcuocolo
Copy link
Owner

rcuocolo commented Jun 3, 2021

Thank you for the contribution. I was flipping only one axis. I will test and implement this ASAP and upload the fixed files. I was waiting for the time to fix this issue prior to submitting the dataset to TCIA.

@rcuocolo
Copy link
Owner

rcuocolo commented Jun 4, 2021

Unfortunately the issue is more complex. The proposed solution causes the mask not to correspond to the lesion anymore. Currently, the only way to ensure lesions are correctly segmented is to convert the DICOM files to NIFTI using dcm2niix (there are the options used by me: dcm2niix -d 9 -z y -9). The issue also affects T2 files (lesion annotations are not correctly placed on DICOM files).
On the bright side, I was able to understand from where the issue arose. In ITKSNAP the DICOM volume is flipped and matches the masks included in the repository. This behavior is not consistent with 3DSlicer, which shows the ROI as misplaced (in all cases, the original annotation, my original transposition to DICOM space, and the fix suggested by @wassname). I am unsure of what ITKSNAP does differently when displaying DICOM images, but this is the reason the issue was undetected previously (I usually employ ITKSNAP rather than 3DSlicer for quick visual check due to ease of loading files). I think it will be better to remove DICOM masks altogether for now and only leave NIFTI masks (which work consistently).
I do not want to rehost the PROSTATEx dataset in NIFTI format here, so each user will have to convert the images to this format independently.
If there are any further suggestions on how to solve the issue, they are very welcome.

@rcuocolo
Copy link
Owner

rcuocolo commented Jun 4, 2021

For @wassname, your image overlay seems indeed correct, but I was unable to save it and not have the issue present in 3DSlicer (probably due to using the affine from the unflipped mask to save). Could you test your approach with lesion 1 from the first patient and upload the files? It is the case I am using for troubleshooting right now.

@rcuocolo rcuocolo mentioned this issue Jun 4, 2021
@wassname
Copy link
Contributor

wassname commented Jun 9, 2021

Sure I will have a look today

@wassname
Copy link
Contributor

wassname commented Jun 9, 2021

Here we are, this gist has links to my files, and example code to load them.

I also tried using your dcm2niix command dcm2niix -d 9 -z y -9 and it still works the same.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants