figpack 0.2.14__py3-none-any.whl → 0.2.16__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.
Potentially problematic release.
This version of figpack might be problematic. Click here for more details.
- figpack/__init__.py +3 -1
- figpack/core/_bundle_utils.py +24 -15
- figpack/core/_view_figure.py +1 -1
- figpack/core/extension_view.py +2 -2
- figpack/core/figpack_view.py +2 -2
- figpack/core/zarr.py +61 -0
- figpack/figpack-figure-dist/assets/{index-F6uGre7p.js → index-DtOnN02w.js} +64 -64
- figpack/figpack-figure-dist/index.html +1 -1
- figpack/franklab/views/TrackAnimation.py +2 -1
- figpack/spike_sorting/views/Autocorrelograms.py +3 -5
- figpack/spike_sorting/views/AverageWaveforms.py +2 -3
- figpack/spike_sorting/views/CrossCorrelograms.py +2 -3
- figpack/spike_sorting/views/RasterPlot.py +2 -6
- figpack/spike_sorting/views/SpikeAmplitudes.py +2 -12
- figpack/spike_sorting/views/UnitMetricsGraph.py +2 -4
- figpack/spike_sorting/views/UnitsTable.py +2 -9
- figpack/views/Box.py +2 -3
- figpack/views/DataFrame.py +6 -12
- figpack/views/Gallery.py +2 -3
- figpack/views/Image.py +3 -9
- figpack/views/Markdown.py +3 -4
- figpack/views/MatplotlibFigure.py +2 -11
- figpack/views/MultiChannelTimeseries.py +2 -6
- figpack/views/PlotlyExtension/PlotlyExtension.py +7 -13
- figpack/views/Spectrogram.py +2 -7
- figpack/views/Splitter.py +2 -3
- figpack/views/TabLayout.py +2 -3
- figpack/views/TimeseriesGraph.py +6 -10
- {figpack-0.2.14.dist-info → figpack-0.2.16.dist-info}/METADATA +21 -2
- figpack-0.2.16.dist-info/RECORD +61 -0
- figpack-0.2.14.dist-info/RECORD +0 -60
- {figpack-0.2.14.dist-info → figpack-0.2.16.dist-info}/WHEEL +0 -0
- {figpack-0.2.14.dist-info → figpack-0.2.16.dist-info}/entry_points.txt +0 -0
- {figpack-0.2.14.dist-info → figpack-0.2.16.dist-info}/licenses/LICENSE +0 -0
- {figpack-0.2.14.dist-info → figpack-0.2.16.dist-info}/top_level.txt +0 -0
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/png" href="./assets/neurosift-logo-CLsuwLMO.png" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>figpack figure</title>
|
|
8
|
-
<script type="module" crossorigin src="./assets/index-
|
|
8
|
+
<script type="module" crossorigin src="./assets/index-DtOnN02w.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="./assets/index-D9a3K6eW.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
@@ -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)
|
figpack/views/Box.py
CHANGED
|
@@ -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
|
|
figpack/views/DataFrame.py
CHANGED
|
@@ -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))
|
figpack/views/Gallery.py
CHANGED
|
@@ -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
|
|
figpack/views/Image.py
CHANGED
|
@@ -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 Image(FigpackView):
|
|
@@ -69,7 +70,7 @@ class Image(FigpackView):
|
|
|
69
70
|
except Exception as e:
|
|
70
71
|
raise ValueError(f"Failed to download image from URL: {str(e)}")
|
|
71
72
|
|
|
72
|
-
def _write_to_zarr_group(self, group:
|
|
73
|
+
def _write_to_zarr_group(self, group: Group) -> None:
|
|
73
74
|
"""
|
|
74
75
|
Write the image data to a Zarr group
|
|
75
76
|
|
|
@@ -98,11 +99,6 @@ class Image(FigpackView):
|
|
|
98
99
|
group.create_dataset(
|
|
99
100
|
"image_data",
|
|
100
101
|
data=image_array,
|
|
101
|
-
dtype=np.uint8,
|
|
102
|
-
chunks=True,
|
|
103
|
-
compressor=zarr.Blosc(
|
|
104
|
-
cname="zstd", clevel=3, shuffle=zarr.Blosc.SHUFFLE
|
|
105
|
-
),
|
|
106
102
|
)
|
|
107
103
|
|
|
108
104
|
# Try to determine format from file signature
|
|
@@ -124,6 +120,4 @@ class Image(FigpackView):
|
|
|
124
120
|
group.attrs["image_format"] = "Unknown"
|
|
125
121
|
group.attrs["data_size"] = 0
|
|
126
122
|
# Create empty array as placeholder
|
|
127
|
-
group.create_dataset(
|
|
128
|
-
"image_data", data=np.array([], dtype=np.uint8), dtype=np.uint8
|
|
129
|
-
)
|
|
123
|
+
group.create_dataset("image_data", data=np.array([], dtype=np.uint8))
|
figpack/views/Markdown.py
CHANGED
|
@@ -6,6 +6,7 @@ import numpy as np
|
|
|
6
6
|
import zarr
|
|
7
7
|
|
|
8
8
|
from ..core.figpack_view import FigpackView
|
|
9
|
+
from ..core.zarr import Group
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class Markdown(FigpackView):
|
|
@@ -22,7 +23,7 @@ class Markdown(FigpackView):
|
|
|
22
23
|
"""
|
|
23
24
|
self.content = content
|
|
24
25
|
|
|
25
|
-
def _write_to_zarr_group(self, group:
|
|
26
|
+
def _write_to_zarr_group(self, group: Group) -> None:
|
|
26
27
|
"""
|
|
27
28
|
Write the markdown data to a Zarr group
|
|
28
29
|
|
|
@@ -37,9 +38,7 @@ class Markdown(FigpackView):
|
|
|
37
38
|
content_array = np.frombuffer(content_bytes, dtype=np.uint8)
|
|
38
39
|
|
|
39
40
|
# Store the markdown content as a zarr array
|
|
40
|
-
group.create_dataset(
|
|
41
|
-
"content_data", data=content_array, dtype=np.uint8, chunks=True
|
|
42
|
-
)
|
|
41
|
+
group.create_dataset("content_data", data=content_array, chunks=True)
|
|
43
42
|
|
|
44
43
|
# Store content size in attrs
|
|
45
44
|
group.attrs["data_size"] = len(content_bytes)
|
|
@@ -9,6 +9,7 @@ from typing import Any, Union
|
|
|
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 MatplotlibFigure(FigpackView):
|
|
@@ -25,7 +26,7 @@ class MatplotlibFigure(FigpackView):
|
|
|
25
26
|
"""
|
|
26
27
|
self.fig = fig
|
|
27
28
|
|
|
28
|
-
def _write_to_zarr_group(self, group:
|
|
29
|
+
def _write_to_zarr_group(self, group: Group) -> None:
|
|
29
30
|
"""
|
|
30
31
|
Write the matplotlib figure data to a Zarr group
|
|
31
32
|
|
|
@@ -54,11 +55,6 @@ class MatplotlibFigure(FigpackView):
|
|
|
54
55
|
group.create_dataset(
|
|
55
56
|
"svg_data",
|
|
56
57
|
data=svg_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 figure dimensions for reference
|
|
@@ -77,11 +73,6 @@ class MatplotlibFigure(FigpackView):
|
|
|
77
73
|
group.create_dataset(
|
|
78
74
|
"svg_data",
|
|
79
75
|
data=np.array([], dtype=np.uint8),
|
|
80
|
-
dtype=np.uint8,
|
|
81
|
-
chunks=True,
|
|
82
|
-
compressor=zarr.Blosc(
|
|
83
|
-
cname="zstd", clevel=3, shuffle=zarr.Blosc.SHUFFLE
|
|
84
|
-
),
|
|
85
76
|
)
|
|
86
77
|
group.attrs["error"] = f"Failed to export matplotlib figure: {str(e)}"
|
|
87
78
|
group.attrs["figure_width_inches"] = 6.0
|
|
@@ -6,9 +6,9 @@ import math
|
|
|
6
6
|
from typing import List, Optional, Union
|
|
7
7
|
|
|
8
8
|
import numpy as np
|
|
9
|
-
import zarr
|
|
10
9
|
|
|
11
10
|
from ..core.figpack_view import FigpackView
|
|
11
|
+
from ..core.zarr import Group
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class MultiChannelTimeseries(FigpackView):
|
|
@@ -174,7 +174,7 @@ class MultiChannelTimeseries(FigpackView):
|
|
|
174
174
|
else: # len(shape) == 3
|
|
175
175
|
return (chunk_timepoints, 2, n_channels)
|
|
176
176
|
|
|
177
|
-
def _write_to_zarr_group(self, group:
|
|
177
|
+
def _write_to_zarr_group(self, group: Group) -> None:
|
|
178
178
|
"""
|
|
179
179
|
Write the multi-channel timeseries data to a Zarr group
|
|
180
180
|
|
|
@@ -198,8 +198,6 @@ class MultiChannelTimeseries(FigpackView):
|
|
|
198
198
|
"data",
|
|
199
199
|
data=self.data,
|
|
200
200
|
chunks=original_chunks,
|
|
201
|
-
compression="blosc",
|
|
202
|
-
compression_opts={"cname": "lz4", "clevel": 5, "shuffle": 1},
|
|
203
201
|
)
|
|
204
202
|
|
|
205
203
|
# Store downsampled data arrays
|
|
@@ -216,8 +214,6 @@ class MultiChannelTimeseries(FigpackView):
|
|
|
216
214
|
dataset_name,
|
|
217
215
|
data=downsampled_array,
|
|
218
216
|
chunks=ds_chunks,
|
|
219
|
-
compression="blosc",
|
|
220
|
-
compression_opts={"cname": "lz4", "clevel": 5, "shuffle": 1},
|
|
221
217
|
)
|
|
222
218
|
|
|
223
219
|
print(
|
|
@@ -5,7 +5,7 @@ import urllib.request
|
|
|
5
5
|
import urllib.error
|
|
6
6
|
from datetime import date, datetime
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import figpack
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
def _download_plotly_library():
|
|
@@ -42,17 +42,17 @@ except Exception as e:
|
|
|
42
42
|
additional_files = {}
|
|
43
43
|
|
|
44
44
|
# Create and register the plotly extension
|
|
45
|
-
_plotly_extension = FigpackExtension(
|
|
45
|
+
_plotly_extension = figpack.FigpackExtension(
|
|
46
46
|
name="figpack_plotly",
|
|
47
47
|
javascript_code=_load_javascript_code(),
|
|
48
48
|
additional_files=additional_files,
|
|
49
49
|
version="1.0.0",
|
|
50
50
|
)
|
|
51
51
|
|
|
52
|
-
ExtensionRegistry.register(_plotly_extension)
|
|
52
|
+
figpack.ExtensionRegistry.register(_plotly_extension)
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
class PlotlyFigure(ExtensionView):
|
|
55
|
+
class PlotlyFigure(figpack.ExtensionView):
|
|
56
56
|
"""
|
|
57
57
|
A Plotly graph visualization view using the plotly library.
|
|
58
58
|
|
|
@@ -67,12 +67,12 @@ class PlotlyFigure(ExtensionView):
|
|
|
67
67
|
fig: The plotly figure object
|
|
68
68
|
"""
|
|
69
69
|
# for some reason, we need to reregister here to avoid issues with pytest
|
|
70
|
-
ExtensionRegistry.register(_plotly_extension)
|
|
70
|
+
figpack.ExtensionRegistry.register(_plotly_extension)
|
|
71
71
|
super().__init__(extension_name="figpack_plotly")
|
|
72
72
|
|
|
73
73
|
self.fig = fig
|
|
74
74
|
|
|
75
|
-
def _write_to_zarr_group(self, group:
|
|
75
|
+
def _write_to_zarr_group(self, group: figpack.Group) -> None:
|
|
76
76
|
"""
|
|
77
77
|
Write the plotly figure data to a Zarr group
|
|
78
78
|
|
|
@@ -92,13 +92,7 @@ class PlotlyFigure(ExtensionView):
|
|
|
92
92
|
json_array = np.frombuffer(json_bytes, dtype=np.uint8)
|
|
93
93
|
|
|
94
94
|
# Store the figure data as compressed array
|
|
95
|
-
group.create_dataset(
|
|
96
|
-
"figure_data",
|
|
97
|
-
data=json_array,
|
|
98
|
-
dtype=np.uint8,
|
|
99
|
-
chunks=True,
|
|
100
|
-
compressor=zarr.Blosc(cname="zstd", clevel=3, shuffle=zarr.Blosc.SHUFFLE),
|
|
101
|
-
)
|
|
95
|
+
group.create_dataset("figure_data", data=json_array)
|
|
102
96
|
|
|
103
97
|
# Store data size for reference
|
|
104
98
|
group.attrs["data_size"] = len(json_bytes)
|
figpack/views/Spectrogram.py
CHANGED
|
@@ -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 Spectrogram(FigpackView):
|
|
@@ -185,7 +186,7 @@ class Spectrogram(FigpackView):
|
|
|
185
186
|
|
|
186
187
|
return (chunk_timepoints, n_frequencies)
|
|
187
188
|
|
|
188
|
-
def _write_to_zarr_group(self, group:
|
|
189
|
+
def _write_to_zarr_group(self, group: Group) -> None:
|
|
189
190
|
"""
|
|
190
191
|
Write the spectrogram data to a Zarr group
|
|
191
192
|
|
|
@@ -212,8 +213,6 @@ class Spectrogram(FigpackView):
|
|
|
212
213
|
group.create_dataset(
|
|
213
214
|
"frequencies",
|
|
214
215
|
data=self.frequencies,
|
|
215
|
-
compression="blosc",
|
|
216
|
-
compression_opts={"cname": "lz4", "clevel": 5, "shuffle": 1},
|
|
217
216
|
)
|
|
218
217
|
|
|
219
218
|
# Store original data with optimal chunking
|
|
@@ -222,8 +221,6 @@ class Spectrogram(FigpackView):
|
|
|
222
221
|
"data",
|
|
223
222
|
data=self.data,
|
|
224
223
|
chunks=original_chunks,
|
|
225
|
-
compression="blosc",
|
|
226
|
-
compression_opts={"cname": "lz4", "clevel": 5, "shuffle": 1},
|
|
227
224
|
)
|
|
228
225
|
|
|
229
226
|
# Store downsampled data arrays
|
|
@@ -240,8 +237,6 @@ class Spectrogram(FigpackView):
|
|
|
240
237
|
dataset_name,
|
|
241
238
|
data=downsampled_array,
|
|
242
239
|
chunks=ds_chunks,
|
|
243
|
-
compression="blosc",
|
|
244
|
-
compression_opts={"cname": "lz4", "clevel": 5, "shuffle": 1},
|
|
245
240
|
)
|
|
246
241
|
|
|
247
242
|
print(f"Stored Spectrogram with {len(downsample_factors)} downsampled levels:")
|