Questions on nifti data loading with GPU #1385
-
Hi Nibabel experts, recently I did some research on how to use GPU Direct Storage (GDS) for NIFTI data loading, and I have some successful trials on Decathlon datasets.
Then, I use the following code to get the header, and the fdata:
I have some questions on the above implementation:
It would be very appreciate if you can help to answer them, thanks very much! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
img = nb.load(filename)
shape = img.shape
offset = img.dataobj.offset
data_dtype = img.dataobj.dtype
slope = img.dataobj.slope
inter = img.dataobj.inter
raw = ... # Do what's needed to get your cupy array.
if (slope, inter) != (1, 0):
data = slope * raw + inter
else:
data = raw |
Beta Was this translation helpful? Give feedback.
kvikio.CuFile
handles compression, but many NIfTI files are gzipped. You will need to account for that if it's not done automatically. The construction of the header, affine and data seem reasonable. However, if there are scale factors, you will not get the same data. Also, nibabel lazily loads data, so you can get the header and your parameters like: