Skip to content
Closed
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
3 changes: 2 additions & 1 deletion PYME/Acquire/SpoolController.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@ def StartSpooling(self, fn=None, stack=None, compLevel=None,
if stack:
protocol = protocol_z
protocol.dwellTime = z_dwell
#print(protocol)
stack_settings = stack if hasattr(stack, 'keys') else None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let me rest on it for a bit, but not 100% comfortable with the re-purposing of the boolean stack parameter. Can see arguments both ways ...

protocol.set_stack_positions(stack_settings)
else:
protocol = protocol

Expand Down
18 changes: 11 additions & 7 deletions PYME/Acquire/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,14 @@ def __init__(self, taskList, startFrame, dwellTime, metadataEntries=[], prefligh
self.slice_order = slice_order

self.require_camera_restart = require_camera_restart

def Init(self, spooler):
self.zPoss = np.arange(scope.stackSettings.GetStartPos(),
scope.stackSettings.GetEndPos() + .95 * scope.stackSettings.GetStepSize(),
scope.stackSettings.GetStepSize() * scope.stackSettings.GetDirection())

def set_stack_positions(self, stack_mdh=None):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

a) see PR #799 for re-factored StackSettings object. Any function to set one of these should either take a StackSettings object, or a dict of arguments (as provided by the http endpoints), not a metadata handler.

A dedicated object/handler is needed as some of the properties are computed rather than directly read, depending on stack mode (hard ends, or middle & number). It makes sense that the logic for computing these is in one place and not duplicated. Notably, this code will probably not do what you want as the default mode is middle & number. Protocol then uses it's own StackSettings object/the one that it gets passed rather than the scope one, leaving the rest of the code the same.

a) having this as a separate function (rather than in Init()) feels a bit off, but could grow on me.

stack_mdh = dict() if stack_mdh is None else stack_mdh
start = stack_mdh.get('StackSettings.StartPos', scope.stackSettings.GetStartPos())
stop = stack_mdh.get('StackSettings.EndPos', scope.stackSettings.GetEndPos())
direction = 1 if stop > start else -1
step = direction * stack_mdh.get('StackSettings.StepSize', scope.stackSettings.GetStepSize())
self.zPoss = np.arange(start, stop + .95 * step, step)

if self.slice_order != 'saw':
if self.slice_order == 'random':
Expand All @@ -208,9 +211,10 @@ def Init(self, spooler):
else:
# even
self.zPoss = np.concatenate([self.zPoss[::2], self.zPoss[-1::-2]])

self.piezoName = 'Positioning.%s' % stack_mdh.get('StackSettings.ScanPiezo', scope.stackSettings.GetScanChannel())


self.piezoName = 'Positioning.%s' % scope.stackSettings.GetScanChannel()
def Init(self, spooler):
self.startPos = scope.state[self.piezoName + '_target'] #FIXME - _target positions shouldn't be part of scope state
self.pos = 0

Expand Down