Exporters module¶
The spikeinterface.exporters
module includes functions to export SpikeInterface objects to other commonly
used frameworks.
Exporting to Phy¶
The export_to_phy()
function allows you to use the
Phy template GUI for visual inspection and manual curation of spike sorting
results.
Note : export_to_phy()
speed and the size of the folder will highly depend
on the sparsity of the WaveformExtractor
itself or the external specified sparsity.
The Phy viewer enables one to explore PCA projections, spike amplitudes, waveforms and quality of the results.
So if these pieces of information have already been computed as extensions as already (see WaveformExtractor extensions),
then exporting to Phy should be fast (and the user has better control on the parameters for the extensions).
If not pre-computed, then the required extensions (e.g., spike_amplitudes
, principal_components
)
can be computed direcly at export time.
The input of the export_to_phy()
is a WaveformExtractor
object.
from spikeinterface.postprocessing import compute_spike_amplitudes, compute_principal_components
from spikeinterface.exporters import export_to_phy
# the waveforms is sparse so it is faster to export to phy
folder = 'waveforms'
we = extract_waveforms(recording, sorting, folder, sparse=True)
# some computations are done before to control all options
compute_spike_amplitudes(we)
compute_principal_components(we, n_components=3, mode='by_channel_global')
# the export process is fast because everything is pre-computed
export_to_phy(we, output_folder='path/to/phy_folder')
Export a spike sorting report¶
The export_report()
provides an overview of the spike sorting output.
The report is a simple folder that contains figures (in png, svg or pdf format) and tables (csv) that can be easily
explored without any GUI.
It is designed to be a common and shareable report to assess spike sorting quality with students,
collaborators, and journals.
The report includes summary figures of the spike sorting output (e.g. amplitude distributions, unit localization and depth VS amplitude) as well as unit-specific reports, that include waveforms, templates, template maps, ISI distributions, and more.
Note : similarly to export_to_phy()
the
export_report()
depends on the sparsity of the WaveformExtractor
itself and
on which extensions have been computed. For example, spike_amplitudes
and correlograms
related plots
will be automatically included in the report if the associated extensions are computed in advance.
The function can perform these computations as well, but it is a better practice to compute everything that’s needed
beforehand.
Note that every unit will generate a summary unit figure, so the export process can be slow for spike sorting outputs with many units!
from spikeinterface.postprocessing import compute_spike_amplitudes, compute_correlograms
from spikeinterface.qualitymetrics import compute_quality_metrics
from spikeinterface.exporters import export_report
# the waveforms is sparse for better interpretable figures
we = extract_waveforms(recording, sorting, folder='path/to/wf', sparse=True)
# some computations are done before to control all options
compute_spike_amplitudes(we)
compute_correlograms(we)
compute_quality_metrics(we, metric_names=['snr', 'isi_violation', 'presence_ratio'])
# the export process
export_report(we, output_folder='path/to/spikeinterface-report-folder')