Can MONAI dataloader use simpleITK for loading nifti data? #6335
Unanswered
fengling0410
asked this question in
Q&A
Replies: 1 comment
-
please try MONAI/monai/data/image_reader.py Lines 182 to 188 in fa7411a for more examples please see https://github.com/Project-MONAI/tutorials/blob/main/modules/load_medical_images.ipynb |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I'm working with our in-house organ segmentation pipeline which is based on the MONAI package. But we got some alignment issue for scans and the predicted labelmap.
The first step of our pipeline is to extract nifti file from DICOM scans, and the nifti files are saved with SimpleITK, with the following code:
`
def sitk_2_nifti(dicom_dir,
output_dir=None,
filename=None,
skip_write = True):
`
After saving all the nifti files with simpleITK, these files are loaded to our model using MONAI dataloader. As I noticed, the MONAI dataloader makes use of Nibabel for loading nifti files, but simpleITK (LPS) is not consistent with Nibabel (RAS) in terms of coordinate system. Here are the visualization of numpy arrays loaded from MONAI dataloader and simpleITK reader:
It seems like the numpy array loaded from MONAI dataloader is a rotated version of that loaded from simpleITK image reader. Therefore, the predicted labelmap output (saved using simpleITK) from our model is also a rotated version of the original scan. When we visualize the scan and labelmap using 3D slicer, the alignment issue appears:
The MONAI data transformation is used is:
`
def get_transforms():
"""
Initialize transforms for inference pipeline.
`
I've also tried to add Orientationd(keys=["image"], axcodes="RAS") but that doesn't really solve the problem. It just makes the labelmap rotate in another direction and still mis-align with the scan.
May I ask for some possible reasons on why this happens and maybe also some suggestions about the next step? Thanks in advance! :)
Beta Was this translation helpful? Give feedback.
All reactions