cedalion.dataclasses.accessors

Accessors for Cedalion data types.

Classes

CedalionAccessor(xarray_obj)

Accessor for time series data stored in xarray DataArrays.

PointsAccessor(xarray_obj)

StimAccessor(pandas_obj)

Accessor for stimulus DataFrames.

class cedalion.dataclasses.accessors.CedalionAccessor(xarray_obj)[source]

Bases: object

Accessor for time series data stored in xarray DataArrays.

property sampling_rate[source]

Return the sampling rate of the time series.

The sampling rate is calculated as the reciprocal of the mean time difference

between consecutive samples.

to_epochs(
df_stim: pd.DataFrame,
trial_types: list[str],
before: cdt.QTime,
after: cdt.QTime,
)[source]

Extract epochs from the time series based on stimulus events.

Parameters:
  • df_stim – DataFrame containing stimulus events.

  • trial_types – List of trial types to include in the epochs.

  • before – Time before stimulus event to include in epoch.

  • after – Time after stimulus event to include in epoch.

Returns:

Array containing the extracted epochs.

Return type:

xarray.DataArray

freq_filter(fmin, fmax, butter_order=4)[source]

Applys a Butterworth filter.

Parameters:
  • fmin (float) – The lower cutoff frequency.

  • fmax (float) – The upper cutoff frequency.

  • butter_order (int) – The order of the Butterworth filter.

Returns:

The filtered time series.

Return type:

result (xarray.DataArray)

class cedalion.dataclasses.accessors.PointsAccessor(xarray_obj)[source]

Bases: object

to_homogeneous()[source]
rename(translations: Dict[str, str])[source]
common_labels(
other: DataArray,
) List[str][source]

Return labels contained in both LabledPointClouds.

apply_transform(transform: cdt.AffineTransform | np.ndarray)[source]
property crs[source]
set_crs(value: str)[source]
add(
label: str | List[str],
coordinates: ArrayLike,
type: PointType | List[PointType],
group: str | List[str] = None,
) cdt.LabeledPointCloud[source]
remove(label)[source]
class cedalion.dataclasses.accessors.StimAccessor(pandas_obj)[source]

Bases: object

Accessor for stimulus DataFrames.

rename_events(rename_dict)[source]

Renames trial types in the DataFrame based on the provided dictionary.

Parameters:

rename_dict (dict) – A dictionary with the old trial type as key and the new trial type as value.

conditions()[source]
to_xarray(time: DataArray)[source]