ibllib.ephys.spikes

Functions

detection

Detects and de-duplicates negative voltage spikes based on voltage thresholding.

ks2_to_alf

Convert Kilosort 2 output to ALF dataset for single probe data

ks2_to_tar

Compress output from kilosort 2 into tar file in order to register to flatiron and move to spikesorters/ks2_matlab/probexx path.

probes_description

Aggregate probes information into ALF files Register alyx probe insertions and Micro-manipulator trajectories Input: raw_ephys_data/probeXX/ Output: alf/probes.description.npy

sync_spike_sorting

Synchronizes the spike.times using the previously computed sync files

probes_description(ses_path, one)[source]

Aggregate probes information into ALF files Register alyx probe insertions and Micro-manipulator trajectories Input:

raw_ephys_data/probeXX/

Output:

alf/probes.description.npy

sync_spike_sorting(ap_file, out_path)[source]

Synchronizes the spike.times using the previously computed sync files

Parameters:
  • ap_file – raw binary data file for the probe insertion

  • out_path – probe output path (usually {session_path}/alf/{probe_label})

ks2_to_alf(ks_path, bin_path, out_path, bin_file=None, ampfactor=1, label=None, force=True)[source]

Convert Kilosort 2 output to ALF dataset for single probe data

Parameters:
  • ks_path

  • bin_path – path of raw data

  • out_path

Returns:

ks2_to_tar(ks_path, out_path, force=False)[source]

Compress output from kilosort 2 into tar file in order to register to flatiron and move to spikesorters/ks2_matlab/probexx path. Output file to register

Parameters:
  • ks_path – path to kilosort output

  • out_path – path to keep the

:return path to tar ks output

To extract files from the tar file can use this code .. rubric:: Example

save_path = Path(‘folder you want to extract to’) with tarfile.open(‘_kilosort_output.tar’, ‘r’) as tar_dir:

tar_dir.extractall(path=save_path)

detection(data, fs, h, detect_threshold=-4, time_tol=0.002, distance_threshold_um=70)[source]

Detects and de-duplicates negative voltage spikes based on voltage thresholding. The de-duplication step locks in maximum amplitude events. To account for collisions the amplitude is assumed to be decaying from the peak. If this is a multipeak event, each is labeled as a spike.

Parameters:
  • data – 2D numpy array nsamples x nchannels

  • fs – sampling frequency (Hz)

  • h – dictionary with neuropixel geometry header: see. neuropixel.trace_header

  • detect_threshold – negative value below which the voltage is considered to be a spike

  • time_tol – time in seconds for which samples before and after are assumed to be part of the spike

  • distance_threshold_um – distance for which exceeding threshold values are assumed to part of the same spike

Returns:

spikes dictionary of vectors with keys “time”, “trace”, “amp” and “ispike”