cedalion.nirs.common
Shared NIRS utilities: extinction coefficients and channel-distance helpers.
Functions
|
Calculate distances between channels. |
|
Provide a matrix of extinction coefficients from tabulated data. |
|
Split a time series into two based on channel distances. |
- cedalion.nirs.common.get_extinction_coefficients(spectrum: str, wavelengths: ArrayLike)[source]
Provide a matrix of extinction coefficients from tabulated data.
- Parameters:
spectrum –
The type of spectrum to use. Currently supported options are:
"prahl": Molar extinction coefficients compiled by S. A. Prahl (Prahl [Pra98]) from data by W. B. Gratzer (Med. Res. Council Labs, London) and N. Kollias (Harvard Medical School). Tabulated values originally distributed with Homer2/3. Units in the source file are cm⁻¹/(mol/L); cedalion converts to mm⁻¹/M on load.
wavelengths – An array-like object containing the wavelengths at which to calculate the extinction coefficients.
- Returns:
- A matrix of extinction coefficients with dimensions
"chromo" (chromophore, e.g. HbO/HbR) and
"wavelength"(e.g. 750, 850, …) in units of mm⁻¹/M.
- A matrix of extinction coefficients with dimensions
- Return type:
xr.DataArray
Note
To convert this data to absorbance A, multiply by the molar concentration and the pathlength. For example, if x is the number of grams per liter and a 1 cm cuvette is being used, then the absorbance is given by
[(1/cm)/(moles/liter)] (x) [g/liter] (1) [cm]
- A = —————————————————
66,500 [g/mole]
using 66,500 as the gram molecular weight of hemoglobin. To convert this data to absorption coefficient in (cm⁻1), multiply by the molar concentration and 2.303, µa = (2.303) e (x g/liter)/(66,500 g Hb/mole) where x is the number of grams per liter. A typical value of x for whole blood is x=150 g Hb/liter.
- cedalion.nirs.common.channel_distances(amplitudes: cdt.NDTimeSeries, geo3d: cdt.LabeledPoints)[source]
Calculate distances between channels.
- Parameters:
amplitudes – A DataArray representing the amplitudes with dimensions (channel, *).
geo3d (xr.DataArray) – A DataArray containing the 3D coordinates of the channels with dimensions (channel, pos).
- Returns:
- A DataArray containing the calculated distances between
source and detector channels. The resulting DataArray has the dimension ‘channel’.
- Return type:
dists (xr.DataArray)
- cedalion.nirs.common.split_long_short_channels(
- ts: cdt.NDTimeSeries,
- geo3d: cdt.LabeledPoints,
- distance_threshold: cdt.QLength = <Quantity(1.5,
- 'centimeter')>,
Split a time series into two based on channel distances.
- Parameters:
ts (cdt.NDTimeSeries) – Time series to split.
geo3d (cdt.LabeledPoints) – 3D coordinates of the optodes.
distance_threshold (Quantity) – Distance threshold for splitting the channels.
- Returns:
time series with channel distances >= distance_threshold ts_short : time series with channel distances < distance_threshold
- Return type:
ts_long