multispectral

class LinearUnmixing(global_settings, component_settings_key: str)[source]

Bases: MultispectralProcessingAlgorithm

Performs linear spectral unmixing (LU) using Fast Linear Unmixing for PhotoAcoustic Imaging (FLUPAI) on the defined data field for each chromophore specified in the component settings.

If tag LINEAR_UNMIXING_NON_NEGATIVE is set to True non-negative linear unmixing is performed, which solves the KKT (Karush-Kuhn-Tucker) conditions for the non-negative least squares problem.

This component saves a dictionary containing the chromophore concentrations and corresponding wavelengths for each chromophore. If the tag LINEAR_UNMIXING_COMPUTE_SO2 is set True the blood oxygen saturation is saved as well, however, this is only possible if the chromophores oxy- and deoxyhemoglobin are specified. IMPORTANT: Linear unmixing should only be performed with at least two wavelengths: e.g. Tags.WAVELENGTHS: [750, 800]

Parameters: Tags.DATA_FIELD (required) Tags.LINEAR_UNMIXING_SPECTRA (required) Tags.WAVELENGTHS (default: None, if None, then settings[Tags.WAVELENGTHS] will be used.) Tags.LINEAR_UNMIXING_COMPUTE_SO2 (default: False) Tags.LINEAR_UNMIXING_NON_NEGATIVE (default: False) global_settings (required) component_settings_key (required)

Instantiates a multispectral processing algorithm.

Per default, this methods loads all data from a certain Tags.DATA_FIELD into a data array for all Tags.WAVELENGTHS.

build_chromophore_spectra_dict()[source]

This function builds the absorption spectra dictionary for each chromophore using SIMPAs spectral library and saves the result in self.chromophore_spectra_dict. This function might have to change drastically if the design of the spectral library changes in the future!

calculate_sO2() ndarray[source]

Function calculates sO2 (blood oxygen saturation) values for given concentrations of oxyhemoglobin and deoxyhemoglobin. Of course this is only possible if the concentrations of both chromophores were calculated by this component/were specified in settings.

create_absorption_matrix() ndarray[source]

Method that returns the absorption (endmember) matrix needed for linear unmixing.

Returns:

absorption matrix

create_chromophore_spectra_entry(spectrum: Spectrum)[source]

This function builds the spectra for a chromophore specified by tag and name and saves it in self.chromophore_spectra_dict and creates a dictionary containing the corresponding wavelengths. The name must match the ones used in the spectral library of SIMPA.

flupai(non_negative=False) list[source]

Fast Linear Unmixing for PhotoAcoustic Imaging (FLUPAI) is based on SVD decomposition with a pseudo inverse, which is equivalent to a least squares ansatz for linear spectral unmixing of multi-spectral photoacoustic images.

Returns:

list with unmixed images containing the chromophore concentration.

Raise:

SystemExit.

run()[source]

This method must be implemented by the multispectral algorithm, such that any multispectral algorithm can be executed by invoking the run method.

class MultispectralProcessingAlgorithm(global_settings, component_settings_key: str)[source]

Bases: ABC

A MultispectralProcessingAlgorithm class represents an algorithm that works with multispectral input data.

Instantiates a multispectral processing algorithm.

Per default, this methods loads all data from a certain Tags.DATA_FIELD into a data array for all Tags.WAVELENGTHS.

abstract run()[source]

This method must be implemented by the multispectral algorithm, such that any multispectral algorithm can be executed by invoking the run method.