def next(self, seeking=False): """ Go to the next position (next iteration). seeking -- Boolean that indicates whether the explorer is calling next() from seek(). If True, the explorer should avoid unnecessary computation that would not affect the seek command. The last call to next() from seek() will be with seeking=False. """ BaseExplorer.next(self) if self.pointIndex is None: self.first() self.pointIndex += 1 if self.pointIndex < len(self.currentPoints): # Next fixation point for this image self._setOffset() else: # Ran out of points for this image image = self.position['image'] + 1 if image >= self.numImages: self.first() return while not self.names[image] in self.points: image += 1 if image >= self.numImages: self.first() return self.position['image'] = image self._firstPoint()
def next(self, seeking=False): """ Go to the next position (next iteration). seeking -- Boolean that indicates whether the explorer is calling next() from seek(). If True, the explorer should avoid unnecessary computation that would not affect the seek command. The last call to next() from seek() will be with seeking=False. """ BaseExplorer.next(self) self._computeNextPosn()
def next(self, seeking=False): """ Go to the next position (next iteration). seeking -- Boolean that indicates whether the explorer is calling next() from seek(). If True, the explorer should avoid unnecessary computation that would not affect the seek command. The last call to next() from seek() will be with seeking=False. """ BaseExplorer.next(self) if self._verbosity >= 1: print "BlockSpread: next():" # ======================================================================== # Update to next position self._spreadPosIdx += 1 if self._spreadPosIdx == self._numSpreadOffsets: self._spreadPosIdx = 0 self._centerPosIdx += 1 # If we've run through all the center positions, advance to the next # filtered image if self._centerPosIdx == self._numCenterOffsets: self._centerPosIdx = 0 # -------------------------------------------------------------------- # Go to next filter for this image, or next image # Iterate through the filters first needNewImage = True for i in xrange(self.numFilters): self.position['filters'][i] += 1 if self.position['filters'][i] < self.numFilterOutputs[i]: needNewImage = False break else: self.position['filters'][i] = 0 # Go to the next image if ready if needNewImage: self.position['image'] += 1 if self.position['image'] == self.numImages: self.position['image'] = 0 # ----------------------------------------------------------------- # Get the home position for this new filtered image self._getHomePosition() # ======================================================================== # Get the X,Y corrdinates and reset signal if not seeking: self._getPosition()
def next(self, seeking=False): """ Go to the next position (next iteration). seeking -- Boolean that indicates whether the explorer is calling next() from seek(). If True, the explorer should avoid unnecessary computation that would not affect the seek command. The last call to next() from seek() will be with seeking=False. """ BaseExplorer.next(self) # If filters were changed, order may be invalid if self.order is None or \ len([x for x in self.order if type(x) == int]) != self.numFilters: # If user did not set a custom order, just create new one automatically if not self.customOrder: self.order = ["image"] self.order.extend(range(self.numFilters)) self.order += ["sweep"] # Otherwise, user needs to recreate the explorer with a new order else: raise RuntimeError( "'order' is invalid. Must recreate explorer with " "valid order after changing filters.") if self.position['reset'] and self.blankWithReset: # Last iteration was a blank, so don't increment the position self.position['reset'] = False else: self.position['reset'] = False for x in reversed(self.order): if x == 'image': # Iterate the image self.position['image'] += 1 if self.position['image'] == self.numImages: self.position['image'] = 0 self.position['reset'] = True else: break elif x == 'sweep': # Iterate the sweep position nextImage = self._nextSweepPosition() if not nextImage: break else: # Iterate the filter with index x self.position['filters'][x] += 1 if self.position['filters'][x] == self.numFilterOutputs[x]: self.position['filters'][x] = 0 self.position['reset'] = True else: break if nextImage: self._firstSweepPosition()
def next(self, seeking=False): """ Go to the next position (next iteration). seeking -- Boolean that indicates whether the explorer is calling next() from seek(). If True, the explorer should avoid unnecessary computation that would not affect the seek command. The last call to next() from seek() will be with seeking=False. """ BaseExplorer.next(self) # If filters were changed, order may be invalid if self.order is None or len([x for x in self.order if type(x) == int]) != self.numFilters: # If user did not set a custom order, just create new one automatically if not self.customOrder: self.order = ["image"] self.order.extend(range(self.numFilters)) self.order += ["sweep"] # Otherwise, user needs to recreate the explorer with a new order else: raise RuntimeError( "'order' is invalid. Must recreate explorer with " "valid order after changing filters." ) if self.position["reset"] and self.blankWithReset: # Last iteration was a blank, so don't increment the position self.position["reset"] = False else: self.position["reset"] = False for x in reversed(self.order): if x == "image": # Iterate the image self.position["image"] += 1 if self.position["image"] == self.numImages: self.position["image"] = 0 self.position["reset"] = True else: break elif x == "sweep": # Iterate the sweep position nextImage = self._nextSweepPosition() if not nextImage: break else: # Iterate the filter with index x self.position["filters"][x] += 1 if self.position["filters"][x] == self.numFilterOutputs[x]: self.position["filters"][x] = 0 self.position["reset"] = True else: break if nextImage: self._firstSweepPosition()
def next(self, seeking=False): """ Go to the next position (next iteration). seeking -- Boolean that indicates whether the explorer is calling next() from seek(). If True, the explorer should avoid unnecessary computation that would not affect the seek command. The last call to next() from seek() will be with seeking=False. """ BaseExplorer.next(self) if self.position["reset"] and self.blankWithReset: # Last iteration was a blank, so don't increment the position self.position["reset"] = False else: self.position["reset"] = False self._nextSweepPosition() # Begin a new sweep if necessary if self.position["reset"]: self.first()
def next(self, seeking=False): """ Go to the next position (next iteration). seeking -- Boolean that indicates whether the explorer is calling next() from seek(). If True, the explorer should avoid unnecessary computation that would not affect the seek command. The last call to next() from seek() will be with seeking=False. """ BaseExplorer.next(self) if self.position['reset'] and self.blankWithReset: # Last iteration was a blank, so don't increment the position self.position['reset'] = False else: self.position['reset'] = False self._nextSweepPosition() # Begin a new sweep if necessary if self.position['reset']: self.first()
def next(self, seeking=False): """ Go to the next position (next iteration). seeking -- Boolean that indicates whether the explorer is calling next() from seek(). If True, the explorer should avoid unnecessary computation that would not affect the seek command. The last call to next() from seek() will be with seeking=False. """ BaseExplorer.next(self) if self.position['reset'] and self.blankWithReset: # Last iteration was a blank, so don't increment the position self.position['reset'] = False return self.position['reset'] = False prevPosition = self._copyPosition(self.position) # Translation sweep if self.dimension['name'] == 'translation': self._nextTranslationPosition() bounceDirections = self._getBounceDirections() while self.position['reset'] and self.length < self.minSweepLength and \ bounceDirections: # Sweep is too short - bounce and continue self.position = self._copyPosition(prevPosition) self.direction = bounceDirections.pop(0) self._nextTranslationPosition() # Image sweep elif self.dimension['name'] == 'image': self._nextImagePosition() if self.position['reset'] and self.length < self.minSweepLength: # Sweep is too short - bounce and continue self.position = prevPosition if self.direction == 'up': self.direction = 'down' else: self.direction = 'up' self._nextImagePosition() # Parsed dimension sweep elif self.dimension['name'] in self.parsedDimensions: self._nextParsedPosition() if self.position['reset'] and self.length < self.minSweepLength: # Sweep is too short - bounce and continue self.position = prevPosition if self.direction == 'up': self.direction = 'down' else: self.direction = 'up' self._nextParsedPosition() # Filter sweep else: self._nextFilterPosition() if self.position['reset'] and self.length < self.minSweepLength: # Sweep is too short - bounce and continue self.position = prevPosition if self.direction == 'up': self.direction = 'down' else: self.direction = 'up' self._nextFilterPosition() # Stop the sweep if it has fallen off the object if not self.position['reset'] \ and self.isBlank(self.dimension['sweepOffObject']): self.position['reset'] = True # Begin a new sweep if necessary if self.position['reset']: self.first() else: self.length += 1