馃殌 Feature
A loading functionality for .raw image files.
Motivation
I often work directly with .raw files and loading .raw files would be a nice extention of the current dataloading functions using SimpleITK, NiBabel and so on. Many CT-devices for example work primarily with raw files.
Pitch
One possible implementation would be a function read_raw inside src/torchio/data/io.py, where the raw file is opened and read via np.fromfile(). Since raw binary files contain no metadata, the loader would require the image shape, data type and affine (or spacing/orientation information) to be provided explicitly:
- shape: dimensions of the image, for example [456, 400, 512]
- dtype: What data type the image should be loaded in, e.g. np.float32
- affine: Affine matrix
- returns: [tensor, affine]
Alternatives
I am not aware of existing support for loading raw binary data with any imaging framework like MONAI, SimpleITK or NiBabel.
Additional context
I have something similar implemented, this would need some adaptions to integrate to torchio. How the function could look like:
def read_raw(path, shape, dtype, affine):
# read raw file from filepath
img = np.fromfile(path, dtype=dtype)
# reshape 1D array from raw file to given image dimensions
img = np.reshape(img, (shape[2], shape[1], shape[0]))
img = np.transpose(img, (2, 1, 0))
return torch.from_numpy(img), affine
Also: This is my first GitHub issue, I am open for feedback :)
馃殌 Feature
A loading functionality for
.rawimage files.Motivation
I often work directly with
.rawfiles and loading.rawfiles would be a nice extention of the current dataloading functions using SimpleITK, NiBabel and so on. Many CT-devices for example work primarily with raw files.Pitch
One possible implementation would be a function
read_rawinside src/torchio/data/io.py, where the raw file is opened and read vianp.fromfile(). Since raw binary files contain no metadata, the loader would require the image shape, data type and affine (or spacing/orientation information) to be provided explicitly:Alternatives
I am not aware of existing support for loading raw binary data with any imaging framework like MONAI, SimpleITK or NiBabel.
Additional context
I have something similar implemented, this would need some adaptions to integrate to torchio. How the function could look like:
Also: This is my first GitHub issue, I am open for feedback :)