mne_videobrowser.AudioFileHelsinkiVideoMEG#
- class mne_videobrowser.AudioFileHelsinkiVideoMEG(fname: str, magic_str: str = 'HELSINKI_VIDEO_MEG_PROJECT_AUDIO_FILE', regression_segment_length: int = 20)[source]#
Bases:
AudioFileRead an audio file in the Helsinki VideoMEG project format.
In addition to the properties of AudioFile interface, the following attributes are available:
buffer_timestamps_ms: buffers’ timestamps (unix time in milliseconds)
format_string: format string for the audio data
buffer_size: buffer size (bytes)
- Parameters:
fname (str) – Full path to the audio file.
magic_str (str, optional) – Magic string that should be at the beginning of video file. Default is “HELSINKI_VIDEO_MEG_PROJECT_AUDIO_FILE”.
regression_segment_length (int, optional) – Length of segments (in seconds) used in piecewise linear regression to compute timestamps for all audio samples. Default is 20 seconds.
Methods
close()Close the audio file.
get_audio_all_channels([sample_range])Get audio data for all channels in the specified sample range.
get_audio_mean([sample_range])Get mean audio data across channels in the specified sample range.
Get timestamps for all audio samples in milliseconds.
get_global_max_amplitude([...])Get the maximum absolute amplitude across all channels in the audio file.
get_min_max_envelope(window_size, channel_idx)Calculate min-max envelope of the audio data using non-overlapping windows.
print_stats()Print basic statistics about the audio file.
resample_poly(target_rate, channel_idx)Resample the audio to the target sampling rate using polyphase filtering.
Attributes
Return the bit depth of the audio.
Return the duration of the audio in seconds.
fnameReturn full path to the audio file that is being read.
Return the number of channels in the audio.
Return the number of samples (per channel) in the audio.
Return the nominal sampling rate of the audio.
- get_audio_all_channels(sample_range: tuple[int, int] | None = None) ndarray[tuple[Any, ...], dtype[float32]][source]#
Get audio data for all channels in the specified sample range.
- Parameters:
sample_range (tuple[int, int] | None) – A tuple specifying the start and end (exclusive) sample indices to include in the output. If None (default), all the samples are included.
- Returns:
A 2D array of shape (n_channels, n_samples) containing the audio data.
- Return type:
npt.NDArray[np.float32]
- get_audio_mean(sample_range: tuple[int, int] | None = None) ndarray[tuple[Any, ...], dtype[float32]][source]#
Get mean audio data across channels in the specified sample range.
- Parameters:
sample_range (tuple[int, int] | None) – A tuple specifying the start and end (exclusive) sample indices to include in the output. If None (default), all the samples are included.
- Returns:
A 1D array containing the mean audio data for the specified sample range.
- Return type:
npt.NDArray[np.float32]