Skip to content

Conversation

@maragall
Copy link

This refactor eliminates duplicate T/FOV sliders when using load_dataset() (pull mode) by adopting a hybrid architecture:

Problem

When loading datasets via load_dataset(), NDV's ArrayViewer created its own sliders for the 6D array dimensions (time, fov, z, channel, y, x), while LightweightViewer also had custom T/FOV sliders - resulting in duplicate controls.

Solution: Hybrid Architecture

  • Pull mode (load_dataset): Build the full 6D dask array once, then use custom T/FOV sliders to navigate via NDV's display_model API (fast, no array rebuilds)
  • Push mode (start_acquisition/register_image): Keep existing 4D array rebuild approach for live acquisition

Key Changes

New Internal State

  • _pull_mode: Flag to track navigation mode (True = fast NDV navigation)
  • _is_ome_format: Track dataset format for proper plane loading
  • _ome_file_index: Map FOV indices to OME-TIFF filepaths
  • _pixel_size_um, _dz_um: Scale metadata for 3D rendering

New Methods

  • _navigate_ndv(dim, value): Navigate NDV viewer without array rebuilds
  • _hide_ndv_dimension_sliders(dims): Hide NDV's built-in time/fov sliders
  • _insert_sliders_into_ndv_layout(): Position custom sliders adjacent to NDV's z-slider for cohesive visual grouping
  • _on_ndv_ndims_requested(ndims): Re-hide sliders when 2D/3D toggle clicked
  • _build_6d_lazy_array(): Build complete 6D dask array for pull mode
  • _load_ome_plane(): Load planes from OME-TIFF format files
  • _scan_ome_tiff_to_state(): Scan OME-TIFF datasets

Modified Slider Handlers

  • _on_time_slider_changed: Check _pull_mode to either navigate NDV or rebuild array
  • _on_fov_slider_changed: Same hybrid behavior

UI Improvements

  • Custom T/FOV sliders now appear directly below NDV's z-slider
  • NDV's duplicate time/fov sliders are hidden via official API
  • Signal connection prevents slider duplication when toggling 3D mode

Testing

Tested with 9 datasets covering single-TIFF and OME-TIFF formats:

  • 20x_scan, DIPG17pons, empty_slide_20x, fcs2_20x_left, Monkey, ps-m1-t72, successful_run, test_10x_laser_af_z_stack, tissue_slide_20x

maragall and others added 2 commits January 22, 2026 08:08
This refactor eliminates duplicate T/FOV sliders when using load_dataset()
(pull mode) by adopting a hybrid architecture:

## Problem
When loading datasets via load_dataset(), NDV's ArrayViewer created its own
sliders for the 6D array dimensions (time, fov, z, channel, y, x), while
LightweightViewer also had custom T/FOV sliders - resulting in duplicate
controls.

## Solution: Hybrid Architecture
- **Pull mode (load_dataset)**: Build the full 6D dask array once, then use
  custom T/FOV sliders to navigate via NDV's display_model API (fast, no
  array rebuilds)
- **Push mode (start_acquisition/register_image)**: Keep existing 4D array
  rebuild approach for live acquisition

## Key Changes

### New Internal State
- `_pull_mode`: Flag to track navigation mode (True = fast NDV navigation)
- `_is_ome_format`: Track dataset format for proper plane loading
- `_ome_file_index`: Map FOV indices to OME-TIFF filepaths
- `_pixel_size_um`, `_dz_um`: Scale metadata for 3D rendering

### New Methods
- `_navigate_ndv(dim, value)`: Navigate NDV viewer without array rebuilds
- `_hide_ndv_dimension_sliders(dims)`: Hide NDV's built-in time/fov sliders
- `_insert_sliders_into_ndv_layout()`: Position custom sliders adjacent to
  NDV's z-slider for cohesive visual grouping
- `_on_ndv_ndims_requested(ndims)`: Re-hide sliders when 2D/3D toggle clicked
- `_build_6d_lazy_array()`: Build complete 6D dask array for pull mode
- `_load_ome_plane()`: Load planes from OME-TIFF format files
- `_scan_ome_tiff_to_state()`: Scan OME-TIFF datasets

### Modified Slider Handlers
- `_on_time_slider_changed`: Check `_pull_mode` to either navigate NDV or
  rebuild array
- `_on_fov_slider_changed`: Same hybrid behavior

### UI Improvements
- Custom T/FOV sliders now appear directly below NDV's z-slider
- NDV's duplicate time/fov sliders are hidden via official API
- Signal connection prevents slider duplication when toggling 3D mode

## Testing
Tested with 9 datasets covering single-TIFF and OME-TIFF formats:
- 20x_scan, DIPG17pons, empty_slide_20x, fcs2_20x_left, Monkey,
  ps-m1-t72, successful_run, test_10x_laser_af_z_stack, tissue_slide_20x

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant