Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 23, 2025

This PR refactors the Virtual Microscope implementation to integrate properly with ImSwitch's centralized controller architecture, addressing feedback to consolidate duplicate functionality and improve system consistency.

Key Changes Made

Controller Integration

  • Removed standalone methods that duplicated existing functionality:
    • setExposureAndGain() - now handled through SettingsController's setDetectorExposureTime() and setDetectorGain()
    • switchObjective() - now handled through ObjectiveController's moveToObjective()

Enhanced Integration Architecture

  • Added listener methods to respond to changes from existing controllers:
    • _onDetectorSettingChanged() - automatically updates virtual illuminator when exposure/gain changes
    • _onObjectiveChanged() - automatically updates virtual objective binning when objectives switch
  • Virtual microscope now participates in ImSwitch's unified settings management

Improved Stage Drift Simulation

  • Changed from absolute positioning to relative increments applied at fixed intervals
  • Supports separate drift rates for X, Y, Z axes as requested
  • More realistic simulation of thermal and mechanical drift behavior

Extended VirtualMicroscopeManager

  • updateExposureGain() - scales illuminator intensity based on detector settings
  • setObjective() - controls camera binning to simulate magnification changes

Usage Impact

The virtual microscope now responds automatically to standard ImSwitch operations:

# These standard operations now automatically update the virtual microscope
settingsController.setDetectorExposureTime("Camera", 50.0)  # Updates virtual illuminator
objectiveController.moveToObjective(2)                     # Updates virtual binning

Educational and simulation features remain fully functional while integrating seamlessly with ImSwitch's controller ecosystem. This eliminates duplicate API endpoints and ensures consistent behavior across real and virtual hardware.

Fixes #72.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits August 23, 2025 08:30
Co-authored-by: beniroquai <4345528+beniroquai@users.noreply.github.com>
…eatures

Co-authored-by: beniroquai <4345528+beniroquai@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Virtual Microscope Improvements Enhance Virtual Microscope Manager with comprehensive simulation capabilities and API endpoints Aug 23, 2025
@Copilot Copilot AI requested a review from beniroquai August 23, 2025 08:37
Copilot finished work on behalf of beniroquai August 23, 2025 08:37
@beniroquai
Copy link
Collaborator

@copilot some remarks:

  •    def setExposureAndGain(self, exposure_time: float = None, gain: float = None) -> Dict: should rather be merged into the settingscontroller. We control exposure time/gain from a central point for all cameras. once we do this through the     def setDetectorExposureTime(self, detectorName: str=None, exposureTime: float=1) -> None: the brightness should increase accordingly 
    
  • Same for the switchObjective - this is done through the objectivecontroller
  • applydrift should add relative drift to each axis with a settable constant different for xyz - this should be called in an fixed interval

…ngsController and ObjectiveController

Co-authored-by: beniroquai <4345528+beniroquai@users.noreply.github.com>
Copy link
Author

Copilot AI commented Aug 23, 2025

@copilot some remarks:

  •    def setExposureAndGain(self, exposure_time: float = None, gain: float = None) -> Dict: should rather be merged into the settingscontroller. We control exposure time/...
    

I've implemented all the requested changes in commit 5821e27:

1. setExposureAndGain merged into SettingsController:

  • Removed the standalone setExposureAndGain method from VirtualMicroscopeController
  • Added integration with SettingsController via _onDetectorSettingChanged() which listens for exposure and gain changes
  • Virtual microscope now responds to setDetectorExposureTime() and setDetectorGain() calls through the central settings system

2. switchObjective integrated with ObjectiveController:

  • Removed the standalone switchObjective method from VirtualMicroscopeController
  • Added integration via _onObjectiveChanged() which listens for objective changes from ObjectiveController
  • Virtual microscope now responds to moveToObjective() calls and automatically updates binning based on objective slot

3. Drift now applies relative increments:

  • Modified _applyDrift() to apply relative position changes (is_absolute=False) at fixed intervals
  • Uses separate drift constants for X, Y, Z axes as requested
  • Tracks time intervals and applies drift_rate_x/y/z * time_interval as relative offsets
  • Removed absolute positioning based on elapsed time from start

The VirtualMicroscopeManager now has updateExposureGain() and setObjective() methods that integrate with the centralized controllers while maintaining all existing functionality.

@Copilot Copilot AI changed the title Enhance Virtual Microscope Manager with comprehensive simulation capabilities and API endpoints Integrate Virtual Microscope with centralized SettingsController and ObjectiveController Aug 23, 2025
Copilot finished work on behalf of beniroquai August 23, 2025 16:38
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.

Virtual Microscope Improvements

2 participants