cedalion.nirs package
Submodules
cedalion.nirs.common module
Shared NIRS utilities: extinction coefficients and channel-distance helpers.
- 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
cedalion.nirs.cw module
Functionality for continous wave NIRS.
- cedalion.nirs.cw.int2od(amplitudes: cdt.NDTimeSeries, return_baseline: bool = False)[source]
Calculate optical density from intensity amplitude data.
Computes the log-ratio of intensity relative to its temporal mean, implementing the first step of the modified Beer-Lambert law (Delpy et al. [DCvdZ+88], Villringer and Chance [VC97]).
- Parameters:
amplitudes (xr.DataArray, (time, channel, *)) – amplitude data.
return_baseline (bool, optional) – If True, also return the baseline data used for OD conversion (useful to get back to intensity). Defaults to False.
- Returns:
(xr.DataArray, (time, channel,*): The optical density data. baseline: (xr.DataArray, (channel, *)): The intensity baseline data
(average time series) used for conversion to OD.
- Return type:
od
- cedalion.nirs.cw.od2int(od: cdt.NDTimeSeries, baseline: cdt.NDTimeSeries)[source]
Recover intensity amplitude data from optical density data.
- cedalion.nirs.cw.od2conc(
- od: cdt.NDTimeSeries,
- geo3d: cdt.LabeledPoints,
- dpf: DataArray,
- spectrum: str = 'prahl',
Calculate concentration changes from optical density data.
Applies the modified Beer-Lambert law (Delpy et al. [DCvdZ+88], Villringer and Chance [VC97]) to convert optical density changes to haemoglobin concentration changes (HbO, HbR).
- Parameters:
od (xr.DataArray, (channel, wavelength, *)) – The optical density data array
geo3d (xr.DataArray) – The 3D coordinates of the optodes.
dpf (xr.DataArray, (wavelength, *)) – The differential pathlength factor data
spectrum (str, optional) – The type of spectrum to use for calculating extinction coefficients. Defaults to “prahl”.
- Returns:
A data array containing concentration changes by channel.
- Return type:
conc (xr.DataArray, (channel, *))
- cedalion.nirs.cw.conc2od(
- conc: cdt.NDTimeSeries,
- geo3d: cdt.LabeledPoints,
- dpf: DataArray,
- spectrum: str = 'prahl',
Calculate optical density data from concentration changes.
- Parameters:
conc (xr.DataArray, (channel, *)) – The concentration changes by channel.
geo3d (xr.DataArray) – The 3D coordinates of the optodes.
dpf (xr.DataArray, (wavelength, *)) – The differential pathlength factor data.
spectrum (str, optional) – The type of spectrum to use for calculating extinction coefficients. Defaults to “prahl”.
- Returns:
- A data array containing
optical density data.
- Return type:
od (xr.DataArray, (channel, wavelength, *))
- cedalion.nirs.cw.beer_lambert(
- amplitudes: cdt.NDTimeSeries,
- geo3d: cdt.LabeledPoints,
- dpf: DataArray,
- spectrum: str = 'prahl',
Calculate concentration changes from amplitude via the modified Beer-Lambert law.
Convenience wrapper combining
int2od()andod2conc(). Implements the modified Beer-Lambert law (Delpy et al. [DCvdZ+88], Villringer and Chance [VC97]).- Parameters:
amplitudes (xr.DataArray, (channel, wavelength, *)) – The input data array containing the raw intensities.
geo3d (xr.DataArray) – The 3D coordinates of the optodes.
dpf (xr.DataArray, (wavelength,*)) – The differential pathlength factors
spectrum (str, optional) – The type of spectrum to use for calculating extinction coefficients. Defaults to “prahl”.
- Returns:
- A data array containing
concentration changes according to the modified Beer-Lambert law.
- Return type:
conc (xr.DataArray, (channel, *))
cedalion.nirs.fd module
Functionality for frequency-domain NIRS.
cedalion.nirs.td module
Functionality for time-domain NIRS.
Module contents
Functionality to process NIRS data.