Skip to content

Commit d292984

Browse files
Merge pull request #979 from VH-Lab/claude/lightsheet-zarr-ndi-viewer-djp5vk
Lightsheet pyramids: ingest from OME-Zarr or SmartSPIM, chunk materialization, cloud round trip, and napari viewing
2 parents 44e707a + d94973c commit d292984

61 files changed

Lines changed: 10948 additions & 233 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎find_napari_debug_log.sh‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env zsh
2+
# find_napari_debug_log.sh - locate and print the napariViewLightsheet debug
3+
# log written by ndi.test.cloud.lightsheet_blob_cloud_roundtrip.
4+
#
5+
# The demo defaults DebugLogFile to fullfile(tempdir, 'NapariLightSheetDebugging.txt')
6+
# which on macOS resolves under $TMPDIR (typically /var/folders/xx/yyy/T/),
7+
# not /tmp. This script looks in the usual spots, picks the newest match,
8+
# and cats it.
9+
10+
set -u
11+
setopt NULL_GLOB EXTENDED_GLOB
12+
13+
name="NapariLightSheetDebugging.txt"
14+
15+
# Places to check, ordered by likelihood on macOS.
16+
locations=(
17+
"${TMPDIR:-}/$name" # matches MATLAB's tempdir
18+
"/tmp/$name" # a user who set DebugLogFile explicitly
19+
"$HOME/$name" # or dropped it in their home
20+
"/private/tmp/$name" # macOS's real /tmp target
21+
)
22+
23+
# De-duplicate, drop empties, and keep only paths that actually exist.
24+
typeset -a found
25+
for p in "${locations[@]}"; do
26+
[[ -n "$p" && -f "$p" ]] && found+=("$p")
27+
done
28+
29+
# Wider net if the shortlist misses: recurse under /var/folders and $TMPDIR
30+
# (macOS parks per-user tempdirs there). Prune common noise; keep the
31+
# recent ones.
32+
if (( ${#found} == 0 )); then
33+
for root in "${TMPDIR:-}" /var/folders /private/var/folders /tmp; do
34+
[[ -n "$root" && -d "$root" ]] || continue
35+
while IFS= read -r hit; do
36+
[[ -n "$hit" ]] && found+=("$hit")
37+
done < <(find "$root" -maxdepth 6 -type f -name "$name" 2>/dev/null)
38+
done
39+
fi
40+
41+
if (( ${#found} == 0 )); then
42+
print -u2 "No $name found. If your demo ran with a custom DebugLogFile,"
43+
print -u2 "point me at it: $0 /full/path/to/logfile"
44+
print -u2 "Or check the value of tempdir in MATLAB (>> tempdir)."
45+
exit 1
46+
fi
47+
48+
# Pick the newest match if multiple.
49+
newest="$found[1]"
50+
newest_mtime=$(stat -f %m "$newest" 2>/dev/null || stat -c %Y "$newest" 2>/dev/null)
51+
for f in "$found[@]"; do
52+
m=$(stat -f %m "$f" 2>/dev/null || stat -c %Y "$f" 2>/dev/null)
53+
if [[ -n "$m" && "$m" -gt "$newest_mtime" ]]; then
54+
newest="$f"
55+
newest_mtime="$m"
56+
fi
57+
done
58+
59+
print -u2 "=== Reading: $newest ==="
60+
if (( ${#found} > 1 )); then
61+
print -u2 "(also found: ${(j:, :)found[2,-1]})"
62+
fi
63+
print -u2 ""
64+
65+
cat -- "$newest"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
%LIGHTSHEET_TEST_BLOB_INGEST_AND_VIEW - end-to-end smoke test on the synthetic blob
2+
%
3+
% Builds a small OME-Zarr fixture on disk (a couple of MB), ingests it
4+
% into a fresh NDI session with the blosc-zstd fast path, and launches
5+
% the napari viewer on the resulting pyramid. Use this to sanity-check
6+
% the ingest -> document -> viewer pipeline without touching the real
7+
% SmartSPIM data. Runs in under a minute on a laptop.
8+
%
9+
% Edit CONFIG below if you want to keep the fixture / session between
10+
% runs, change the blob size, or point at a different napari launcher.
11+
%
12+
% See also: ndi.test.lightsheet.makeBlobFixture,
13+
% ndi.test.lightsheet.ingestBlobFixture,
14+
% ndi.fun.doc.lightsheet.fromOMEZarr,
15+
% ndi.fun.doc.lightsheet.view
16+
17+
% -------------------- CONFIG -----------------------------------------
18+
% Leave scratch dirs empty to land under tempname (fresh every run).
19+
sessionDir = ''; % e.g. '~/ndi-sessions/blob-demo'
20+
zarrDir = ''; % e.g. '~/ndi-sessions/blob-demo/zarr'
21+
subjectName = 'blob@vhlab';
22+
23+
% Blob size / shape. 128^3 uint16 across 2 channels ~= 16 MB raw; small
24+
% enough for a fast smoke test, big enough that the pyramid has real
25+
% levels to look at.
26+
shape = [128 128 128];
27+
numChannels = 2;
28+
chunkShape = [32 32 32];
29+
numLevels = 3;
30+
31+
% Ingest options. blosc-zstd exercises the encodeChunk fast path; keep
32+
% clevel modest for a smoke test.
33+
codec = 'blosc-zstd';
34+
clevel = 5;
35+
36+
% Napari launcher. Same wrapper the real-data script uses.
37+
launcher = '/usr/local/bin/napariViewLightsheet';
38+
% ---------------------------------------------------------------------
39+
40+
fprintf('Building blob fixture and ingesting ...\n');
41+
[S, P, info] = ndi.test.lightsheet.ingestBlobFixture( ...
42+
'sessionDir', sessionDir, ...
43+
'zarrDir', zarrDir, ...
44+
'subject', subjectName, ...
45+
'Shape', shape, ...
46+
'NumChannels', numChannels, ...
47+
'ChunkShape', chunkShape, ...
48+
'NumLevels', numLevels, ...
49+
'codec', codec, ...
50+
'clevel', clevel);
51+
52+
fprintf('Session: %s\n', char(S.path()));
53+
fprintf('Zarr: %s\n', info.zarrPath);
54+
fprintf('Pyramid: %s\n', P.id());
55+
56+
fprintf('Launching napari viewer ...\n');
57+
ndi.fun.doc.lightsheet.view(S, P.id(), 'launcher', launcher);

0 commit comments

Comments
 (0)