Skip to content

Questions on nifti data loading with GPU #1385

Answered by effigies
yiheng-wang-nv asked this question in Q&A
Discussion options

You must be logged in to vote
  1. No.
  2. I don't know if 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:
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

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@yiheng-wang-nv
Comment options

@effigies
Comment options

Answer selected by yiheng-wang-nv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants