LION.utils.normaliser

Classes

Normalisation([normalisation_type, dataset, ...])

How images are scaled to [0, 1], for models that need their inputs normalised and say how (LIONmodel.set_normalisation).


class LION.utils.normaliser.Normalisation(normalisation_type='none', dataset=None, data_range=None)[source]

Bases: object

How images are scaled to [0, 1], for models that need their inputs normalised and say how (LIONmodel.set_normalisation). Normalisation in CT isn’t trivial; normalisation_type is one of:

  • “none”: nothing;

  • “sample”: each image by its own range;

  • “dataset”: by the range of the dataset’s ground truths (read once from dataset, or given as data_range when known, e.g. from a model file);

  • “custom”: by data_range, (min, max).

record() and from_record save and make it again.

record()[source]

What makes this normalisation again (from_record): its type, and its range for “dataset” and “custom”.

static from_record(record)[source]

The normalisation record() describes (without its dataset); a dict or a LIONParameter.

normalise(x)[source]

The images x (B, C, H, W) scaled to [0, 1] by the normalisation’s range (“sample”: each image’s, kept for unnormalise).

normalise_measurements(y, op=None)[source]

The measurements of the normalised images, by linearity: if images are mapped to (x - min) / s, measurements y = A x are mapped to (y - A(min)) / s, A(min) being the measurements of an image of value min everywhere (computed with op; none needed when min is 0). For models that take measurements; the operator is unchanged. Not defined for “sample” (an image’s range isn’t known before reconstructing).

unnormalise(x, reference=None)[source]

Undo normalise. reference: the input that was normalised (a “sample” normalisation maps x back to its range; without it, to the range of the last normalise call).