biopsykit.io.biopac module

Module for importing data recorded by the Biopac system.

class biopsykit.io.biopac.BiopacDataset(data_dict, sampling_rate_dict, start_time=None, event_markers=None, tz=None)[source]

Bases: object

Get new Dataset instance.

Note

Usually you shouldn’t use this init directly. Use the provided from_acq_file constructor to handle loading recorded Biopac Sessions.

Parameters
  • data_dict (dict) – Dictionary containing data of the channels as pandas.DataFrame. The keys of the dictionary are the channel names.

  • sampling_rate_dict (dict) – Dictionary containing the sampling rate of the channels. The keys of the dictionary are the channel names.

  • start_time (pandas.Timestamp, optional) – Start time of the recording, if present, or None if no start time is available.

  • event_markers (list of bioread.reader.EventMarker, optional) – List of event markers set during the recording if present or None if no event markers are available.

  • tz (str, optional) – Timezone of the recording, if present or None if no timezone is available.

classmethod from_acq_file(path, channel_mapping=None, tz='Europe/Berlin')[source]

Create a new Dataset from a valid .acq file.

Parameters
  • path (pathlib.Path or str) – Path to the file

  • channel_mapping (dict, optional) – Dictionary containing the mapping of the channel names in the .acq to the channel names used in the Dataset.

  • tz (str, optional) – Timezone str of the recording. This can be used to localize the start and end time. Note, this should not be the timezone of your current PC, but the timezone relevant for the specific recording.

property start_time_unix: Optional[pandas._libs.tslibs.timestamps.Timestamp]

Start time of the recording in UTC time.

property timezone: str

Timezone the dataset was recorded in.

property event_markers

Event markers set in the AcqKnowledge software during the recording.

data_as_df(datastreams=None, index=None, start_time=None)[source]

Return all data as one combined pandas.DataFrame.

Parameters
  • datastreams (str, optional) – name(s) of datastream to return in dataframe. If None, all datastreams are returned.

  • index (str, optional) – Specify which index should be used for the dataset. The options are: * “time”: For the time in seconds since the first sample * “utc”: For the utc time stamp of each sample * “utc_datetime”: for a pandas DateTime index in UTC time * “local_datetime”: for a pandas DateTime index in the timezone set for the session * None: For a simple index (0…N)

  • start_time (str, datetime.datetime, pandas.Timestamp, optional) – Start time of the recording. Can be used to provide a custom start time if no start time can be inferred from the recording or to overwrite the start time extracted from the recording.

Return type

pandas.core.frame.DataFrame