Feat/flimlabsintegration - #319
Open
beniroquai wants to merge 18 commits into
Open
Conversation
…eirmentcontrolelr
Improves FLIM acquisition reliability and UX across frontend and backend: slower/adaptive polling, backend-gated FLIM tab visibility, and clearer status/hint/debug reporting. Adds scan-area crop offsets (top/right/bottom/left) wired from UI through detector geometry so image size is derived from galvo scan minus offsets. Updates FLIM client/controller behavior with better server error surfacing, cumulative frame display/reset handling, frame-loss diagnostics, safer card serial handling during runs, and aligns galvo defaults/auto-start behavior for validated FLIM raster settings.
…/ImSwitch into feat/flimlabsintegration # Conflicts: # imswitch/imcontrol/controller/controllers/FLIMLabsController.py # imswitch/imcontrol/model/interfaces/flimlabsclient.py
… of galvo scanner in the backend
Extended FLIM Labs backend and frontend integration with new APIs and UI workflows: save acquired FLIM data (TIFF + decay + metadata) to the ImSwitch data folder, fetch/render decay histograms, adjust field of view in µm, and list/select stored calibrations for phasor runs. Also updated acquisition controls to use measured laser frequency values and added live display averaging, plus ignored the local macOS ToupCam dylib in git.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reworks the FLIM LABS integration so the ImSwitch backend becomes the single owner of the flim-imager server connection (including its single-consumer /data stream), while the frontend becomes a thin client that drives FLIM via ImSwitch APIs and persists bridge settings in the setup file.
Changes:
- Added backend-side FLIM LABS detector + client (REST + binary WS parsing) and refactored
FLIMLabsControllerinto a backend facade for status/image/phasor/calibration/export. - Updated Galvo Scanner UI to show the FLIM tab only when the backend advertises FLIM availability, and expanded Redux state/UI for calibration/phasors/export.
- Added persistence endpoints for FLIM bridge settings and adjusted galvo scan defaults/behavior (including boot-time scanner auto-start).
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Adds OpenCV “fix” instructions for installs. |
| imswitch/imcontrol/model/SetupInfo.py | Persists FLIM bridge settings in setup under flimLabs. |
| imswitch/imcontrol/model/managers/galvoscanners/GalvoScannerManager.py | Updates galvo scan defaults and introduces autoStartScan behavior flag. |
| imswitch/imcontrol/model/managers/detectors/FLIMLabsDetectorManager.py | New detector manager exposing FLIM card as a standard 2D detector (galvo-coupled geometry, calibration index). |
| imswitch/imcontrol/model/interfaces/flimlabsclient.py | New backend FLIM server client + binary WS protocol parser and frame assembler. |
| imswitch/imcontrol/controller/controllers/GalvoScannerController.py | Binds galvo scanners to FLIM detectors, propagates geometry changes, adds setup-file persistence endpoints, wraps park response. |
| imswitch/imcontrol/controller/controllers/FLIMLabsController.py | Refactors into backend FLIM facade (status, acquisition control, images, phasors, decay, export). |
| frontend/src/utils/flimBinaryParser.js | Marks browser-side binary parsing as superseded/unused (backend now owns /data). |
| frontend/src/state/slices/GalvoScannerSlice.js | Aligns frontend galvo defaults with backend scan defaults. |
| frontend/src/state/slices/FlimLabsSlice.js | Expands FLIM state for health/calibration/phasors/export + config hydration. |
| frontend/src/components/GalvoScannerController.jsx | Conditionally shows FLIM tab based on backend-reported availability. |
| frontend/src/components/FlimLabsPanel.jsx | Replaces direct flim-server control with backend API polling/control; adds calibration/phasor UI and persistence hooks. |
| frontend/src/backendapi/apiGalvoScannerController.js | Adds get/set FLIM bridge config endpoints. |
| frontend/src/backendapi/apiFlimLabs.js | Rewrites FLIM API client to call ImSwitch backend controller instead of flim-server directly. |
| .gitignore | Ignores a macOS Toupcam dylib. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+343
to
+357
| def setFlimParameter(self, name: str, value: float) -> Dict[str, Any]: | ||
| """Set a FLIM detector parameter (dwell_time, frames_to_integrate, | ||
| frequency_mhz, reconstruction). | ||
|
|
||
| Example: | ||
| GET /api/FLIMLabsController/setFlimParameter?name=dwell_time&value=25 | ||
| """ | ||
| det = self._detector | ||
| if det is None: | ||
| return {'error': 'No FLIM detector configured'} | ||
| try: | ||
| det.setParameter(name, value) | ||
| return {'status': 'ok', 'name': name, 'value': det.getParameter(name)} | ||
| except Exception as e: | ||
| return {'error': str(e)} |
| # Start scanning at ImSwitch boot with these defaults (the FLIM rig | ||
| # wants the trigger pattern present from the start). Disable with | ||
| # "autoStartScan": false in managerProperties. | ||
| self._autoStartScan = bool(props.get('autoStartScan', True)) |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…uto start and block the other process on startup
…/ImSwitch into feat/flimlabsintegration
Introduces per-axis joystick speed multiplier control across the stack. Added new UC2Config API wrappers in the frontend, a new Joystick tab in Motor Settings for inversion and multiplier editing, and renamed the Settings menu entry to “ESP32 & Updates”. On the backend, UC2ConfigController/Manager and ESP32StageManager now expose get/set multiplier methods, cache values per axis, apply them on startup, and persist them into setup managerProperties alongside joystick direction settings.
…/ImSwitch into feat/flimlabsintegration
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 pull request introduces significant enhancements to the FLIM Labs integration in the ImSwitch frontend, refactoring the FLIM Labs API client to route all calls through the ImSwitch backend, improving feature detection and tab visibility, and expanding the Redux state and API for FLIM Labs calibration and configuration management. These changes make the FLIM Labs functionality more robust, backend-driven, and easier to configure and extend.
Key changes include:
1. FLIM Labs API Refactor and Backend Routing
apiFlimLabs.jsmodule is completely rewritten to route all FLIM Labs operations through the ImSwitch backend (FLIMLabsController) instead of direct communication with the FLIM server. This centralizes control, prevents data stream conflicts, and allows for richer backend-driven features. All previous direct REST/WS calls are replaced with backend API endpoints, and new methods are added for status, image, phasor, calibration, and export operations.2. FLIM Labs Tab Visibility and Feature Detection
GalvoScannerControllerUI is now only shown if the backend advertises FLIM Labs support (probed viaapiFlimGetStatus). The tab is hidden if unavailable, and the active tab is reset if needed to avoid UI errors. [1] [2] [3] [4] [5]3. FLIM Labs Configuration Persistence and API
apiGetFlimLabsConfigandapiSetFlimLabsConfigand integrated into the API export. [1] [2]4. Redux State Expansion for FLIM Labs
FlimLabsSliceRedux state is expanded to include new fields for server health, calibration parameters and results, phasor settings, export options, and configuration hydration. New reducers are added for calibration results, health, and config hydration, supporting more advanced workflows and persistent state. [1] [2] [3] [4]5. Documentation Update for OpenCV Setup
README.mdis updated with new instructions for fixing OpenCV installations, ensuring that the correct dependencies and versions are installed for image processing.