refactor: Unify pull and push mode architectures for standalone viewing#24
Open
maragall wants to merge 3 commits intoCephla-Lab:mainfrom
Open
refactor: Unify pull and push mode architectures for standalone viewing#24maragall wants to merge 3 commits intoCephla-Lab:mainfrom
maragall wants to merge 3 commits intoCephla-Lab:mainfrom
Conversation
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>
- Adopt _fov_slider_container naming from upstream - Keep pull mode fast navigation via _navigate_ndv() - Use _load_current_position() router for push mode (handles zarr + TIFF) - Apply black formatting Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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 renderingNew 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 datasetsModified Slider Handlers
_on_time_slider_changed: Check_pull_modeto either navigate NDV or rebuild array_on_fov_slider_changed: Same hybrid behaviorUI Improvements
Testing
Tested with 9 datasets covering single-TIFF and OME-TIFF formats: