Skip to content

Commit

Permalink
Merge pull request #338 from catalystneuro/spike2
Browse files Browse the repository at this point in the history
change ced to spike2
  • Loading branch information
bendichter authored Feb 26, 2023
2 parents dc517e2 + 9aaa91f commit dea9a25
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 17 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
* Moved NeuroConv catalogue from ReadMe.md to ReadTheDocs.
[PR #322](https://github.com/catalystneuro/neuroconv/pull/322)
* Moved instructions to build the documentation from README.md to ReadTheDocs. [PR #323](https://github.com/catalystneuro/neuroconv/pull/323)
* Add `Spike2RecordingInterface` to conversion gallery. [PR #338](https://github.com/catalystneuro/neuroconv/pull/338)

### Pending deprecation
* Change name from `CedRecordingInterface` to `Spike2RecordingInterface`. [PR #338](https://github.com/catalystneuro/neuroconv/pull/338)


# v0.2.4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ NeuroConv is a Python package for converting neurophysiology data in a variety o

Features:

* Reads data from 36 popular neurophysiology data formats and writes to NWB using best practices.
* Reads data from 38 popular neurophysiology data formats and writes to NWB using best practices.
* Extracts relevant metadata from each format.
* Handles large data volume by reading datasets piece-wise.
* Minimizes the size of the NWB files by automatically applying chunking and lossless compression.
Expand Down
8 changes: 4 additions & 4 deletions docs/api/interfaces.ecephys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ Blackrock Recording
-------------------
.. automodule:: neuroconv.datainterfaces.ecephys.blackrock.blackrockdatainterface

Cambridge Electronic Design (CED) Recording
-------------------------------------------
.. automodule:: neuroconv.datainterfaces.ecephys.ced.ceddatainterface

CellExplorer Sorting
--------------------
.. automodule:: neuroconv.datainterfaces.ecephys.cellexplorer.cellexplorerdatainterface
Expand Down Expand Up @@ -53,6 +49,10 @@ Phy Sorting
-----------
.. automodule:: neuroconv.datainterfaces.ecephys.phy.phydatainterface

Spike2
------
.. automodule:: neuroconv.datainterfaces.ecephys.spike2.spike2datainterface

Spikegadgets Recording
----------------------
.. automodule:: neuroconv.datainterfaces.ecephys.spikegadgets.spikegadgetsdatainterface
Expand Down
16 changes: 9 additions & 7 deletions docs/conversion_examples_gallery/conversion_example_gallery.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Conversion Gallery
==================

The examples here are guaranteed to be running correctly with our testing suite.
Their aim is to be a showcase of the library capabilities and to get you to hit the ground running with your own conversion.
The examples here are guaranteed to be running correctly with our testing suite. Their aim is to be a showcase of the
library capabilities and to get you to hit the ground running with your own conversion.

Extracellular electrophysiology
-------------------------------
Expand All @@ -19,16 +19,17 @@ Recording
Axona <recording/axona>
Biocam <recording/biocam>
Blackrock <recording/blackrock>
European Data Format (EDF) <recording/edf>
Intan <recording/intan>
MEArec <recording/mearec>
MCSRaw <recording/mcsraw>
MEArec <recording/mearec>
Neuralynx <recording/neuralynx>
NeuroScope <recording/neuroscope>
OpenEphys <recording/openephys>
Plexon <recording/plexon>
Spike2 <recording/spike2>
Spikegadgets <recording/spikegadgets>
SpikeGLX <recording/spikeglx>
European Data Format (EDF) <recording/edf>
Tucker-Davis Technologies (TDT) <recording/tdt>

Sorting
Expand Down Expand Up @@ -73,21 +74,22 @@ Segmentation
.. toctree::
:maxdepth: 1

Suite2P <segmentation/suite2p>
Caiman <segmentation/caiman>
EXTRACT <segmentation/extract>
CNMFE <segmentation/cnmfe>
EXTRACT <segmentation/extract>
Suite2P <segmentation/suite2p>

Behavior
--------

.. toctree::
:maxdepth: 1

Audio <behavior/audio>
DeepLabCut <behavior/deeplabcut>
SLEAP <behavior/sleap>
Videos <behavior/video>
Audio <behavior/audio>


Text
----
Expand Down
33 changes: 33 additions & 0 deletions docs/conversion_examples_gallery/recording/spike2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Spike2 data conversion
----------------------

Install NeuroConv with the additional dependencies necessary for reading Spike2 data by CED.

.. code-block:: bash
pip install neuroconv[spike2]
Convert Spike2 data to NWB using
:py:class:`~neuroconv.datainterfaces.ecephys.spike2.spike2datainterface.Spike2RecordingInterface`.

.. code-block:: python
from datetime import datetime
from dateutil import tz
from pathlib import Path
from neuroconv.datainterfaces import Spike2RecordingInterface
# For this interface we need to pass the specific path to the files.
file_path = f"{ECEPHY_DATA_PATH}/spike2/m365_1sec.smrx"
# Change the file_path to the location in your system
interface = Spike2RecordingInterface(file_path=file_path, verbose=False)
# Extract what metadata we can from the source files
metadata = interface.get_metadata()
# For data provenance we add the time zone information to the conversion
session_start_time = datetime(2020, 1, 1, 12, 30, 0, tzinfo=tz.gettz("US/Pacific"))
metadata["NWBFile"].update(session_start_time=session_start_time)
# Choose a path for saving the nwb file and run the conversion
nwbfile_path = f"{path_to_save_nwbfile}"
interface.run_conversion(nwbfile_path=nwbfile_path, metadata=metadata)
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ of proprietary formats to the Neurodata Without Borders (NWB) standard.

Features:

* Reads data from 37 popular neurophysiology data formats and writes to NWB using best practices.
* Reads data from 38 popular neurophysiology data formats and writes to NWB using best practices.
* Extracts relevant metadata from each format.
* Handles large data volume by reading datasets piece-wise.
* Minimizes the size of the NWB files by automatically applying chunking and lossless compression.
Expand Down
4 changes: 3 additions & 1 deletion src/neuroconv/datainterfaces/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from .ecephys.spikeglx.spikeglxnidqinterface import SpikeGLXNIDQInterface
from .ecephys.spikegadgets.spikegadgetsdatainterface import SpikeGadgetsRecordingInterface
from .ecephys.intan.intandatainterface import IntanRecordingInterface
from .ecephys.ced.ceddatainterface import CEDRecordingInterface
from .ecephys.spike2.spike2datainterface import Spike2RecordingInterface
from .ecephys.spike2.spike2datainterface import CEDRecordingInterface
from .ecephys.cellexplorer.cellexplorerdatainterface import CellExplorerSortingInterface
from .ecephys.blackrock.blackrockdatainterface import (
BlackrockRecordingInterface,
Expand Down Expand Up @@ -66,6 +67,7 @@
NeuroScopeRecordingInterface,
NeuroScopeSortingInterface,
NeuroScopeLFPInterface,
Spike2RecordingInterface,
SpikeGLXRecordingInterface,
SpikeGLXLFPInterface,
SpikeGLXNIDQInterface,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Authors: Heberto Mayorquin, Luiz Tauffer."""
from pathlib import Path
from warnings import warn

from ..baserecordingextractorinterface import BaseRecordingExtractorInterface
from ....tools import get_package
Expand All @@ -14,8 +15,9 @@ def _test_sonpy_installation() -> None:
)


class CEDRecordingInterface(BaseRecordingExtractorInterface):
"""Primary data interface class for converting data from CED (Cambridge Electronic
class Spike2RecordingInterface(BaseRecordingExtractorInterface):
"""
Data interface class for converting Spike2 data from CED (Cambridge Electronic
Design) using the :py:class:`~spikeinterface.extractors.CedRecordingExtractor`."""

ExtractorName = "CedRecordingExtractor"
Expand All @@ -35,7 +37,8 @@ def get_all_channels_info(cls, file_path: FilePathType):

def __init__(self, file_path: FilePathType, verbose: bool = True, es_key: str = "ElectricalSeries"):
"""
Initialize reading of CED file.
Initialize reading of Spike2 file. CEDRecordingInterface will soon be deprecated. Please use
Spike2RecordingInterface instead.
Parameters
----------
Expand All @@ -53,3 +56,22 @@ def __init__(self, file_path: FilePathType, verbose: bool = True, es_key: str =
signal_channels = self.recording_extractor.neo_reader.header["signal_channels"]
channel_ids_of_raw_data = [channel_info[1] for channel_info in signal_channels if channel_info[4] == "mV"]
self.recording_extractor = self.recording_extractor.channel_slice(channel_ids=channel_ids_of_raw_data)


class CEDRecordingInterface(Spike2RecordingInterface):
def __init__(self, file_path: FilePathType, verbose: bool = True, es_key: str = "ElectricalSeries"):
"""
Initialize reading of CED file.
Parameters
----------
file_path : FilePathType
Path to .smr or .smrx file.
verbose : bool, default: True
es_key : str, default: "ElectricalSeries"
"""
warn(
message="CEDRecordingInterface will soon be deprecated. Please use Spike2RecordingInterface instead.",
category=DeprecationWarning,
)
super().__init__(file_path=file_path, verbose=verbose, es_key=es_key)

0 comments on commit dea9a25

Please sign in to comment.