You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dave Flitney requested a leaner way to get access to parts of a 4D image (NIfTI in his case), i.e. the ability to get data of a single volume or timeseries. He sent the following sketch::
class FSLNiftiImage(nb.Nifti1Image):
# def __init__(self):
# super(FSLNiftiImage, self).__init__()
@memoized
def get_fileobj(self):
fileobj = allopen(self.get_filename())
return fileobj
def get_volume(self, v):
dtype = self.get_data_dtype()
s = self.get_header().get_data_shape()
shape = (s[0], s[1], s[2])
offset = self.get_header().get_data_offset() + (v * np.prod(shape))
data = array_from_file(shape, dtype, self.get_fileobj(), offset)
return data
Dave Flitney requested a leaner way to get access to parts of a 4D image (NIfTI in his case), i.e. the ability to get data of a single volume or timeseries. He sent the following sketch::
Usage:
The text was updated successfully, but these errors were encountered: