From d816d0fcaa244f5cb2bd60907db1a95d0a9fbf48 Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Thu, 30 May 2024 16:50:42 +0100 Subject: [PATCH 01/10] make a sorting wip --- doc/how_to/make_a_sorting.rst | 75 +++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 doc/how_to/make_a_sorting.rst diff --git a/doc/how_to/make_a_sorting.rst b/doc/how_to/make_a_sorting.rst new file mode 100644 index 0000000000..8586de3af5 --- /dev/null +++ b/doc/how_to/make_a_sorting.rst @@ -0,0 +1,75 @@ +How to Make your own Sorting +============================ + +Why make a :code:`Sorting`? + +The :code:`Sorting` object is one of the core objects within the SpikeInterface library +along with :code:`Recording` and :code:`SortingAnalyzer`. Although SpikeInterface has +many tools for reading sorting formats you may have some data in a nonstandard format +(e.g. old csv file). If this is this the case you would need to make your own :code:`Sorting`. + + +Making a :code:`Sorting` +------------------------ + +For most formats the :code:`Sorting` is automatically generated. For example one could do + +.. code-block:: python + + from spikeinterface.extractors import read_kilosort, read_phy + + # For kilosort/phy files we can use either reader + ks_sorting = read_kilosort('path/to/folder') + phy_sorting = read_phy('path/to/folder') + +This :code:`Sorting` contains important information about your spike trains including +the spike times (i.e. when the neurons were actually firing) the unit labels (i.e. +who the spikes belong to. Also called cluster ids by some sorters), the unit ids (the unique +set of unit labels) and the sampling_frequency. To make your own :code:`Sorting` object you can +use :code:`NumpySorting`. There are 3 options: + +With lists +---------- + +In this case we need a list or array of spike times, unit labels, sampling_frequency and optional +unit_ids if you want specific labels to be used. + +.. code-block:: python + + from spikeinterface.core import NumpySorting + + my_sorting = NumpySorting.from_times_labels(times_list = [1,2,3,4], + labels_list = [0,1,0,1], + sampling_frequency = 30_000.0 + ) + + +With a unit dict +---------------- + +We can also use a dictionary where each unit is a key and its spike times are values. +This is entered as either a list of dicts with each dict being a segment or as a single +dict for monosegment. + +.. code-block:: python + + from spikeinterface.core import NumpySorting + + my_sorting = NumpySorting.from_unit_dict(units_dict_list={'0': [1,3], + '1': [2,4] + }, + sampling_frequency=30_000.0 + ) + + +From Neo +-------- + +Finally since SpikeInterface is tightly integrated with the Neo project you can create +a sorting from :code:`Neo.SpikeTrain` objects. + +.. code-block:: python + + from spikeinterface.core import NumpySorting + + my_sorting = NumpySorting.from_neo_spiketrain_list(neo_spiketrain, sampling_frequency=30_000.0) From f1e46853ca92f67ec353f5c72cace1bda1844071 Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Fri, 31 May 2024 09:36:53 +0100 Subject: [PATCH 02/10] continued docs --- doc/how_to/make_a_sorting.rst | 36 +++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/doc/how_to/make_a_sorting.rst b/doc/how_to/make_a_sorting.rst index 8586de3af5..e9f1476f57 100644 --- a/doc/how_to/make_a_sorting.rst +++ b/doc/how_to/make_a_sorting.rst @@ -6,7 +6,12 @@ Why make a :code:`Sorting`? The :code:`Sorting` object is one of the core objects within the SpikeInterface library along with :code:`Recording` and :code:`SortingAnalyzer`. Although SpikeInterface has many tools for reading sorting formats you may have some data in a nonstandard format -(e.g. old csv file). If this is this the case you would need to make your own :code:`Sorting`. +(e.g. old csv file). If this is the case you would need to make your own :code:`Sorting`. + +At a fundamental level the :code:`Sorting` is a series of spike times and a series of +labels for each spike along with some associated metadata. Thus by providing this +information you can easily make a :code:`Sorting` object to be used for various analyses +(e.g. correlograms or for generating a :code:`SortingAnalyzer`) Making a :code:`Sorting` @@ -26,30 +31,36 @@ This :code:`Sorting` contains important information about your spike trains incl the spike times (i.e. when the neurons were actually firing) the unit labels (i.e. who the spikes belong to. Also called cluster ids by some sorters), the unit ids (the unique set of unit labels) and the sampling_frequency. To make your own :code:`Sorting` object you can -use :code:`NumpySorting`. There are 3 options: +use :code:`NumpySorting`. It is important to note if you are new to spike trains that they +are typically stored in samples/frames rather than in seconds. So you should input the times +in samples/frames. The sampling_frequency allows for easily switching between samples and seconds. + +There are 3 options (along with making a NumpySorting from another sorting which will not be covered here): -With lists ----------- +With lists of spike trains and spike labels +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -In this case we need a list or array of spike times, unit labels, sampling_frequency and optional -unit_ids if you want specific labels to be used. +In this case we need a list or array (or lists of lists for multisegment) of spike times, +unit labels, sampling_frequency and optional unit_ids if you want specific labels to be +used (in this case we only create the :code:`Sorting` based on the requested unit_ids). .. code-block:: python from spikeinterface.core import NumpySorting + # in this case we are making a monosegment sorting my_sorting = NumpySorting.from_times_labels(times_list = [1,2,3,4], labels_list = [0,1,0,1], sampling_frequency = 30_000.0 ) -With a unit dict ----------------- +With a unit dictionary +^^^^^^^^^^^^^^^^^^^^^^ We can also use a dictionary where each unit is a key and its spike times are values. This is entered as either a list of dicts with each dict being a segment or as a single -dict for monosegment. +dict for monosegment. We still need to separately specify the sampling_frequency .. code-block:: python @@ -62,11 +73,12 @@ dict for monosegment. ) -From Neo --------- +With Neo SpikeTrains +^^^^^^^^^^^^^^^^^^^^ Finally since SpikeInterface is tightly integrated with the Neo project you can create -a sorting from :code:`Neo.SpikeTrain` objects. +a sorting from :code:`Neo.SpikeTrain` objects. See Neo documentation for more information on +using :code:`Neo.SpikeTrain`'s. .. code-block:: python From 6b4d9346f5e49e8f323bf325290eef5db84b723d Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Fri, 31 May 2024 13:32:44 +0100 Subject: [PATCH 03/10] add to index --- doc/how_to/index.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/how_to/index.rst b/doc/how_to/index.rst index 79156e2690..38a2797f30 100644 --- a/doc/how_to/index.rst +++ b/doc/how_to/index.rst @@ -1,5 +1,5 @@ How to Guides -========= +============= Guides on how to solve specific, short problems in SpikeInterface. Learn how to... @@ -12,3 +12,4 @@ Guides on how to solve specific, short problems in SpikeInterface. Learn how to. load_matlab_data combine_recordings process_by_channel_group + make_a_sorting From 15854f72f5c08a2616955218e4239c761ebb563e Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Fri, 31 May 2024 14:00:32 +0100 Subject: [PATCH 04/10] tidy the how-to --- doc/how_to/make_a_sorting.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/how_to/make_a_sorting.rst b/doc/how_to/make_a_sorting.rst index e9f1476f57..70e91beb69 100644 --- a/doc/how_to/make_a_sorting.rst +++ b/doc/how_to/make_a_sorting.rst @@ -1,5 +1,5 @@ -How to Make your own Sorting -============================ +Make your own Sorting +===================== Why make a :code:`Sorting`? @@ -69,7 +69,7 @@ dict for monosegment. We still need to separately specify the sampling_frequency my_sorting = NumpySorting.from_unit_dict(units_dict_list={'0': [1,3], '1': [2,4] }, - sampling_frequency=30_000.0 + sampling_frequency=30_000.0 ) @@ -84,4 +84,6 @@ using :code:`Neo.SpikeTrain`'s. from spikeinterface.core import NumpySorting - my_sorting = NumpySorting.from_neo_spiketrain_list(neo_spiketrain, sampling_frequency=30_000.0) + # neo_spiketrain is a Neo spiketrain object + my_sorting = NumpySorting.from_neo_spiketrain_list(neo_spiketrain, + sampling_frequency=30_000.0) From 8f9ca83fc8811e217e8357a43f1bf0f6ce7e3fec Mon Sep 17 00:00:00 2001 From: Zach McKenzie <92116279+zm711@users.noreply.github.com> Date: Sat, 1 Jun 2024 15:13:42 -0400 Subject: [PATCH 05/10] Heberto improvement Co-authored-by: Heberto Mayorquin --- doc/how_to/make_a_sorting.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/how_to/make_a_sorting.rst b/doc/how_to/make_a_sorting.rst index 70e91beb69..c62a29be48 100644 --- a/doc/how_to/make_a_sorting.rst +++ b/doc/how_to/make_a_sorting.rst @@ -31,7 +31,7 @@ This :code:`Sorting` contains important information about your spike trains incl the spike times (i.e. when the neurons were actually firing) the unit labels (i.e. who the spikes belong to. Also called cluster ids by some sorters), the unit ids (the unique set of unit labels) and the sampling_frequency. To make your own :code:`Sorting` object you can -use :code:`NumpySorting`. It is important to note if you are new to spike trains that they +use :code:`NumpySorting`. It is important to note that in SpikeiInterface spike trains are handled internally in samples/frames rather than in seconds and we use the sampling frequency to ... are typically stored in samples/frames rather than in seconds. So you should input the times in samples/frames. The sampling_frequency allows for easily switching between samples and seconds. From 5914e624c2da50e870934c47dc5079666ee0e614 Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Thu, 6 Jun 2024 08:33:46 -0400 Subject: [PATCH 06/10] everyone's feedback I hope --- doc/how_to/index.rst | 2 +- doc/how_to/load_your_data_into_sorting.rst | 152 +++++++++++++++++++++ doc/how_to/make_a_sorting.rst | 89 ------------ 3 files changed, 153 insertions(+), 90 deletions(-) create mode 100644 doc/how_to/load_your_data_into_sorting.rst delete mode 100644 doc/how_to/make_a_sorting.rst diff --git a/doc/how_to/index.rst b/doc/how_to/index.rst index 38a2797f30..54fd404848 100644 --- a/doc/how_to/index.rst +++ b/doc/how_to/index.rst @@ -12,4 +12,4 @@ Guides on how to solve specific, short problems in SpikeInterface. Learn how to. load_matlab_data combine_recordings process_by_channel_group - make_a_sorting + load_your_data_into_sorting diff --git a/doc/how_to/load_your_data_into_sorting.rst b/doc/how_to/load_your_data_into_sorting.rst new file mode 100644 index 0000000000..bdcfc905cd --- /dev/null +++ b/doc/how_to/load_your_data_into_sorting.rst @@ -0,0 +1,152 @@ +Load Your Own Data into a Sorting +================================= + +Why make a :code:`Sorting`? + +SpikeInterface contains pre-build readers for the output of many common sorters. +However, what if you have sorting output that is not in a standard format (e.g. +old csv file)? If this is the case you can make your own Sorting object to load +your data into SpikeInterface. This means you can still easily apply various +downstream analyses to your results (e.g. building correlograms or for generating +a :code:`SortingAnalyzer``). + +The Sorting object is a core object within SpikeInterface that acts as a convenient +way to interface with sorting results, no matter which sorter was used to generate +them. **At a fundamental level it is a series of spike times and a series of labels +for each spike along with some associated metadata.** Below, we will show you have +to take your existing data and load it as a SpikeInterface :code:`Sorting`` object. + + +Reading a standard spike sorting format into a :code:`Sorting` +------------------------------------------------------------- + +For most spike sorting output formats the :code:`Sorting` is automatically generated. For example one could do + +.. code-block:: python + + from spikeinterface.extractors import read_phy + + # For kilosort/phy output files we can use the read_phy + # most formats will have a read_xx that can used. + phy_sorting = read_phy('path/to/folder') + +And voila you now have your :code:`Sorting` object generated and can use it for further analysis. For all the +current formats see :ref:`compatible_formats`. + + + +Loading your own data into a :code:`Sorting` +------------------------------------------- + + +This :code:`Sorting` contains important information about your spike trains including: + + * spike times: the peaks of the extracellular potentials expressed in samples/frames these can + be converted to seconds under the hood using the sampling_frequency + * spike labels: the neuron id for each spike, can also be called cluster ids or unit ids + Stored as the :code:`unit_ids` in SpikeInterface + * sampling_frequency: the rate at which the recording equipment was run at. Note this is the + frequency and not the period. This value allows for switching between samples/frames to seconds + + +There are 3 options for loading your own data into a sorting object + +With lists of spike trains and spike labels +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +In this case we need a list of spike times unit labels, sampling_frequency and optional unit_ids +if you want specific labels to be used (in this case we only create the :code:`Sorting` based on +the requested unit_ids). + +.. code-block:: python + + import numpy as np + from spikeinterface.core import NumpySorting + + # in this case we are making a monosegment sorting + # we have four spikes that are spread among two neurons + my_sorting = NumpySorting.from_times_labels( + times_list=[ + np.array([1000,12000,15000,22000]) + ], + labels_list=[ + np.array([0,1,0,1]) + ], + sampling_frequency=30_000.0 + ) + + +With a unit dictionary +^^^^^^^^^^^^^^^^^^^^^^ + +We can also use a dictionary where each unit is a key and its spike times are values. +This is entered as either a list of dicts with each dict being a segment or as a single +dict for monosegment. We still need to separately specify the sampling_frequency + +.. code-block:: python + + from spikeinterface.core import NumpySorting + + my_sorting = NumpySorting.from_unit_dict( + units_dict_list={ + '0': [1000,15000], + '1': [12000,22000], + }, + sampling_frequency=30_000.0 + ) + + +With Neo SpikeTrains +^^^^^^^^^^^^^^^^^^^^ + +Finally since SpikeInterface is tightly integrated with the Neo project you can create +a sorting from :code:`Neo.SpikeTrain` objects. See :doc:`Neo documentation`` for more information on +using :code:`Neo.SpikeTrain`'s. + +.. code-block:: python + + from spikeinterface.core import NumpySorting + + # neo_spiketrain is a Neo spiketrain object + my_sorting = NumpySorting.from_neo_spiketrain_list(neo_spiketrain, + sampling_frequency=30_000.0) + + +Loading multisegment data into a :code:`Sorting` +----------------------------------------------- + +One of the great advantages of SpikeInterface :code:`Sorting` objects is that they can also handle +multisegment recordings and sortings (e.g. you have a baseline, stimulus, post-stimulus). The +exact same machinery can be used to generate your sorting, but in this case we do a list of arrays instead of +a single list. Let's go through one example for using :code:`from_times_labels`: + +.. code-block:: python + + import numpy as np + from spikeinterface.core import NumpySorting + + # in this case we are making three-segment sorting + # we have four spikes that are spread among two neurons + # in each segment + my_sorting = NumpySorting.from_times_labels( + times_list=[ + np.array([1000,12000,15000,22000]), + np.array([30000,33000, 41000, 47000]), + np.array([50000,53000,64000,70000]), + ], + labels_list=[ + np.array([0,1,0,1]), + np.array([0,0,1,1]), + np.array([1,0,1,0]), + ], + sampling_frequency=30_000.0 + ) + + +Next steps +---------- + +Now that we've created a Sorting object you can combine it with a Recording to make a +:ref:`SortingAnalyzer` +or start visualizing using plotting functions from our widgets model such as +:py:func:`~spikeinterface.widgets.plot_crosscorrelograms`. diff --git a/doc/how_to/make_a_sorting.rst b/doc/how_to/make_a_sorting.rst deleted file mode 100644 index c62a29be48..0000000000 --- a/doc/how_to/make_a_sorting.rst +++ /dev/null @@ -1,89 +0,0 @@ -Make your own Sorting -===================== - -Why make a :code:`Sorting`? - -The :code:`Sorting` object is one of the core objects within the SpikeInterface library -along with :code:`Recording` and :code:`SortingAnalyzer`. Although SpikeInterface has -many tools for reading sorting formats you may have some data in a nonstandard format -(e.g. old csv file). If this is the case you would need to make your own :code:`Sorting`. - -At a fundamental level the :code:`Sorting` is a series of spike times and a series of -labels for each spike along with some associated metadata. Thus by providing this -information you can easily make a :code:`Sorting` object to be used for various analyses -(e.g. correlograms or for generating a :code:`SortingAnalyzer`) - - -Making a :code:`Sorting` ------------------------- - -For most formats the :code:`Sorting` is automatically generated. For example one could do - -.. code-block:: python - - from spikeinterface.extractors import read_kilosort, read_phy - - # For kilosort/phy files we can use either reader - ks_sorting = read_kilosort('path/to/folder') - phy_sorting = read_phy('path/to/folder') - -This :code:`Sorting` contains important information about your spike trains including -the spike times (i.e. when the neurons were actually firing) the unit labels (i.e. -who the spikes belong to. Also called cluster ids by some sorters), the unit ids (the unique -set of unit labels) and the sampling_frequency. To make your own :code:`Sorting` object you can -use :code:`NumpySorting`. It is important to note that in SpikeiInterface spike trains are handled internally in samples/frames rather than in seconds and we use the sampling frequency to ... -are typically stored in samples/frames rather than in seconds. So you should input the times -in samples/frames. The sampling_frequency allows for easily switching between samples and seconds. - -There are 3 options (along with making a NumpySorting from another sorting which will not be covered here): - -With lists of spike trains and spike labels -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -In this case we need a list or array (or lists of lists for multisegment) of spike times, -unit labels, sampling_frequency and optional unit_ids if you want specific labels to be -used (in this case we only create the :code:`Sorting` based on the requested unit_ids). - -.. code-block:: python - - from spikeinterface.core import NumpySorting - - # in this case we are making a monosegment sorting - my_sorting = NumpySorting.from_times_labels(times_list = [1,2,3,4], - labels_list = [0,1,0,1], - sampling_frequency = 30_000.0 - ) - - -With a unit dictionary -^^^^^^^^^^^^^^^^^^^^^^ - -We can also use a dictionary where each unit is a key and its spike times are values. -This is entered as either a list of dicts with each dict being a segment or as a single -dict for monosegment. We still need to separately specify the sampling_frequency - -.. code-block:: python - - from spikeinterface.core import NumpySorting - - my_sorting = NumpySorting.from_unit_dict(units_dict_list={'0': [1,3], - '1': [2,4] - }, - sampling_frequency=30_000.0 - ) - - -With Neo SpikeTrains -^^^^^^^^^^^^^^^^^^^^ - -Finally since SpikeInterface is tightly integrated with the Neo project you can create -a sorting from :code:`Neo.SpikeTrain` objects. See Neo documentation for more information on -using :code:`Neo.SpikeTrain`'s. - -.. code-block:: python - - from spikeinterface.core import NumpySorting - - # neo_spiketrain is a Neo spiketrain object - my_sorting = NumpySorting.from_neo_spiketrain_list(neo_spiketrain, - sampling_frequency=30_000.0) From 42ae4b733c83023948fc46cf62faf492d0903429 Mon Sep 17 00:00:00 2001 From: Zach McKenzie <92116279+zm711@users.noreply.github.com> Date: Thu, 6 Jun 2024 12:12:53 -0400 Subject: [PATCH 07/10] Heberto improvements Co-authored-by: Heberto Mayorquin --- doc/how_to/load_your_data_into_sorting.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/how_to/load_your_data_into_sorting.rst b/doc/how_to/load_your_data_into_sorting.rst index bdcfc905cd..aff3a84733 100644 --- a/doc/how_to/load_your_data_into_sorting.rst +++ b/doc/how_to/load_your_data_into_sorting.rst @@ -13,8 +13,8 @@ a :code:`SortingAnalyzer``). The Sorting object is a core object within SpikeInterface that acts as a convenient way to interface with sorting results, no matter which sorter was used to generate them. **At a fundamental level it is a series of spike times and a series of labels -for each spike along with some associated metadata.** Below, we will show you have -to take your existing data and load it as a SpikeInterface :code:`Sorting`` object. +for each unit and a sampling frequency for transforming frames to time.** Below, we will show you have +to take your existing data and load it as a SpikeInterface :code:`Sorting` object. Reading a standard spike sorting format into a :code:`Sorting` @@ -30,7 +30,7 @@ For most spike sorting output formats the :code:`Sorting` is automatically gener # most formats will have a read_xx that can used. phy_sorting = read_phy('path/to/folder') -And voila you now have your :code:`Sorting` object generated and can use it for further analysis. For all the +And voilĂ  you now have your :code:`Sorting` object generated and can use it for further analysis. For all the current formats see :ref:`compatible_formats`. @@ -70,7 +70,7 @@ the requested unit_ids). np.array([1000,12000,15000,22000]) ], labels_list=[ - np.array([0,1,0,1]) + np.array(["a","b","a","b"]) ], sampling_frequency=30_000.0 ) From 7e639e0700aee45a4352616ce116d9e3caf60ce5 Mon Sep 17 00:00:00 2001 From: Zach McKenzie <92116279+zm711@users.noreply.github.com> Date: Thu, 6 Jun 2024 12:13:52 -0400 Subject: [PATCH 08/10] another Heberto clarification Co-authored-by: Heberto Mayorquin --- doc/how_to/load_your_data_into_sorting.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/how_to/load_your_data_into_sorting.rst b/doc/how_to/load_your_data_into_sorting.rst index aff3a84733..22e13004f7 100644 --- a/doc/how_to/load_your_data_into_sorting.rst +++ b/doc/how_to/load_your_data_into_sorting.rst @@ -67,7 +67,7 @@ the requested unit_ids). # we have four spikes that are spread among two neurons my_sorting = NumpySorting.from_times_labels( times_list=[ - np.array([1000,12000,15000,22000]) + np.array([1000,12000,15000,22000]) # Note these are samples/frames not times in seconds ], labels_list=[ np.array(["a","b","a","b"]) From 62ccf27c8539e8ca843a2a3e8b4f4ce52dd55227 Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Fri, 7 Jun 2024 07:00:11 -0400 Subject: [PATCH 09/10] spacing of examples --- doc/how_to/load_your_data_into_sorting.rst | 60 +++++++++++----------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/doc/how_to/load_your_data_into_sorting.rst b/doc/how_to/load_your_data_into_sorting.rst index 22e13004f7..dcc75577d0 100644 --- a/doc/how_to/load_your_data_into_sorting.rst +++ b/doc/how_to/load_your_data_into_sorting.rst @@ -66,14 +66,14 @@ the requested unit_ids). # in this case we are making a monosegment sorting # we have four spikes that are spread among two neurons my_sorting = NumpySorting.from_times_labels( - times_list=[ - np.array([1000,12000,15000,22000]) # Note these are samples/frames not times in seconds - ], - labels_list=[ - np.array(["a","b","a","b"]) - ], - sampling_frequency=30_000.0 - ) + times_list=[ + np.array([1000,12000,15000,22000]) # Note these are samples/frames not times in seconds + ], + labels_list=[ + np.array(["a","b","a","b"]) + ], + sampling_frequency=30_000.0 + ) With a unit dictionary @@ -88,19 +88,19 @@ dict for monosegment. We still need to separately specify the sampling_frequency from spikeinterface.core import NumpySorting my_sorting = NumpySorting.from_unit_dict( - units_dict_list={ - '0': [1000,15000], - '1': [12000,22000], - }, - sampling_frequency=30_000.0 - ) + units_dict_list={ + '0': [1000,15000], + '1': [12000,22000], + }, + sampling_frequency=30_000.0 + ) With Neo SpikeTrains ^^^^^^^^^^^^^^^^^^^^ Finally since SpikeInterface is tightly integrated with the Neo project you can create -a sorting from :code:`Neo.SpikeTrain` objects. See :doc:`Neo documentation`` for more information on +a sorting from :code:`Neo.SpikeTrain` objects. See :doc:`Neo documentation` for more information on using :code:`Neo.SpikeTrain`'s. .. code-block:: python @@ -108,8 +108,10 @@ using :code:`Neo.SpikeTrain`'s. from spikeinterface.core import NumpySorting # neo_spiketrain is a Neo spiketrain object - my_sorting = NumpySorting.from_neo_spiketrain_list(neo_spiketrain, - sampling_frequency=30_000.0) + my_sorting = NumpySorting.from_neo_spiketrain_list( + neo_spiketrain, + sampling_frequency=30_000.0, + ) Loading multisegment data into a :code:`Sorting` @@ -129,18 +131,18 @@ a single list. Let's go through one example for using :code:`from_times_labels`: # we have four spikes that are spread among two neurons # in each segment my_sorting = NumpySorting.from_times_labels( - times_list=[ - np.array([1000,12000,15000,22000]), - np.array([30000,33000, 41000, 47000]), - np.array([50000,53000,64000,70000]), - ], - labels_list=[ - np.array([0,1,0,1]), - np.array([0,0,1,1]), - np.array([1,0,1,0]), - ], - sampling_frequency=30_000.0 - ) + times_list=[ + np.array([1000,12000,15000,22000]), + np.array([30000,33000, 41000, 47000]), + np.array([50000,53000,64000,70000]), + ], + labels_list=[ + np.array([0,1,0,1]), + np.array([0,0,1,1]), + np.array([1,0,1,0]), + ], + sampling_frequency=30_000.0 + ) Next steps From 9edf693a56a65fff82ad96c763f74449b8310c09 Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Fri, 7 Jun 2024 07:01:46 -0400 Subject: [PATCH 10/10] one more spacing --- doc/how_to/load_your_data_into_sorting.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/how_to/load_your_data_into_sorting.rst b/doc/how_to/load_your_data_into_sorting.rst index dcc75577d0..21c4460c5a 100644 --- a/doc/how_to/load_your_data_into_sorting.rst +++ b/doc/how_to/load_your_data_into_sorting.rst @@ -89,9 +89,9 @@ dict for monosegment. We still need to separately specify the sampling_frequency my_sorting = NumpySorting.from_unit_dict( units_dict_list={ - '0': [1000,15000], - '1': [12000,22000], - }, + '0': [1000,15000], + '1': [12000,22000], + }, sampling_frequency=30_000.0 )