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

Conversation

drew-sinha
Copy link
Contributor

This is a combined bug report + fix addressing rpc-scope guide acquisitions on the inverted microscope. When attempting acquisitions, the code available on iscope (commit unknown; not switched to external pysrc yet) suffers from the following errors:

2018-12-12 14:10:35 ERROR . Exception in timepoint:
Traceback (most recent call last):
File "/usr/local/miniconda3/lib/python3.6/site-packages/scope/timecourse/base_handler.py", line 114, in run_timepoint
self.configure_timepoint()
File "/usr/local/miniconda3/lib/python3.6/site-packages/scope/timecourse/timecourse_handler.py", line 152, in configure_timepoint
self.scope.il.shutter_open = True
File "/usr/local/miniconda3/lib/python3.6/site-packages/scope/simple_rpc/rpc_client.py", line 147, in setattr
raise RPCError('Attribute "{}" is not known, so its state cannot be communicated to the server.'.format(name))

(and on the appropriate fix,)

2018-12-12 15:42:31 ERROR . Exception in timepoint:
Traceback (most recent call last):
File "/usr/local/miniconda3/lib/python3.6/site-packages/scope/timecourse/base_handler.py", line 114, in run_timepoint
self.configure_timepoint()
File "/usr/local/miniconda3/lib/python3.6/site-packages/scope/timecourse/timecourse_handler.py", line 177, in configure_timepoint
self.configure_calibrations() # sets self.bf_exposure and self.tl_intensity
File "/usr/local/miniconda3/lib/python3.6/site-packages/scope/timecourse/timecourse_handler.py", line 206, in configure_calibrations
self.dark_corrector = calibrate.DarkCurrentCorrector(self.scope)
File "/usr/local/miniconda3/lib/python3.6/site-packages/scope/client_util/calibrate.py", line 34, in init
stack.enter_context(scope.il.in_state(shutter_open=False))
File "/usr/local/miniconda3/lib/python3.6/contextlib.py", line 330, in enter_context
result = cm_type.enter(cm)
File "/usr/local/miniconda3/lib/python3.6/contextlib.py", line 81, in enter
return next(self.gen)
File "/usr/local/miniconda3/lib/python3.6/site-packages/scope/util/state_stack.py", line 60, in in_state
self.push_state(**state)
File "", line 10, in push_state
File "/usr/local/miniconda3/lib/python3.6/site-packages/scope/simple_rpc/rpc_client.py", line 36, in call
raise RPCError(retval)
scope.simple_rpc.rpc_client.RPCError: Traceback (most recent call last):
File "/usr/local/miniconda3/lib/python3.6/site-packages/scope/simple_rpc/rpc_server.py", line 43, in call
response = self.run_command(py_command, args, kwargs)
File "/usr/local/miniconda3/lib/python3.6/site-packages/scope/simple_rpc/rpc_server.py", line 232, in run_command
return py_command(*args, **kwargs)
File "/usr/local/miniconda3/lib/python3.6/site-packages/scope/device/leica/stand.py", line 96, in push_state
super().push_state(**state)
File "/usr/local/miniconda3/lib/python3.6/site-packages/scope/util/state_stack.py", line 39, in push_state
old_state = {p:getattr(self, 'get
'+p)() for p, v in state.items()}
File "/usr/local/miniconda3/lib/python3.6/site-packages/scope/util/state_stack.py", line 39, in
old_state = {p:getattr(self, 'get_'+p)() for p, v in state.items()}
AttributeError: 'IL' object has no attribute 'get_shutter_open'

Both of these errors arise from the unique inverted scope configuration (i.e. not having shutters, etc.). These problem spots are preserved up to the current rpc-scope master. This fix patches these issues.

Copy link
Contributor

@zpincus zpincus left a comment

Choose a reason for hiding this comment

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

Sorry this took so long!

Also, since timecourse_handler.py has changed in the interim, you'll need to merge the current master into your branch and fix the merge conflicts.

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.

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.

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.

2 participants