-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add NumPyDataLoader for reading .npy and .npz files #19
Conversation
The `.npy` or `npz` file may contain an array of dimension between 1 to 5 (axes: time, K, J, I, component). The `NumPyDataLoader` reader was created to follow-up on Slicer forum discussions. See https://discourse.slicer.org/t/import-numpy-file-in-as-image-volume/3653/5 Notes: * User is responsible for setting the correct IJK to RAS matrix. * For the 4D and 5D cases, having the channel-last convention corresponds to the ITK/VTK memory layout and is different from the convention used in `PyTorch` for [NCHW for 4D][NCHW] tensors/arrays and [NCDHW for 5D][NCDHW]. [NCHW]: https://pytorch.org/docs/stable/generated/torch.nn.Conv2d.html#torch.nn.Conv2d [NCDHW]: https://pytorch.org/docs/stable/generated/torch.nn.Conv3d.html#torch.nn.Conv3d Based on: * https://github.com/pieper/SlicerDMRI/blob/9565f89d16cd72618cd87f1c9046542450e4937b/Modules/Scripted/NIfTIFile/NIfTIFile.py * https://github.com/Slicer/Slicer/blob/9390be6bf76e048e6fd384d8bfd607eba2857b5a/Applications/SlicerApp/Testing/Python/SlicerScriptedFileReaderWriterTest.py Co-authored-by: Andras Lasso <lasso@queensu.ca> Co-authored-by: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
Summary of changes compared to version proposed in Slicer/Slicer#6733 (Slicer/Slicer@aaba225):
|
I confirm that running the tests on Ubuntu 20.04 against Slicer/Slicer@ce1ab3d work as expected:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to current limitations (incorrect spacing by default, potentially incorrect axis order) the reader is not ready to be included in Slicer core, it makes sense to make it available in the Sandbox to let users experiment with it.
This pull request was created based on these comments:
to follow up on Slicer forum discussion1 related to import of NumPy file as image volume.
The
.npy
ornpz
file may contain an array of dimension between 1 to 5 (axes:time
,K
,J
,I
,component
).Notes:
PyTorch
for NCHW for 4D tensors/arrays and NCDHW for 5D.Based on:
Footnotes
https://discourse.slicer.org/t/import-numpy-file-in-as-image-volume/3653/5 ↩