rcuocolo / PROSTATEx_masks

Lesion and prostate masks for the PROSTATEx training dataset, after a lesion-by-lesion quality check.
https://rcuocolo.github.io/PROSTATEx_masks/
Creative Commons Attribution 4.0 International
76 stars 17 forks source link

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

Open enliden1 opened 3 years ago

enliden1 commented 3 years ago

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:

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 commented 3 years ago

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

rcuocolo commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

I believe that you can reverse what dcm2niix did with

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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.

wassname commented 3 years ago

Sure I will have a look today

wassname commented 3 years ago

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.