Nii-Data

Since delira aims to provide dataloading tools for medical data (which is often stored in Nii-Files), the following classes and functions provide a basic way to load data from nii-files:

load_nii

load_nii(path)[source]

Loads a single nii file :param path: path to nii file which should be loaded :type path: str

Returns

numpy array containing the loaded data

Return type

np.ndarray

BaseLabelGenerator

class BaseLabelGenerator(fpath)[source]

Bases: object

Base Class to load labels from json files

_load()[source]

Private Helper function to load the file

Returns

loaded values from file

Return type

Any

abstract get_labels()[source]

Abstractmethod to get labels from class

Raises

NotImplementedError – if not overwritten in subclass

load_sample_nii

load_sample_nii(files, label_load_cls)[source]

Load sample from multiple ITK files

Parameters
  • files (dict with keys img and label) – filenames of nifti files and label file

  • label_load_cls (class) – function to be used for label parsing

Returns

sample: dict with keys data and label containing images and label

Return type

dict

Raises

AssertionError – if img.max() is greater than 511 or smaller than 1