cedalion.models.glm.design_matrix
Functions to create the design matrix for the GLM.
Functions
|
Create a regressor by averaging all short channels. |
|
Build an array indicating active stimulus periods. |
|
Create channel-wise regressors using the closest nearby short channel. |
|
Create drift regressors. |
|
Create regressors modelling the hemodynamic response to stimuli. |
|
Create channel-wise regressors using the most correlated short channels. |
Classes
|
- class cedalion.models.glm.design_matrix.DesignMatrix(
- common: 'xr.DataArray | None' = None,
- channel_wise: 'list[xr.DataArray]' = <factory>,
Bases:
object
- iter_computational_groups(
- ts: cdt.NDTimeSeries,
- channel_groups: list[int] | None = None,
Combine universal and channel-wise regressors and yield a DM for each group.
- Parameters:
ts – The time series to be modeled.
channel_groups – Optional list of channel groups.
- Yields:
A tuple containing – - dim3 (str): The third dimension name. - group_y (cdt.NDTimeSeries): The grouped time series. - group_design_matrix (xr.DataArray): The grouped design matrix.
- cedalion.models.glm.design_matrix.hrf_regressors(
- ts: cdt.NDTimeSeries,
- stim: DataFrame,
- basis_function: TemporalBasisFunction,
Create regressors modelling the hemodynamic response to stimuli.
- Parameters:
ts (NDTimeSeries) – Time series data.
stim (pd.DataFrame) – Stimulus DataFrame.
basis_function (TemporalBasisFunction) – TemporalBasisFunction object defining the HRF.
- Returns:
A DataArray containing the regressors.
- Return type:
regressors (xr.DataArray)
- cedalion.models.glm.design_matrix.drift_regressors(
- ts: cdt.NDTimeSeries,
- drift_order,
Create drift regressors.
- Parameters:
ts (cdt.NDTimeSeries) – Time series data.
drift_order (int) – The highest polynomial order of the drift terms.
- Returns:
A DataArray containing the drift regressors.
- Return type:
xr.DataArray
- cedalion.models.glm.design_matrix.build_stim_array(
- time: ArrayLike,
- onsets: ArrayLike,
- durations: None | ArrayLike,
- values: ArrayLike,
Build an array indicating active stimulus periods.
The resuting array values are set from values between onset and onset+duration and zero everywhere else.
- Parameters:
time – the time axis
onsets – times of stimulus onsets
durations – either durations of each stimulus or None, in which case the stimulus duration is set to one sample.
values – Stimulus values.
- Returns:
The array denoting
- cedalion.models.glm.design_matrix.closest_short_channel_regressor(
- ts_long: cdt.NDTimeSeries,
- ts_short: cdt.NDTimeSeries,
- geo3d: cdt.LabeledPointCloud,
Create channel-wise regressors using the closest nearby short channel.
- Parameters:
ts_long (NDTimeSeries) – Time series of long channels
ts_short (NDTimeSeries) – Time series of short channels
geo3d (LabeledPointCloud) – Probe geometry
- Returns:
Channel-wise regressor
- Return type:
regressors (xr.DataArray)
- cedalion.models.glm.design_matrix.max_corr_short_channel_regressor(ts_long: cdt.NDTimeSeries, ts_short: cdt.NDTimeSeries)[source]
Create channel-wise regressors using the most correlated short channels.
For each long channel the short channel is selected that has the highest correleation coefficient in any wavelength or chromophore.
- Parameters:
ts_long (NDTimeSeries) – time series of long channels
ts_short (NDTimeSeries) – time series of short channels
- Returns:
channel-wise regressors
- Return type:
xr.DataArray