cedalion package

Subpackages

Submodules

cedalion.datasets module

Cedalin datasets and utility functions.

cedalion.datasets.get_colin27_headmodel()
cedalion.datasets.get_colin27_segmentation(downsampled=False)
cedalion.datasets.get_fingertapping()
cedalion.datasets.get_fingertapping_snirf_path()
cedalion.datasets.get_imagereco_example_fluence()
cedalion.datasets.get_multisubject_fingertapping_path()
Return type:

Path

cedalion.datasets.get_multisubject_fingertapping_snirf_paths()
cedalion.datasets.get_photogrammetry_example_scan()
cedalion.datasets.get_snirf_test_data()

cedalion.nirs module

cedalion.nirs.beer_lambert(amplitudes, geo3d, dpf, spectrum='prahl')

Calculate concentration changes from amplitude using the modified BL law.

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 mBLL.

Return type:

conc (xr.DataArray, (channel, wavelength, *))

cedalion.nirs.channel_distances(amplitudes, geo3d)

Calculate distances between channels.

Parameters:
  • amplitudes (xr.DataArray) – 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.get_extinction_coefficients(spectrum, wavelengths)

Provide a matrix of extinction coefficients from tabulated data.

Parameters:
  • spectrum (str) –

    The type of spectrum to use. Currently supported options are: - “prahl”: Extinction coefficients based on the Prahl absorption spectrum

    (Prahl1998).

  • wavelengths (Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]) – 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, …) at which the coefficients for each chromophore are given in units of “mm^-1 / M”.

Return type:

xr.DataArray

References

(Prahl 1998) - taken from Homer2/3, Copyright 2004 - 2006 - The General Hospital

Corporation and President and Fellows of Harvard University. “These values for the molar extinction coefficient e in [cm-1/(moles/liter)] were compiled by Scott Prahl (prahl@ece.ogi.edu) using data from W. B. Gratzer, Med. Res. Council Labs, Holly Hill, London N. Kollias, Wellman Laboratories, Harvard Medical School, Boston 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 (e) [(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.int2od(amplitudes)

Calculate optical density from intensity amplitude data.

Parameters:

amplitudes (xr.DataArray, (time, channel, *)) – amplitude data.

Returns:

(xr.DataArray, (time, channel,*): The optical density data.

Return type:

od

cedalion.nirs.od2conc(od, geo3d, dpf, spectrum='prahl')

Calculate concentration changes from optical density data.

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 with dimensions “channel” and “wavelength”.

Return type:

conc (xr.DataArray, (channel, wavelength, *))

cedalion.plots module

cedalion.plots.plot3d(brain_mesh, scalp_mesh, geo3d, timeseries, poly_lines=[], brain_scalars=None)
cedalion.plots.plot_labeled_points(plotter, points, color=None)
cedalion.plots.plot_montage3D(amp, geo3d)
cedalion.plots.plot_surface(plotter, surface, color=None, opacity=1.0, **kwargs)
cedalion.plots.plot_vector_field(plotter, points, vectors)

cedalion.typing module

cedalion.validators module

cedalion.validators.check_dimensionality(name, q, dim)
cedalion.validators.has_channel(array)
cedalion.validators.has_positions(array, npos=None)
cedalion.validators.has_time(array)
cedalion.validators.has_wavelengths(array)
cedalion.validators.is_quantified(array)

cedalion.vtktutils module

cedalion.vtktutils.pyvista_polydata_to_trimesh(polydata)
Return type:

Trimesh

cedalion.vtktutils.trimesh_to_vtk_polydata(mesh)

cedalion.xrutils module

Utility functions for xarray objects.

cedalion.xrutils.apply_mask(data_array, mask, operator, dim_collapse)

Apply a boolean mask to a DataArray according to the defined “operator”.

INPUTS: data_array: NDTimeSeries, input time series data xarray :rtype: DataArray

mask: input boolean mask array with a subset of dimensions matching data_array operator: operators to apply to the mask and data_array

“nan”: inserts NaNs in the data_array where mask is False “drop”: drops value in the data_array where mask is False

dim_collapse: mask dimension to collapse to, merging boolean masks along all other

dimensions. can be skipped with “none”. Example: collapsing to “channel” dimension will drop or nan a channel if it is “False” along any other dimensions

OUTPUTS: masked_data_array: input data_array with applied mask masked_elements: list of elements in data_array that were masked (e.g. dropped or set to NaN)

cedalion.xrutils.convolve(data_array, kernel, dim)

Convolve a DataArray along a given dimension “dim” with a “kernel”.

Return type:

DataArray

cedalion.xrutils.mask(array, initval)

Create a boolean mask array with the same shape as the input array.

Return type:

DataArray

cedalion.xrutils.norm(array, dim)

Calculate the vector norm along a given dimension.

Return type:

DataArray

cedalion.xrutils.pinv(array)

Calculate the pseudoinverse of a 2D xr.DataArray.

Return type:

DataArray

FIXME: handles unitless and quantified DataArrays but not

DataArrays with units in their attrs.

Module contents