-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into support_python_3.13
- Loading branch information
Showing
132 changed files
with
5,281 additions
and
1,035 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,20 @@ | ||
name: Install packages | ||
description: This action installs the package and its dependencies for testing | ||
|
||
inputs: | ||
python-version: | ||
description: 'Python version to set up' | ||
required: false | ||
os: | ||
description: 'Operating system to set up' | ||
required: false | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Install dependencies | ||
run: | | ||
sudo apt install git | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "CI Almighty" | ||
python -m venv ${{ github.workspace }}/test_env # Environment used in the caching step | ||
python -m pip install -U pip # Official recommended way | ||
source ${{ github.workspace }}/test_env/bin/activate | ||
pip install tabulate # This produces summaries at the end | ||
pip install -e .[test,extractors,streaming_extractors,test_extractors,full] | ||
shell: bash | ||
- name: Force installation of latest dev from key-packages when running dev (not release) | ||
run: | | ||
source ${{ github.workspace }}/test_env/bin/activate | ||
spikeinterface_is_dev_version=$(python -c "import spikeinterface; print(spikeinterface.DEV_MODE)") | ||
if [ $spikeinterface_is_dev_version = "True" ]; then | ||
echo "Running spikeinterface dev version" | ||
pip install --no-cache-dir git+https://github.com/NeuralEnsemble/python-neo | ||
pip install --no-cache-dir git+https://github.com/SpikeInterface/probeinterface | ||
fi | ||
echo "Running tests for release, using pyproject.toml versions of neo and probeinterface" | ||
- name: Install git-annex | ||
shell: bash | ||
- name: git-annex install | ||
run: | | ||
pip install datalad-installer | ||
wget https://downloads.kitenet.net/git-annex/linux/current/git-annex-standalone-amd64.tar.gz | ||
mkdir /home/runner/work/installation | ||
mv git-annex-standalone-amd64.tar.gz /home/runner/work/installation/ | ||
|
@@ -44,4 +23,14 @@ runs: | |
tar xvzf git-annex-standalone-amd64.tar.gz | ||
echo "$(pwd)/git-annex.linux" >> $GITHUB_PATH | ||
cd $workdir | ||
git config --global filter.annex.process "git-annex filter-process" # recommended for efficiency | ||
- name: Force installation of latest dev from key-packages when running dev (not release) | ||
run: | | ||
spikeinterface_is_dev_version=$(python -c "import spikeinterface; print(spikeinterface.DEV_MODE)") | ||
if [ $spikeinterface_is_dev_version = "True" ]; then | ||
echo "Running spikeinterface dev version" | ||
pip install --no-cache-dir git+https://github.com/NeuralEnsemble/python-neo | ||
pip install --no-cache-dir git+https://github.com/SpikeInterface/probeinterface | ||
fi | ||
echo "Running tests for release, using pyproject.toml versions of neo and probeinterface" | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
How to use a trained model to predict the curation labels | ||
========================================================= | ||
|
||
For a more detailed guide to using trained models, `read our tutorial here | ||
<https://spikeinterface.readthedocs.io/en/latest/tutorials/curation/plot_1_automated_curation.html>`_). | ||
|
||
There is a Collection of models for automated curation available on the | ||
`SpikeInterface HuggingFace page <https://huggingface.co/SpikeInterface>`_. | ||
|
||
We'll apply the model ``toy_tetrode_model`` from ``SpikeInterface`` on a SortingAnalyzer | ||
called ``sorting_analyzer``. We assume that the quality and template metrics have | ||
already been computed. | ||
|
||
We need to pass the ``sorting_analyzer``, the ``repo_id`` (which is just the part of the | ||
repo's URL after huggingface.co/) and that we trust the model. | ||
|
||
.. code:: | ||
from spikeinterface.curation import auto_label_units | ||
labels_and_probabilities = auto_label_units( | ||
sorting_analyzer = sorting_analyzer, | ||
repo_id = "SpikeInterface/toy_tetrode_model", | ||
trust_model = True | ||
) | ||
If you have a local directory containing the model in a ``skops`` file you can use this to | ||
create the labels: | ||
|
||
.. code:: | ||
labels_and_probabilities = si.auto_label_units( | ||
sorting_analyzer = sorting_analyzer, | ||
model_folder = "my_folder_with_a_model_in_it", | ||
) | ||
The returned labels are a dictionary of model's predictions and it's confidence. These | ||
are also saved as a property of your ``sorting_analyzer`` and can be accessed like so: | ||
|
||
.. code:: | ||
labels = sorting_analyzer.sorting.get_property("classifier_label") | ||
probabilities = sorting_analyzer.sorting.get_property("classifier_probability") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
How to train a model to predict curation labels | ||
=============================================== | ||
|
||
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>`_. | ||
|
||
Here, we assume that you have: | ||
|
||
* Two SortingAnalyzers called ``analyzer_1`` and | ||
``analyzer_2``, and have calculated some template and quality metrics for both | ||
* Manually curated labels for the units in each analyzer, in lists called | ||
``analyzer_1_labels`` and ``analyzer_2_labels``. If you have used phy, the lists can | ||
be accessed using ``curated_labels = analyzer.sorting.get_property("quality")``. | ||
|
||
With these objects calculated, you can train a model as follows | ||
|
||
.. code:: | ||
from spikeinterface.curation import train_model | ||
analyzer_list = [analyzer_1, analyzer_2] | ||
labels_list = [analyzer_1_labels, analyzer_2_labels] | ||
output_folder = "/path/to/output_folder" | ||
trainer = train_model( | ||
mode="analyzers", | ||
labels=labels_list, | ||
analyzers=analyzer_list, | ||
output_folder=output_folder, | ||
metric_names=None, # Set if you want to use a subset of metrics, defaults to all calculated quality and template metrics | ||
imputation_strategies=None, # Default is all available imputation strategies | ||
scaling_techniques=None, # Default is all available scaling techniques | ||
classifiers=None, # Defaults to Random Forest classifier only - we usually find this gives the best results, but a range of classifiers is available | ||
seed=None, # Set a seed for reproducibility | ||
) | ||
The trainer tries several models and chooses the most accurate one. This model and | ||
some metadata are stored in the ``output_folder``, which can later be loaded using the | ||
``load_model`` function (`more details <https://spikeinterface.readthedocs.io/en/latest/tutorials/curation/plot_1_automated_curation.html#download-a-pretrained-model>`_). | ||
We can also access the model, which is an sklearn ``Pipeline``, from the trainer object | ||
|
||
.. code:: | ||
best_model = trainer.best_pipeline | ||
The training function can also be run in “csv” mode, if you prefer to | ||
store metrics in as .csv files. If the target labels are stored as a column in | ||
the file, you can point to these with the ``target_label`` parameter | ||
|
||
.. code:: | ||
trainer = train_model( | ||
mode="csv", | ||
metrics_paths = ["/path/to/csv_file_1", "/path/to/csv_file_2"], | ||
target_label = "my_label", | ||
output_folder=output_folder, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.