fepegar / torchio

Medical imaging toolkit for deep learning
http://www.torchio.org
Apache License 2.0
2.04k stars 238 forks source link

Generalize io module #82

Closed fepegar closed 4 years ago

fepegar commented 4 years ago

Code to write NRRD files is missing: https://github.com/fepegar/torchio/blob/128895a88cdb1165f8b8533e11835a6b1db12b8c/torchio/data/io.py#L83-L88

bcdarwin commented 4 years ago

Wouldn't it be easier to use Nibabel (and/or SITK) to do file writes and avoid writing Nifti-specific header information, which would also give support for DICOM, MINC, etc.? Any conversion issues could be pushed upstream to Nibabel.

bcdarwin commented 4 years ago

(To answer my own question: Nibabel doesn't yet support NRRD)

fepegar commented 4 years ago

NiBabel doesn't support NRRD. But you're right, It would be simpler to use SITK in general.

bcdarwin commented 4 years ago

At least, write_nifti could be generalized to write_nibabel.

fepegar commented 4 years ago

Exactly. DICOM support will be trickier, especially for writing. But maybe SITK can try to handle it.

fepegar commented 4 years ago

We're crossing messages, sorry. Maybe a good approach is trying to write the image with nibabel and falling back to SITK if it fails.

bcdarwin commented 4 years ago

Sounds reasonable, especially with an option to override.

fepegar commented 4 years ago

an option to override.

I'm not sure what you mean with this.

bcdarwin commented 4 years ago

an option to override.

I'm not sure what you mean with this.

You might prefer SITK even if Nibabel can technically read your file, e.g. due to some bug/edge case in format support, or you might care about IO performance and find SITK is faster, etc.

fepegar commented 4 years ago

@bcdarwin, can you take a look at #92 and let me know what you think?

bcdarwin commented 4 years ago

Sure, I'll look into this in a bit.