figpack 0.2.15__tar.gz → 0.2.16__tar.gz
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.
Potentially problematic release.
This version of figpack might be problematic. Click here for more details.
- {figpack-0.2.15/figpack.egg-info → figpack-0.2.16}/PKG-INFO +21 -2
- {figpack-0.2.15 → figpack-0.2.16}/figpack/__init__.py +3 -1
- {figpack-0.2.15 → figpack-0.2.16}/figpack/core/_bundle_utils.py +24 -15
- {figpack-0.2.15 → figpack-0.2.16}/figpack/core/_view_figure.py +1 -1
- {figpack-0.2.15 → figpack-0.2.16}/figpack/core/extension_view.py +2 -2
- {figpack-0.2.15 → figpack-0.2.16}/figpack/core/figpack_view.py +2 -2
- figpack-0.2.16/figpack/core/zarr.py +61 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/franklab/views/TrackAnimation.py +2 -1
- {figpack-0.2.15 → figpack-0.2.16}/figpack/spike_sorting/views/Autocorrelograms.py +3 -5
- {figpack-0.2.15 → figpack-0.2.16}/figpack/spike_sorting/views/AverageWaveforms.py +2 -3
- {figpack-0.2.15 → figpack-0.2.16}/figpack/spike_sorting/views/CrossCorrelograms.py +2 -3
- {figpack-0.2.15 → figpack-0.2.16}/figpack/spike_sorting/views/RasterPlot.py +2 -6
- {figpack-0.2.15 → figpack-0.2.16}/figpack/spike_sorting/views/SpikeAmplitudes.py +2 -12
- {figpack-0.2.15 → figpack-0.2.16}/figpack/spike_sorting/views/UnitMetricsGraph.py +2 -4
- {figpack-0.2.15 → figpack-0.2.16}/figpack/spike_sorting/views/UnitsTable.py +2 -9
- {figpack-0.2.15 → figpack-0.2.16}/figpack/views/Box.py +2 -3
- {figpack-0.2.15 → figpack-0.2.16}/figpack/views/DataFrame.py +6 -12
- {figpack-0.2.15 → figpack-0.2.16}/figpack/views/Gallery.py +2 -3
- {figpack-0.2.15 → figpack-0.2.16}/figpack/views/Image.py +3 -9
- {figpack-0.2.15 → figpack-0.2.16}/figpack/views/Markdown.py +3 -4
- {figpack-0.2.15 → figpack-0.2.16}/figpack/views/MatplotlibFigure.py +2 -11
- {figpack-0.2.15 → figpack-0.2.16}/figpack/views/MultiChannelTimeseries.py +2 -6
- {figpack-0.2.15 → figpack-0.2.16}/figpack/views/PlotlyExtension/PlotlyExtension.py +7 -13
- {figpack-0.2.15 → figpack-0.2.16}/figpack/views/Spectrogram.py +2 -7
- {figpack-0.2.15 → figpack-0.2.16}/figpack/views/Splitter.py +2 -3
- {figpack-0.2.15 → figpack-0.2.16}/figpack/views/TabLayout.py +2 -3
- {figpack-0.2.15 → figpack-0.2.16}/figpack/views/TimeseriesGraph.py +6 -10
- {figpack-0.2.15 → figpack-0.2.16/figpack.egg-info}/PKG-INFO +21 -2
- {figpack-0.2.15 → figpack-0.2.16}/figpack.egg-info/SOURCES.txt +1 -1
- {figpack-0.2.15 → figpack-0.2.16}/figpack.egg-info/requires.txt +22 -1
- {figpack-0.2.15 → figpack-0.2.16}/pyproject.toml +25 -3
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_average_waveforms.py +9 -6
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_box.py +5 -2
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_cli.py +0 -1
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_core.py +4 -4
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_dataframe.py +19 -20
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_gallery.py +5 -5
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_image.py +7 -5
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_markdown.py +11 -9
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_matplotlib_figure.py +12 -20
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_multichannel_timeseries.py +6 -4
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_plotly_figure.py +8 -10
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_raster_plot.py +7 -2
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_server_manager.py +0 -6
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_spectrogram.py +4 -42
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_spike_amplitudes.py +7 -83
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_spike_sorting_correlograms.py +19 -10
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_splitter.py +6 -4
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_tablayout.py +8 -6
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_timeseries_graph.py +4 -2
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_track_animation.py +4 -3
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_units_table.py +15 -15
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_upload_bundle.py +0 -7
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_view_figure.py +1 -3
- figpack-0.2.15/tests/test_show_view.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/LICENSE +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/MANIFEST.in +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/README.md +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/cli.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/core/__init__.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/core/_save_figure.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/core/_server_manager.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/core/_show_view.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/core/_upload_bundle.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/core/config.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/core/figpack_extension.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/figpack-figure-dist/assets/index-D9a3K6eW.css +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/figpack-figure-dist/assets/index-DtOnN02w.js +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/figpack-figure-dist/assets/neurosift-logo-CLsuwLMO.png +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/figpack-figure-dist/index.html +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/franklab/__init__.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/franklab/views/__init__.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/spike_sorting/__init__.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/spike_sorting/views/AutocorrelogramItem.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/spike_sorting/views/CrossCorrelogramItem.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/spike_sorting/views/RasterPlotItem.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/spike_sorting/views/SpikeAmplitudesItem.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/spike_sorting/views/UnitSimilarityScore.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/spike_sorting/views/UnitsTableColumn.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/spike_sorting/views/UnitsTableRow.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/spike_sorting/views/__init__.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/views/GalleryItem.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/views/LayoutItem.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/views/PlotlyExtension/__init__.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/views/PlotlyExtension/plotly_view.js +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/views/TabLayoutItem.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack/views/__init__.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack.egg-info/dependency_links.txt +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack.egg-info/entry_points.txt +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/figpack.egg-info/top_level.txt +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/setup.cfg +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_extension_system.py +0 -0
- {figpack-0.2.15 → figpack-0.2.16}/tests/test_figpack_view.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: figpack
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.16
|
|
4
4
|
Summary: A Python package for creating shareable, interactive visualizations in the browser
|
|
5
5
|
Author-email: Jeremy Magland <jmagland@flatironinstitute.org>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -25,7 +25,7 @@ Requires-Python: >=3.8
|
|
|
25
25
|
Description-Content-Type: text/markdown
|
|
26
26
|
License-File: LICENSE
|
|
27
27
|
Requires-Dist: numpy
|
|
28
|
-
Requires-Dist: zarr
|
|
28
|
+
Requires-Dist: zarr
|
|
29
29
|
Requires-Dist: requests
|
|
30
30
|
Requires-Dist: psutil
|
|
31
31
|
Provides-Extra: test
|
|
@@ -37,6 +37,25 @@ Requires-Dist: matplotlib; extra == "test"
|
|
|
37
37
|
Requires-Dist: plotly; extra == "test"
|
|
38
38
|
Requires-Dist: Pillow; extra == "test"
|
|
39
39
|
Requires-Dist: pandas; extra == "test"
|
|
40
|
+
Provides-Extra: test-zarr2
|
|
41
|
+
Requires-Dist: pytest>=7.0; extra == "test-zarr2"
|
|
42
|
+
Requires-Dist: pytest-cov>=4.0; extra == "test-zarr2"
|
|
43
|
+
Requires-Dist: pytest-mock>=3.10; extra == "test-zarr2"
|
|
44
|
+
Requires-Dist: spikeinterface; extra == "test-zarr2"
|
|
45
|
+
Requires-Dist: matplotlib; extra == "test-zarr2"
|
|
46
|
+
Requires-Dist: plotly; extra == "test-zarr2"
|
|
47
|
+
Requires-Dist: Pillow; extra == "test-zarr2"
|
|
48
|
+
Requires-Dist: pandas; extra == "test-zarr2"
|
|
49
|
+
Requires-Dist: zarr<3; extra == "test-zarr2"
|
|
50
|
+
Provides-Extra: test-zarr3
|
|
51
|
+
Requires-Dist: pytest>=7.0; extra == "test-zarr3"
|
|
52
|
+
Requires-Dist: pytest-cov>=4.0; extra == "test-zarr3"
|
|
53
|
+
Requires-Dist: pytest-mock>=3.10; extra == "test-zarr3"
|
|
54
|
+
Requires-Dist: matplotlib; extra == "test-zarr3"
|
|
55
|
+
Requires-Dist: plotly; extra == "test-zarr3"
|
|
56
|
+
Requires-Dist: Pillow; extra == "test-zarr3"
|
|
57
|
+
Requires-Dist: pandas; extra == "test-zarr3"
|
|
58
|
+
Requires-Dist: zarr>=3; extra == "test-zarr3"
|
|
40
59
|
Provides-Extra: dev
|
|
41
60
|
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
42
61
|
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
figpack - A Python package for creating shareable, interactive visualizations in the browser
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
__version__ = "0.2.
|
|
5
|
+
__version__ = "0.2.16"
|
|
6
6
|
|
|
7
7
|
from .cli import view_figure
|
|
8
8
|
from .core import FigpackView, FigpackExtension, ExtensionRegistry, ExtensionView
|
|
9
|
+
from .core.zarr import Group
|
|
9
10
|
|
|
10
11
|
__all__ = [
|
|
11
12
|
"view_figure",
|
|
@@ -13,4 +14,5 @@ __all__ = [
|
|
|
13
14
|
"FigpackExtension",
|
|
14
15
|
"ExtensionRegistry",
|
|
15
16
|
"ExtensionView",
|
|
17
|
+
"Group",
|
|
16
18
|
]
|
|
@@ -7,6 +7,7 @@ import zarr
|
|
|
7
7
|
from .figpack_view import FigpackView
|
|
8
8
|
from .figpack_extension import ExtensionRegistry
|
|
9
9
|
from .extension_view import ExtensionView
|
|
10
|
+
from .zarr import Group, _check_zarr_version
|
|
10
11
|
|
|
11
12
|
thisdir = pathlib.Path(__file__).parent.resolve()
|
|
12
13
|
|
|
@@ -45,24 +46,32 @@ def prepare_figure_bundle(
|
|
|
45
46
|
target_sub = target / subitem.name
|
|
46
47
|
target_sub.write_bytes(subitem.read_bytes())
|
|
47
48
|
|
|
48
|
-
#
|
|
49
|
-
|
|
50
|
-
pathlib.Path(tmpdir) / "data.zarr",
|
|
51
|
-
mode="w",
|
|
52
|
-
synchronizer=zarr.ThreadSynchronizer(),
|
|
53
|
-
)
|
|
54
|
-
view._write_to_zarr_group(zarr_group)
|
|
49
|
+
# If we are using zarr 3, then we set the default zarr format to 2 temporarily
|
|
50
|
+
# because we only support version 2 on the frontend right now.
|
|
55
51
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
zarr_group.attrs["description"] = description
|
|
52
|
+
if _check_zarr_version() == 3:
|
|
53
|
+
old_default_zarr_format = zarr.config.get("default_zarr_format")
|
|
54
|
+
zarr.config.set({"default_zarr_format": 2})
|
|
60
55
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
try:
|
|
57
|
+
# Write the view data to the Zarr group
|
|
58
|
+
zarr_group = zarr.open_group(pathlib.Path(tmpdir) / "data.zarr", mode="w")
|
|
59
|
+
zarr_group = Group(zarr_group)
|
|
60
|
+
view._write_to_zarr_group(zarr_group)
|
|
64
61
|
|
|
65
|
-
|
|
62
|
+
# Add title and description as attributes on the top-level zarr group
|
|
63
|
+
zarr_group.attrs["title"] = title
|
|
64
|
+
if description is not None:
|
|
65
|
+
zarr_group.attrs["description"] = description
|
|
66
|
+
|
|
67
|
+
# Discover and write extension JavaScript files
|
|
68
|
+
required_extensions = _discover_required_extensions(view)
|
|
69
|
+
_write_extension_files(required_extensions, tmpdir)
|
|
70
|
+
|
|
71
|
+
zarr.consolidate_metadata(zarr_group._zarr_group.store)
|
|
72
|
+
finally:
|
|
73
|
+
if _check_zarr_version() == 3:
|
|
74
|
+
zarr.config.set({"default_zarr_format": old_default_zarr_format})
|
|
66
75
|
|
|
67
76
|
|
|
68
77
|
def _discover_required_extensions(view: FigpackView) -> Set[str]:
|
|
@@ -109,7 +109,7 @@ def view_figure(figure_path: str, port: Union[int, None] = None) -> None:
|
|
|
109
109
|
|
|
110
110
|
try:
|
|
111
111
|
with tarfile.open(figure_path, "r:gz") as tar:
|
|
112
|
-
tar.extractall(temp_path)
|
|
112
|
+
tar.extractall(temp_path, filter="data")
|
|
113
113
|
|
|
114
114
|
# Count extracted files
|
|
115
115
|
extracted_files = list(temp_path.rglob("*"))
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Base class for views that use figpack extensions
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
import zarr
|
|
6
5
|
from .figpack_view import FigpackView
|
|
7
6
|
from .figpack_extension import ExtensionRegistry
|
|
7
|
+
from ..core.zarr import Group
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class ExtensionView(FigpackView):
|
|
@@ -32,7 +32,7 @@ class ExtensionView(FigpackView):
|
|
|
32
32
|
)
|
|
33
33
|
self.extension = extension
|
|
34
34
|
|
|
35
|
-
def _write_to_zarr_group(self, group:
|
|
35
|
+
def _write_to_zarr_group(self, group: Group) -> None:
|
|
36
36
|
"""
|
|
37
37
|
Write the extension view metadata to a Zarr group.
|
|
38
38
|
Subclasses should call super()._write_to_zarr_group(group) first,
|
|
@@ -7,7 +7,7 @@ import random
|
|
|
7
7
|
import string
|
|
8
8
|
from typing import Union
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
from .zarr import Group
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class FigpackView:
|
|
@@ -155,7 +155,7 @@ class FigpackView:
|
|
|
155
155
|
|
|
156
156
|
_save_figure(self, output_path, title=title)
|
|
157
157
|
|
|
158
|
-
def _write_to_zarr_group(self, group:
|
|
158
|
+
def _write_to_zarr_group(self, group: Group) -> None:
|
|
159
159
|
"""
|
|
160
160
|
Write the view data to a Zarr group. Must be implemented by subclasses.
|
|
161
161
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
from typing import Any, Dict
|
|
2
|
+
import zarr
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
_UNSPECIFIED = object()
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Group:
|
|
9
|
+
def __init__(self, zarr_group: zarr.Group):
|
|
10
|
+
self._zarr_group = zarr_group
|
|
11
|
+
|
|
12
|
+
def create_group(self, name: str) -> "Group":
|
|
13
|
+
return Group(self._zarr_group.create_group(name))
|
|
14
|
+
|
|
15
|
+
def create_dataset(
|
|
16
|
+
self,
|
|
17
|
+
name: str,
|
|
18
|
+
*,
|
|
19
|
+
data=_UNSPECIFIED,
|
|
20
|
+
dtype=_UNSPECIFIED,
|
|
21
|
+
chunks=_UNSPECIFIED,
|
|
22
|
+
compressor=_UNSPECIFIED,
|
|
23
|
+
) -> None:
|
|
24
|
+
kwargs = {}
|
|
25
|
+
if data is not _UNSPECIFIED:
|
|
26
|
+
kwargs["data"] = data
|
|
27
|
+
if dtype is not _UNSPECIFIED:
|
|
28
|
+
kwargs["dtype"] = dtype
|
|
29
|
+
if chunks is not _UNSPECIFIED:
|
|
30
|
+
kwargs["chunks"] = chunks
|
|
31
|
+
if compressor is not _UNSPECIFIED:
|
|
32
|
+
kwargs["compressor"] = compressor
|
|
33
|
+
if _check_zarr_version() == 2:
|
|
34
|
+
self._zarr_group.create_dataset(name, **kwargs)
|
|
35
|
+
elif _check_zarr_version() == 3:
|
|
36
|
+
self._zarr_group.create_array(name, **kwargs)
|
|
37
|
+
else:
|
|
38
|
+
raise RuntimeError("Unsupported Zarr version")
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def attrs(self) -> Dict[str, Any]:
|
|
42
|
+
return self._zarr_group.attrs
|
|
43
|
+
|
|
44
|
+
def __getitem__(self, key: str) -> Any:
|
|
45
|
+
return self._zarr_group[key]
|
|
46
|
+
|
|
47
|
+
# implement in operator
|
|
48
|
+
def __contains__(self, key: str) -> bool:
|
|
49
|
+
return key in self._zarr_group
|
|
50
|
+
|
|
51
|
+
def __iter__(self):
|
|
52
|
+
return iter(self._zarr_group)
|
|
53
|
+
|
|
54
|
+
def __reversed__(self):
|
|
55
|
+
return reversed(self._zarr_group)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _check_zarr_version():
|
|
59
|
+
version = zarr.__version__
|
|
60
|
+
major_version = int(version.split(".")[0])
|
|
61
|
+
return major_version
|
|
@@ -8,6 +8,7 @@ import numpy as np
|
|
|
8
8
|
import zarr
|
|
9
9
|
|
|
10
10
|
from ...core.figpack_view import FigpackView
|
|
11
|
+
from ...core.zarr import Group
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
class TrackAnimation(FigpackView):
|
|
@@ -116,7 +117,7 @@ class TrackAnimation(FigpackView):
|
|
|
116
117
|
self.track_bin_height = track_bin_height
|
|
117
118
|
self.track_bin_width = track_bin_width
|
|
118
119
|
|
|
119
|
-
def _write_to_zarr_group(self, group:
|
|
120
|
+
def _write_to_zarr_group(self, group: Group) -> None:
|
|
120
121
|
"""
|
|
121
122
|
Write the track animation data to a Zarr group
|
|
122
123
|
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Autocorrelograms view for figpack - displays multiple autocorrelograms
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from typing import List
|
|
5
|
+
from typing import List
|
|
6
6
|
|
|
7
7
|
import numpy as np
|
|
8
|
-
import zarr
|
|
9
8
|
|
|
10
9
|
from ...core.figpack_view import FigpackView
|
|
10
|
+
from ...core.zarr import Group
|
|
11
11
|
from .AutocorrelogramItem import AutocorrelogramItem
|
|
12
12
|
|
|
13
13
|
|
|
@@ -66,7 +66,7 @@ class Autocorrelograms(FigpackView):
|
|
|
66
66
|
view = Autocorrelograms(autocorrelograms=ac_items)
|
|
67
67
|
return view
|
|
68
68
|
|
|
69
|
-
def _write_to_zarr_group(self, group:
|
|
69
|
+
def _write_to_zarr_group(self, group: Group) -> None:
|
|
70
70
|
"""
|
|
71
71
|
Write the Autocorrelograms data to a Zarr group
|
|
72
72
|
|
|
@@ -90,7 +90,6 @@ class Autocorrelograms(FigpackView):
|
|
|
90
90
|
group.create_dataset(
|
|
91
91
|
"bin_edges_sec",
|
|
92
92
|
data=self.autocorrelograms[0].bin_edges_sec,
|
|
93
|
-
dtype=np.float32,
|
|
94
93
|
)
|
|
95
94
|
|
|
96
95
|
# Create 2D array for all bin counts
|
|
@@ -111,7 +110,6 @@ class Autocorrelograms(FigpackView):
|
|
|
111
110
|
group.create_dataset(
|
|
112
111
|
"bin_counts",
|
|
113
112
|
data=bin_counts,
|
|
114
|
-
dtype=np.int32,
|
|
115
113
|
)
|
|
116
114
|
|
|
117
115
|
# Store the autocorrelogram metadata
|
|
@@ -8,6 +8,7 @@ import numpy as np
|
|
|
8
8
|
import zarr
|
|
9
9
|
|
|
10
10
|
from ...core.figpack_view import FigpackView
|
|
11
|
+
from ...core.zarr import Group
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
class AverageWaveformItem:
|
|
@@ -97,7 +98,7 @@ class AverageWaveforms(FigpackView):
|
|
|
97
98
|
view = AverageWaveforms(average_waveforms=average_waveform_items)
|
|
98
99
|
return view
|
|
99
100
|
|
|
100
|
-
def _write_to_zarr_group(self, group:
|
|
101
|
+
def _write_to_zarr_group(self, group: Group) -> None:
|
|
101
102
|
"""
|
|
102
103
|
Write the AverageWaveforms data to a Zarr group
|
|
103
104
|
|
|
@@ -127,13 +128,11 @@ class AverageWaveforms(FigpackView):
|
|
|
127
128
|
group.create_dataset(
|
|
128
129
|
f"{waveform_name}/waveform",
|
|
129
130
|
data=waveform.waveform,
|
|
130
|
-
dtype=waveform.waveform.dtype,
|
|
131
131
|
)
|
|
132
132
|
if waveform.waveform_std_dev is not None:
|
|
133
133
|
group.create_dataset(
|
|
134
134
|
f"{waveform_name}/waveform_std_dev",
|
|
135
135
|
data=waveform.waveform_std_dev,
|
|
136
|
-
dtype=waveform.waveform_std_dev.dtype,
|
|
137
136
|
)
|
|
138
137
|
if waveform.waveform_percentiles is not None:
|
|
139
138
|
for j, p in enumerate(waveform.waveform_percentiles):
|
|
@@ -8,6 +8,7 @@ import numpy as np
|
|
|
8
8
|
import zarr
|
|
9
9
|
|
|
10
10
|
from ...core.figpack_view import FigpackView
|
|
11
|
+
from ...core.zarr import Group
|
|
11
12
|
from .CrossCorrelogramItem import CrossCorrelogramItem
|
|
12
13
|
|
|
13
14
|
|
|
@@ -75,7 +76,7 @@ class CrossCorrelograms(FigpackView):
|
|
|
75
76
|
view = CrossCorrelograms(cross_correlograms=cc_items, hide_unit_selector=False)
|
|
76
77
|
return view
|
|
77
78
|
|
|
78
|
-
def _write_to_zarr_group(self, group:
|
|
79
|
+
def _write_to_zarr_group(self, group: Group) -> None:
|
|
79
80
|
"""
|
|
80
81
|
Write the CrossCorrelograms data to a Zarr group
|
|
81
82
|
|
|
@@ -103,7 +104,6 @@ class CrossCorrelograms(FigpackView):
|
|
|
103
104
|
group.create_dataset(
|
|
104
105
|
"bin_edges_sec",
|
|
105
106
|
data=self.cross_correlograms[0].bin_edges_sec,
|
|
106
|
-
dtype=np.float32,
|
|
107
107
|
)
|
|
108
108
|
|
|
109
109
|
# Create 2D array for all bin counts
|
|
@@ -125,7 +125,6 @@ class CrossCorrelograms(FigpackView):
|
|
|
125
125
|
group.create_dataset(
|
|
126
126
|
"bin_counts",
|
|
127
127
|
data=bin_counts,
|
|
128
|
-
dtype=np.int32,
|
|
129
128
|
)
|
|
130
129
|
|
|
131
130
|
# Store the cross-correlogram metadata
|
|
@@ -7,6 +7,7 @@ import numpy as np
|
|
|
7
7
|
import zarr
|
|
8
8
|
|
|
9
9
|
from ...core.figpack_view import FigpackView
|
|
10
|
+
from ...core.zarr import Group
|
|
10
11
|
from .RasterPlotItem import RasterPlotItem
|
|
11
12
|
from .UnitsTable import UnitsTable, UnitsTableColumn, UnitsTableRow
|
|
12
13
|
from ...views.Box import Box, LayoutItem
|
|
@@ -105,7 +106,7 @@ class RasterPlot(FigpackView):
|
|
|
105
106
|
else:
|
|
106
107
|
return view
|
|
107
108
|
|
|
108
|
-
def _write_to_zarr_group(self, group:
|
|
109
|
+
def _write_to_zarr_group(self, group: Group) -> None:
|
|
109
110
|
"""
|
|
110
111
|
Args:
|
|
111
112
|
group: Zarr group to write data into
|
|
@@ -141,25 +142,21 @@ class RasterPlot(FigpackView):
|
|
|
141
142
|
group.create_dataset(
|
|
142
143
|
"timestamps",
|
|
143
144
|
data=unified_data["timestamps"],
|
|
144
|
-
dtype=np.float32,
|
|
145
145
|
chunks=chunks,
|
|
146
146
|
)
|
|
147
147
|
group.create_dataset(
|
|
148
148
|
"unit_indices",
|
|
149
149
|
data=unified_data["unit_indices"],
|
|
150
|
-
dtype=np.uint16,
|
|
151
150
|
chunks=chunks,
|
|
152
151
|
)
|
|
153
152
|
group.create_dataset(
|
|
154
153
|
"reference_times",
|
|
155
154
|
data=unified_data["reference_times"],
|
|
156
|
-
dtype=np.float32,
|
|
157
155
|
chunks=(len(unified_data["reference_times"]),),
|
|
158
156
|
)
|
|
159
157
|
group.create_dataset(
|
|
160
158
|
"reference_indices",
|
|
161
159
|
data=unified_data["reference_indices"],
|
|
162
|
-
dtype=np.uint32,
|
|
163
160
|
chunks=(len(unified_data["reference_indices"]),),
|
|
164
161
|
)
|
|
165
162
|
|
|
@@ -188,7 +185,6 @@ class RasterPlot(FigpackView):
|
|
|
188
185
|
group.create_dataset(
|
|
189
186
|
"spike_counts_1sec",
|
|
190
187
|
data=spike_counts,
|
|
191
|
-
dtype=np.uint16,
|
|
192
188
|
chunks=(min(num_bins, 10000), min(num_units, 500)),
|
|
193
189
|
)
|
|
194
190
|
|
|
@@ -5,9 +5,9 @@ SpikeAmplitudes view for figpack - displays spike amplitudes over time
|
|
|
5
5
|
from typing import List
|
|
6
6
|
|
|
7
7
|
import numpy as np
|
|
8
|
-
import zarr
|
|
9
8
|
|
|
10
9
|
from ...core.figpack_view import FigpackView
|
|
10
|
+
from ...core.zarr import Group
|
|
11
11
|
from .SpikeAmplitudesItem import SpikeAmplitudesItem
|
|
12
12
|
from .UnitsTable import UnitsTable, UnitsTableColumn, UnitsTableRow
|
|
13
13
|
from ...views.Box import Box, LayoutItem
|
|
@@ -112,7 +112,7 @@ class SpikeAmplitudes(FigpackView):
|
|
|
112
112
|
else:
|
|
113
113
|
return view
|
|
114
114
|
|
|
115
|
-
def _write_to_zarr_group(self, group:
|
|
115
|
+
def _write_to_zarr_group(self, group: Group) -> None:
|
|
116
116
|
"""
|
|
117
117
|
Write the SpikeAmplitudes data to a Zarr group using unified storage format
|
|
118
118
|
|
|
@@ -151,31 +151,26 @@ class SpikeAmplitudes(FigpackView):
|
|
|
151
151
|
group.create_dataset(
|
|
152
152
|
"timestamps",
|
|
153
153
|
data=unified_data["timestamps"],
|
|
154
|
-
dtype=np.float32,
|
|
155
154
|
chunks=chunks,
|
|
156
155
|
)
|
|
157
156
|
group.create_dataset(
|
|
158
157
|
"unit_indices",
|
|
159
158
|
data=unified_data["unit_indices"],
|
|
160
|
-
dtype=np.uint16,
|
|
161
159
|
chunks=chunks,
|
|
162
160
|
)
|
|
163
161
|
group.create_dataset(
|
|
164
162
|
"amplitudes",
|
|
165
163
|
data=unified_data["amplitudes"],
|
|
166
|
-
dtype=np.float32,
|
|
167
164
|
chunks=chunks,
|
|
168
165
|
)
|
|
169
166
|
group.create_dataset(
|
|
170
167
|
"reference_times",
|
|
171
168
|
data=unified_data["reference_times"],
|
|
172
|
-
dtype=np.float32,
|
|
173
169
|
chunks=(len(unified_data["reference_times"]),),
|
|
174
170
|
)
|
|
175
171
|
group.create_dataset(
|
|
176
172
|
"reference_indices",
|
|
177
173
|
data=unified_data["reference_indices"],
|
|
178
|
-
dtype=np.uint32,
|
|
179
174
|
chunks=(len(unified_data["reference_indices"]),),
|
|
180
175
|
)
|
|
181
176
|
|
|
@@ -202,31 +197,26 @@ class SpikeAmplitudes(FigpackView):
|
|
|
202
197
|
factor_group.create_dataset(
|
|
203
198
|
"timestamps",
|
|
204
199
|
data=data["timestamps"],
|
|
205
|
-
dtype=np.float32,
|
|
206
200
|
chunks=chunks,
|
|
207
201
|
)
|
|
208
202
|
factor_group.create_dataset(
|
|
209
203
|
"unit_indices",
|
|
210
204
|
data=data["unit_indices"],
|
|
211
|
-
dtype=np.uint16,
|
|
212
205
|
chunks=chunks,
|
|
213
206
|
)
|
|
214
207
|
factor_group.create_dataset(
|
|
215
208
|
"amplitudes",
|
|
216
209
|
data=data["amplitudes"],
|
|
217
|
-
dtype=np.float32,
|
|
218
210
|
chunks=chunks,
|
|
219
211
|
)
|
|
220
212
|
factor_group.create_dataset(
|
|
221
213
|
"reference_times",
|
|
222
214
|
data=data["reference_times"],
|
|
223
|
-
dtype=np.float32,
|
|
224
215
|
chunks=(len(data["reference_times"]),),
|
|
225
216
|
)
|
|
226
217
|
factor_group.create_dataset(
|
|
227
218
|
"reference_indices",
|
|
228
219
|
data=data["reference_indices"],
|
|
229
|
-
dtype=np.uint32,
|
|
230
220
|
chunks=(len(data["reference_indices"]),),
|
|
231
221
|
)
|
|
232
222
|
|
|
@@ -9,6 +9,7 @@ import numpy as np
|
|
|
9
9
|
import zarr
|
|
10
10
|
|
|
11
11
|
from ...core.figpack_view import FigpackView
|
|
12
|
+
from ...core.zarr import Group
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
class UnitMetricsGraphMetric:
|
|
@@ -97,7 +98,7 @@ class UnitMetricsGraph(FigpackView):
|
|
|
97
98
|
self.metrics = metrics
|
|
98
99
|
self.height = height
|
|
99
100
|
|
|
100
|
-
def _write_to_zarr_group(self, group:
|
|
101
|
+
def _write_to_zarr_group(self, group: Group) -> None:
|
|
101
102
|
"""
|
|
102
103
|
Write the UnitMetricsGraph data to a Zarr group
|
|
103
104
|
|
|
@@ -122,8 +123,5 @@ class UnitMetricsGraph(FigpackView):
|
|
|
122
123
|
group.create_dataset(
|
|
123
124
|
"units_data",
|
|
124
125
|
data=units_array,
|
|
125
|
-
dtype=np.uint8,
|
|
126
|
-
chunks=True,
|
|
127
|
-
compressor=zarr.Blosc(cname="zstd", clevel=3, shuffle=zarr.Blosc.SHUFFLE),
|
|
128
126
|
)
|
|
129
127
|
group.attrs["units_data_size"] = len(units_json)
|
|
@@ -9,6 +9,7 @@ import numpy as np
|
|
|
9
9
|
import zarr
|
|
10
10
|
|
|
11
11
|
from ...core.figpack_view import FigpackView
|
|
12
|
+
from ...core.zarr import Group
|
|
12
13
|
from .UnitSimilarityScore import UnitSimilarityScore
|
|
13
14
|
from .UnitsTableColumn import UnitsTableColumn
|
|
14
15
|
from .UnitsTableRow import UnitsTableRow
|
|
@@ -41,7 +42,7 @@ class UnitsTable(FigpackView):
|
|
|
41
42
|
self.similarity_scores = similarity_scores or []
|
|
42
43
|
self.height = height
|
|
43
44
|
|
|
44
|
-
def _write_to_zarr_group(self, group:
|
|
45
|
+
def _write_to_zarr_group(self, group: Group) -> None:
|
|
45
46
|
"""
|
|
46
47
|
Write the UnitsTable data to a Zarr group
|
|
47
48
|
|
|
@@ -66,9 +67,6 @@ class UnitsTable(FigpackView):
|
|
|
66
67
|
group.create_dataset(
|
|
67
68
|
"rows_data",
|
|
68
69
|
data=rows_array,
|
|
69
|
-
dtype=np.uint8,
|
|
70
|
-
chunks=True,
|
|
71
|
-
compressor=zarr.Blosc(cname="zstd", clevel=3, shuffle=zarr.Blosc.SHUFFLE),
|
|
72
70
|
)
|
|
73
71
|
group.attrs["rows_data_size"] = len(rows_json)
|
|
74
72
|
|
|
@@ -80,10 +78,5 @@ class UnitsTable(FigpackView):
|
|
|
80
78
|
group.create_dataset(
|
|
81
79
|
"similarity_scores_data",
|
|
82
80
|
data=scores_array,
|
|
83
|
-
dtype=np.uint8,
|
|
84
|
-
chunks=True,
|
|
85
|
-
compressor=zarr.Blosc(
|
|
86
|
-
cname="zstd", clevel=3, shuffle=zarr.Blosc.SHUFFLE
|
|
87
|
-
),
|
|
88
81
|
)
|
|
89
82
|
group.attrs["similarity_scores_data_size"] = len(scores_json)
|
|
@@ -4,9 +4,8 @@ Box view for figpack - a layout container that handles other views
|
|
|
4
4
|
|
|
5
5
|
from typing import Any, Dict, List, Literal, Optional
|
|
6
6
|
|
|
7
|
-
import zarr
|
|
8
|
-
|
|
9
7
|
from ..core.figpack_view import FigpackView
|
|
8
|
+
from ..core.zarr import Group
|
|
10
9
|
from .LayoutItem import LayoutItem
|
|
11
10
|
|
|
12
11
|
|
|
@@ -43,7 +42,7 @@ class Box(FigpackView):
|
|
|
43
42
|
self.items = items
|
|
44
43
|
self.title = title
|
|
45
44
|
|
|
46
|
-
def _write_to_zarr_group(self, group:
|
|
45
|
+
def _write_to_zarr_group(self, group: Group) -> None:
|
|
47
46
|
"""
|
|
48
47
|
Write the Box layout data to a Zarr group
|
|
49
48
|
|
|
@@ -3,13 +3,12 @@ DataFrame view for figpack - displays pandas DataFrames as interactive tables
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
import json
|
|
6
|
-
from typing import Any, Dict, Union
|
|
7
6
|
|
|
8
7
|
import numpy as np
|
|
9
|
-
import pandas as pd
|
|
10
8
|
import zarr
|
|
11
9
|
|
|
12
10
|
from ..core.figpack_view import FigpackView
|
|
11
|
+
from ..core.zarr import Group
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
class DataFrame(FigpackView):
|
|
@@ -17,7 +16,7 @@ class DataFrame(FigpackView):
|
|
|
17
16
|
A DataFrame visualization component for displaying pandas DataFrames as interactive tables
|
|
18
17
|
"""
|
|
19
18
|
|
|
20
|
-
def __init__(self, df
|
|
19
|
+
def __init__(self, df):
|
|
21
20
|
"""
|
|
22
21
|
Initialize a DataFrame view
|
|
23
22
|
|
|
@@ -27,12 +26,14 @@ class DataFrame(FigpackView):
|
|
|
27
26
|
Raises:
|
|
28
27
|
ValueError: If df is not a pandas DataFrame
|
|
29
28
|
"""
|
|
29
|
+
import pandas as pd
|
|
30
|
+
|
|
30
31
|
if not isinstance(df, pd.DataFrame):
|
|
31
32
|
raise ValueError("df must be a pandas DataFrame")
|
|
32
33
|
|
|
33
34
|
self.df = df
|
|
34
35
|
|
|
35
|
-
def _write_to_zarr_group(self, group:
|
|
36
|
+
def _write_to_zarr_group(self, group: Group) -> None:
|
|
36
37
|
"""
|
|
37
38
|
Write the DataFrame data to a Zarr group
|
|
38
39
|
|
|
@@ -54,11 +55,6 @@ class DataFrame(FigpackView):
|
|
|
54
55
|
group.create_dataset(
|
|
55
56
|
"csv_data",
|
|
56
57
|
data=csv_array,
|
|
57
|
-
dtype=np.uint8,
|
|
58
|
-
chunks=True,
|
|
59
|
-
compressor=zarr.Blosc(
|
|
60
|
-
cname="zstd", clevel=3, shuffle=zarr.Blosc.SHUFFLE
|
|
61
|
-
),
|
|
62
58
|
)
|
|
63
59
|
|
|
64
60
|
# Store metadata about the DataFrame
|
|
@@ -104,6 +100,4 @@ class DataFrame(FigpackView):
|
|
|
104
100
|
group.attrs["data_size"] = 0
|
|
105
101
|
group.attrs["column_info"] = "[]"
|
|
106
102
|
# Create empty array as placeholder
|
|
107
|
-
group.create_dataset(
|
|
108
|
-
"csv_data", data=np.array([], dtype=np.uint8), dtype=np.uint8
|
|
109
|
-
)
|
|
103
|
+
group.create_dataset("csv_data", data=np.array([], dtype=np.uint8))
|
|
@@ -4,9 +4,8 @@ Gallery view for figpack - a gallery layout container that handles other views w
|
|
|
4
4
|
|
|
5
5
|
from typing import Any, Dict, List, Optional
|
|
6
6
|
|
|
7
|
-
import zarr
|
|
8
|
-
|
|
9
7
|
from ..core.figpack_view import FigpackView
|
|
8
|
+
from ..core.zarr import Group
|
|
10
9
|
from .GalleryItem import GalleryItem
|
|
11
10
|
|
|
12
11
|
|
|
@@ -45,7 +44,7 @@ class Gallery(FigpackView):
|
|
|
45
44
|
max(0, min(initial_item_index, len(items) - 1)) if items else 0
|
|
46
45
|
)
|
|
47
46
|
|
|
48
|
-
def _write_to_zarr_group(self, group:
|
|
47
|
+
def _write_to_zarr_group(self, group: Group) -> None:
|
|
49
48
|
"""
|
|
50
49
|
Write the Gallery data to a Zarr group
|
|
51
50
|
|