ibl_alignment_gui.convertors.extract_ephys
Functions
|
Whether a SpikeGLX file was recorded with a Neuropixels 2.0 probe, read from its metadata. |
|
Compute the RMS and the summed spectral density of windows of a recording. |
|
Get the first and last sample of each window the RMS is computed on. |
|
Return the factor that converts the raw AP data of a file to Volts. |
Convert a Kilosort output and its raw data into the datasets the alignment GUI reads. |
|
Write the _ibl_ephysRmsMap and _ibl_ephysSpectra ALF files for a binary file. |
|
Convert Kilosort 2 output to an ALF dataset for single probe data. |
|
Compute the RMS map in the time domain and the spectra for each channel of the probe. |
- ibl_alignment_gui.convertors.extract_ephys.extract_data(ks_path, ephys_path, out_path)[source]
Convert a Kilosort output and its raw data into the datasets the alignment GUI reads.
Writes the ALF spike sorting datasets, and the RMS and spectral density files for each AP and LF binary file found alongside them. For NP2 recordings without an LF file, as told by their metadata, the LF RMS and spectral density are computed from the AP file.
- Parameters:
ks_path (pathlib.Path) – Path of the Kilosort output.
ephys_path (pathlib.Path) – Path of the raw ephys data.
out_path (pathlib.Path) – Path to write the datasets to. Must differ from
ks_pathso that the Kilosort output is not overwritten.
- ibl_alignment_gui.convertors.extract_ephys.extract_rmsmap(fbin, out_folder=None, spectra=True, sample_spacing_secs=10, lfp_from_ap=False, n_workers=4)[source]
Write the _ibl_ephysRmsMap and _ibl_ephysSpectra ALF files for a binary file.
- Parameters:
fbin (str or pathlib.Path) – Binary file in SpikeGLX format; the attached metadata is looked up alongside it.
out_folder (str, pathlib.Path or None) – Folder to write the ALF files to. Defaults to the folder the
fbinfile lives in.spectra (bool) – Whether to compute the power spectrum, which is only needed for LF data.
sample_spacing_secs (float or None) – The RMS and spectra are computed on a sample taken every
sample_spacing_secsseconds, which is enough for the plots and reads a fraction of the file. None reads the whole recording.lfp_from_ap (bool) – Whether to compute the LF band from an AP file, for NP2 probes that have no LF file.
n_workers (int) – The number of threads the windows are shared between.
- Raises:
ValueError – If
lfp_from_apis set for a file that is not from an NP2 probe, whose AP band holds no LFP.
- ibl_alignment_gui.convertors.extract_ephys.ks2_to_alf(ks_path, bin_path, out_path, bin_file=None, ampfactor=1, label=None, force=True)[source]
Convert Kilosort 2 output to an ALF dataset for single probe data.
- Parameters:
ks_path (pathlib.Path) – Path of the Kilosort output.
bin_path (pathlib.Path) – Path of the raw data.
out_path (pathlib.Path) – Path to write the ALF dataset to.
bin_file (pathlib.Path or None) – The specific binary file to read, when the path holds more than one.
ampfactor (float) – Factor converting the spike amplitudes to Volts.
label (str or None) – Optional label added to the dataset names.
force (bool) – Whether to overwrite an existing dataset.
- ibl_alignment_gui.convertors.extract_ephys.rmsmap(fbin, spectra=True, sample_spacing_secs=None, lfp_from_ap=False, n_workers=4)[source]
Compute the RMS map in the time domain and the spectra for each channel of the probe.
- Parameters:
fbin (str, pathlib.Path or spikeglx.Reader) – Binary file in SpikeGLX format; the attached metadata is looked up alongside it.
spectra (bool) – Whether to compute the power spectrum, which is only needed for LF data.
sample_spacing_secs (float or None) – When given, the RMS and spectra are computed on a sample taken every
sample_spacing_secsseconds, ofAP_SAMPLE_LENGTH_SECSfor the AP band andLF_SAMPLE_LENGTH_SECSfor the LF band. When None, the whole recording is read in windows of aboutRMS_WIN_LENGTH_SECS.lfp_from_ap (bool) – Whether to compute the LF band from an AP file, for NP2 probes that record wideband and have no LF file. The AP data are decimated to the LF sampling rate.
n_workers (int) – The number of threads the windows are shared between, each with its own reader. The filtering and FFTs release the GIL, so the threads run in parallel.
- Returns:
The RMS amplitudes in channel-time space, the spectral density in channel-frequency space averaged over the windows, the time and frequency scales, and the raw file index of each channel.
- Return type:
dict
Notes
The channels are returned in the order they are stored in the binary file, whatever the channel order of the reader, so that they can be indexed with the raw channel indices (
channels.rawInd) used by the GUI.The AP band is destriped before computing the RMS: high-passed at 300 Hz, corrected for the sample shift of the ADCs and re-referenced to the median of the channels of each shank. The LF band is high-passed at 1 Hz.