Metadata
This page acts as the technical reference for the metadata subpackage.
The metadata subpackage provides classes for managing information related to the files, which are managed by the FrameData and PairedFrameData classes. The BaseMetadata class provides a guideline for implementing a Metadata class, while the others provide concrete ready-to-use classes to manage image metadata and video metadata.
BaseMetadata
Bases: ABC
Base class for enforcing the format of metadata classes. Each metadata class must implement their own init method and have a common interface for checking metadata matches via is_match.
Source code in clair_torch/metadata/base.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
is_match(other, attributes, *, missing_key_fails=True)
Function for checking if two instances of metadata classes are a match or not based on the given mapping of attributes to tolerances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
BaseMetadata
|
an instance of a concrete implementation of a metadata class. |
required |
attributes
|
dict[str, None | int | float]
|
dictionary mapping attribute names to their tolerances. A None value means an exact match is required. |
required |
missing_key_fails
|
bool
|
whether a missing attribute results in a failed check or not. |
True
|
Returns:
Type | Description |
---|---|
bool
|
True if a match, False if not. |
Source code in clair_torch/metadata/base.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
ImagingMetadata
Bases: BaseMetadata
Class for managing the metadata of an optical microscope image, containing metadata fields for exposure time, magnification, illumination type and subject name. The metadata is parsed based on the file name, which is assumed to have the following parts, in arbitrary order, for successful parsing. White space is reserved for separating parts. 1. Exposure time in milliseconds with a point for decimal separator, ending in ms with no white space. e.g. '10.5ms'. 2. Magnification as float with a point for decimal separator, ending in 'x' or 'X' with no white space. e.g. '50.0x'. 3. Illumination type is reserved as 'BF' or 'bf' for bright field and 'DF' or 'df' for dark field. 4. Subject name will be parsed as the first part that doesn't fit into any of the aforementioned categories.
Source code in clair_torch/metadata/imaging_metadata.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
__init__(val_input_path)
Initialization of a ImagingMetadata instance. Metadata parsing based on the file name. Args: val_input_path: the path to the file for which to parse metadata.
Source code in clair_torch/metadata/imaging_metadata.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
VideoMetadata
Bases: ImagingMetadata
Class for managing the metadata of a video file, based off of the ImagingMetadata class. Additional feature to that is the numeric metadata field 'number_of_frames', which is parsed using a function that calls OpenCV to get the number of frames.
Source code in clair_torch/metadata/imaging_metadata.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|