resurfemg.data_connector.adicht_reader module¶
The class AdichtReader is designed to load EMG data from an ADInstruments device using the .adicht file format (Labchart) and prepares it for use in ReSurfEMG. The foundation of the AdichtReader class is the repository ‘adinstruments_sdk_python’ by Jim Hokanson, available at: https://github.com/JimHokanson/adinstruments_sdk_python
An example of how to use this class is provided in the main block of this file. This example executes only if the script is run directly by the Python interpreter and not when imported as a module.
- class AdichtReader(file_path: str)¶
Bases:
object
Class for loading timeseries data from an ADInstruments devices using the .adicht/.adidat/.adibin file formats (LabChart, BIOPAC) and prepare it for use in ReSurfEMG. Based on the ‘adinstruments_sdk_python’ repository by Jim Hokanson, available at: https://github.com/JimHokanson/adinstruments_sdk_python
- extract_data(channel_idxs=None, record_idx=None, resample_channels=None, **kwargs)¶
Extract channel data from specified channels and record. Optionally, resample specified channels to equalize sampling rates across channels. Resampling all channels to a different, not yet used, rate is not supported. There must be at least one channel that already has the target rate and is not specified in the resampling. ———————————————————————– :param channel_idxs: List of channel indices. :type channel_idxs: list[int] :param record_idx: The record index to extract the data from. :type record_idx: int :param resample_channels: Resample specified channels to a new rate. :type resample_channels: {channel_idx: target_rate} Example: {1: 2000, 3: 2000} - Resample ch 1 and ch 3 to 2000 Hz :param kwargs: Additional arguments to specify the channel IDs or record IDs instead of indices. :return: A tuple containing: - A pandas DataFrame with the extracted and resampled data. - The sampling rate (in Hz) of the leading channel. :rtype: Tuple[pd.DataFrame, int]
- generate_metadata()¶
Extracts metadata on channels, samples, records, sampling rates, units, and time step and sets it in self.metadata and self.metadata_table.
- get_labels(channel_idxs=None, channel_ids=None)¶
Returns a list of channel names based on a list of channel indices.¶
- param channel_idxs:
List of channel indices
- type channel_idxs:
list[int]
- param channel_ids:
List of channel IDs to retrieve the labels for
- type channel_ids:
list
- return:
List of channel names.
- rtype:
list[str]
- get_units(channel_idxs=None, record_idx=None, channel_ids=None, record_id=None)¶
Returns a list of units based on a list of channel indices and a record id. ———————————————————————– :param channel_idxs: List of channel indices :type channel_idxs: list[int] :param channel_ids: List of channel IDs to retrieve the labels for :type channel_ids: list Either channel_idxs or channel_ids must be set. :param record_idx: The record index to retrieve the units for :type record_idx: int :param record_id: The record ID to retrieve the units for :type record_id: int Either record_idx or record_id must be set. :return: List of units :rtype: list[str]
- print_metadata()¶
Extracts and provides a tabular overview of the channels, samples, records, sampling rates, units, and time step.
- resample_channel(fs_target, channel_idx=None, record_idx=None, **kwargs)¶
Resample the specified channel using a linear interpolation method and adds an additional row to the resampled DataFrame. ———————————————————————– :param channel_idx: The channel index to be resampled. :type channel_idx: int :param record_idx: The record index to be resampled. :type record_idx: int Either record_idx or record_id must be set. :param fs_target: The target sampling rate in Hz. :type fs_target: int :param kwargs: Additional arguments to specify the channel ID or record ID instead of indices.
- Returns:
Record DataFrame with resampled data for the specified idx.
- Return type:
pd.DataFrame