arrayview 0.58.4__tar.gz → 0.58.5__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.
- {arrayview-0.58.4 → arrayview-0.58.5}/PKG-INFO +1 -1
- {arrayview-0.58.4 → arrayview-0.58.5}/pyproject.toml +1 -1
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_overlays.py +6 -3
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_render.py +81 -19
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_routes_preload.py +5 -1
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_routes_rendering.py +11 -2
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_routes_websocket.py +8 -1
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_session.py +5 -1
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_viewer.html +649 -101
- {arrayview-0.58.4 → arrayview-0.58.5}/.gitignore +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/LICENSE +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/README.md +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/ARCHITECTURE.md +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/__init__.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/__main__.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_analysis.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_app.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_bootstrap_app.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_config.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_diagnostics.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_dicom.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_diff.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_extra_ports.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_icon.png +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_imaging.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_instance_registry.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_io.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_launch_plan.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_launch_trace.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_launcher.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_lifecycle.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_peer_guard.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_platform.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_routes_analysis.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_routes_drop.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_routes_export.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_routes_loading.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_routes_persistence.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_routes_preferences.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_routes_query.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_routes_segmentation.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_routes_state.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_routes_vectorfield.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_segmentation.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_server.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_session_spec.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_shell.html +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_source_safety.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_synthetic_mri.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_torch.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_tutorial.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_vectorfield.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_view_memory.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_vscode.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_vscode_browser.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_vscode_extension.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_vscode_signal.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/_watch.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/arrayview-opener.vsix +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/gsap.min.js +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/src/arrayview/todo.md +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/capture_patient_loading.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/capture_v_animation.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/conftest.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/make_vectorfield_test_arrays.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_1d_arrays.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_api.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_backend_shared.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_cli.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_config.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_dicom.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_drop_import.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_first_slice_warmup.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_instance_registry.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_io.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_large_arrays.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_launch_blackbox.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_nifti_meta.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_nifti_series.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_peer_guard.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_safe_server_stop.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_shared_home_registrations.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_source_safety.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_torch.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_tutorial.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_view_memory.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_viewer_port.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/test_vsix_bundle.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/ui_audit.py +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/v_anim_frames/.gitkeep +0 -0
- {arrayview-0.58.4 → arrayview-0.58.5}/tests/visual_smoke.py +0 -0
|
@@ -9,6 +9,7 @@ from arrayview._render import (
|
|
|
9
9
|
_composite_overlay_mask,
|
|
10
10
|
mosaic_grid_cols,
|
|
11
11
|
mosaic_tile_indices,
|
|
12
|
+
mosaic_tile_in_bounds,
|
|
12
13
|
_extract_overlay_mask,
|
|
13
14
|
_overlay_is_label_map,
|
|
14
15
|
)
|
|
@@ -114,6 +115,8 @@ def _composite_mosaic_overlays(
|
|
|
114
115
|
base_shape: tuple[int, ...],
|
|
115
116
|
mosaic_cols: int | None = None,
|
|
116
117
|
dim_z2: int = -1,
|
|
118
|
+
z_sel: tuple[int, int, int] | None = None,
|
|
119
|
+
z2_sel: tuple[int, int, int] | None = None,
|
|
117
120
|
) -> np.ndarray:
|
|
118
121
|
"""Composite each overlay as a mosaic using the base mosaic's frame indices.
|
|
119
122
|
|
|
@@ -135,9 +138,9 @@ def _composite_mosaic_overlays(
|
|
|
135
138
|
else []
|
|
136
139
|
)
|
|
137
140
|
tile_shape = (int(base_shape[dim_y]), int(base_shape[dim_x]))
|
|
138
|
-
tiles = mosaic_tile_indices(base_shape, dim_z, dim_z2, idx_tuple)
|
|
141
|
+
tiles = mosaic_tile_indices(base_shape, dim_z, dim_z2, idx_tuple, z_sel, z2_sel)
|
|
139
142
|
n_frames = len(tiles)
|
|
140
|
-
mosaic_cols = mosaic_grid_cols(base_shape, dim_z, dim_z2, mosaic_cols)
|
|
143
|
+
mosaic_cols = mosaic_grid_cols(base_shape, dim_z, dim_z2, mosaic_cols, z_sel)
|
|
141
144
|
|
|
142
145
|
for i, sid in enumerate(sids):
|
|
143
146
|
color, hidden = (
|
|
@@ -160,7 +163,7 @@ def _composite_mosaic_overlays(
|
|
|
160
163
|
tuple(frame_idx),
|
|
161
164
|
expected_shape=tile_shape,
|
|
162
165
|
base_shape=base_shape,
|
|
163
|
-
)
|
|
166
|
+
) if mosaic_tile_in_bounds(base_shape, frame_idx) else None
|
|
164
167
|
frames.append(
|
|
165
168
|
ov_raw if ov_raw is not None else np.zeros(tile_shape, dtype=np.float32)
|
|
166
169
|
)
|
|
@@ -169,17 +169,62 @@ def mosaic_shape(batch):
|
|
|
169
169
|
return tuple(mshape)
|
|
170
170
|
|
|
171
171
|
|
|
172
|
-
def
|
|
172
|
+
def parse_mosaic_sel(value, n):
|
|
173
|
+
"""``"start:stop:step"`` -> (start, stop, step) slices of a mosaic dim of size n.
|
|
174
|
+
|
|
175
|
+
None for every slice (also for empty or bad input), so a thinned and a
|
|
176
|
+
full request never share a cache key and a full one keys as before.
|
|
177
|
+
"""
|
|
178
|
+
if value is None or value == "":
|
|
179
|
+
return None
|
|
180
|
+
try:
|
|
181
|
+
start, stop, step = (int(v) for v in str(value).split(":"))
|
|
182
|
+
except ValueError:
|
|
183
|
+
return None
|
|
184
|
+
n = int(n)
|
|
185
|
+
step = max(1, step)
|
|
186
|
+
start = min(max(0, start), max(0, n - 1))
|
|
187
|
+
stop = min(max(start + 1, stop), n)
|
|
188
|
+
if start == 0 and stop == n and step == 1:
|
|
189
|
+
return None
|
|
190
|
+
return (start, stop, step)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def mosaic_range(shape, dim, sel=None):
|
|
194
|
+
"""Slices of *dim* a mosaic shows: all of them, or ``sel`` (start, stop, step).
|
|
195
|
+
|
|
196
|
+
A whole dim taken every few slices (start < step, stop = the end) always
|
|
197
|
+
has ceil(n / step) tiles, whichever slice it starts on, so the grid keeps
|
|
198
|
+
its shape while scrolling cycles the start; a last slot past the end is
|
|
199
|
+
left blank (see mosaic_tile_in_bounds).
|
|
200
|
+
"""
|
|
201
|
+
if not sel:
|
|
202
|
+
return range(int(shape[dim]))
|
|
203
|
+
start, stop, step = sel
|
|
204
|
+
n = int(shape[dim])
|
|
205
|
+
if step > 1 and start < step and stop == n:
|
|
206
|
+
return range(start, start + -(-n // step) * step, step)
|
|
207
|
+
return range(*sel)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def mosaic_tile_in_bounds(shape, tile):
|
|
211
|
+
"""False for a blank padding tile (an index past the end of its dim)."""
|
|
212
|
+
return all(0 <= int(v) < int(s) for v, s in zip(tile, shape))
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def mosaic_tile_indices(shape, dim_z, dim_z2, idx, z_sel=None, z2_sel=None):
|
|
173
216
|
"""Index list of every mosaic tile, row by row.
|
|
174
217
|
|
|
175
|
-
*dim_z* runs across the grid; *dim_z2* (``-1`` for none) runs down it
|
|
176
|
-
|
|
218
|
+
*dim_z* runs across the grid; *dim_z2* (``-1`` for none) runs down it.
|
|
219
|
+
``z_sel`` / ``z2_sel`` (start, stop, step) thin either dim; tile ``k`` is
|
|
220
|
+
the ``k % cols``-th shown slice of dim_z and the ``k // cols``-th of dim_z2.
|
|
177
221
|
"""
|
|
178
222
|
base = list(idx)
|
|
179
|
-
rows =
|
|
223
|
+
rows = mosaic_range(shape, dim_z2, z2_sel) if dim_z2 >= 0 else (None,)
|
|
224
|
+
cols = mosaic_range(shape, dim_z, z_sel)
|
|
180
225
|
tiles = []
|
|
181
226
|
for r in rows:
|
|
182
|
-
for c in
|
|
227
|
+
for c in cols:
|
|
183
228
|
t = list(base)
|
|
184
229
|
t[dim_z] = c
|
|
185
230
|
if r is not None:
|
|
@@ -188,9 +233,9 @@ def mosaic_tile_indices(shape, dim_z, dim_z2, idx):
|
|
|
188
233
|
return tiles
|
|
189
234
|
|
|
190
235
|
|
|
191
|
-
def mosaic_grid_cols(shape, dim_z, dim_z2, mosaic_cols=None):
|
|
236
|
+
def mosaic_grid_cols(shape, dim_z, dim_z2, mosaic_cols=None, z_sel=None):
|
|
192
237
|
"""Column count a mosaic is laid out with (None = near-square)."""
|
|
193
|
-
return
|
|
238
|
+
return len(mosaic_range(shape, dim_z, z_sel)) if dim_z2 >= 0 else mosaic_cols
|
|
194
239
|
|
|
195
240
|
|
|
196
241
|
def _build_mosaic_grid(all_data, n, gap=2, cols=None):
|
|
@@ -925,9 +970,14 @@ def render_mosaic(
|
|
|
925
970
|
fit=None,
|
|
926
971
|
dim_z2=-1,
|
|
927
972
|
window_out=None,
|
|
973
|
+
z_sel=None,
|
|
974
|
+
z2_sel=None,
|
|
928
975
|
):
|
|
929
976
|
"""Render the mosaic grid of every slice along *dim_z* (and *dim_z2*, down).
|
|
930
977
|
|
|
978
|
+
``z_sel`` / ``z2_sel`` (start, stop, step, from parse_mosaic_sel) show
|
|
979
|
+
only those slices of dim_z / dim_z2.
|
|
980
|
+
|
|
931
981
|
``fit=(w, h)`` returns the grid already shrunk to the viewer's canvas
|
|
932
982
|
(as the live socket would before sending) and caches it that way, so a
|
|
933
983
|
grid warmed ahead of time is ready to send: the shrink of a 240-slice
|
|
@@ -940,7 +990,7 @@ def render_mosaic(
|
|
|
940
990
|
idx_norm[dim_z] = 0
|
|
941
991
|
if dim_z2 >= 0:
|
|
942
992
|
idx_norm[dim_z2] = 0
|
|
943
|
-
key = (dim_x, dim_y, dim_z, tuple(idx_norm), colormap, dr, complex_mode, log_scale, mosaic_cols, vmin_override, vmax_override, dim_z2)
|
|
993
|
+
key = (dim_x, dim_y, dim_z, tuple(idx_norm), colormap, dr, complex_mode, log_scale, mosaic_cols, vmin_override, vmax_override, dim_z2, z_sel, z2_sel)
|
|
944
994
|
|
|
945
995
|
windows = session.__dict__.setdefault("_mosaic_windows", {})
|
|
946
996
|
|
|
@@ -949,7 +999,7 @@ def render_mosaic(
|
|
|
949
999
|
rgba = _build_mosaic_rgba(
|
|
950
1000
|
session, dim_x, dim_y, dim_z, idx_tuple, colormap, dr, complex_mode,
|
|
951
1001
|
log_scale, mosaic_cols, vmin_override, vmax_override, progress,
|
|
952
|
-
dim_z2=dim_z2, window_out=win,
|
|
1002
|
+
dim_z2=dim_z2, window_out=win, z_sel=z_sel, z2_sel=z2_sel,
|
|
953
1003
|
)
|
|
954
1004
|
if win:
|
|
955
1005
|
if len(windows) > 256:
|
|
@@ -1037,11 +1087,11 @@ def fit_rgba(rgba, canvas_w, canvas_h):
|
|
|
1037
1087
|
def _build_mosaic_rgba(
|
|
1038
1088
|
session, dim_x, dim_y, dim_z, idx_tuple, colormap, dr, complex_mode,
|
|
1039
1089
|
log_scale, mosaic_cols, vmin_override, vmax_override, progress,
|
|
1040
|
-
dim_z2=-1, window_out=None,
|
|
1090
|
+
dim_z2=-1, window_out=None, z_sel=None, z2_sel=None,
|
|
1041
1091
|
):
|
|
1042
|
-
tiles = mosaic_tile_indices(session.shape, dim_z, dim_z2, idx_tuple)
|
|
1092
|
+
tiles = mosaic_tile_indices(session.shape, dim_z, dim_z2, idx_tuple, z_sel, z2_sel)
|
|
1043
1093
|
n = len(tiles)
|
|
1044
|
-
mosaic_cols = mosaic_grid_cols(session.shape, dim_z, dim_z2, mosaic_cols)
|
|
1094
|
+
mosaic_cols = mosaic_grid_cols(session.shape, dim_z, dim_z2, mosaic_cols, z_sel)
|
|
1045
1095
|
# Reported per slice rather than estimated: each slice faults in roughly the
|
|
1046
1096
|
# same number of pages, so slice i of n is an honest fraction of the wait.
|
|
1047
1097
|
# On an array whose display axes are the outer ones this loop is the whole
|
|
@@ -1050,13 +1100,18 @@ def _build_mosaic_rgba(
|
|
|
1050
1100
|
# cover the entire file.
|
|
1051
1101
|
frames_raw = []
|
|
1052
1102
|
for i, tile in enumerate(tiles):
|
|
1053
|
-
|
|
1103
|
+
inside = mosaic_tile_in_bounds(session.shape, tile)
|
|
1104
|
+
frames_raw.append(extract_slice(session, dim_x, dim_y, tile) if inside else None)
|
|
1054
1105
|
if progress is not None:
|
|
1055
1106
|
progress(i + 1, n)
|
|
1056
|
-
frames = [apply_complex_mode(f, complex_mode) for f in frames_raw]
|
|
1107
|
+
frames = [None if f is None else apply_complex_mode(f, complex_mode) for f in frames_raw]
|
|
1057
1108
|
if log_scale:
|
|
1058
|
-
frames = [np.log1p(np.abs(f)).astype(np.float32) for f in frames]
|
|
1059
|
-
|
|
1109
|
+
frames = [None if f is None else np.log1p(np.abs(f)).astype(np.float32) for f in frames]
|
|
1110
|
+
# Blank padding tiles: NaN, so they draw as empty grid and stay out of the window.
|
|
1111
|
+
shown = [f for f in frames if f is not None]
|
|
1112
|
+
blank = np.full(shown[0].shape, np.nan, dtype=np.float32)
|
|
1113
|
+
all_data = np.stack([blank if f is None else f for f in frames])
|
|
1114
|
+
window_data = np.stack(shown) if len(shown) < len(frames) else all_data
|
|
1060
1115
|
|
|
1061
1116
|
if vmin_override is not None and vmax_override is not None:
|
|
1062
1117
|
vmin, vmax = float(vmin_override), float(vmax_override)
|
|
@@ -1065,7 +1120,7 @@ def _build_mosaic_rgba(
|
|
|
1065
1120
|
else:
|
|
1066
1121
|
# One call partitions once for both ends; two calls sorted the whole
|
|
1067
1122
|
# stack twice (~0.14 s of a 240-slice mosaic step).
|
|
1068
|
-
vmin, vmax = (float(v) for v in np.percentile(
|
|
1123
|
+
vmin, vmax = (float(v) for v in np.percentile(window_data, [1, 99]))
|
|
1069
1124
|
if window_out is not None:
|
|
1070
1125
|
window_out.append((vmin, vmax))
|
|
1071
1126
|
|
|
@@ -1111,15 +1166,17 @@ def _run_preload(
|
|
|
1111
1166
|
log_scale=False,
|
|
1112
1167
|
dim_z2=-1,
|
|
1113
1168
|
mosaic_cols=None,
|
|
1169
|
+
z_sel=None,
|
|
1170
|
+
z2_sel=None,
|
|
1114
1171
|
):
|
|
1115
1172
|
shape = session.spatial_shape if session.rgb_axis is not None else session.shape
|
|
1116
1173
|
n = shape[slice_dim]
|
|
1117
1174
|
H = shape[dim_y]
|
|
1118
1175
|
W = shape[dim_x]
|
|
1119
1176
|
if dim_z >= 0:
|
|
1120
|
-
nz = shape
|
|
1177
|
+
nz = len(mosaic_range(shape, dim_z, z_sel))
|
|
1121
1178
|
mrows, mcols = (
|
|
1122
|
-
(shape
|
|
1179
|
+
(len(mosaic_range(shape, dim_z2, z2_sel)), nz) if dim_z2 >= 0
|
|
1123
1180
|
else (-(-nz // mosaic_cols), mosaic_cols) if mosaic_cols
|
|
1124
1181
|
else mosaic_shape(nz)
|
|
1125
1182
|
)
|
|
@@ -1153,6 +1210,8 @@ def _run_preload(
|
|
|
1153
1210
|
log_scale,
|
|
1154
1211
|
mosaic_cols=mosaic_cols,
|
|
1155
1212
|
dim_z2=dim_z2,
|
|
1213
|
+
z_sel=z_sel,
|
|
1214
|
+
z2_sel=z2_sel,
|
|
1156
1215
|
)
|
|
1157
1216
|
else:
|
|
1158
1217
|
if session.rgb_axis is not None:
|
|
@@ -1211,6 +1270,9 @@ __all__ = [
|
|
|
1211
1270
|
"LABEL_COLORS",
|
|
1212
1271
|
# Mosaic
|
|
1213
1272
|
"render_mosaic",
|
|
1273
|
+
"parse_mosaic_sel",
|
|
1274
|
+
"mosaic_range",
|
|
1275
|
+
"mosaic_tile_in_bounds",
|
|
1214
1276
|
# Preload
|
|
1215
1277
|
"_run_preload",
|
|
1216
1278
|
]
|
|
@@ -2,7 +2,7 @@ import threading
|
|
|
2
2
|
|
|
3
3
|
from fastapi import Request
|
|
4
4
|
|
|
5
|
-
from arrayview._render import _run_preload
|
|
5
|
+
from arrayview._render import _run_preload, parse_mosaic_sel
|
|
6
6
|
from arrayview._session import SESSIONS
|
|
7
7
|
|
|
8
8
|
|
|
@@ -24,6 +24,8 @@ def register_preload_routes(app) -> None:
|
|
|
24
24
|
dim_z2 = int(body.get("dim_z2", -1)) if dim_z >= 0 else -1
|
|
25
25
|
_mc = body.get("mosaic_cols") if dim_z >= 0 else None
|
|
26
26
|
mosaic_cols = int(_mc) if _mc is not None else None
|
|
27
|
+
z_sel = parse_mosaic_sel(body.get("z_sel"), session.shape[dim_z]) if dim_z >= 0 else None
|
|
28
|
+
z2_sel = parse_mosaic_sel(body.get("z2_sel"), session.shape[dim_z2]) if dim_z2 >= 0 else None
|
|
27
29
|
complex_mode = int(body.get("complex_mode", 0))
|
|
28
30
|
log_scale = bool(body.get("log_scale", False))
|
|
29
31
|
|
|
@@ -45,6 +47,8 @@ def register_preload_routes(app) -> None:
|
|
|
45
47
|
log_scale,
|
|
46
48
|
dim_z2,
|
|
47
49
|
mosaic_cols,
|
|
50
|
+
z_sel,
|
|
51
|
+
z2_sel,
|
|
48
52
|
),
|
|
49
53
|
daemon=True,
|
|
50
54
|
).start()
|
|
@@ -12,6 +12,8 @@ from arrayview._render import (
|
|
|
12
12
|
LUTS,
|
|
13
13
|
_build_mosaic_grid,
|
|
14
14
|
mosaic_tile_indices,
|
|
15
|
+
mosaic_tile_in_bounds,
|
|
16
|
+
parse_mosaic_sel,
|
|
15
17
|
_compute_vmin_vmax,
|
|
16
18
|
_ensure_lut,
|
|
17
19
|
_init_luts,
|
|
@@ -87,6 +89,8 @@ def register_rendering_routes(app, *, get_session_or_404) -> None:
|
|
|
87
89
|
slice_dim: int = -1,
|
|
88
90
|
dim_z: int = -1,
|
|
89
91
|
dim_z2: int = -1,
|
|
92
|
+
z_sel: str | None = None,
|
|
93
|
+
z2_sel: str | None = None,
|
|
90
94
|
complex_mode: int = 0,
|
|
91
95
|
log_scale: bool = False,
|
|
92
96
|
vmin_override: float | None = None,
|
|
@@ -172,6 +176,8 @@ def register_rendering_routes(app, *, get_session_or_404) -> None:
|
|
|
172
176
|
vmax_override=vmax_override,
|
|
173
177
|
)
|
|
174
178
|
else:
|
|
179
|
+
zs = parse_mosaic_sel(z_sel, session.shape[dim_z])
|
|
180
|
+
z2s = parse_mosaic_sel(z2_sel, session.shape[dim_z2]) if dim_z2 >= 0 else None
|
|
175
181
|
rgba = render_mosaic(
|
|
176
182
|
session,
|
|
177
183
|
dim_x,
|
|
@@ -186,11 +192,13 @@ def register_rendering_routes(app, *, get_session_or_404) -> None:
|
|
|
186
192
|
vmin_override=vmin_override,
|
|
187
193
|
vmax_override=vmax_override,
|
|
188
194
|
dim_z2=dim_z2,
|
|
195
|
+
z_sel=zs,
|
|
196
|
+
z2_sel=z2s,
|
|
189
197
|
)
|
|
190
198
|
rgba = _composite_mosaic_overlays(
|
|
191
199
|
rgba, overlay_sid, overlay_colors, overlay_alpha, overlay_alphas,
|
|
192
200
|
overlay_outline, dim_x, dim_y, dim_z, idx_tuple, session.shape,
|
|
193
|
-
mosaic_cols, dim_z2=dim_z2,
|
|
201
|
+
mosaic_cols, dim_z2=dim_z2, z_sel=zs, z2_sel=z2s,
|
|
194
202
|
)
|
|
195
203
|
if vmin_override is not None and vmax_override is not None:
|
|
196
204
|
vmin, vmax = float(vmin_override), float(vmax_override)
|
|
@@ -198,8 +206,9 @@ def register_rendering_routes(app, *, get_session_or_404) -> None:
|
|
|
198
206
|
frames_raw = [
|
|
199
207
|
extract_slice(session, dim_x, dim_y, tile)
|
|
200
208
|
for tile in mosaic_tile_indices(
|
|
201
|
-
session.shape, dim_z, dim_z2, idx_tuple
|
|
209
|
+
session.shape, dim_z, dim_z2, idx_tuple, zs, z2s
|
|
202
210
|
)
|
|
211
|
+
if mosaic_tile_in_bounds(session.shape, tile)
|
|
203
212
|
]
|
|
204
213
|
frames = [apply_complex_mode(frame, complex_mode) for frame in frames_raw]
|
|
205
214
|
if log_scale:
|
|
@@ -18,6 +18,7 @@ from arrayview._render import (
|
|
|
18
18
|
_ensure_lut,
|
|
19
19
|
extract_projection,
|
|
20
20
|
extract_slice,
|
|
21
|
+
parse_mosaic_sel,
|
|
21
22
|
render_mosaic,
|
|
22
23
|
render_projection_rgba,
|
|
23
24
|
render_rgb_rgba,
|
|
@@ -634,6 +635,9 @@ def register_websocket_routes(app) -> None:
|
|
|
634
635
|
dim_z = int(msg.get("dim_z", -1))
|
|
635
636
|
# Second mosaic dim (down the rows); plain mosaic only.
|
|
636
637
|
dim_z2 = int(msg.get("dim_z2", -1)) if dim_z >= 0 else -1
|
|
638
|
+
# Thinned mosaic dims, "start:stop:step" (plain mosaic only).
|
|
639
|
+
z_sel = parse_mosaic_sel(msg.get("z_sel"), session.shape[dim_z]) if dim_z >= 0 else None
|
|
640
|
+
z2_sel = parse_mosaic_sel(msg.get("z2_sel"), session.shape[dim_z2]) if dim_z2 >= 0 else None
|
|
637
641
|
complex_mode = int(msg.get("complex_mode", 0))
|
|
638
642
|
log_scale = bool(msg.get("log_scale", False))
|
|
639
643
|
_vmin_ov = msg.get("vmin_override")
|
|
@@ -741,6 +745,8 @@ def register_websocket_routes(app) -> None:
|
|
|
741
745
|
fit=mosaic_fit,
|
|
742
746
|
dim_z2=dim_z2,
|
|
743
747
|
window_out=mosaic_window,
|
|
748
|
+
z_sel=z_sel,
|
|
749
|
+
z2_sel=z2_sel,
|
|
744
750
|
),
|
|
745
751
|
)
|
|
746
752
|
rgba = _composite_mosaic_overlays(
|
|
@@ -748,6 +754,7 @@ def register_websocket_routes(app) -> None:
|
|
|
748
754
|
float(msg.get("overlay_alpha", 0.45)), msg.get("overlay_alphas"),
|
|
749
755
|
bool(msg.get("overlay_outline", False)), dim_x, dim_y, dim_z,
|
|
750
756
|
idx_tuple, session.shape, mosaic_cols, dim_z2=dim_z2,
|
|
757
|
+
z_sel=z_sel, z2_sel=z2_sel,
|
|
751
758
|
)
|
|
752
759
|
h, w = rgba.shape[:2]
|
|
753
760
|
if mosaic_window:
|
|
@@ -961,7 +968,7 @@ def register_websocket_routes(app) -> None:
|
|
|
961
968
|
colormap=colormap, dr=dr, complex_mode=complex_mode,
|
|
962
969
|
log_scale=log_scale, mosaic_cols=mosaic_cols,
|
|
963
970
|
vmin_override=vmin_override, vmax_override=vmax_override,
|
|
964
|
-
fit=mosaic_fit, dim_z2=dim_z2,
|
|
971
|
+
fit=mosaic_fit, dim_z2=dim_z2, z_sel=z_sel, z2_sel=z2_sel,
|
|
965
972
|
),
|
|
966
973
|
)
|
|
967
974
|
stack_axes = tuple(getattr(session.data, "_stack_axes", ()))
|
|
@@ -437,7 +437,11 @@ def _schedule_mosaic_prefetch(session, dim_x, dim_y, dim_z, idx_list, slice_dim,
|
|
|
437
437
|
target = current + direction
|
|
438
438
|
if not 0 <= target < session.shape[slice_dim]:
|
|
439
439
|
return
|
|
440
|
-
|
|
440
|
+
from arrayview._render import mosaic_range
|
|
441
|
+
|
|
442
|
+
frames = len(mosaic_range(session.shape, dim_z, render_args.get("z_sel"))) * (
|
|
443
|
+
len(mosaic_range(session.shape, dim_z2, render_args.get("z2_sel"))) if dim_z2 >= 0 else 1
|
|
444
|
+
)
|
|
441
445
|
grid_bytes = frames * session.shape[dim_x] * session.shape[dim_y] * 4
|
|
442
446
|
# Never let the warmed grid push the one on screen out of the cache.
|
|
443
447
|
if 2 * grid_bytes > getattr(session, "MOSAIC_CACHE_BYTES", 0):
|