arrayview 0.48.0__py3-none-any.whl → 0.48.1__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.
- arrayview/_config.py +10 -2
- arrayview/_io.py +382 -9
- arrayview/_render.py +6 -1
- arrayview/_server.py +2 -0
- arrayview/_viewer.html +144 -14
- {arrayview-0.48.0.dist-info → arrayview-0.48.1.dist-info}/METADATA +1 -1
- {arrayview-0.48.0.dist-info → arrayview-0.48.1.dist-info}/RECORD +10 -10
- {arrayview-0.48.0.dist-info → arrayview-0.48.1.dist-info}/WHEEL +0 -0
- {arrayview-0.48.0.dist-info → arrayview-0.48.1.dist-info}/entry_points.txt +0 -0
- {arrayview-0.48.0.dist-info → arrayview-0.48.1.dist-info}/licenses/LICENSE +0 -0
arrayview/_config.py
CHANGED
|
@@ -38,6 +38,7 @@ BUILTIN_PREFERENCES = {
|
|
|
38
38
|
"viewer": {
|
|
39
39
|
"theme": "dark",
|
|
40
40
|
"rounded_panes": True,
|
|
41
|
+
"qmri_gapless": False,
|
|
41
42
|
"ortho_layout": None,
|
|
42
43
|
"dimbar_mode": "compact",
|
|
43
44
|
},
|
|
@@ -47,6 +48,7 @@ PREFERENCE_SCHEMA = {
|
|
|
47
48
|
"viewer": {
|
|
48
49
|
"theme": sorted(_VALID_THEMES),
|
|
49
50
|
"rounded_panes": "boolean",
|
|
51
|
+
"qmri_gapless": "boolean",
|
|
50
52
|
"colormaps": "non-empty list of names",
|
|
51
53
|
"ortho_layout": sorted(_VALID_ORTHO_LAYOUTS),
|
|
52
54
|
"dimbar_mode": sorted(_VALID_DIMBAR_MODES),
|
|
@@ -118,9 +120,9 @@ def _validate_preference(section: str, key: str, value):
|
|
|
118
120
|
)
|
|
119
121
|
if section == "viewer" and key == "theme":
|
|
120
122
|
return _normalized_string(value, _VALID_THEMES, "viewer.theme")
|
|
121
|
-
if section == "viewer" and key
|
|
123
|
+
if section == "viewer" and key in ("rounded_panes", "qmri_gapless"):
|
|
122
124
|
if not isinstance(value, bool):
|
|
123
|
-
raise InvalidPreferenceError("viewer.
|
|
125
|
+
raise InvalidPreferenceError(f"viewer.{key} must be a boolean")
|
|
124
126
|
return value
|
|
125
127
|
if section == "viewer" and key == "colormaps":
|
|
126
128
|
if (
|
|
@@ -238,6 +240,12 @@ def get_viewer_rounded_panes() -> bool | None:
|
|
|
238
240
|
return None
|
|
239
241
|
|
|
240
242
|
|
|
243
|
+
def get_viewer_qmri_gapless() -> bool:
|
|
244
|
+
"""Whether qMRI maps are laid out touching, with no space between them."""
|
|
245
|
+
viewer_cfg = load_config().get("viewer", {})
|
|
246
|
+
return isinstance(viewer_cfg, dict) and viewer_cfg.get("qmri_gapless") is True
|
|
247
|
+
|
|
248
|
+
|
|
241
249
|
def get_viewer_ortho_layout() -> str | None:
|
|
242
250
|
"""Return the preferred initial ortho-view layout."""
|
|
243
251
|
viewer_cfg = load_config().get("viewer", {})
|
arrayview/_io.py
CHANGED
|
@@ -11,7 +11,7 @@ import re
|
|
|
11
11
|
import sys
|
|
12
12
|
import threading
|
|
13
13
|
import zlib
|
|
14
|
-
from concurrent.futures import ThreadPoolExecutor
|
|
14
|
+
from concurrent.futures import Future, ThreadPoolExecutor
|
|
15
15
|
from collections import OrderedDict
|
|
16
16
|
|
|
17
17
|
import numpy as np
|
|
@@ -562,6 +562,310 @@ def read_gzip_file_parallel(filepath):
|
|
|
562
562
|
return b"".join(out)
|
|
563
563
|
|
|
564
564
|
|
|
565
|
+
# ---------------------------------------------------------------------------
|
|
566
|
+
# Scattered slices of mapped files — read the whole region instead
|
|
567
|
+
# ---------------------------------------------------------------------------
|
|
568
|
+
|
|
569
|
+
# A slice that cuts across a file's storage order touches every page of the
|
|
570
|
+
# volume it lives in. Faulted in through the map that is a long chain of small
|
|
571
|
+
# waits: one map of a (224,240,204,6) float32 file took 2.1 s off an SMB share,
|
|
572
|
+
# where 4 MB reads, several in flight, fetched the same 42 MB in 0.45 s (the
|
|
573
|
+
# link's ~100 MB/s). Small targeted reads lost too: 204 single-row reads took
|
|
574
|
+
# 0.46 s even 64 at a time, because each one is a ~13 ms round trip.
|
|
575
|
+
_REGION_READ_CHUNK_BYTES = 4 * 1024 * 1024
|
|
576
|
+
_REGION_READ_THREADS = 8
|
|
577
|
+
_REGION_READ_POOL = None
|
|
578
|
+
_REGION_WARM_POOL = None
|
|
579
|
+
_REGION_POOL_LOCK = threading.Lock()
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
def _region_pools():
|
|
583
|
+
global _REGION_READ_POOL, _REGION_WARM_POOL
|
|
584
|
+
with _REGION_POOL_LOCK:
|
|
585
|
+
if _REGION_READ_POOL is None:
|
|
586
|
+
_REGION_READ_POOL = ThreadPoolExecutor(
|
|
587
|
+
max_workers=_REGION_READ_THREADS, thread_name_prefix="arrayview-region-read"
|
|
588
|
+
)
|
|
589
|
+
# One background lane, so warming never competes with itself for
|
|
590
|
+
# the link the visible frame is waiting on.
|
|
591
|
+
_REGION_WARM_POOL = ThreadPoolExecutor(
|
|
592
|
+
max_workers=1, thread_name_prefix="arrayview-region-warm"
|
|
593
|
+
)
|
|
594
|
+
return _REGION_READ_POOL, _REGION_WARM_POOL
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
def _mapped_file_span(view):
|
|
598
|
+
"""Where the bytes behind a view of an ``np.memmap`` sit in its file.
|
|
599
|
+
|
|
600
|
+
Returns ``(filename, file_offset, nbytes, first_element_offset)``, or None
|
|
601
|
+
when *view* is not backed by a file map.
|
|
602
|
+
"""
|
|
603
|
+
if not isinstance(view, np.ndarray) or view.size == 0:
|
|
604
|
+
return None
|
|
605
|
+
root = view
|
|
606
|
+
while isinstance(root.base, np.ndarray):
|
|
607
|
+
root = root.base
|
|
608
|
+
if not isinstance(root, np.memmap) or not getattr(root, "filename", None):
|
|
609
|
+
return None
|
|
610
|
+
ptr = view.__array_interface__["data"][0]
|
|
611
|
+
lo = ptr + sum(min(0, (n - 1) * s) for n, s in zip(view.shape, view.strides))
|
|
612
|
+
hi = ptr + sum(max(0, (n - 1) * s) for n, s in zip(view.shape, view.strides))
|
|
613
|
+
hi += view.itemsize
|
|
614
|
+
root_ptr = root.__array_interface__["data"][0]
|
|
615
|
+
return root.filename, int(root.offset) + (lo - root_ptr), hi - lo, ptr - lo
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
def _mapped_slice_is_scattered(view) -> bool:
|
|
619
|
+
"""Whether reading *view* through its map drags in far more than it holds."""
|
|
620
|
+
span = _mapped_file_span(view)
|
|
621
|
+
if span is None:
|
|
622
|
+
return False
|
|
623
|
+
nbytes = span[2]
|
|
624
|
+
return nbytes > 4 * view.nbytes and nbytes > _REGION_READ_CHUNK_BYTES
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
def _pread_into(fd, buf, offset):
|
|
628
|
+
if hasattr(os, "preadv"):
|
|
629
|
+
return os.preadv(fd, [buf], offset)
|
|
630
|
+
data = os.pread(fd, len(buf), offset)
|
|
631
|
+
buf[: len(data)] = data
|
|
632
|
+
return len(data)
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
def read_mapped_region(view, progress=None):
|
|
636
|
+
"""Read the file bytes behind memmap view *view* into RAM with large parallel reads.
|
|
637
|
+
|
|
638
|
+
Returns an in-memory array equal to *view*. *progress*, if given, is called
|
|
639
|
+
with ``(bytes_done, bytes_total)`` as chunks land.
|
|
640
|
+
"""
|
|
641
|
+
span = _mapped_file_span(view)
|
|
642
|
+
if span is None:
|
|
643
|
+
return np.array(view)
|
|
644
|
+
filename, file_lo, nbytes, first = span
|
|
645
|
+
buf = np.empty(nbytes, dtype=np.uint8)
|
|
646
|
+
mv = memoryview(buf)
|
|
647
|
+
lock = threading.Lock()
|
|
648
|
+
done = [0]
|
|
649
|
+
fd = os.open(filename, os.O_RDONLY)
|
|
650
|
+
try:
|
|
651
|
+
|
|
652
|
+
def _read(start):
|
|
653
|
+
stop = min(start + _REGION_READ_CHUNK_BYTES, nbytes)
|
|
654
|
+
pos = start
|
|
655
|
+
while pos < stop:
|
|
656
|
+
n = _pread_into(fd, mv[pos:stop], file_lo + pos)
|
|
657
|
+
if n <= 0:
|
|
658
|
+
raise OSError(f"short read from {filename}")
|
|
659
|
+
pos += n
|
|
660
|
+
if progress is not None:
|
|
661
|
+
with lock:
|
|
662
|
+
done[0] += stop - start
|
|
663
|
+
finished = done[0]
|
|
664
|
+
try:
|
|
665
|
+
progress(finished, nbytes)
|
|
666
|
+
except Exception:
|
|
667
|
+
pass
|
|
668
|
+
|
|
669
|
+
pool, _warm = _region_pools()
|
|
670
|
+
for _ in pool.map(_read, range(0, nbytes, _REGION_READ_CHUNK_BYTES)):
|
|
671
|
+
pass
|
|
672
|
+
finally:
|
|
673
|
+
os.close(fd)
|
|
674
|
+
return np.ndarray(view.shape, view.dtype, buffer=buf, offset=first, strides=view.strides)
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
class _ScatteredRegionMixin:
|
|
678
|
+
"""Serve scattered slices of mapped NIfTI files from regions held in RAM.
|
|
679
|
+
|
|
680
|
+
A region is one whole spatial volume of a file: all of a 3D file, or one
|
|
681
|
+
map of a 4D one. When a requested slice would be scattered across its
|
|
682
|
+
region, the region is read in one go (see ``read_mapped_region``) and kept;
|
|
683
|
+
every later slice of it, in any direction, is then served from memory.
|
|
684
|
+
Afterwards the case's other regions and the neighbouring case are read in
|
|
685
|
+
the background, so the next step — another map, the next patient — is
|
|
686
|
+
usually already there.
|
|
687
|
+
"""
|
|
688
|
+
|
|
689
|
+
def _init_region_cache(self):
|
|
690
|
+
self._region_cache: OrderedDict = OrderedDict()
|
|
691
|
+
self._region_cache_bytes = 0
|
|
692
|
+
self._region_cache_max_bytes = int(
|
|
693
|
+
os.environ.get("ARRAYVIEW_NIFTI_REGION_CACHE_BYTES", 2 * 1024**3)
|
|
694
|
+
)
|
|
695
|
+
self._region_lock = threading.Lock()
|
|
696
|
+
self._region_jobs = {}
|
|
697
|
+
self._region_generation = 0
|
|
698
|
+
self._region_last_case = None
|
|
699
|
+
self._mapped_vols = {}
|
|
700
|
+
|
|
701
|
+
def _mapped_volume(self, p_idx, m_idx, vol):
|
|
702
|
+
"""*vol* as a memmap-backed array, or None if it is not one."""
|
|
703
|
+
if isinstance(vol, np.ndarray):
|
|
704
|
+
return vol if _mapped_file_span(vol) is not None else None
|
|
705
|
+
key = (p_idx, m_idx)
|
|
706
|
+
with self._region_lock:
|
|
707
|
+
if key in self._mapped_vols:
|
|
708
|
+
return self._mapped_vols[key]
|
|
709
|
+
mapped = None
|
|
710
|
+
# An uncompressed, unscaled proxy maps without reading anything.
|
|
711
|
+
slope = getattr(vol, "slope", None)
|
|
712
|
+
inter = getattr(vol, "inter", None)
|
|
713
|
+
if (
|
|
714
|
+
getattr(vol, "is_proxy", False)
|
|
715
|
+
and slope == 1
|
|
716
|
+
and inter == 0
|
|
717
|
+
and str(getattr(vol, "file_like", "")).endswith(".nii")
|
|
718
|
+
):
|
|
719
|
+
try:
|
|
720
|
+
arr = np.asanyarray(vol)
|
|
721
|
+
if _mapped_file_span(arr) is not None:
|
|
722
|
+
mapped = arr
|
|
723
|
+
except Exception:
|
|
724
|
+
mapped = None
|
|
725
|
+
with self._region_lock:
|
|
726
|
+
self._mapped_vols[key] = mapped
|
|
727
|
+
return mapped
|
|
728
|
+
|
|
729
|
+
@staticmethod
|
|
730
|
+
def _region_split(mapped, spatial_key):
|
|
731
|
+
"""Split *spatial_key* into the region's key and the key within it."""
|
|
732
|
+
n_sp = min(3, mapped.ndim)
|
|
733
|
+
rest = tuple(spatial_key[n_sp:])
|
|
734
|
+
if not all(isinstance(r, (int, np.integer)) for r in rest):
|
|
735
|
+
return None
|
|
736
|
+
return tuple(int(r) for r in rest), tuple(spatial_key[:n_sp])
|
|
737
|
+
|
|
738
|
+
def _region_view(self, mapped, rest):
|
|
739
|
+
n_sp = min(3, mapped.ndim)
|
|
740
|
+
return mapped[(slice(None),) * n_sp + rest]
|
|
741
|
+
|
|
742
|
+
def _cached_region(self, key):
|
|
743
|
+
with self._region_lock:
|
|
744
|
+
arr = self._region_cache.get(key)
|
|
745
|
+
if arr is not None:
|
|
746
|
+
self._region_cache.move_to_end(key)
|
|
747
|
+
return arr
|
|
748
|
+
|
|
749
|
+
def _load_region(self, key, view, progress=None):
|
|
750
|
+
with self._region_lock:
|
|
751
|
+
arr = self._region_cache.get(key)
|
|
752
|
+
if arr is not None:
|
|
753
|
+
self._region_cache.move_to_end(key)
|
|
754
|
+
return arr
|
|
755
|
+
fut = self._region_jobs.get(key)
|
|
756
|
+
owner = fut is None
|
|
757
|
+
if owner:
|
|
758
|
+
fut = Future()
|
|
759
|
+
self._region_jobs[key] = fut
|
|
760
|
+
if not owner:
|
|
761
|
+
return fut.result()
|
|
762
|
+
try:
|
|
763
|
+
arr = read_mapped_region(view, progress)
|
|
764
|
+
except BaseException as exc:
|
|
765
|
+
fut.set_exception(exc)
|
|
766
|
+
raise
|
|
767
|
+
finally:
|
|
768
|
+
with self._region_lock:
|
|
769
|
+
self._region_jobs.pop(key, None)
|
|
770
|
+
with self._region_lock:
|
|
771
|
+
self._region_cache[key] = arr
|
|
772
|
+
self._region_cache_bytes += arr.nbytes
|
|
773
|
+
while (
|
|
774
|
+
self._region_cache_bytes > self._region_cache_max_bytes
|
|
775
|
+
and len(self._region_cache) > 1
|
|
776
|
+
):
|
|
777
|
+
_old, evicted = self._region_cache.popitem(last=False)
|
|
778
|
+
self._region_cache_bytes -= evicted.nbytes
|
|
779
|
+
fut.set_result(arr)
|
|
780
|
+
return arr
|
|
781
|
+
|
|
782
|
+
def _scattered_region_slice(self, p_idx, m_idx, vol, spatial_key, progress=None):
|
|
783
|
+
"""``vol[spatial_key]`` from a region in RAM, or None to read it as usual."""
|
|
784
|
+
mapped = self._mapped_volume(p_idx, m_idx, vol)
|
|
785
|
+
if mapped is None:
|
|
786
|
+
return None
|
|
787
|
+
split = self._region_split(mapped, spatial_key)
|
|
788
|
+
if split is None:
|
|
789
|
+
return None
|
|
790
|
+
rest, inner = split
|
|
791
|
+
key = (p_idx, m_idx, rest)
|
|
792
|
+
region = self._cached_region(key)
|
|
793
|
+
if region is None:
|
|
794
|
+
try:
|
|
795
|
+
if not _mapped_slice_is_scattered(mapped[tuple(spatial_key)]):
|
|
796
|
+
return None
|
|
797
|
+
view = self._region_view(mapped, rest)
|
|
798
|
+
if view.nbytes > self._region_cache_max_bytes // 2:
|
|
799
|
+
return None
|
|
800
|
+
region = self._load_region(key, view, progress)
|
|
801
|
+
except Exception:
|
|
802
|
+
return None
|
|
803
|
+
self._schedule_region_warm(p_idx, m_idx, rest, spatial_key)
|
|
804
|
+
return region[inner]
|
|
805
|
+
|
|
806
|
+
def _schedule_region_warm(self, p_idx, m_idx, rest, spatial_key):
|
|
807
|
+
case = (p_idx, m_idx)
|
|
808
|
+
with self._region_lock:
|
|
809
|
+
last = self._region_last_case
|
|
810
|
+
if last == case:
|
|
811
|
+
return
|
|
812
|
+
self._region_last_case = case
|
|
813
|
+
self._region_generation += 1
|
|
814
|
+
generation = self._region_generation
|
|
815
|
+
n_p = len(self._file_matrix)
|
|
816
|
+
n_m = len(self._file_matrix[0]) if self._file_matrix else 0
|
|
817
|
+
# Neighbours along whichever stack axis was stepped: patients, or
|
|
818
|
+
# channels when separate files were stacked that way.
|
|
819
|
+
along_m = (n_p == 1 and n_m > 1) or (
|
|
820
|
+
last is not None and last[0] == p_idx and last[1] != m_idx
|
|
821
|
+
)
|
|
822
|
+
if along_m:
|
|
823
|
+
step = -1 if last is not None and last[1] > m_idx else 1
|
|
824
|
+
neighbours = [(p_idx, m_idx + step), (p_idx, m_idx - step)]
|
|
825
|
+
else:
|
|
826
|
+
step = -1 if last is not None and last[0] > p_idx else 1
|
|
827
|
+
neighbours = [(p_idx + step, m_idx), (p_idx - step, m_idx)]
|
|
828
|
+
# Which axes are on screen is all that carries over to another case;
|
|
829
|
+
# the indices along the others may not fit a differently-sized one.
|
|
830
|
+
probe = tuple(
|
|
831
|
+
slice(None) if isinstance(k, slice) else 0 for k in spatial_key[: min(3, len(spatial_key))]
|
|
832
|
+
)
|
|
833
|
+
plan = [(p_idx, m_idx)] + [
|
|
834
|
+
(p, m) for p, m in neighbours if 0 <= p < n_p and 0 <= m < n_m
|
|
835
|
+
]
|
|
836
|
+
first_rest = rest
|
|
837
|
+
|
|
838
|
+
def _warm():
|
|
839
|
+
budget = self._region_cache_max_bytes // 2
|
|
840
|
+
for p, m in plan:
|
|
841
|
+
with self._region_lock:
|
|
842
|
+
if generation != self._region_generation:
|
|
843
|
+
return
|
|
844
|
+
try:
|
|
845
|
+
if self._file_matrix[p][m] is None:
|
|
846
|
+
continue
|
|
847
|
+
mapped = self._mapped_volume(p, m, self._get_volume(p, m))
|
|
848
|
+
if mapped is None or not _mapped_slice_is_scattered(mapped[probe + first_rest]):
|
|
849
|
+
continue
|
|
850
|
+
n_sp = min(3, mapped.ndim)
|
|
851
|
+
rests = list(np.ndindex(*mapped.shape[n_sp:])) or [()]
|
|
852
|
+
# The visible map first, then the case's others.
|
|
853
|
+
rests.sort(key=lambda r: r != first_rest)
|
|
854
|
+
for r in rests:
|
|
855
|
+
with self._region_lock:
|
|
856
|
+
if generation != self._region_generation:
|
|
857
|
+
return
|
|
858
|
+
view = self._region_view(mapped, tuple(int(i) for i in r))
|
|
859
|
+
budget -= view.nbytes
|
|
860
|
+
if budget < 0:
|
|
861
|
+
return
|
|
862
|
+
self._load_region((p, m, tuple(int(i) for i in r)), view)
|
|
863
|
+
except Exception:
|
|
864
|
+
continue
|
|
865
|
+
|
|
866
|
+
_region_pools()[1].submit(_warm)
|
|
867
|
+
|
|
868
|
+
|
|
565
869
|
# ---------------------------------------------------------------------------
|
|
566
870
|
# File series — lazy 4D/5D view over a directory of same-shape volumes
|
|
567
871
|
# ---------------------------------------------------------------------------
|
|
@@ -646,7 +950,7 @@ class _ProgressiveNiftiSeriesMixin:
|
|
|
646
950
|
return None
|
|
647
951
|
|
|
648
952
|
|
|
649
|
-
class _NiftiSeries(_ProgressiveNiftiSeriesMixin):
|
|
953
|
+
class _NiftiSeries(_ProgressiveNiftiSeriesMixin, _ScatteredRegionMixin):
|
|
650
954
|
"""Lazy 4D/5D view over a directory of same-shape NIfTI files.
|
|
651
955
|
|
|
652
956
|
``file_matrix`` is a P x M list-of-lists of filepaths (P patients,
|
|
@@ -682,6 +986,7 @@ class _NiftiSeries(_ProgressiveNiftiSeriesMixin):
|
|
|
682
986
|
self._cache_lock = threading.Lock()
|
|
683
987
|
self._load_locks = {}
|
|
684
988
|
self._init_progressive_loading()
|
|
989
|
+
self._init_region_cache()
|
|
685
990
|
|
|
686
991
|
@property
|
|
687
992
|
def dtype(self):
|
|
@@ -724,6 +1029,10 @@ class _NiftiSeries(_ProgressiveNiftiSeriesMixin):
|
|
|
724
1029
|
return vol
|
|
725
1030
|
|
|
726
1031
|
def __getitem__(self, key):
|
|
1032
|
+
return self.read_slice(key)
|
|
1033
|
+
|
|
1034
|
+
def read_slice(self, key, progress=None):
|
|
1035
|
+
"""``self[key]``; *progress* follows any whole-region read it needs."""
|
|
727
1036
|
if not isinstance(key, tuple):
|
|
728
1037
|
key = (key,)
|
|
729
1038
|
has_special = any(k is None or k is Ellipsis for k in key)
|
|
@@ -765,6 +1074,11 @@ class _NiftiSeries(_ProgressiveNiftiSeriesMixin):
|
|
|
765
1074
|
if plane is not None:
|
|
766
1075
|
return plane
|
|
767
1076
|
vol = self._get_volume(p_idx, m_idx)
|
|
1077
|
+
region = self._scattered_region_slice(
|
|
1078
|
+
p_idx, m_idx, vol, spatial_key, progress
|
|
1079
|
+
)
|
|
1080
|
+
if region is not None:
|
|
1081
|
+
return region
|
|
768
1082
|
return vol[spatial_key]
|
|
769
1083
|
return np.asarray(self)[key]
|
|
770
1084
|
|
|
@@ -873,7 +1187,7 @@ class _FileSeries:
|
|
|
873
1187
|
return result
|
|
874
1188
|
|
|
875
1189
|
|
|
876
|
-
class _RaggedFileSeries(_ProgressiveNiftiSeriesMixin):
|
|
1190
|
+
class _RaggedFileSeries(_ProgressiveNiftiSeriesMixin, _ScatteredRegionMixin):
|
|
877
1191
|
"""Lazy collection view over same-rank, same-dtype files with varying shapes.
|
|
878
1192
|
|
|
879
1193
|
The public ``shape`` is a max-spatial-shape facade so existing viewer
|
|
@@ -923,6 +1237,7 @@ class _RaggedFileSeries(_ProgressiveNiftiSeriesMixin):
|
|
|
923
1237
|
self._cache_lock = threading.Lock()
|
|
924
1238
|
self._load_locks = {}
|
|
925
1239
|
self._init_progressive_loading()
|
|
1240
|
+
self._init_region_cache()
|
|
926
1241
|
|
|
927
1242
|
@property
|
|
928
1243
|
def dtype(self):
|
|
@@ -1000,6 +1315,10 @@ class _RaggedFileSeries(_ProgressiveNiftiSeriesMixin):
|
|
|
1000
1315
|
return vol
|
|
1001
1316
|
|
|
1002
1317
|
def __getitem__(self, key):
|
|
1318
|
+
return self.read_slice(key)
|
|
1319
|
+
|
|
1320
|
+
def read_slice(self, key, progress=None):
|
|
1321
|
+
"""``self[key]``; *progress* follows any whole-region read it needs."""
|
|
1003
1322
|
if not isinstance(key, tuple):
|
|
1004
1323
|
key = (key,)
|
|
1005
1324
|
has_special = any(k is None or k is Ellipsis for k in key)
|
|
@@ -1040,7 +1359,14 @@ class _RaggedFileSeries(_ProgressiveNiftiSeriesMixin):
|
|
|
1040
1359
|
plane = self._get_progressive_plane(p_idx, m_idx, z_index)
|
|
1041
1360
|
if plane is not None:
|
|
1042
1361
|
return plane
|
|
1043
|
-
|
|
1362
|
+
vol = self._get_volume(p_idx, m_idx)
|
|
1363
|
+
if self._all_nifti:
|
|
1364
|
+
region = self._scattered_region_slice(
|
|
1365
|
+
p_idx, m_idx, vol, tuple(spatial_key), progress
|
|
1366
|
+
)
|
|
1367
|
+
if region is not None:
|
|
1368
|
+
return region
|
|
1369
|
+
return vol[tuple(spatial_key)]
|
|
1044
1370
|
raise TypeError("Ragged collections require concrete collection indices.")
|
|
1045
1371
|
|
|
1046
1372
|
def __array__(self, dtype=None):
|
|
@@ -1107,6 +1433,38 @@ def _collection_pattern_paths(pattern):
|
|
|
1107
1433
|
return paths
|
|
1108
1434
|
|
|
1109
1435
|
|
|
1436
|
+
def _explicit_case_files(patterns):
|
|
1437
|
+
"""Plain file paths given as several patterns, or None.
|
|
1438
|
+
|
|
1439
|
+
An unquoted ``--match dir/*/maps.nii`` reaches us already expanded by the
|
|
1440
|
+
shell: one literal path per case. Read as separate image patterns, that
|
|
1441
|
+
became one case with a channel per file — every patient on the channel
|
|
1442
|
+
axis, where patient navigation and prefetch never see them.
|
|
1443
|
+
"""
|
|
1444
|
+
if len(patterns) < 2:
|
|
1445
|
+
return None
|
|
1446
|
+
if any(_GLOB_MAGIC.search(str(p)) or not os.path.isfile(p) for p in patterns):
|
|
1447
|
+
return None
|
|
1448
|
+
paths = [os.path.abspath(p) for p in patterns if _is_supported_collection_path(p)]
|
|
1449
|
+
if len(paths) != len(patterns) or len(set(paths)) != len(paths):
|
|
1450
|
+
return None
|
|
1451
|
+
return sorted(paths)
|
|
1452
|
+
|
|
1453
|
+
|
|
1454
|
+
def _distinguishing_path_parts(paths):
|
|
1455
|
+
"""Name each path by the first path component in which the paths differ."""
|
|
1456
|
+
split = [os.path.normpath(p).split(os.sep) for p in paths]
|
|
1457
|
+
if len({len(parts) for parts in split}) == 1:
|
|
1458
|
+
for i in range(len(split[0])):
|
|
1459
|
+
names = [parts[i] for parts in split]
|
|
1460
|
+
if len(set(names)) == len(names):
|
|
1461
|
+
return [_strip_array_ext(n) if i == len(split[0]) - 1 else n for n in names]
|
|
1462
|
+
return [_default_collection_case_key(p) for p in paths]
|
|
1463
|
+
|
|
1464
|
+
|
|
1465
|
+
_GLOB_MAGIC = re.compile(r"[*?[]")
|
|
1466
|
+
|
|
1467
|
+
|
|
1110
1468
|
def _collection_pattern_map(pattern, case_regex):
|
|
1111
1469
|
paths = _collection_pattern_paths(pattern)
|
|
1112
1470
|
by_case = {}
|
|
@@ -1339,6 +1697,7 @@ def load_dir_collection(
|
|
|
1339
1697
|
overlays = overlays or []
|
|
1340
1698
|
|
|
1341
1699
|
inferred_case_depth = None
|
|
1700
|
+
explicit_cases = None
|
|
1342
1701
|
if case_regex:
|
|
1343
1702
|
base_maps = [
|
|
1344
1703
|
_collection_pattern_map(pattern, case_regex=case_regex)
|
|
@@ -1354,11 +1713,21 @@ def load_dir_collection(
|
|
|
1354
1713
|
raise ValueError("; ".join(missing))
|
|
1355
1714
|
base_matrix = [[by_case[case] for by_case in base_maps] for case in case_ids]
|
|
1356
1715
|
else:
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1716
|
+
explicit_cases = _explicit_case_files(base_patterns)
|
|
1717
|
+
base_lists = (
|
|
1718
|
+
[explicit_cases]
|
|
1719
|
+
if explicit_cases is not None
|
|
1720
|
+
else [_collection_pattern_paths(pattern) for pattern in base_patterns]
|
|
1360
1721
|
)
|
|
1361
|
-
|
|
1722
|
+
inferred_maps, inferred_case_depth = (
|
|
1723
|
+
(None, None)
|
|
1724
|
+
if explicit_cases is not None
|
|
1725
|
+
else _infer_collection_layout_maps(base_lists, base_patterns)
|
|
1726
|
+
)
|
|
1727
|
+
if explicit_cases is not None:
|
|
1728
|
+
case_ids = _distinguishing_path_parts(explicit_cases)
|
|
1729
|
+
base_matrix = [[path] for path in explicit_cases]
|
|
1730
|
+
elif inferred_maps is not None:
|
|
1362
1731
|
case_ids = sorted(inferred_maps[0])
|
|
1363
1732
|
base_matrix = [
|
|
1364
1733
|
[by_case[case] for by_case in inferred_maps] for case in case_ids
|
|
@@ -1490,7 +1859,11 @@ def load_dir_collection(
|
|
|
1490
1859
|
|
|
1491
1860
|
summary = {
|
|
1492
1861
|
"cases": case_ids,
|
|
1493
|
-
"base_patterns":
|
|
1862
|
+
"base_patterns": (
|
|
1863
|
+
[f"{len(explicit_cases)} files, one per case"]
|
|
1864
|
+
if not case_regex and explicit_cases is not None
|
|
1865
|
+
else list(base_patterns)
|
|
1866
|
+
),
|
|
1494
1867
|
"overlays": overlay_reports,
|
|
1495
1868
|
"shape": tuple(int(s) for s in data.shape),
|
|
1496
1869
|
"spatial_shape": tuple(int(s) for s in spatial_shape),
|
arrayview/_render.py
CHANGED
|
@@ -219,7 +219,12 @@ def extract_slice(session, dim_x, dim_y, idx_list, progress=None):
|
|
|
219
219
|
)
|
|
220
220
|
except Exception:
|
|
221
221
|
pass
|
|
222
|
-
|
|
222
|
+
if hasattr(data, "read_slice"):
|
|
223
|
+
# NIfTI collections read scattered slices as whole regions and report
|
|
224
|
+
# that read themselves; blocking it here would hide the wait.
|
|
225
|
+
extracted = np.array(data.read_slice(tuple(slicer), progress))
|
|
226
|
+
else:
|
|
227
|
+
extracted = _extract_with_progress(data, slicer, progress)
|
|
223
228
|
if dim_x < dim_y:
|
|
224
229
|
extracted = extracted.T
|
|
225
230
|
# scipy.io.loadmat returns complex arrays as structured dtypes; convert here.
|
arrayview/_server.py
CHANGED
|
@@ -54,6 +54,7 @@ from arrayview._config import (
|
|
|
54
54
|
get_viewer_dimbar_mode,
|
|
55
55
|
get_viewer_ortho_layout,
|
|
56
56
|
get_viewer_rounded_panes,
|
|
57
|
+
get_viewer_qmri_gapless,
|
|
57
58
|
get_viewer_theme,
|
|
58
59
|
)
|
|
59
60
|
|
|
@@ -482,6 +483,7 @@ def _viewer_ui_response(
|
|
|
482
483
|
.replace("__ARRAYVIEW_BOOT_METADATA__", _boot_metadata_json(sid))
|
|
483
484
|
.replace("__DEFAULT_THEME_IDX__", str(_default_theme_idx))
|
|
484
485
|
.replace("__DEFAULT_ROUNDED_PANES__", _default_rounded_panes)
|
|
486
|
+
.replace("__DEFAULT_QMRI_GAPLESS__", "true" if get_viewer_qmri_gapless() else "false")
|
|
485
487
|
.replace("__DEFAULT_ORTHO_LAYOUT__", _default_ortho_layout)
|
|
486
488
|
.replace("__DEFAULT_DIMBAR_MODE__", _default_dimbar_mode)
|
|
487
489
|
.replace("__BODY_CLASS__", "av-loading" if sid else "")
|
arrayview/_viewer.html
CHANGED
|
@@ -569,8 +569,8 @@
|
|
|
569
569
|
the tick room under the island as margin while ticks are hidden,
|
|
570
570
|
and swap it for padding when they show (7px base bottom pad from
|
|
571
571
|
.cb-wrap → 18px with ticks), so the pane never changes size. */
|
|
572
|
-
.qv-canvas-wrap > .qv-cb-island:not(.qmri-mv-vcb-island):not(.fs-overlay) { margin-bottom: 11px; }
|
|
573
|
-
.qv-canvas-wrap > .qv-cb-island.cb-has-ticks:not(.qmri-mv-vcb-island):not(.fs-overlay) { margin-bottom: 0; }
|
|
572
|
+
.qv-canvas-wrap > .qv-cb-island:not(.qmri-mv-vcb-island):not(.fs-overlay):not(.qv-cb-inset) { margin-bottom: 11px; }
|
|
573
|
+
.qv-canvas-wrap > .qv-cb-island.cb-has-ticks:not(.qmri-mv-vcb-island):not(.fs-overlay):not(.qv-cb-inset) { margin-bottom: 0; }
|
|
574
574
|
.cb-tooltip {
|
|
575
575
|
position: absolute; top: 0; left: 0;
|
|
576
576
|
font-size: 12px; font-family: 'SF Mono', ui-monospace, 'Cascadia Code', monospace;
|
|
@@ -4870,6 +4870,28 @@
|
|
|
4870
4870
|
pointer-events: none !important;
|
|
4871
4871
|
}
|
|
4872
4872
|
body.fullscreen-mode .qv-cb-island.fs-overlay > * { pointer-events: auto; }
|
|
4873
|
+
/* qMRI maps touching (Preferences): no gaps; with two rows the
|
|
4874
|
+
colour bars float inside the maps like the immersive islands. */
|
|
4875
|
+
body.qmri-gapless #qmri-view-wrap.active { gap: 0 !important; }
|
|
4876
|
+
body.qmri-gapless #qmri-view-wrap > .qv-row:not(.qmri-mosaic-row) { gap: 0 !important; }
|
|
4877
|
+
body.qmri-gapless #qmri-view-wrap .qv-pane { gap: 0; }
|
|
4878
|
+
body.qmri-gapless #qmri-view-wrap .qv-canvas-clip { border-radius: 0 !important; }
|
|
4879
|
+
#qmri-view-wrap .qv-cb-island.qv-cb-inset {
|
|
4880
|
+
opacity: 1 !important; position: absolute !important; bottom: 8px !important;
|
|
4881
|
+
left: 50% !important; transform: translateX(-50%) !important;
|
|
4882
|
+
margin: 0 !important; padding: 3px 8px !important;
|
|
4883
|
+
background: rgba(30, 30, 30, 0.8) !important;
|
|
4884
|
+
backdrop-filter: blur(12px) !important; -webkit-backdrop-filter: blur(12px) !important;
|
|
4885
|
+
border: 1px solid rgba(255, 255, 255, 0.06) !important;
|
|
4886
|
+
border-radius: 8px !important; z-index: 2;
|
|
4887
|
+
box-shadow: 0 2px 12px rgba(0,0,0,0.4) !important;
|
|
4888
|
+
pointer-events: none !important;
|
|
4889
|
+
}
|
|
4890
|
+
#qmri-view-wrap .qv-cb-island.qv-cb-inset > * { pointer-events: auto; }
|
|
4891
|
+
:root.light #qmri-view-wrap .qv-cb-island.qv-cb-inset .qv-cb-val { color: #fff; }
|
|
4892
|
+
/* Floating islands are narrow: the value labels must not take the
|
|
4893
|
+
bar's room with their 10ch strip-layout reservation. */
|
|
4894
|
+
#qmri-view-wrap .qv-cb-island.qv-cb-inset .slim-cb-val { min-width: 5ch !important; }
|
|
4873
4895
|
/* qMRI pane titles as text-stroke corner labels in immersive */
|
|
4874
4896
|
body.fullscreen-mode .qmri-pane > .qv-label {
|
|
4875
4897
|
top: 4px; left: 4px;
|
|
@@ -5954,6 +5976,7 @@
|
|
|
5954
5976
|
// browser as one cacheable script instead of re-sending ~2 MB each time.
|
|
5955
5977
|
const DEFAULT_THEME_IDX = __DEFAULT_THEME_IDX__;
|
|
5956
5978
|
const DEFAULT_ROUNDED_PANES = __DEFAULT_ROUNDED_PANES__;
|
|
5979
|
+
const DEFAULT_QMRI_GAPLESS = __DEFAULT_QMRI_GAPLESS__;
|
|
5957
5980
|
const DEFAULT_ORTHO_LAYOUT = __DEFAULT_ORTHO_LAYOUT__;
|
|
5958
5981
|
const DEFAULT_DIMBAR_MODE = __DEFAULT_DIMBAR_MODE__;
|
|
5959
5982
|
// The array's description, written into the page by the server when it
|
|
@@ -6979,19 +7002,30 @@
|
|
|
6979
7002
|
let _mainRenderPatientIndex = null;
|
|
6980
7003
|
let _compareRenderPatientIndex = null;
|
|
6981
7004
|
|
|
6982
|
-
|
|
7005
|
+
// One number per case: the patient index, combined with the channel
|
|
7006
|
+
// index when files were also stacked as channels. Stepping either one
|
|
7007
|
+
// swaps every pane's source file, so both count as a case change.
|
|
7008
|
+
function _caseIndexFromIndices(idx) {
|
|
6983
7009
|
if (!Number.isInteger(collectionSpatialNdim) || collectionSpatialNdim < 0
|
|
6984
|
-
|| collectionSpatialNdim >=
|
|
6985
|
-
|
|
6986
|
-
|
|
7010
|
+
|| collectionSpatialNdim >= idx.length) return null;
|
|
7011
|
+
let key = 0;
|
|
7012
|
+
for (let k = collectionSpatialNdim; k < idx.length; k++) {
|
|
7013
|
+
const value = Number(idx[k]);
|
|
7014
|
+
if (!Number.isInteger(value)) return null;
|
|
7015
|
+
key = key * Math.max(1, Number(shape[k]) || 1) + value;
|
|
7016
|
+
}
|
|
7017
|
+
return key;
|
|
7018
|
+
}
|
|
7019
|
+
|
|
7020
|
+
function _currentPatientIndex() {
|
|
7021
|
+
return _caseIndexFromIndices(indices);
|
|
6987
7022
|
}
|
|
6988
7023
|
|
|
6989
7024
|
function _patientIndexFromRenderParams(params) {
|
|
6990
7025
|
if (!params || !Number.isInteger(collectionSpatialNdim) || collectionSpatialNdim < 0) return null;
|
|
6991
7026
|
const raw = params.get('indices');
|
|
6992
7027
|
if (!raw) return null;
|
|
6993
|
-
|
|
6994
|
-
return Number.isInteger(value) ? value : null;
|
|
7028
|
+
return _caseIndexFromIndices(raw.split(','));
|
|
6995
7029
|
}
|
|
6996
7030
|
|
|
6997
7031
|
function _beginPatientLoading() {
|
|
@@ -7018,6 +7052,59 @@
|
|
|
7018
7052
|
}, PATIENT_LOADING_THRESHOLD_MS);
|
|
7019
7053
|
}
|
|
7020
7054
|
|
|
7055
|
+
// On a patient change every pane of a multi-pane mode (qMRI maps,
|
|
7056
|
+
// ortho views) fetches its own frame, and off a slow share they land
|
|
7057
|
+
// seconds apart: one map flipped to the new patient while the rest
|
|
7058
|
+
// still showed the old one. Hold each new-patient frame until every
|
|
7059
|
+
// pane has one, then draw them together. Nothing new is drawn while
|
|
7060
|
+
// holding, so the patient-loading overlay stays up meanwhile.
|
|
7061
|
+
const PATIENT_GROUP_HOLD_MAX_MS = 15000;
|
|
7062
|
+
let _patientHold = null;
|
|
7063
|
+
let _patientHoldReleasing = false;
|
|
7064
|
+
|
|
7065
|
+
function _releasePatientHold(views, draw, p) {
|
|
7066
|
+
_patientHoldReleasing = true;
|
|
7067
|
+
try {
|
|
7068
|
+
views.forEach(o => {
|
|
7069
|
+
if (o._framePatientIndex === p && o.lastImageData !== o._shownImageData) draw(o);
|
|
7070
|
+
});
|
|
7071
|
+
} finally {
|
|
7072
|
+
_patientHoldReleasing = false;
|
|
7073
|
+
}
|
|
7074
|
+
}
|
|
7075
|
+
|
|
7076
|
+
// True when *v*'s new frame must wait; the caller then skips drawing.
|
|
7077
|
+
function _holdForPatientGroup(v, views, draw) {
|
|
7078
|
+
// A redraw of what is already on screen (resize, zoom) never waits.
|
|
7079
|
+
if (v.lastImageData === v._shownImageData) return false;
|
|
7080
|
+
const p = v._renderPatientIndex;
|
|
7081
|
+
v._framePatientIndex = p;
|
|
7082
|
+
const hold = !_patientHoldReleasing
|
|
7083
|
+
&& Number.isInteger(p) && p !== _displayedPatientIndex
|
|
7084
|
+
&& views.length > 1 && views.includes(v)
|
|
7085
|
+
&& !views.every(o => o._framePatientIndex === p);
|
|
7086
|
+
if (!hold) {
|
|
7087
|
+
v._shownImageData = v.lastImageData;
|
|
7088
|
+
if (!_patientHoldReleasing && _patientHold && _patientHold.p === p) {
|
|
7089
|
+
clearTimeout(_patientHold.timer);
|
|
7090
|
+
_patientHold = null;
|
|
7091
|
+
_releasePatientHold(views.filter(o => o !== v), draw, p);
|
|
7092
|
+
}
|
|
7093
|
+
return false;
|
|
7094
|
+
}
|
|
7095
|
+
if (!_patientHold || _patientHold.p !== p || _patientHold.views !== views) {
|
|
7096
|
+
if (_patientHold) clearTimeout(_patientHold.timer);
|
|
7097
|
+
// A pane whose frame never comes must not freeze the others.
|
|
7098
|
+
const timer = setTimeout(() => {
|
|
7099
|
+
if (!_patientHold || _patientHold.timer !== timer) return;
|
|
7100
|
+
_patientHold = null;
|
|
7101
|
+
_releasePatientHold(views, draw, p);
|
|
7102
|
+
}, PATIENT_GROUP_HOLD_MAX_MS);
|
|
7103
|
+
_patientHold = { p, views, timer };
|
|
7104
|
+
}
|
|
7105
|
+
return true;
|
|
7106
|
+
}
|
|
7107
|
+
|
|
7021
7108
|
function _patientFrameDisplayed(framePatientIndex) {
|
|
7022
7109
|
if (!Number.isInteger(framePatientIndex)) return;
|
|
7023
7110
|
_displayedPatientIndex = framePatientIndex;
|
|
@@ -7377,6 +7464,7 @@
|
|
|
7377
7464
|
let _mvNavRenderTimer = null; // throttle timer for oblique crosshair-nav renders
|
|
7378
7465
|
let canvasBorders = true; // toggled by 'b' key
|
|
7379
7466
|
let roundedPanes = DEFAULT_ROUNDED_PANES; // toggled by Shift+B; default on unless config viewer.rounded_panes=false
|
|
7467
|
+
let qmriGapless = DEFAULT_QMRI_GAPLESS; // Preferences → qMRI maps touching (viewer.qmri_gapless)
|
|
7380
7468
|
let squareStretch = false; // toggled by 'a' — stretch each pane to a square box
|
|
7381
7469
|
let compareActive = false;
|
|
7382
7470
|
let compareSid = urlParams.get('compare_sid') || null;
|
|
@@ -24126,6 +24214,7 @@
|
|
|
24126
24214
|
const PREFERENCE_COPY = {
|
|
24127
24215
|
'viewer.theme': ['Theme', 'Applies immediately and to future viewers.'],
|
|
24128
24216
|
'viewer.rounded_panes': ['Rounded panes', 'Applies immediately across viewer modes.'],
|
|
24217
|
+
'viewer.qmri_gapless': ['qMRI maps touching', 'No space between qMRI maps, so they can be larger. With two rows, colour bars move inside the maps.'],
|
|
24129
24218
|
'viewer.colormaps': ['Colormap cycle', 'Comma-separated names used by the colormap picker.'],
|
|
24130
24219
|
'viewer.ortho_layout': ['Ortho-view layout', 'Default arrangement when ortho view opens.'],
|
|
24131
24220
|
'viewer.dimbar_mode': ['Dimbar mode', 'Whether dimension extents start compact or extended.'],
|
|
@@ -24181,6 +24270,10 @@
|
|
|
24181
24270
|
} else if (key === 'rounded_panes') {
|
|
24182
24271
|
roundedPanes = !!value;
|
|
24183
24272
|
_reconcileLayout();
|
|
24273
|
+
} else if (key === 'qmri_gapless') {
|
|
24274
|
+
qmriGapless = !!value;
|
|
24275
|
+
_reconcileLayout();
|
|
24276
|
+
if (qmriActive) qvScaleAllCanvases();
|
|
24184
24277
|
} else if (key === 'ortho_layout' && _getOrthoPreset(value)) {
|
|
24185
24278
|
orthoLayoutMode = value;
|
|
24186
24279
|
_orthoAutoLayoutMode = null;
|
|
@@ -27732,6 +27825,13 @@
|
|
|
27732
27825
|
showStatus('immersive: not available in ortho view');
|
|
27733
27826
|
return;
|
|
27734
27827
|
}
|
|
27828
|
+
if (qmriActive) {
|
|
27829
|
+
// Three maps side by side are limited by width, which
|
|
27830
|
+
// immersive does not free up; it would only add chrome
|
|
27831
|
+
// motion for no bigger maps.
|
|
27832
|
+
showStatus('immersive: not available in qMRI');
|
|
27833
|
+
return;
|
|
27834
|
+
}
|
|
27735
27835
|
if (_fullscreenActive) {
|
|
27736
27836
|
// Exit immersive — animated reverse via existing drive path.
|
|
27737
27837
|
userZoom = _normalFitZoom;
|
|
@@ -37209,6 +37309,7 @@
|
|
|
37209
37309
|
|
|
37210
37310
|
function compareQmriDrawFrame(v) {
|
|
37211
37311
|
if (!v.lastW || !v.lastH || !v.lastImageData) return;
|
|
37312
|
+
if (_holdForPatientGroup(v, compareQmriViews, compareQmriDrawFrame)) return;
|
|
37212
37313
|
if (v.canvas.width !== v.lastW || v.canvas.height !== v.lastH) {
|
|
37213
37314
|
v.canvas.width = v.lastW;
|
|
37214
37315
|
v.canvas.height = v.lastH;
|
|
@@ -37798,6 +37899,7 @@
|
|
|
37798
37899
|
|
|
37799
37900
|
function compareMvDrawFrame(v) {
|
|
37800
37901
|
if (!v.lastW || !v.lastH || !v.lastImageData) return;
|
|
37902
|
+
if (_holdForPatientGroup(v, compareMvViews, compareMvDrawFrame)) return;
|
|
37801
37903
|
if (v.canvas.width !== v.lastW || v.canvas.height !== v.lastH) {
|
|
37802
37904
|
v.canvas.width = v.lastW;
|
|
37803
37905
|
v.canvas.height = v.lastH;
|
|
@@ -38396,6 +38498,7 @@
|
|
|
38396
38498
|
|
|
38397
38499
|
function qmriMvDrawFrame(v) {
|
|
38398
38500
|
if (!v.lastW || !v.lastH || !v.lastImageData) return;
|
|
38501
|
+
if (_holdForPatientGroup(v, qmriMvViews, qmriMvDrawFrame)) return;
|
|
38399
38502
|
if (v.canvas.width !== v.lastW || v.canvas.height !== v.lastH) {
|
|
38400
38503
|
v.canvas.width = v.lastW;
|
|
38401
38504
|
v.canvas.height = v.lastH;
|
|
@@ -38609,6 +38712,7 @@
|
|
|
38609
38712
|
|
|
38610
38713
|
function qvDrawFrame(v) {
|
|
38611
38714
|
if (!v.lastW || !v.lastH || !v.lastImageData) return;
|
|
38715
|
+
if (_holdForPatientGroup(v, qmriViews, qvDrawFrame)) return;
|
|
38612
38716
|
if (v.canvas.width !== v.lastW || v.canvas.height !== v.lastH) {
|
|
38613
38717
|
v.canvas.width = v.lastW;
|
|
38614
38718
|
v.canvas.height = v.lastH;
|
|
@@ -38763,6 +38867,16 @@
|
|
|
38763
38867
|
mosaicPan.endDrag();
|
|
38764
38868
|
});
|
|
38765
38869
|
|
|
38870
|
+
// Touching qMRI maps in more than one row leave no room for a colour
|
|
38871
|
+
// bar under each map, so the bars float inside the maps instead, as
|
|
38872
|
+
// they do in immersive view.
|
|
38873
|
+
function _qmriColorbarsInset() {
|
|
38874
|
+
if (!qmriActive || !qmriGapless || qmriMosaicActive || _fullscreenActive) return false;
|
|
38875
|
+
const rows = Array.from(document.querySelectorAll('#qmri-view-wrap > .qv-row'))
|
|
38876
|
+
.filter(r => Array.from(r.children).some(el => !el.classList.contains('qv-placeholder')));
|
|
38877
|
+
return rows.length > 1;
|
|
38878
|
+
}
|
|
38879
|
+
|
|
38766
38880
|
function qvScaleAllCanvases() {
|
|
38767
38881
|
const ready = qmriViews.filter(v => v.lastW && v.lastH);
|
|
38768
38882
|
if (!ready.length) return;
|
|
@@ -38844,18 +38958,25 @@
|
|
|
38844
38958
|
const rowPaneCounts = domRows.map(r => Array.from(r.children).filter(el => !el.classList.contains('qv-placeholder')).length).filter(Boolean);
|
|
38845
38959
|
const rows = Math.max(1, rowPaneCounts.length || ((n === 5 || n === 6) ? 2 : 1));
|
|
38846
38960
|
const cols = Math.max(1, ...(rowPaneCounts.length ? rowPaneCounts : [((n === 5 || n === 6) ? 3 : n)]));
|
|
38847
|
-
|
|
38848
|
-
const
|
|
38849
|
-
const
|
|
38961
|
+
_reconcileCbVisibility();
|
|
38962
|
+
const cbInset = _qmriColorbarsInset();
|
|
38963
|
+
const colGap = qmriGapless ? 0 : 24; // matches .qv-row gap
|
|
38964
|
+
const rowGap = qmriGapless ? 0 : 14; // matches #qmri-view-wrap gap
|
|
38965
|
+
const sidePad = qmriGapless ? 80 : 120; // 40px padding (+ colorbar label flanks)
|
|
38850
38966
|
const labelH = 0; // qMRI labels are overlaid inside each pane
|
|
38851
38967
|
// Reserve: colorbar strip + margin-top + label row + padding.
|
|
38852
38968
|
// When any colorbar is expanded (histogram visible), reserve extra height.
|
|
38853
38969
|
const anyExpanded = ready.some(v => v._colorBar && v._colorBar._expanded);
|
|
38854
38970
|
const hasSynthControls = ready.some(v => v.syntheticId && v.paramControls);
|
|
38855
|
-
const cbH = hasSynthControls ? 60
|
|
38971
|
+
const cbH = hasSynthControls ? 60
|
|
38972
|
+
: cbInset ? 0
|
|
38973
|
+
: (anyExpanded ? 33 + (CB_DEFAULT_EXPANDED_H - CB_COLLAPSED_H) : 33);
|
|
38856
38974
|
const bottomPad = 24; // breathing room below last colorbar
|
|
38975
|
+
// With inset colour bars only the contrast row keeps a strip of
|
|
38976
|
+
// sliders below it; the map rows need nothing.
|
|
38977
|
+
const belowRows = cbInset ? (hasSynthControls ? 60 : 0) : rows * (labelH + cbH);
|
|
38857
38978
|
const totalH = window.innerHeight - uiReserveV()
|
|
38858
|
-
-
|
|
38979
|
+
- belowRows
|
|
38859
38980
|
- (rows - 1) * rowGap
|
|
38860
38981
|
- bottomPad;
|
|
38861
38982
|
const absMaxScaleW = (window.innerWidth - sidePad - (cols - 1) * colGap) / cols;
|
|
@@ -38892,7 +39013,11 @@
|
|
|
38892
39013
|
// Keep colorbar island width clamped to target
|
|
38893
39014
|
if (v._colorBar && v._colorBar.wrap) {
|
|
38894
39015
|
const qvPaneW = fittedViewport.w;
|
|
38895
|
-
|
|
39016
|
+
// A bar floating inside the map (touching maps in two rows)
|
|
39017
|
+
// is an island, not a strip: keep it narrower than the map.
|
|
39018
|
+
const qvCbW = cbInset && cbTargetWidth(qvPaneW) != null
|
|
39019
|
+
? Math.min(Math.round(qvPaneW * 0.7), 360)
|
|
39020
|
+
: cbTargetWidth(qvPaneW);
|
|
38896
39021
|
v._colorBar.wrap.style.display = qvCbW == null ? 'none' : '';
|
|
38897
39022
|
if (qvCbW != null) v._colorBar.wrap.style.width = qvCbW + 'px';
|
|
38898
39023
|
}
|
|
@@ -39519,6 +39644,7 @@
|
|
|
39519
39644
|
|
|
39520
39645
|
function mvDrawFrame(v) {
|
|
39521
39646
|
if (!v.lastW || !v.lastH || !v.lastImageData) return;
|
|
39647
|
+
if (_holdForPatientGroup(v, mvViews, mvDrawFrame)) return;
|
|
39522
39648
|
if (v.canvas.width !== v.lastW || v.canvas.height !== v.lastH) {
|
|
39523
39649
|
v.canvas.width = v.lastW;
|
|
39524
39650
|
v.canvas.height = v.lastH;
|
|
@@ -41087,6 +41213,7 @@
|
|
|
41087
41213
|
// i.e. the vertical space limits fit-zoom more than horizontal.
|
|
41088
41214
|
// Immersive reclaims the bottom chrome reserve; if width was
|
|
41089
41215
|
// already limiting, entering immersive gains nothing.
|
|
41216
|
+
if (qmriActive) return false; // see the immersive.toggle command
|
|
41090
41217
|
let w, h;
|
|
41091
41218
|
if (compareActive && compareFrames.length) {
|
|
41092
41219
|
// In compare mode, use first frame dimensions × column count
|
|
@@ -42070,6 +42197,7 @@
|
|
|
42070
42197
|
|
|
42071
42198
|
// 6. Rounded panes — single body-level class drives CSS across all modes
|
|
42072
42199
|
document.body.classList.toggle('rounded-panes', roundedPanes);
|
|
42200
|
+
document.body.classList.toggle('qmri-gapless', qmriGapless);
|
|
42073
42201
|
|
|
42074
42202
|
// 7. qMRI options hint — lives with the bottom-right help/tool hints
|
|
42075
42203
|
const qmriHint = document.getElementById('qmri-hint');
|
|
@@ -42186,8 +42314,10 @@
|
|
|
42186
42314
|
: animPhase === 'exit-3' ? false
|
|
42187
42315
|
: _fullscreenActive;
|
|
42188
42316
|
if (qmriActive) {
|
|
42317
|
+
const inset = !animPhase && _qmriColorbarsInset();
|
|
42189
42318
|
document.querySelectorAll('#qmri-view-wrap .qv-cb-island').forEach(el => {
|
|
42190
42319
|
el.classList.toggle('fs-overlay', showQmriFsOverlay);
|
|
42320
|
+
el.classList.toggle('qv-cb-inset', inset && !showQmriFsOverlay);
|
|
42191
42321
|
});
|
|
42192
42322
|
}
|
|
42193
42323
|
|
|
@@ -4,7 +4,7 @@ arrayview/__main__.py,sha256=Fj5RszShrCcAS7_nIyBndtkpMI_PLBxM5GG9huzqhVs,101
|
|
|
4
4
|
arrayview/_analysis.py,sha256=yZ-5Pp3kaZn9eKjJAL9ERKxNwqbnBAc6qHUpscRePQg,12576
|
|
5
5
|
arrayview/_app.py,sha256=tf4W155N3yd9fdki0oD-OVhmnfC1Djr9W1Tg4V9sK7s,5301
|
|
6
6
|
arrayview/_bootstrap_app.py,sha256=ljiZ0o5D3nkJqEGcyyVF06dFWxXujBufQjbcn50QzXM,4655
|
|
7
|
-
arrayview/_config.py,sha256=
|
|
7
|
+
arrayview/_config.py,sha256=5ovQTO2I-j3fxCxEKcZKE2pqiahLESGTGS24nQdP61I,13493
|
|
8
8
|
arrayview/_diagnostics.py,sha256=XB0rCoDn3cpfhz4H-ayLktOgCMIoVJ0wM9N0ep_kKkQ,11018
|
|
9
9
|
arrayview/_dicom.py,sha256=tNY353MNWTvcXavHeIkqj3242dbgfH_ctwcx9NDee-E,19607
|
|
10
10
|
arrayview/_diff.py,sha256=oOwomSxq_xtPEyH1j31N2V-ukUY4CA6ywOQ3iKmOoP4,5802
|
|
@@ -12,14 +12,14 @@ arrayview/_extra_ports.py,sha256=MZcx04NI9Eg4coydb-yPIHp7uJbE6UscyYGnw8fxid0,111
|
|
|
12
12
|
arrayview/_icon.png,sha256=a8RTAbvweLhh3hzD5eGg76Peq-KSDcS6YrCphRb_HEs,2748
|
|
13
13
|
arrayview/_imaging.py,sha256=MQX1uy4m1lofOeoLDhCp6cHO5p_V5fXm4qlSu9Ykn-c,534
|
|
14
14
|
arrayview/_instance_registry.py,sha256=h7vyvCl0LTt9R8sDB1Vxe4a-KzfkLVuwrSw_ANpPTD8,8833
|
|
15
|
-
arrayview/_io.py,sha256=
|
|
15
|
+
arrayview/_io.py,sha256=xd2BM8awCPZ4-2ErgvsDlkxRJCM_dM9pkzcAI7i4cUw,105151
|
|
16
16
|
arrayview/_launch_plan.py,sha256=KGgIPGsflXArECB2txnIAewjuPvF4fZTbO63alC8x28,23570
|
|
17
17
|
arrayview/_launch_trace.py,sha256=4yjJdkFyEvSrPN14QVFJ3u6on2q0TH2ySSdgUp9SjKI,5668
|
|
18
18
|
arrayview/_launcher.py,sha256=Hljfeq4AmxVTDiDgYyMtHT5eiatgFdrvcr6bq75onZY,243267
|
|
19
19
|
arrayview/_lifecycle.py,sha256=bqG0oKr-e-5S1ssCTlGmF-yBE47ilrpO1S_Owfjs9Z8,5365
|
|
20
20
|
arrayview/_overlays.py,sha256=CksypG9rWfCz_3RRGIeyaKeXse17AFxvkEjmYyXnIIE,5399
|
|
21
21
|
arrayview/_platform.py,sha256=qSWjRcx9rLIdLvKrRArSueFnbyn5GPKfTEMOc5mCIUs,29970
|
|
22
|
-
arrayview/_render.py,sha256=
|
|
22
|
+
arrayview/_render.py,sha256=aymnz7v9VgfLRRaGrsLpuqjTbP5nzOXzxyFa1ybP5ME,34845
|
|
23
23
|
arrayview/_routes_analysis.py,sha256=Xz9Ysr04u07pzSRB4Fzmcl6XwVxyaG6xCWxGwYZi_80,33085
|
|
24
24
|
arrayview/_routes_drop.py,sha256=FC4e7STdCo3hYIA0C4Yy9Ka2UKFx7nLDU5dkujmc1Vo,12477
|
|
25
25
|
arrayview/_routes_export.py,sha256=Ha8mMO2E9TlRL5x25-ADV8_8xUiC-jRz9N1oWwgKOsg,3898
|
|
@@ -34,7 +34,7 @@ arrayview/_routes_state.py,sha256=T_xoYcRlv7L47ydTxxiXb0Fp5M5x9KR2U-wkxaVeuMY,12
|
|
|
34
34
|
arrayview/_routes_vectorfield.py,sha256=OWZtAONwRKQHdYnbDAMbOVf0q6pH7kqV8fa1icDhKHM,9734
|
|
35
35
|
arrayview/_routes_websocket.py,sha256=CADgPfAsYWfB7IA75_qJ4voL8dQ3y4RjfzPO0vahIkc,42093
|
|
36
36
|
arrayview/_segmentation.py,sha256=aENWHmefrKDScXhcZL1X3KgYXE784dpMkmFFo83qnrw,7377
|
|
37
|
-
arrayview/_server.py,sha256=
|
|
37
|
+
arrayview/_server.py,sha256=Ejh-6rWpWo0luhBhtsVq1Z4RFIyOPVv5nzExHtXb7iA,23042
|
|
38
38
|
arrayview/_session.py,sha256=jDOERph1hRzqLr9_uzy4Yi0AlLYLD4Y8JJD8bM8r56M,35867
|
|
39
39
|
arrayview/_session_spec.py,sha256=mKDfMRsPYQdEmN9hLXmDU_9N7etiDyBXr8mz-fB8QBo,6825
|
|
40
40
|
arrayview/_shell.html,sha256=vNa2Kiwx_eoB5H329jolYafLhwJDCH9DsJafBqvVMWU,13194
|
|
@@ -43,7 +43,7 @@ arrayview/_synthetic_mri.py,sha256=CNL-2WC835i6WCqkvmWBCO6WQ5w7HE5trNb8OyEfe64,7
|
|
|
43
43
|
arrayview/_torch.py,sha256=13sqIMCUu_-b9SQ9KfDCExDz2UMStL87EDVjnbJxAEo,7536
|
|
44
44
|
arrayview/_tutorial.py,sha256=2zZHJGJDa4n30GE1-9ADjKFAifGBH9vvHXP4uDt7BaA,19547
|
|
45
45
|
arrayview/_vectorfield.py,sha256=eDqMCMEGjO8Jdt-6Auh01cz3WD9dbF7xYUWD9xHAf1E,8115
|
|
46
|
-
arrayview/_viewer.html,sha256=
|
|
46
|
+
arrayview/_viewer.html,sha256=KJecxCJXM-dVDb3df9BftEAxiKuiqKfksaWlnj6xHY4,2387023
|
|
47
47
|
arrayview/_vscode.py,sha256=EKnGN2zrjlybc4FQOmYA8BvYdtkcJbLHDEdgtvO7ul4,837
|
|
48
48
|
arrayview/_vscode_browser.py,sha256=VCH9JpAAjFuhO0wQe8tIGjAL5837AXg_bpmBFtWOQqc,20573
|
|
49
49
|
arrayview/_vscode_extension.py,sha256=eYsWAQmik2tt7HMWad9vBnn2kpRyRpLrh42FBGQy0M4,53156
|
|
@@ -52,8 +52,8 @@ arrayview/_watch.py,sha256=PxxS_5hcj_S6xQf9Ep4p1HLRkrI5iDMh1aRa4olV7ew,1873
|
|
|
52
52
|
arrayview/arrayview-opener.vsix,sha256=44uiTM39qj_RXji3pFQaR8TA1jhNB3LYwVU_dGFbP4c,62284
|
|
53
53
|
arrayview/gsap.min.js,sha256=VGihm4idI0E1uqrWezWsiScB9F_jMosn7qs6pPSkeac,72304
|
|
54
54
|
arrayview/todo.md,sha256=KhnRzpn6_jezR0nDDB61-zhox-rbOmEGW-A7Z0_7FnU,622
|
|
55
|
-
arrayview-0.48.
|
|
56
|
-
arrayview-0.48.
|
|
57
|
-
arrayview-0.48.
|
|
58
|
-
arrayview-0.48.
|
|
59
|
-
arrayview-0.48.
|
|
55
|
+
arrayview-0.48.1.dist-info/METADATA,sha256=CFJ0u2vmhoO0Aha0UjUmknepEdM3A1GiEd6D7aRaJhE,2288
|
|
56
|
+
arrayview-0.48.1.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
57
|
+
arrayview-0.48.1.dist-info/entry_points.txt,sha256=-0s08axutXkTbINiKs0Q7iv-33aWuTaamUg2q2-NyQ4,60
|
|
58
|
+
arrayview-0.48.1.dist-info/licenses/LICENSE,sha256=34OivjM9faB2QaPjZpMRTIiSx31V3U9cEyQ6F2k-bH0,1062
|
|
59
|
+
arrayview-0.48.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|