You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/development/development.rst
+38-17Lines changed: 38 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,7 +61,7 @@ for the :code:`spikeinterface.extractors` module, you can use the following comm
61
61
62
62
The markers are located in the :code:`pyproject.toml` file in the root of the repository.
63
63
64
-
Note that you should install the package before running the tests. You can do this by running the following command:
64
+
Note that you should install spikeinterface before running the tests. You can do this by running the following command:
65
65
66
66
.. code-block:: bash
67
67
@@ -72,7 +72,7 @@ You can change the :code:`[test,extractors,full]` to install only the dependenci
72
72
The specific environment for the CI is specified in the :code:`.github/actions/build-test-environment/action.yml` and you can
73
73
find the full tests in the :code:`.github/workflows/full_test.yml` file.
74
74
75
-
The extractor tests require datalad for some of the tests. Here are instructions for installing datalad:
75
+
Some of the extractor tests require datalad. Here are instructions for installing datalad:
76
76
77
77
Installing Datalad
78
78
------------------
@@ -87,13 +87,13 @@ Stylistic conventions
87
87
88
88
SpikeInterface maintains a consistent coding style across the project. This helps to ensure readability and
89
89
maintainability of the code, making it easier for contributors to collaborate. To facilitate code style
90
-
for the developer we use the follwing tools and conventions:
90
+
for the developer we use the following tools and conventions:
91
91
92
92
93
93
Install Black and pre-commit
94
94
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
95
95
96
-
We use the python formatter Black, with defaults set in the :code:`pyproject.toml`. This allows for
96
+
We use the Python formatter Black, with defaults set in the :code:`pyproject.toml`. This allows for
97
97
easy local formatting of code.
98
98
99
99
To install Black, you can use pip, the Python package installer. Run the following command in your terminal:
@@ -213,6 +213,25 @@ We use Sphinx to build the documentation. To build the documentation locally, yo
213
213
214
214
This will build the documentation in the :code:`doc/_build/html` folder. You can open the :code:`index.html` file in your browser to see the documentation.
To add a new tutorial, add your ``.py`` file to ``spikeinterface/examples``.
227
+
Then, update the ``spikeinterface/doc/tutorials_custom_index.rst`` file
228
+
to make a new card linking to the page and an optional image. See
229
+
``tutorials_custom_index.rst`` header for more information.
230
+
231
+
For other sections, write your documentation in ``.rst`` format and add
232
+
the page to the appropriate ``index.rst`` file found in the relevant
233
+
folder (e.g. ``how_to/index.rst``).
234
+
216
235
How to run code coverage locally
217
236
--------------------------------
218
237
To run code coverage locally, you can use the following command:
@@ -223,7 +242,7 @@ To run code coverage locally, you can use the following command:
223
242
224
243
This will run the tests and generate a report in the :code:`htmlcov` folder. You can open the :code:`index.html` file in your browser to see the report.
225
244
226
-
Note, however, that the running time of the command above will be slow. If you want to run the tests for a specific module, you can use the following command:
245
+
Note, however, that the running time of the command above will be quite long. If you want to run the tests for a specific module, you can use the following command:
227
246
228
247
.. code-block:: bash
229
248
@@ -233,21 +252,21 @@ Implement a new extractor
233
252
-------------------------
234
253
235
254
SpikeInterface already supports over 30 file formats, but the acquisition system you use might not be among the
236
-
supported formats list (***ref***). Most of the extractors rely on the `NEO <https://github.com/NeuralEnsemble/python-neo>`_
255
+
supported formats list (****ref****). Most of the extractors rely on the `NEO <https://github.com/NeuralEnsemble/python-neo>`_
237
256
package to read information from files.
238
257
Therefore, to implement a new extractor to handle the unsupported format, we recommend making a new :code:`neo.rawio.BaseRawIO` class (see `example <https://github.com/NeuralEnsemble/python-neo/blob/master/neo/rawio/examplerawio.py#L44>`_).
239
258
Once that is done, the new class can be easily wrapped into SpikeInterface as an extension of the
(for :py:class:`~spikeinterface.core.BaseSorting` objects) or with a few lines of
244
-
code (e.g., see reader for `SpikeGLX <https://github.com/SpikeInterface/spikeinterface/blob/0.96.1/spikeinterface/extractors/neoextractors/spikeglx.py>`_
245
-
or `Neuralynx <https://github.com/SpikeInterface/spikeinterface/blob/0.96.1/spikeinterface/extractors/neoextractors/neuralynx.py>`_).
263
+
code (e.g., see reader for `SpikeGLX <https://github.com/SpikeInterface/spikeinterface/blob/main/src/spikeinterface/extractors/neoextractors/spikeglx.py>`_
264
+
or `Neuralynx <https://github.com/SpikeInterface/spikeinterface/blob/main/src/spikeinterface/extractors/neoextractors/neuralynx.py>`_).
246
265
247
-
**NOTE:** implementing a `neo.rawio` Class is not required, but recommended. Several extractors (especially) for :code:`Sorting`
266
+
**NOTE:** implementing a `neo.rawio` class is not required, but recommended. Several extractors (especially) for :code:`Sorting`
248
267
objects are implemented directly in SpikeInterface and inherit from the base classes.
249
-
As examples, see the `CompressedBinaryIblExtractor<https://github.com/SpikeInterface/spikeinterface/blob/0.96.1/spikeinterface/extractors/cbin_ibl.py>`_
250
-
for a :py:class:`~spikeinterface.core.BaseRecording` object, or the `SpykingCircusSortingExtractor <https://github.com/SpikeInterface/spikeinterface/blob/0.96.1/spikeinterface/extractors/spykingcircusextractors.py>`_
268
+
As examples, see the `IblRecordingExtractor<https://github.com/SpikeInterface/spikeinterface/blob/main/src/spikeinterface/extractors/iblextractors.py>`_
269
+
for a :py:class:`~spikeinterface.core.BaseRecording` object, or the `SpykingCircusSortingExtractor <https://github.com/SpikeInterface/spikeinterface/blob/main/src/spikeinterface/extractors/spykingcircusextractors.py>`_
251
270
for a a :py:class:`~spikeinterface.core.BaseSorting` object.
252
271
253
272
@@ -290,7 +309,7 @@ Then, you can start creating a new class:
290
309
291
310
classMySpikeSorter(BaseSorter):
292
311
"""
293
-
Brief description (optional)
312
+
Brief description
294
313
"""
295
314
296
315
sorter_name ='myspikesorter'
@@ -348,7 +367,7 @@ Now you can start filling out the required methods:
348
367
def_check_apply_filter_in_params(cls, params):
349
368
returnFalse
350
369
351
-
# optional
370
+
# optional
352
371
# can be implemented in subclass to check if the filter will be applied
353
372
354
373
@@ -369,10 +388,12 @@ Now you can start filling out the required methods:
369
388
return sorting
370
389
371
390
When your spike sorter class is implemented, you have to add it to the list of available spike sorters in the
372
-
`sorterlist.py`. Then you need to write a test in **tests/test_myspikesorter.py**. In order to be tested, you can
373
-
install the required packages by changing the **pyproject.toml**. Note that MATLAB based tests cannot be run at the moment,
374
-
but we recommend testing the implementation locally.
Then you need to write a test in **tests/test_myspikesorter.py**. In order to be tested, you can
393
+
install the required packages by changing the `pyproject.toml <https://github.com/SpikeInterface/spikeinterface/blob/main/pyproject.toml>`_.
394
+
Note that MATLAB based tests cannot be run at the moment,but we recommend testing the implementation locally.
375
395
376
-
After this you need to add a block in **doc/sorters_info.rst** to describe your sorter.
396
+
After this you need to add a block in `Install Sorters <https://github.com/SpikeInterface/spikeinterface/blob/main/doc/get_started/install_sorters.rst>`_
397
+
to describe your sorter.
377
398
378
399
Finally, make a pull request so we can review the code and incorporate into the sorters module of SpikeInterface!
A full tutorial for model-based curation can be found `here <https://spikeinterface.readthedocs.io/en/latest/tutorials/curation/plot_2_train_a_model.html>`_.
5
+
6
+
Here, we assume that you have:
7
+
8
+
* Two SortingAnalyzers called ``analyzer_1`` and
9
+
``analyzer_2``, and have calculated some template and quality metrics for both
10
+
* Manually curated labels for the units in each analyzer, in lists called
11
+
``analyzer_1_labels`` and ``analyzer_2_labels``. If you have used phy, the lists can
12
+
be accessed using ``curated_labels = analyzer.sorting.get_property("quality")``.
13
+
14
+
With these objects calculated, you can train a model as follows
metric_names=None, # Set if you want to use a subset of metrics, defaults to all calculated quality and template metrics
30
+
imputation_strategies=None, # Default is all available imputation strategies
31
+
scaling_techniques=None, # Default is all available scaling techniques
32
+
classifiers=None, # Defaults to Random Forest classifier only - we usually find this gives the best results, but a range of classifiers is available
33
+
seed=None, # Set a seed for reproducibility
34
+
)
35
+
36
+
37
+
The trainer tries several models and chooses the most accurate one. This model and
38
+
some metadata are stored in the ``output_folder``, which can later be loaded using the
39
+
``load_model`` function (`more details <https://spikeinterface.readthedocs.io/en/latest/tutorials/curation/plot_1_automated_curation.html#download-a-pretrained-model>`_).
40
+
We can also access the model, which is an sklearn ``Pipeline``, from the trainer object
41
+
42
+
.. code::
43
+
44
+
best_model = trainer.best_pipeline
45
+
46
+
47
+
The training function can also be run in “csv” mode, if you prefer to
48
+
store metrics in as .csv files. If the target labels are stored as a column in
49
+
the file, you can point to these with the ``target_label`` parameter
0 commit comments