Project-MONAI / MONAI

AI Toolkit for Healthcare Imaging
https://monai.io/
Apache License 2.0
5.67k stars 1.04k forks source link

The names of different Savers/Writers are not consistent #1560

Closed Jingnan-Jia closed 3 years ago

Jingnan-Jia commented 3 years ago

I have the following questions:

  1. Now that we have ITKReader, why do we still need NibabelReader and PILReader?

ITKReader can read nearly all kinds of images:

Medical formats:

ITK MetaImage (.mha/.raw, .mhd) Neuroimaging Informatics Technology Initiative (NIfTI) (.nia, .nii, .nii.gz, .hdr, .img, .img.gz) Analyze (plain, SPM99, SPM2) (.hdr/.img, .img.gz) Digital Imaging and Communications in Medicine (DICOM) (.dcm, .dicom) Digital Imaging and Communications in Medicine (DICOM) series (/) Nearly Raw Raster Data (Nrrd) (.nrrd, .nhdr) Medical Imaging NetCDF (MINC) (.mnc, .MNC) Guys Image Processing Lab (GIPL) (.gipl, .gipl.gz) Microscopy formats:

Medical Research Council (MRC) (.mrc, .rec) Bio-Rad (.pic, .PIC) LSM (Zeiss) microscopy images (.tif, .TIF, .tiff, .TIFF, .lsm, .LSM) Stimulate / Signal Data (SDT) (.sdt) Visualization formats:

VTK images (.vtk) Other formats:

Portable Network Graphics (PNG) (.png, .PNG) Joint Photographic Experts Group (JPEG) (.jpg, .JPG, .jpeg, .JPEG) Tagged Image File Format (TIFF) (.tif, .TIF, .tiff, .TIFF) Windows bitmap (.bmp, .BMP) Hierarchical Data Format (HDF5) (.h5 , .hdf5 , .he5) MSX-DOS Screen-x (.ge4, .ge5)

Therefore, I think we do not need NibabelReader and PILReader. If I am wrong, please let me know.

  1. The structure of code need to be improved. We have image_reader.py which includes several different ImageReaders(ITKReader, NibabelReader, PILReader and NumpyReader). It loos good. And I expected that we should also have a corresponding image_writer.py and/or image_saver.py. However I can not find them in the same directory. I only find nifty_writer.py, nifti_saver.py, png_writer.py and png_saver.py. I think nowthat we put all kinds of ImageReader into one image_reader.py file, why not put all corresponding ImageSavers into one image_saver.py file?

  2. As described in the above paragraph, we have 4 Readers: ITKReader, NibabelReader, PILReader and NumpyReader yet. And we only have 2 ImageSavers: NiftiSaver and PNGSaver. I feel confused on it. Which Reader corresponds to which Saver? It seems that NiftiSaver used Nibabel internally. So maybe we should replace NiftiSaver with NibabelSaver? Similly, the PNGSaver calls PIL internally, so maybe the PNGSaver should be called "PILSaver"? Then where is other Savers like ITKSaver and NumpySaver? Anyway we should have a more consistent names for these Reader/Savers.

  3. As described in the above paragraph, we have NiftiSaver. And from the name of this Saver I thought it could used to save images with extension of only '.nii' or '.nii.gz'. But actually, it can also be used to save non-nifti files like ".mha", right? If yes, then we need to change the name of this Saver.

aylward commented 3 years ago

Hi,

Great point! The plan (https://github.com/Project-MONAI/MONAI/issues/856) is to have Image_Reader use ITK by default, and allow other readers to be used on demand.

The challenge is that until ITK 5.2, there were issues with supporting how some of the deep learning data was being stored (e.g., as 4D images instead of as 3D images with multiple channels) which was not well handled by ITK.

That has now been fixed in ITK, so hopefully we can re-start the refactoring of the I/O to provide a single, simple interface. I agree that right now it is hampering code portability and causing confusion.

@thewtex @hjmjohnson @Nic-Ma

Nic-Ma commented 3 years ago

Hi @Ordgod and @aylward ,

We already dropped NibabelReader and PILReader in master branch and will release in v0.5. And I think @thewtex is working on some update on ITKReader.

Thanks.

wyli commented 3 years ago

the new SaveImage transform could answer most of the questions here https://github.com/Project-MONAI/MONAI/blob/4ef7d22daf4c9443469f7fa42f74ffec7aa613a5/monai/transforms/io/array.py#L167