data_loading#
- class spidet.load.data_loading.DataLoader[source]#
This class provides the utilities concerned with loading an iEEG dataset.
- static create_trace(label: str, dataset: array, sfreq: int, start_timestamp: float) Trace[source]#
Create a Trace object from a recording of a particular electrode with a corresponding label.
- Parameters:
- labelstr
The label of the trace.
- datasetarray_like
Numerical representation of the recording.
- sfreqint
Sampling frequency of the recording.
- start_timestamp: float
Start timestamp of the recording (UNIX timestamp).
- Returns:
- Trace
A Trace object representing a recording from an electrode with the corresponding label.
- static load_activation_functions(file_path: str, start_timestamp: float, sfreq: int = 50) List[ActivationFunction][source]#
Loads a precomputed H matrix from a csv file and returns a list of ActivationFunctions.
- Parameters:
- file_pathfloat
The path to the file containing the H matrix.
- start_timestampstr
Start time of the recording in the form of a UNIX timestamp. This is necessary to compute the corresponding timestamp for each individual datapoint.
- sfreqint
this is the sampling frequency of the data contained in the H matrix.
- Returns:
- List[ActivationFunction]
A list of ActivationFunction objects representing the content of the H matrix.
- read_edf_or_fif_file(file_path: str, file_format: str, channel_paths: List[str], exclude: List[str] | None = None, bipolar_reference: bool = False, leads: List[str] | None = None) List[Trace][source]#
Loads a file in either FIF or EDF format and transforms its content to a list of Trace objects. Provides the option to perform bipolar referencing for channels within a lead, if the leads are provided as argument.
- Parameters:
- file_pathstr
The path to the file.
- file_formatstr
format indicating whether the file is of type FIF or EDF
- channel_pathsList[str]
Paths to the channels to include within the file (defaults to all if none are given)
- exclude: List[str]
A list of names of the channels to exclude. Instead of defining which channels to include, this option allows to exclude certain channels.
- bipolar_reference: bool (default False)
A boolean indicating whether bipolar references between respective channels should be calculated and subsequently considered as traces
- leads: List[str] (default None)
The leads for whose channels to perform bipolar referencing. NOTE: ‘leads’ cannot be None if ‘bipolar_reference’ is True
- Returns:
- List[Trace]
A list of Trace objects representing the content of the file.
- read_file(path: str, channel_paths: List[str] | None = None, exclude: List[str] | None = None, bipolar_reference: bool = False, leads: List[str] | None = None) List[Trace][source]#
Read EEG data from a file and return a list of Trace objects, containing the EEG data of each channel.
Reads EEG data from a file specified by ‘path’. The supported file formats include ‘.h5’, ‘.fif’, and ‘.edf’.
- Parameters:
- pathstr
The file path of the EEG data file.
- channel_pathsList[str]
Paths to the channels to include within the file (for edf and fif defaults to include all channels)
- bipolar_reference: bool (default False)
A boolean indicating whether bipolar references between respective channels should be calculated and subsequently considered as traces
- leads: List[str] (default None)
The leads for whose channels to perform bipolar referencing. NOTE: ‘leads’ cannot be None if ‘bipolar_reference’ is True
- Returns:
- List[Trace]
A list of Trace objects containing EEG data.
- Raises:
- Exception
If the file format is not supported.
- read_h5_file(file_path: str, channel_paths: List[str], bipolar_reference: bool = False, leads: List[str] | None = None) List[Trace][source]#
Loads a file in HDF5 format and transforms its content to a list of Trace objects. Provides the option to perform bipolar referencing for channels within a lead, if the leads are provided as argument.
- Parameters:
- file_pathstr
The path to the HDF5 file.
- channel_pathsList[str]
Paths to the channels to include within the file
- bipolar_reference: bool (default False)
A boolean indicating whether bipolar references between respective channels should be calculated and subsequently considered as traces
- leads: List[str] (default None)
The leads for whose channels to perform bipolar referencing. NOTE: ‘leads’ cannot be None if ‘bipolar_reference’ is True
- Returns:
- List[Trace]
A list of Trace objects representing the content of the HDF5 file.
- Raises:
- Exception
If the channel paths are None.