Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed fix to allow inverted scope acquisitions #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions scope/client_util/calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ def __init__(self, scope, min_exposure_ms=0.5, max_exposure_ms=1000, frames_to_a
self.exposure_times = []
with contextlib.ExitStack() as stack:
# set up all the scope states
stack.enter_context(scope.il.in_state(shutter_open=False))
stack.enter_context(scope.tl.in_state(shutter_open=False))
if hasattr(scope.il, 'shutter_open'): # Inverted scope doesn't have shutters.
stack.enter_context(scope.il.in_state(shutter_open=False))
stack.enter_context(scope.tl.in_state(shutter_open=False))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a second if-block for the tl shutter open. Right now you're using hasattr(scope.il, 'shutter_open') as a proxy for "is this our inverted scope", which is a bit brittle. Here just test for each shutter and if it's present, open it.

stack.enter_context(scope.tl.lamp.in_state(enabled=False))
if hasattr(scope.il, 'spectra'):
stack.enter_context(scope.il.spectra.in_state(**{lamp+'_enabled': False for lamp in scope.il.spectra.lamp_specs.keys()}))
Expand Down Expand Up @@ -321,4 +322,4 @@ def _smooth_flat_field(image):
image = image[::2, ::2]
image = ndimage.median_filter(image, footprint=_m9)
image = ndimage.zoom(image, 2)
return ndimage.gaussian_filter(image, 5)
return ndimage.gaussian_filter(image, 5)
21 changes: 12 additions & 9 deletions scope/timecourse/timecourse_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,20 @@ def configure_timepoint(self):
pass
assert self.scope.nosepiece.magnification == objective

self.scope.il.shutter_open = True
self.scope.il.spectra.lamps(**{lamp+'_enabled': False for lamp in self.scope.il.spectra.lamp_specs})
self.scope.tl.shutter_open = True
self.scope.tl.lamp.enabled = False
self.scope.tl.condenser_retracted = objective == 5 # only retract condenser for 5x objective
if self.TL_FIELD_DIAPHRAGM is not None:
self.scope.tl.field_diaphragm = self.TL_FIELD_DIAPHRAGM
if self.TL_APERTURE_DIAPHRAGM is not None:
self.scope.tl.aperture_diaphragm = self.TL_APERTURE_DIAPHRAGM
if self.IL_FIELD_WHEEL is not None:
self.scope.il.field_wheel = self.IL_FIELD_WHEEL

if hasattr(self.scope.il, 'shutter_open'): # For non-inverted scope acquisitions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, it's a bit brittle to use hasattr(scope.il, 'shutter_open') in this way. I'd suggest for this change, you actually add a configuration variable to the class, like HAS_MOTORIZED_IL_TL or something. You then set that to false for acquisition scripts to be run on the inverted scope. (Putting each of the below into its own if-block seems a bit clumsy...)

Alternately, we add to the scope config a "scope name" attribute that we could test directly, rather than by proxy with the il.shutter_open thing.

self.scope.il.shutter_open = True
self.scope.tl.shutter_open = True
self.scope.tl.condenser_retracted = objective == 5 # only retract condenser for 5x objective
if self.TL_FIELD_DIAPHRAGM is not None:
self.scope.tl.field_diaphragm = self.TL_FIELD_DIAPHRAGM
if self.TL_APERTURE_DIAPHRAGM is not None:
self.scope.tl.aperture_diaphragm = self.TL_APERTURE_DIAPHRAGM
if self.IL_FIELD_WHEEL is not None:
self.scope.il.field_wheel = self.IL_FIELD_WHEEL

self.scope.il.filter_cube = self.experiment_metadata['filter_cube']
self.scope.camera.sensor_gain = '16-bit (low noise & high well capacity)'
self.scope.camera.readout_rate = self.PIXEL_READOUT_RATE
Expand Down