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: AudioFile

Read 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_audio_timestamps_ms()

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

bit_depth

Return the bit depth of the audio.

duration

Return the duration of the audio in seconds.

fname

Return full path to the audio file that is being read.

n_channels

Return the number of channels in the audio.

n_samples

Return the number of samples (per channel) in the audio.

sampling_rate

Return the nominal sampling rate of the audio.

close() None[source]#

Close the audio file.

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]

get_audio_timestamps_ms() ndarray[tuple[Any, ...], dtype[float64]][source]#

Get timestamps for all audio samples in milliseconds.

Returns:

A 1D array containing timestamps for all audio samples in milliseconds.

Return type:

npt.NDArray[np.float64]

property sampling_rate: int#

Return the nominal sampling rate of the audio.

property n_channels: int#

Return the number of channels in the audio.

property bit_depth: int#

Return the bit depth of the audio.

property n_samples: int#

Return the number of samples (per channel) in the audio.

property duration: float#

Return the duration of the audio in seconds.