edfio.BdfSignal#
- class edfio.BdfSignal(data, sampling_frequency, *, label='', transducer_type='', physical_dimension='', physical_range=None, digital_range=(-8388608, 8388607), prefiltering='')[source]#
A single BDF signal.
See
EdfSignalfor details on the parameters and attributes.Note
BDF uses 24-bit integers (compared to 16-bit for EDF) for the digital values. The default for
digital_range(and the supported depth) thus differs.Attributes
Numpy array containing the physical signal values as floats.
Numpy array containing the digital (uncalibrated) signal values as integers.
Digital maximum, e.g.,
2047.Digital minimum, e.g.,
-2048.The digital range as a tuple of
(digital_min, digital_max).Signal label, e.g.,
"EEG Fpz-Cz"or"Body temp".Physical dimension, e.g.,
"uV"or"degreeC.Physical maximum, e.g.,
500or40.Physical minimum, e.g.,
-500or34.The physical range as a tuple of
(physical_min, physical_max).Signal prefiltering, e.g.,
"HP:0.1Hz LP:75Hz".Reserved signal header field, always
"".Number of samples in each data record.
The sampling frequency in Hz.
Transducer type, e.g.,
"AgAgCl electrode".Methods
__init__Create an EDF signal from a hypnogram, with scaling according to EDF specs.
Get a slice of the signal data.
Get a slice of the digital signal values.
Overwrite physical signal values with an array of equal length.
- property data[source]#
Numpy array containing the physical signal values as floats.
To simplify avoiding inconsistencies between signal data and header fields, individual values in the returned array can not be modified. Use
BdfSignal.update_data()to overwrite with new physical data.
- property digital[source]#
Numpy array containing the digital (uncalibrated) signal values as integers.
The values of the array may be accessed and modified directly.
For EDF these are 16-bit integers, for BDF these are 32-bit integers.
- classmethod from_hypnogram(stages, stage_duration=30, *, label='')[source]#
Create an EDF signal from a hypnogram, with scaling according to EDF specs.
According to the EDF FAQ [1], use integer numbers 0, 1, 2, 3, 4, 5, 6, and 9 for sleep stages W, 1, 2, 3, 4, R, MT, und unscored, respectively. The digital range is set to
(0, 9).- Parameters:
- stages
npt.NDArray[np.float64] The sleep stages, coded as integer numbers.
- stage_duration
float, default:30 The duration of each sleep stage in seconds, used to set the sampling frequency to its inverse.
- label
str, default:"" The signal’s label.
- stages
- Returns:
References
[1]
- get_data_slice(start_second, stop_second)[source]#
Get a slice of the signal data.
If the signal has not been loaded into memory so far, only the requested slice will be read.
- get_digital_slice(start_second, stop_second)[source]#
Get a slice of the digital signal values.
If the signal has not been loaded into memory so far, only the requested slice will be read.
- property samples_per_data_record[source]#
Number of samples in each data record.
For newly instantiated
BdfSignalobjects, this is only set onceBdf.write()is called.
- update_data(data, *, keep_physical_range=False, sampling_frequency=None)[source]#
Overwrite physical signal values with an array of equal length.
- Parameters:
- data
npt.NDArray[np.float64] The new physical data.
- keep_physical_rangebool, default:
False If
True, thephysical_rangeis not modified to accomodate the new data.- sampling_frequency
float|None, default:None If not
None, thesampling_frequencyis updated to the new value. The new data must match the expected length for the new sampling frequency.
- data