Cometa#

SENSOR_LABELS#

A tuple of labels used for the different Cometa sensors.

class epilepsy_tools.cometa.RecordingInfo(fs, samples, channels, start_time, end_time)#

Stores metadata of the recording (raw signals). Construct with RecordingInfo.from_file or RecordingInfo.from_data.

Parameters:
fs#

Original sampling frequency in Hz (before downsampling).

Type:

float

samples#

Total number of data points.

Type:

int

channels#

List of channel labels.

Type:

list[str]

start_time#

Start date and time of recording.

Type:

datetime.datetime

end_time#

End date and time of recording.

Type:

datetime.datetime

duration#

Duration of recording.

Type:

datetime.timedelta

classmethod from_data(data)#

Get the recording info of data already loaded. This is equivalent to instanciating the class directly.

Parameters:

data (pandas.DataFrame) – The Cometa data loaded from load_data().

Returns:

The information of the recording.

Return type:

RecordingInfo

classmethod from_file(file)#

Get the recording info of a given .c3d file.

Parameters:

file (str | os.PathLike) – Path of the .c3d file.

Returns:

The information of the recording.

Return type:

RecordingInfo

epilepsy_tools.cometa.downsample(data, *, ratio)#

Downsample the data to every ratio values. ratio=2 means keep half of the data, 3 keep only the third.

Parameters:
  • data (pandas.DataFrame) – The Cometa data loaded from cometa.load_data.

  • ratio (int) – The ratio of the data to keep. 2 means keep half of the data (1/2), 3 means keep only one value every three (1/3).

Returns:

The downsampled DataFrame

Return type:

pandas.DataFrame

epilepsy_tools.cometa.extract_acceleration_data(data)#

Take the DataFrame returned by load_data and keep only the columns containing the acceleration data.

Parameters:

data (pandas.DataFrame) – The Cometa data loaded from load_data().

Returns:

A DataFrame with only the acceleration data.

Return type:

pandas.DataFrame

epilepsy_tools.cometa.extract_emg_data(data)#

Take the DataFrame returned by load_data and keep only the columns containing the EMG data.

Parameters:

data (pandas.DataFrame) – The Cometa data loaded from load_data().

Returns:

A DataFrame with only the EMG data.

Return type:

pandas.DataFrame

epilepsy_tools.cometa.load_data(file)#

Read a .c3d file from the Cometa device. Depending on how many sensors were installed and which modality was recorded, the shape of the DataFrame might be different.

Parameters:

file (str | os.PathLike) – Path of the .c3d file.

Returns:

The data inside the .c3d file.

Return type:

pandas.DataFrame

Raises:

ValueError – The file provided is not a .c3d file.

epilepsy_tools.cometa.plot_acceleration(data, *, norm=True)#

Plot the acceleration from a Cometa DataFrame. If norm=True (the default), calculate the norm of the acceleration vectors for each sensors (the X, Y and Z components) and plot that.

Parameters:
  • data (pandas.DataFrame) – The Cometa data loaded from load_data().

  • norm (bool, optional) – If we should compute the norm of the acceleration vectors from components, by default True.

Returns:

fig – The Figure with the data plotted.

Return type:

matplotlib.figure.Figure

epilepsy_tools.cometa.plot_emg(data)#

Plot the EMG data from a Cometa DataFrame.

Parameters:

data (pandas.DataFrame) – The Cometa data loaded from load_data().

Returns:

fig – The Figure with the data plotted.

Return type:

matplotlib.figure.Figure

Examples#

See examples in Cometa Examples.