cuvis_ai.data.metadata.Metadata

class cuvis_ai.data.metadata.Metadata(name: str, shape: tuple[int, int, int], wavelengths_nm: list[float], bit_depth: int, references: dict[str, str], integration_time_us: float, framerate: float, flags: dict[str, str], processing_mode: str)[source]

Bases: YAMLWizard

The meta-data dictionary is a collection of meta-data for a data cube or dataset.

This information can be extracted from cubes stored in the cu3s file format automatically.

For all other data, a metadata.yaml file can be placed in the root data path to provide this meta data. The yaml file can either contain any of the attributes of this class directly or contain one or multiple ‘fileset’ entries. Each ‘fileset’ must contain a ‘paths’ entry, specifying a list of filepaths that this set of attributes is valid for.

Possible entries

namestr

Name of the file that this object describes.

shapetuple

Numpy shape describing the cube size as (columns, rows, channels)

wavelengths_nmlist

A list of wavelengths the cube contains. In the same order as the channels.

bit_depthint

Bit depth of the source data the cube was computed from.

referencesDict

A dictionary containing filenames or links to the data references. e.g: white and dark cubes used to calculate reflectance data.

integration_time_usfloat

The integration time (also exposure time) in microseconds used to record the data.

frameratefloat

For video data. The number of measurements taken per second.

flagsDict

Data dependend dictionary. Any additional flags associated with measurements. e.g: Overillumination, dead pixels, missing references or data, bad references, key frames, etc.

processing_modestr

The processing mode the data was calculated with.

__init__(name: str, shape: tuple[int, int, int], wavelengths_nm: list[float], bit_depth: int, references: dict[str, str], integration_time_us: float, framerate: float, flags: dict[str, str], processing_mode: str) None

Methods

__init__(name, shape, wavelengths_nm, ...)

asdict(*[, dict_factory])

Return the fields of a dataclass instance as a new dictionary mapping field names to field values.

dataclass(*[, init, repr, eq, order, ...])

Returns the same class as was passed in, with dunder methods added based on the fields defined in the class.

dict()

from_yaml(string_or_stream, *[, decoder])

Converts a YAML string to an instance of the dataclass, or a list of the dataclass instances.

from_yaml_file(file, *[, decoder])

Reads in the YAML file contents and converts to an instance of the dataclass, or a list of the dataclass instances.

list_to_yaml(instances[, encoder])

Converts a list of dataclass instances to a YAML string representation.

to_yaml(*[, encoder])

Converts the dataclass instance to a YAML string representation.

to_yaml_file(file[, mode, encoder])

Serializes the instance and writes it to a YAML file.

Attributes

name

shape

wavelengths_nm

bit_depth

references

integration_time_us

framerate

flags

processing_mode

asdict(*, dict_factory=<class 'dict'>)

Return the fields of a dataclass instance as a new dictionary mapping field names to field values.

Example usage:

@dataclass class C:

x: int y: int

c = C(1, 2) assert asdict(c) == {‘x’: 1, ‘y’: 2}

If given, ‘dict_factory’ will be used instead of built-in dict. The function applies recursively to field values that are dataclass instances. This will also look into built-in containers: tuples, lists, and dicts.

bit_depth: int
dataclass(*, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False)

Returns the same class as was passed in, with dunder methods added based on the fields defined in the class.

Examines PEP 526 __annotations__ to determine fields.

If init is true, an __init__() method is added to the class. If repr is true, a __repr__() method is added. If order is true, rich comparison dunder methods are added. If unsafe_hash is true, a __hash__() method function is added. If frozen is true, fields may not be assigned to after instance creation. If match_args is true, the __match_args__ tuple is added. If kw_only is true, then by default all fields are keyword-only. If slots is true, an __slots__ attribute is added.

dict()[source]
flags: dict[str, str]
framerate: float
classmethod from_yaml(string_or_stream, *, decoder=None, **decoder_kwargs)

Converts a YAML string to an instance of the dataclass, or a list of the dataclass instances.

classmethod from_yaml_file(file, *, decoder=None, **decoder_kwargs)

Reads in the YAML file contents and converts to an instance of the dataclass, or a list of the dataclass instances.

integration_time_us: float
classmethod list_to_yaml(instances, encoder=None, **encoder_kwargs)

Converts a list of dataclass instances to a YAML string representation.

name: str
processing_mode: str
references: dict[str, str]
shape: tuple[int, int, int]
to_yaml(*, encoder=None, **encoder_kwargs)

Converts the dataclass instance to a YAML string representation.

to_yaml_file(file, mode='w', encoder=None, **encoder_kwargs)

Serializes the instance and writes it to a YAML file.

wavelengths_nm: list[float]