-
|
Is it possible to do lazy loading of numpy arrays by passing a path to the ScalarImage and LabelMap class? import torchio as tio
subj = tio.Subject(
CT = tio.ScalarImage(path = path_to_numpy_CT),
label = tio.LabelMap(tensor = path_to_numpy_ROI)
)I keep getting the error message "RuntimeError: "path_to_numpy_file" not understood. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi, @malteekj.
This is because NumPy is not a suitable format for medical images, as it doesn't store important spatial metadata. Therefore, it's not supported by SimpleITK and NiBabel, which TorchIO uses for I/O. I've added a kwarg in import numpy as np
import torchio as tio
def numpy_reader(path):
return np.load(path), np.eye(4)
subj = tio.Subject(
ct=tio.ScalarImage(path_to_numpy_CT, reader=numpy_reader),
label=tio.LabelMap(path_to_numpy_ROI, reader=numpy_reader)
)I will merge these changes soon, they will be available in I hope that works for you. |
Beta Was this translation helpful? Give feedback.
Hi, @malteekj.
This is because NumPy is not a suitable format for medical images, as it doesn't store important spatial metadata. Therefore, it's not supported by SimpleITK and NiBabel, which TorchIO uses for I/O.
I've added a kwarg in
Imageso you can use your own reader for lazy loading:I will merge these changes soon, they will be available in
v0.18.27.I…