meanap.pipeline.io

I/O helpers for MEA-NAP pipeline files.

Handles HDF5/v7.3 .mat files produced by the Axion MEA system and by the MATLAB MEA-NAP pipeline. scipy.io.loadmat cannot read v7.3 files, so we use h5py throughout.

Functions

load_raw_recording(path)

Load a raw MEA recording .mat file (HDF5/v7.3 format).

load_spike_times_mat(path)

Read spike times from a MEA-NAP _spikes.mat (HDF5/v7.3) file.

load_spike_times_npz(path)

Load spike times saved by save_spike_times_npz.

save_spike_times_npz(path, spike_times, ...)

Save spike detection results to a .npz file.

meanap.pipeline.io.load_raw_recording(path)[source]

Load a raw MEA recording .mat file (HDF5/v7.3 format).

Returns:

  • dat ((n_samples, n_channels) float32 array — raw voltage traces)

  • channels ((n_channels,) int array — channel IDs)

  • fs (float — sampling frequency in Hz)

Parameters:

path (str | Path)

Return type:

tuple[ndarray, ndarray, float]

meanap.pipeline.io.load_spike_times_mat(path)[source]

Read spike times from a MEA-NAP _spikes.mat (HDF5/v7.3) file.

Returns:

spike_timeschannel_index is 0-based. method is e.g. 'bior1p5', 'thr4', 'thr5'.

Return type:

dict[channel_index, dict[method, times_in_seconds]]

Parameters:

path (str | Path)

meanap.pipeline.io.load_spike_times_npz(path)[source]

Load spike times saved by save_spike_times_npz.

Parameters:

path (str | Path)

Return type:

dict[int, dict[str, ndarray]]

meanap.pipeline.io.save_spike_times_npz(path, spike_times, channels, fs, params=None)[source]

Save spike detection results to a .npz file.

Saved arrays

channels — channel IDs fs — sampling frequency spike_times_{ch}_{method} — spike times in seconds for each channel/method

Also saves a text file {stem}_params.txt alongside if params given.

Parameters:
  • path (str | Path)

  • spike_times (dict[int, dict[str, ndarray]])

  • channels (ndarray)

  • fs (float)

  • params (dict[str, Any] | None)

Return type:

None