diff --git a/.gitignore b/.gitignore index 0038f7f..2b30822 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -docs/source/ephys_at_the_swc/auto_examples_ephys +docs/source/ephys_at_swc/auto_examples_ephys/ # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/docs/source/ephys_at_swc/auto_examples_ephys/auto_examples_ephys_jupyter.zip b/docs/source/ephys_at_swc/auto_examples_ephys/auto_examples_ephys_jupyter.zip deleted file mode 100644 index be5f3a9..0000000 Binary files a/docs/source/ephys_at_swc/auto_examples_ephys/auto_examples_ephys_jupyter.zip and /dev/null differ diff --git a/docs/source/ephys_at_swc/auto_examples_ephys/auto_examples_ephys_python.zip b/docs/source/ephys_at_swc/auto_examples_ephys/auto_examples_ephys_python.zip deleted file mode 100644 index 7c7cac3..0000000 Binary files a/docs/source/ephys_at_swc/auto_examples_ephys/auto_examples_ephys_python.zip and /dev/null differ diff --git a/docs/source/ephys_at_swc/auto_examples_ephys/images/thumb/sphx_glr_sara_mederos_thumb.png b/docs/source/ephys_at_swc/auto_examples_ephys/images/thumb/sphx_glr_sara_mederos_thumb.png deleted file mode 100644 index 8a5fed5..0000000 Binary files a/docs/source/ephys_at_swc/auto_examples_ephys/images/thumb/sphx_glr_sara_mederos_thumb.png and /dev/null differ diff --git a/docs/source/ephys_at_swc/auto_examples_ephys/index.rst b/docs/source/ephys_at_swc/auto_examples_ephys/index.rst deleted file mode 100644 index 2c9bf19..0000000 --- a/docs/source/ephys_at_swc/auto_examples_ephys/index.rst +++ /dev/null @@ -1,86 +0,0 @@ -:orphan: - -:orphan: -Example Pipelines -================== - -This page holds example pipelines for researchers -at the SWC. It details their setup, experimental -paradigms along with the pipelines they -use for preprocessing / analysis. Take a look -through and feel free to get in contact with -anyone through Slack. - -Below are a set of SpikeInterface scripts -for preprocessing and sorting of data -from a range of experimental setups. Also -see the list of repositories with code for -mutlimodal analysis including -electrophysiology -in -:ref:`Python ` -and -:ref:`Matlab `. - - -SpikeInterface Preprocessing and Sorting ----------------------------------------- - -TODO: Dammy, Ivana - - - -.. raw:: html - -
- -.. thumbnail-parent-div-open - -.. raw:: html - -
- -.. only:: html - - .. image:: /ephys_at_swc/auto_examples_ephys/images/thumb/sphx_glr_sara_mederos_thumb.png - :alt: - - :ref:`sphx_glr_ephys_at_swc_auto_examples_ephys_sara_mederos.py` - -.. raw:: html - -
Sara's Single Session Open Ephys
-
- - -.. thumbnail-parent-div-close - -.. raw:: html - -
- - -.. toctree:: - :hidden: - - /ephys_at_swc/auto_examples_ephys/sara_mederos - - -.. only:: html - - .. container:: sphx-glr-footer sphx-glr-footer-gallery - - .. container:: sphx-glr-download sphx-glr-download-python - - :download:`Download all examples in Python source code: auto_examples_ephys_python.zip ` - - .. container:: sphx-glr-download sphx-glr-download-jupyter - - :download:`Download all examples in Jupyter notebooks: auto_examples_ephys_jupyter.zip ` - - -.. only:: html - - .. rst-class:: sphx-glr-signature - - `Gallery generated by Sphinx-Gallery `_ diff --git a/docs/source/ephys_at_swc/auto_examples_ephys/sara_mederos.ipynb b/docs/source/ephys_at_swc/auto_examples_ephys/sara_mederos.ipynb deleted file mode 100644 index 361cfa8..0000000 --- a/docs/source/ephys_at_swc/auto_examples_ephys/sara_mederos.ipynb +++ /dev/null @@ -1,50 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n# Sara's Single Session Open Ephys\n\nSara Mederos (Hofer Lab)'s pipeline to ...\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Sara Mederos investigates ... setup ... details...\n\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "import probeinterface.plotting\nfrom spikeinterface import extract_waveforms\nfrom spikeinterface.extractors import read_openephys_event, read_openephys\nfrom spikeinterface.preprocessing import phase_shift, bandpass_filter, common_reference\nfrom spikeinterface.sorters import run_sorter\nfrom pathlib import Path\nfrom probeinterface.plotting import plot_probe, plot_probe_group\nimport matplotlib.pyplot as plt\nfrom spikeinterface import curation\nfrom spikeinterface.widgets import plot_timeseries\nimport spikeinterface as si # TODO\n\ndata_path = Path(\n r\"/ceph/.../test_data/100323/2023-10-03_18-57-09/Record Node 101/experiment1\"\n)\noutput_path = Path(\n r\"/ceph/.../test_data/derivatives/100323/\"\n)\n\nshow_probe = False\nshow_preprocessing = False\n\n# This reads OpenEphys 'Binary' format. It determines the\n# probe using probeinterface.read_openephys, which reads `settings.xml`\n# and requires the NP_PROBE field is filled.\nraw_recording = read_openephys(data_path)\n\nif show_probe:\n probe = raw_recording.get_probe()\n plot_probe(probe)\n plt.show()\n\n# Run the preprocessing steps\nshifted_recording = phase_shift(raw_recording)\nfiltered_recording = bandpass_filter(shifted_recording, freq_min=300, freq_max=6000)\npreprocessed_recording = common_reference(\n filtered_recording, reference=\"global\", operator=\"median\"\n)\n\nif show_preprocessing:\n recs_grouped_by_shank = preprocessed_recording.split_by(\"group\")\n for rec in recs_grouped_by_shank:\n plot_timeseries(\n preprocessed_recording,\n order_channel_by_depth=False,\n time_range=(3500, 3500),\n return_scaled=True,\n show_channel_ids=True,\n mode=\"map\",\n )\n plt.show()\n\n# Run the sorting\nsorting = run_sorter(\n \"kilosort3\",\n preprocessed_recording,\n singularity_image=True,\n output_folder=(output_path / \"sorting\").as_posix(),\n car=False,\n freq_min=150,\n)\n\n# Curate the sorting output and extract waveforms. Calculate\n# quality metrics from the waveforms.\nsorting = sorting.remove_empty_units()\n\nsorting = curation.remove_excess_spikes(sorting, preprocessed_recording)\n\n# The way spikeinterface is setup means that quality metrics are\n# calculated on the spikeinterface-preprocessed, NOT the kilosort\n# preprocessed (i.e. drift-correct data).\n# see https://github.com/SpikeInterface/spikeinterface/pull/1954 for details.\nwaveforms = extract_waveforms(\n preprocessed_recording,\n sorting,\n folder=(output_path / \"postprocessing\").as_posix(),\n ms_before=2,\n ms_after=2,\n max_spikes_per_unit=500,\n return_scaled=True,\n sparse=True,\n peak_sign=\"neg\",\n method=\"radius\",\n radius_um=75,\n)\n\nquality_metrics = si.qualitymetrics.compute_quality_metrics(waveforms)\nquality_metrics.to_csv(output_path / \"postprocessing\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.14" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/docs/source/ephys_at_swc/auto_examples_ephys/sara_mederos.py b/docs/source/ephys_at_swc/auto_examples_ephys/sara_mederos.py deleted file mode 100644 index be4eb8a..0000000 --- a/docs/source/ephys_at_swc/auto_examples_ephys/sara_mederos.py +++ /dev/null @@ -1,98 +0,0 @@ -""" -Sara's Single Session Open Ephys -========================= - -Sara Mederos (Hofer Lab)'s pipeline to ... -""" - -# %% -# Sara Mederos investigates ... setup ... details... - -import probeinterface.plotting -from spikeinterface import extract_waveforms -from spikeinterface.extractors import read_openephys_event, read_openephys -from spikeinterface.preprocessing import phase_shift, bandpass_filter, common_reference -from spikeinterface.sorters import run_sorter -from pathlib import Path -from probeinterface.plotting import plot_probe, plot_probe_group -import matplotlib.pyplot as plt -from spikeinterface import curation -from spikeinterface.widgets import plot_timeseries -import spikeinterface as si # TODO - -data_path = Path( - r"/ceph/.../test_data/100323/2023-10-03_18-57-09/Record Node 101/experiment1" -) -output_path = Path( - r"/ceph/.../test_data/derivatives/100323/" -) - -show_probe = False -show_preprocessing = False - -# This reads OpenEphys 'Binary' format. It determines the -# probe using probeinterface.read_openephys, which reads `settings.xml` -# and requires the NP_PROBE field is filled. -raw_recording = read_openephys(data_path) - -if show_probe: - probe = raw_recording.get_probe() - plot_probe(probe) - plt.show() - -# Run the preprocessing steps -shifted_recording = phase_shift(raw_recording) -filtered_recording = bandpass_filter(shifted_recording, freq_min=300, freq_max=6000) -preprocessed_recording = common_reference( - filtered_recording, reference="global", operator="median" -) - -if show_preprocessing: - recs_grouped_by_shank = preprocessed_recording.split_by("group") - for rec in recs_grouped_by_shank: - plot_timeseries( - preprocessed_recording, - order_channel_by_depth=False, - time_range=(3500, 3500), - return_scaled=True, - show_channel_ids=True, - mode="map", - ) - plt.show() - -# Run the sorting -sorting = run_sorter( - "kilosort3", - preprocessed_recording, - singularity_image=True, - output_folder=(output_path / "sorting").as_posix(), - car=False, - freq_min=150, -) - -# Curate the sorting output and extract waveforms. Calculate -# quality metrics from the waveforms. -sorting = sorting.remove_empty_units() - -sorting = curation.remove_excess_spikes(sorting, preprocessed_recording) - -# The way spikeinterface is setup means that quality metrics are -# calculated on the spikeinterface-preprocessed, NOT the kilosort -# preprocessed (i.e. drift-correct data). -# see https://github.com/SpikeInterface/spikeinterface/pull/1954 for details. -waveforms = extract_waveforms( - preprocessed_recording, - sorting, - folder=(output_path / "postprocessing").as_posix(), - ms_before=2, - ms_after=2, - max_spikes_per_unit=500, - return_scaled=True, - sparse=True, - peak_sign="neg", - method="radius", - radius_um=75, -) - -quality_metrics = si.qualitymetrics.compute_quality_metrics(waveforms) -quality_metrics.to_csv(output_path / "postprocessing") diff --git a/docs/source/ephys_at_swc/auto_examples_ephys/sara_mederos.rst b/docs/source/ephys_at_swc/auto_examples_ephys/sara_mederos.rst deleted file mode 100644 index dc426ee..0000000 --- a/docs/source/ephys_at_swc/auto_examples_ephys/sara_mederos.rst +++ /dev/null @@ -1,144 +0,0 @@ - -.. DO NOT EDIT. -.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. -.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: -.. "ephys_at_swc/auto_examples_ephys/sara_mederos.py" -.. LINE NUMBERS ARE GIVEN BELOW. - -.. only:: html - - .. note:: - :class: sphx-glr-download-link-note - - :ref:`Go to the end ` - to download the full example code. - -.. rst-class:: sphx-glr-example-title - -.. _sphx_glr_ephys_at_swc_auto_examples_ephys_sara_mederos.py: - - -Sara's Single Session Open Ephys -========================= - -Sara Mederos (Hofer Lab)'s pipeline to ... - -.. GENERATED FROM PYTHON SOURCE LINES 9-10 - -Sara Mederos investigates ... setup ... details... - -.. GENERATED FROM PYTHON SOURCE LINES 10-99 - -.. code-block:: Python - - - import probeinterface.plotting - from spikeinterface import extract_waveforms - from spikeinterface.extractors import read_openephys_event, read_openephys - from spikeinterface.preprocessing import phase_shift, bandpass_filter, common_reference - from spikeinterface.sorters import run_sorter - from pathlib import Path - from probeinterface.plotting import plot_probe, plot_probe_group - import matplotlib.pyplot as plt - from spikeinterface import curation - from spikeinterface.widgets import plot_timeseries - import spikeinterface as si # TODO - - data_path = Path( - r"/ceph/.../test_data/100323/2023-10-03_18-57-09/Record Node 101/experiment1" - ) - output_path = Path( - r"/ceph/.../test_data/derivatives/100323/" - ) - - show_probe = False - show_preprocessing = False - - # This reads OpenEphys 'Binary' format. It determines the - # probe using probeinterface.read_openephys, which reads `settings.xml` - # and requires the NP_PROBE field is filled. - raw_recording = read_openephys(data_path) - - if show_probe: - probe = raw_recording.get_probe() - plot_probe(probe) - plt.show() - - # Run the preprocessing steps - shifted_recording = phase_shift(raw_recording) - filtered_recording = bandpass_filter(shifted_recording, freq_min=300, freq_max=6000) - preprocessed_recording = common_reference( - filtered_recording, reference="global", operator="median" - ) - - if show_preprocessing: - recs_grouped_by_shank = preprocessed_recording.split_by("group") - for rec in recs_grouped_by_shank: - plot_timeseries( - preprocessed_recording, - order_channel_by_depth=False, - time_range=(3500, 3500), - return_scaled=True, - show_channel_ids=True, - mode="map", - ) - plt.show() - - # Run the sorting - sorting = run_sorter( - "kilosort3", - preprocessed_recording, - singularity_image=True, - output_folder=(output_path / "sorting").as_posix(), - car=False, - freq_min=150, - ) - - # Curate the sorting output and extract waveforms. Calculate - # quality metrics from the waveforms. - sorting = sorting.remove_empty_units() - - sorting = curation.remove_excess_spikes(sorting, preprocessed_recording) - - # The way spikeinterface is setup means that quality metrics are - # calculated on the spikeinterface-preprocessed, NOT the kilosort - # preprocessed (i.e. drift-correct data). - # see https://github.com/SpikeInterface/spikeinterface/pull/1954 for details. - waveforms = extract_waveforms( - preprocessed_recording, - sorting, - folder=(output_path / "postprocessing").as_posix(), - ms_before=2, - ms_after=2, - max_spikes_per_unit=500, - return_scaled=True, - sparse=True, - peak_sign="neg", - method="radius", - radius_um=75, - ) - - quality_metrics = si.qualitymetrics.compute_quality_metrics(waveforms) - quality_metrics.to_csv(output_path / "postprocessing") - - -.. _sphx_glr_download_ephys_at_swc_auto_examples_ephys_sara_mederos.py: - -.. only:: html - - .. container:: sphx-glr-footer sphx-glr-footer-example - - .. container:: sphx-glr-download sphx-glr-download-jupyter - - :download:`Download Jupyter notebook: sara_mederos.ipynb ` - - .. container:: sphx-glr-download sphx-glr-download-python - - :download:`Download Python source code: sara_mederos.py ` - - -.. only:: html - - .. rst-class:: sphx-glr-signature - - `Gallery generated by Sphinx-Gallery `_ diff --git a/docs/source/ephys_at_swc/auto_examples_ephys/sara_mederos_codeobj.pickle b/docs/source/ephys_at_swc/auto_examples_ephys/sara_mederos_codeobj.pickle deleted file mode 100644 index faf2b51..0000000 Binary files a/docs/source/ephys_at_swc/auto_examples_ephys/sara_mederos_codeobj.pickle and /dev/null differ diff --git a/docs/source/ephys_at_swc/auto_examples_ephys/sg_execution_times.rst b/docs/source/ephys_at_swc/auto_examples_ephys/sg_execution_times.rst deleted file mode 100644 index 46e8395..0000000 --- a/docs/source/ephys_at_swc/auto_examples_ephys/sg_execution_times.rst +++ /dev/null @@ -1,37 +0,0 @@ - -:orphan: - -.. _sphx_glr_ephys_at_swc_auto_examples_ephys_sg_execution_times: - - -Computation times -================= -**00:00.000** total execution time for 1 file **from ephys_at_swc/auto_examples_ephys**: - -.. container:: - - .. raw:: html - - - - - - - - .. list-table:: - :header-rows: 1 - :class: table table-striped sg-datatable - - * - Example - - Time - - Mem (MB) - * - :ref:`sphx_glr_ephys_at_swc_auto_examples_ephys_sara_mederos.py` (``sara_mederos.py``) - - 00:00.000 - - 0.0 diff --git a/docs/source/ephys_at_swc/community.md b/docs/source/ephys_at_swc/community.md index e080822..d1eff6a 100644 --- a/docs/source/ephys_at_swc/community.md +++ b/docs/source/ephys_at_swc/community.md @@ -3,13 +3,12 @@ This site is maintained by the [NeuroInformatics Unit](https://neuroinformatics.dev/). Please don't hesitate to contact us -(in particular Joe Ziminski) on Slack with any questions or feedback -on electrophysiology analysis at the SWC. +(in particular Joe Ziminski) on Slack with any questions or feedback. -For information and advice on extracellular electrophysiology from the SWC community, the +For information and advice on electrophysiology from the SWC community, the best place to go is the `#forum-extracellular-ephys` channel on the SWC Slack. -Outside the SWC, you can address any questions or issues about +Outside the SWC, you can address any questions or issues for [SpikeInterface](https://github.com/SpikeInterface) by raising an issue on their [GitHub repository](https://github.com/SpikeInterface/spikeinterface/issues). @@ -18,5 +17,5 @@ happy to answer any questions! In addition, the [Neuropixels](https://neuropixelsgroup.slack.com/) -Slack is a great resource, with an active community discussing both +Slack is a great resource, with an active community discussing extracellular electrophysiology acquisition and analysis. diff --git a/docs/source/ephys_at_swc/index.md b/docs/source/ephys_at_swc/index.md index abea9a7..e3ee5c5 100644 --- a/docs/source/ephys_at_swc/index.md +++ b/docs/source/ephys_at_swc/index.md @@ -1,14 +1,14 @@ # Electrophysiology -This page acts as an information hub for researchers using +This page acts as an information source for researchers using extracellular electrophysiology in the SWC. It contains -[resources](resources.md) -for preprocessing and analysis, as well as -[example scripts](gallery/index) -in use by researchers in the building. +[Resources](resources.md) providing background on +the technique, as well as +[Example Pipelines](auto_examples_ephys/index) +used researchers in the building. -We encourage all types of contributions. If you've like to contribute a guide or pipeline, -please don't hesitate to get in contact! See the +We encourage all types of contributions. If you've like to contribute a +guide or pipeline, please don't hesitate to get in contact! See the [Community](community.md) page for more details.