Quality control of raw Neuropixel electrophysiology data.

ibllib.ephys.ephysqc.amplitude_cutoff(amplitudes, num_histogram_bins=500, histogram_smoothing_value=3)

Calculate approximate fraction of spikes missing from a distribution of amplitudes

Assumes the amplitude histogram is symmetric (not valid in the presence of drift)

Inspired by metric described in Hill et al. (2011) J Neurosci 31: 8699-8705

amplitudes : numpy.ndarray
Array of amplitudes (don’t need to be in physical units)
fraction_missing : float
Fraction of missing spikes (0-0.5) If more than 50% of spikes are missing, an accurate estimate isn’t possible
ibllib.ephys.ephysqc.extract_rmsmap(fbin, out_folder=None, force=False)

Wrapper for rmsmap that outputs _ibl_ephysRmsMap and _ibl_ephysSpectra ALF files

  • fbin – binary file in spike glx format (will look for attached metatdata)
  • out_folder – folder in which to store output ALF files. Default uses the folder in which the fbin file lives.
  • force – do not re-extract if all ALF files already exist
  • label – string or list of strings that will be appended to the filename before extension


ibllib.ephys.ephysqc.isi_violations(spike_train, min_time, max_time, isi_threshold, min_isi=0)

Calculate ISI violations for a spike train.

Based on metric described in Hill et al. (2011) J Neurosci 31: 8699-8705

modified by Dan Denman from cortex-lab/sortingQuality GitHub by Nick Steinmetz

spike_train : array of spike times min_time : minimum time for potential spikes max_time : maximum time for potential spikes isi_threshold : threshold for isi violation min_isi : threshold for duplicate spikes

fpRate : rate of contaminating spikes as a fraction of overall rate
A perfect unit has a fpRate = 0 A unit with some contamination has a fpRate < 0.5 A unit with lots of contamination has a fpRate > 1.0

num_violations : total number of violations

ibllib.ephys.ephysqc.qc_fpga_task(fpga_trials, alf_trials)

:fpga_task is the dictionary output of ibllib.io.extractors.ephys_fpga.extract_behaviour_sync : bpod_trials is the dictionary output of ibllib.io.extractors.ephys_trials.extract_all : alf_trials is the ALF _ibl_trials object after extraction (alf.io.load_object) :return: qc_session, qc_trials, True means QC passes while False indicates a failure


Computes RMS map in time domain and spectra for each channel of Neuropixel probe

Parameters:fbin (str or pathlib.Path) – binary file in spike glx format (will look for attached metatdata)
Returns:a dictionary with amplitudes in channeltime space, channelfrequency space, time and frequency scales
ibllib.ephys.ephysqc.spike_sorting_metrics(spike_times, spike_clusters, spike_amplitudes, params={'drift_metrics_interval_s': 51, 'drift_metrics_min_spikes_per_interval': 10, 'isi_threshold': 0.0015, 'max_spikes_for_nn': 10000, 'max_spikes_for_unit': 500, 'min_isi': 0.000166, 'n_neighbors': 4, 'n_silhouette': 10000, 'num_channels_to_compare': 13, 'presence_bin_length_secs': 20, 'quality_metrics_output_file': 'metrics.csv'}, epochs=None)

Spike sorting QC metrics

ibllib.ephys.ephysqc.validate_ttl_test(ses_path, display=False)

For a mock session on the Ephys Choice world task, check the sync channels for all device properly connected and perform a synchronization if dual probes to check that all channels are recorded properly :param ses_path: session path :param display: show the probe synchronization plot if several probes :return: True if tests pass, errors otherwise