figpack-spike-sorting 0.1.10__py3-none-any.whl → 0.1.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- figpack_spike_sorting/__init__.py +1 -1
- figpack_spike_sorting/figpack_spike_sorting.js +124 -124
- figpack_spike_sorting/views/SpikeLocations.py +138 -0
- figpack_spike_sorting/views/UnitSimilarityMatrix.py +58 -0
- figpack_spike_sorting/views/__init__.py +5 -0
- {figpack_spike_sorting-0.1.10.dist-info → figpack_spike_sorting-0.1.12.dist-info}/METADATA +1 -1
- {figpack_spike_sorting-0.1.10.dist-info → figpack_spike_sorting-0.1.12.dist-info}/RECORD +9 -7
- {figpack_spike_sorting-0.1.10.dist-info → figpack_spike_sorting-0.1.12.dist-info}/WHEEL +0 -0
- {figpack_spike_sorting-0.1.10.dist-info → figpack_spike_sorting-0.1.12.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"""
|
|
2
|
+
SpikeLocations view for figpack - displays spike locations in 2D space
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import Dict, List, Optional, Tuple, Union
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
import figpack
|
|
9
|
+
from ..spike_sorting_extension import spike_sorting_extension
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class SpikeLocationsItem:
|
|
13
|
+
"""
|
|
14
|
+
Represents spike locations for a single unit
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
*,
|
|
20
|
+
unit_id: Union[str, int],
|
|
21
|
+
spike_times_sec: np.ndarray,
|
|
22
|
+
x_locations: np.ndarray,
|
|
23
|
+
y_locations: np.ndarray,
|
|
24
|
+
):
|
|
25
|
+
"""
|
|
26
|
+
Initialize a SpikeLocationsItem
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
unit_id: Identifier for the unit
|
|
30
|
+
spike_times_sec: Array of spike times in seconds
|
|
31
|
+
x_locations: Array of x coordinates for each spike
|
|
32
|
+
y_locations: Array of y coordinates for each spike
|
|
33
|
+
"""
|
|
34
|
+
self.unit_id = unit_id
|
|
35
|
+
self.spike_times_sec = np.array(spike_times_sec, dtype=np.float32)
|
|
36
|
+
self.x_locations = np.array(x_locations, dtype=np.float32)
|
|
37
|
+
self.y_locations = np.array(y_locations, dtype=np.float32)
|
|
38
|
+
|
|
39
|
+
# Validate that all arrays have the same length
|
|
40
|
+
if not (
|
|
41
|
+
len(self.spike_times_sec) == len(self.x_locations) == len(self.y_locations)
|
|
42
|
+
):
|
|
43
|
+
raise ValueError(
|
|
44
|
+
"spike_times_sec, x_locations, and y_locations must have the same length"
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class SpikeLocations(figpack.ExtensionView):
|
|
49
|
+
"""
|
|
50
|
+
A view that displays spike locations in 2D space
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
def __init__(
|
|
54
|
+
self,
|
|
55
|
+
*,
|
|
56
|
+
units: List[SpikeLocationsItem],
|
|
57
|
+
x_range: Tuple[float, float],
|
|
58
|
+
y_range: Tuple[float, float],
|
|
59
|
+
channel_locations: Optional[Dict[str, np.ndarray]] = None,
|
|
60
|
+
hide_unit_selector: bool = False,
|
|
61
|
+
disable_auto_rotate: bool = False,
|
|
62
|
+
):
|
|
63
|
+
"""
|
|
64
|
+
Initialize a SpikeLocations view
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
units: List of SpikeLocationsItem objects
|
|
68
|
+
x_range: Tuple specifying the x-axis range (min, max)
|
|
69
|
+
y_range: Tuple specifying the y-axis range (min, max)
|
|
70
|
+
channel_locations: Optional dictionary mapping channel IDs to (x, y) coordinates
|
|
71
|
+
hide_unit_selector: Whether to hide the unit selector
|
|
72
|
+
disable_auto_rotate: Whether to disable automatic rotation of the view
|
|
73
|
+
"""
|
|
74
|
+
super().__init__(
|
|
75
|
+
extension=spike_sorting_extension,
|
|
76
|
+
view_type="spike_sorting.SpikeLocations",
|
|
77
|
+
)
|
|
78
|
+
self.units = units
|
|
79
|
+
self.x_range = x_range
|
|
80
|
+
self.y_range = y_range
|
|
81
|
+
self.channel_locations = channel_locations
|
|
82
|
+
self.hide_unit_selector = hide_unit_selector
|
|
83
|
+
self.disable_auto_rotate = disable_auto_rotate
|
|
84
|
+
|
|
85
|
+
def write_to_zarr_group(self, group: figpack.Group) -> None:
|
|
86
|
+
"""
|
|
87
|
+
Write the SpikeLocations data to a Zarr group
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
group: Zarr group to write data into
|
|
91
|
+
"""
|
|
92
|
+
super().write_to_zarr_group(group)
|
|
93
|
+
|
|
94
|
+
# Store metadata
|
|
95
|
+
group.attrs["x_range"] = list(self.x_range)
|
|
96
|
+
group.attrs["y_range"] = list(self.y_range)
|
|
97
|
+
|
|
98
|
+
if self.hide_unit_selector:
|
|
99
|
+
group.attrs["hide_unit_selector"] = True
|
|
100
|
+
|
|
101
|
+
if self.disable_auto_rotate:
|
|
102
|
+
group.attrs["disable_auto_rotate"] = True
|
|
103
|
+
|
|
104
|
+
# Store channel locations if provided
|
|
105
|
+
if self.channel_locations is not None:
|
|
106
|
+
channel_locations_dict = {}
|
|
107
|
+
for ch_id, loc in self.channel_locations.items():
|
|
108
|
+
channel_locations_dict[str(ch_id)] = [float(a) for a in loc]
|
|
109
|
+
group.attrs["channel_locations"] = channel_locations_dict
|
|
110
|
+
|
|
111
|
+
# Store unit data
|
|
112
|
+
unit_metadata = []
|
|
113
|
+
for i, unit_item in enumerate(self.units):
|
|
114
|
+
unit_name = f"unit_{i}"
|
|
115
|
+
|
|
116
|
+
# Store metadata
|
|
117
|
+
metadata = {
|
|
118
|
+
"name": unit_name,
|
|
119
|
+
"unit_id": str(unit_item.unit_id),
|
|
120
|
+
}
|
|
121
|
+
unit_metadata.append(metadata)
|
|
122
|
+
|
|
123
|
+
# Create datasets for this unit
|
|
124
|
+
group.create_dataset(
|
|
125
|
+
f"{unit_name}/spike_times_sec",
|
|
126
|
+
data=unit_item.spike_times_sec,
|
|
127
|
+
)
|
|
128
|
+
group.create_dataset(
|
|
129
|
+
f"{unit_name}/x_locations",
|
|
130
|
+
data=unit_item.x_locations,
|
|
131
|
+
)
|
|
132
|
+
group.create_dataset(
|
|
133
|
+
f"{unit_name}/y_locations",
|
|
134
|
+
data=unit_item.y_locations,
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
# Store the unit metadata
|
|
138
|
+
group.attrs["units"] = unit_metadata
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""
|
|
2
|
+
UnitSimilarityMatrix view for figpack - displays a similarity matrix between units
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import List, Optional, Tuple, Union
|
|
6
|
+
|
|
7
|
+
import figpack
|
|
8
|
+
from ..spike_sorting_extension import spike_sorting_extension
|
|
9
|
+
from .UnitSimilarityScore import UnitSimilarityScore
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class UnitSimilarityMatrix(figpack.ExtensionView):
|
|
13
|
+
"""
|
|
14
|
+
A view that displays a similarity matrix between units
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
*,
|
|
20
|
+
unit_ids: List[Union[str, int]],
|
|
21
|
+
similarity_scores: List[UnitSimilarityScore],
|
|
22
|
+
range: Optional[Tuple[float, float]] = None,
|
|
23
|
+
):
|
|
24
|
+
"""
|
|
25
|
+
Initialize a UnitSimilarityMatrix view
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
unit_ids: List of unit identifiers
|
|
29
|
+
similarity_scores: List of UnitSimilarityScore objects representing pairwise similarities
|
|
30
|
+
range: Optional tuple specifying the range for the color scale (min, max)
|
|
31
|
+
"""
|
|
32
|
+
super().__init__(
|
|
33
|
+
extension=spike_sorting_extension,
|
|
34
|
+
view_type="spike_sorting.UnitSimilarityMatrix",
|
|
35
|
+
)
|
|
36
|
+
self.unit_ids = unit_ids
|
|
37
|
+
self.similarity_scores = similarity_scores
|
|
38
|
+
self.range = range
|
|
39
|
+
|
|
40
|
+
def write_to_zarr_group(self, group: figpack.Group) -> None:
|
|
41
|
+
"""
|
|
42
|
+
Write the UnitSimilarityMatrix data to a Zarr group
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
group: Zarr group to write data into
|
|
46
|
+
"""
|
|
47
|
+
super().write_to_zarr_group(group)
|
|
48
|
+
|
|
49
|
+
# Store unit IDs as strings
|
|
50
|
+
group.attrs["unit_ids"] = [str(uid) for uid in self.unit_ids]
|
|
51
|
+
|
|
52
|
+
# Store similarity scores as a list of dictionaries
|
|
53
|
+
similarity_scores_data = [score.to_dict() for score in self.similarity_scores]
|
|
54
|
+
group.attrs["similarity_scores"] = similarity_scores_data
|
|
55
|
+
|
|
56
|
+
# Store optional range parameter
|
|
57
|
+
if self.range is not None:
|
|
58
|
+
group.attrs["range"] = list(self.range)
|
|
@@ -8,11 +8,13 @@ from .UnitsTableRow import UnitsTableRow
|
|
|
8
8
|
from .UnitsTableColumn import UnitsTableColumn
|
|
9
9
|
from .UnitsTable import UnitsTable
|
|
10
10
|
from .UnitSimilarityScore import UnitSimilarityScore
|
|
11
|
+
from .UnitSimilarityMatrix import UnitSimilarityMatrix
|
|
11
12
|
from .AverageWaveforms import AverageWaveforms, AverageWaveformItem
|
|
12
13
|
from .CrossCorrelograms import CrossCorrelograms, CrossCorrelogramItem
|
|
13
14
|
from .RasterPlot import RasterPlot
|
|
14
15
|
from .RasterPlotItem import RasterPlotItem
|
|
15
16
|
from .SpikeAmplitudes import SpikeAmplitudes, SpikeAmplitudesItem
|
|
17
|
+
from .SpikeLocations import SpikeLocations, SpikeLocationsItem
|
|
16
18
|
from .UnitLocations import UnitLocations, UnitLocationsItem
|
|
17
19
|
from .UnitMetricsGraph import (
|
|
18
20
|
UnitMetricsGraph,
|
|
@@ -29,6 +31,7 @@ __all__ = [
|
|
|
29
31
|
"UnitsTableColumn",
|
|
30
32
|
"UnitsTable",
|
|
31
33
|
"UnitSimilarityScore",
|
|
34
|
+
"UnitSimilarityMatrix",
|
|
32
35
|
"AverageWaveforms",
|
|
33
36
|
"AverageWaveformItem",
|
|
34
37
|
"CrossCorrelograms",
|
|
@@ -37,6 +40,8 @@ __all__ = [
|
|
|
37
40
|
"RasterPlotItem",
|
|
38
41
|
"SpikeAmplitudes",
|
|
39
42
|
"SpikeAmplitudesItem",
|
|
43
|
+
"SpikeLocations",
|
|
44
|
+
"SpikeLocationsItem",
|
|
40
45
|
"UnitLocations",
|
|
41
46
|
"UnitLocationsItem",
|
|
42
47
|
"UnitMetricsGraph",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
figpack_spike_sorting/__init__.py,sha256=
|
|
2
|
-
figpack_spike_sorting/figpack_spike_sorting.js,sha256=
|
|
1
|
+
figpack_spike_sorting/__init__.py,sha256=KmrACoB-IMTH3OdbGdJt4N1jk2huodjYbRErU6P2rlM,101
|
|
2
|
+
figpack_spike_sorting/figpack_spike_sorting.js,sha256=TMfa_sfgauvw1CL4LXXkiTv0AjA2CeU6fLe1iC6f7Yw,1521126
|
|
3
3
|
figpack_spike_sorting/spike_sorting_extension.py,sha256=ugpk8hDsO4RmyQRNjfhB4Pw5p10FmhQeu3koBynSPHU,755
|
|
4
4
|
figpack_spike_sorting/style.css,sha256=R4pcnrpSMpOsBn7X1t-JBP8ODktsc5e8o95Fl_0LVps,3208
|
|
5
5
|
figpack_spike_sorting/views/AutocorrelogramItem.py,sha256=qHmvIdHpbfVA_utPb5N2oP3hSP2cGnlT8VLaxOXV4UM,738
|
|
@@ -12,15 +12,17 @@ figpack_spike_sorting/views/RasterPlotItem.py,sha256=iW7fuDEjSfvf5YMIwrF_6cmKvD7
|
|
|
12
12
|
figpack_spike_sorting/views/SortingCuration.py,sha256=J3p9vrhbnRt05qeihZk_i6EBWDcTGYs293WVW_9qLSk,1243
|
|
13
13
|
figpack_spike_sorting/views/SpikeAmplitudes.py,sha256=H_VV0Z1kAVCztNaTYnOW8tqyu6FLtgFPWNrlmokVKeI,13290
|
|
14
14
|
figpack_spike_sorting/views/SpikeAmplitudesItem.py,sha256=j5Na-diY-vRUAPu0t0VkyFCSKFnQ_f5HT077mB3Cy8c,1134
|
|
15
|
+
figpack_spike_sorting/views/SpikeLocations.py,sha256=uSJVGZZ8nen1YOjePTA7SAQD8RtOzLTeQmKNQqKhUrs,4485
|
|
15
16
|
figpack_spike_sorting/views/TiledImage.py,sha256=_nvFhvRoGWd7MN84d9CphB0bK4j0txlx035zm-hCDic,5457
|
|
16
17
|
figpack_spike_sorting/views/UnitLocations.py,sha256=K18oJFnKshn0fZ9NtgKXcWGroJGc_OaF3f_ZEEInZPA,2336
|
|
17
18
|
figpack_spike_sorting/views/UnitMetricsGraph.py,sha256=8YZo2-5d-RHKSfyUKYAfDvW9hZDCTzmnUAyb3fPWo3I,3373
|
|
19
|
+
figpack_spike_sorting/views/UnitSimilarityMatrix.py,sha256=fO1vC9Ih-UipjczOqlsZCE0jQl35DLVaPQ75JwIqxlE,1880
|
|
18
20
|
figpack_spike_sorting/views/UnitSimilarityScore.py,sha256=cJA9MkETos9qHhV1tqgA7SfNEaPo-duXYCE76hSFGnA,948
|
|
19
21
|
figpack_spike_sorting/views/UnitsTable.py,sha256=8aluJ2tCnwsFOLbjbJDyY2z1ml9VK7Sz5_bxdRUAeDI,2758
|
|
20
22
|
figpack_spike_sorting/views/UnitsTableColumn.py,sha256=zBnuoeILTuiVLDvtcOxqa37E5WlbR12rlwNJUeWXxY4,847
|
|
21
23
|
figpack_spike_sorting/views/UnitsTableRow.py,sha256=rEb2hMTA_pl2fTW1nOvnGir0ysfNx4uww3aekZzfWjk,720
|
|
22
|
-
figpack_spike_sorting/views/__init__.py,sha256=
|
|
23
|
-
figpack_spike_sorting-0.1.
|
|
24
|
-
figpack_spike_sorting-0.1.
|
|
25
|
-
figpack_spike_sorting-0.1.
|
|
26
|
-
figpack_spike_sorting-0.1.
|
|
24
|
+
figpack_spike_sorting/views/__init__.py,sha256=_Ffl0GtgA5hgVRt1hLlod60nGmgTbwplaPPS59uC2hA,1603
|
|
25
|
+
figpack_spike_sorting-0.1.12.dist-info/METADATA,sha256=R9AIdvxvGLasVI5O5-6XQJv6aHSINYjJ329k6P9V84g,1219
|
|
26
|
+
figpack_spike_sorting-0.1.12.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
27
|
+
figpack_spike_sorting-0.1.12.dist-info/top_level.txt,sha256=CAkWrQc1wGK5laYDkT2GBjGgAuNwWNXKodTQlTcpxus,22
|
|
28
|
+
figpack_spike_sorting-0.1.12.dist-info/RECORD,,
|
|
File without changes
|
{figpack_spike_sorting-0.1.10.dist-info → figpack_spike_sorting-0.1.12.dist-info}/top_level.txt
RENAMED
|
File without changes
|