def load(self, path, image_field="image", meta_field="metadata"): """ A method that load the data and associated metadata. Parameters ---------- path: str the path to the data to be loaded. image_field: str, default 'image' the name of the data field that contains the image array. image_field: str, default 'metadata' the name of the data field that contains the image metadata. Return ------ image: Image the loaded image. """ data = loadmat(path) _array = data[image_field] _meta = {"path": path} if meta_field in data: _meta.update(data[meta_field]) return Image(data_type="scalar", metadata=_meta, data=_array)
def load(self, path): """ A method that load the image data and associated metadata. Parameters ---------- path: str the path to the image to be loaded. Returns ------- image: Image the loaded image. """ cube = np.load(path) return Image(data_type="scalar", data=cube)
def load(self, path): """ A method that load the image data and associated metadata. Parameters ---------- path: str the path to the image to be loaded. Return ------ image: Image the loaded image. """ _image = nibabel.load(path) return Image(spacing=_image.header.get_zooms(), data_type="scalar", metadata={"path": path}, data=_image.get_data())
def load(self, path): """ A method that load the image data and associated metadata. Parameters ---------- path: str the path to the image to be loaded. Return ------ image: Image the loaded image. """ hdulist = pyfits.open(path) if len(hdulist) != 1: raise Exception("Only one HDU object supported yet. Can't " "read '{0}'.".format(path)) cube = hdulist[0].data header = dict(hdulist[0].header.items()) header["path"] = path hdulist.close() return Image(data_type="scalar", metadata=header, data=cube)