コード例 #1
0
    def onAdd(self, event=None):
        start = guiUtils.tryParseNum(self.startText, float)
        stop = guiUtils.tryParseNum(self.stopText, float)
        if start >= stop:
            # No-op; easiest way for this to happen is for the stop text to
            # have no value.
            return
        # Go through our list of sequences and see if we need to merge them
        # together.
        self.sequence.append([start, stop])
        indexToDelete = len(self.sequence) - 1
        didChange = True
        while didChange:
            didChange = False
            for i, (altStart, altStop) in enumerate(self.sequence):
                # Check for overlap.
                if ((start < altStart and stop > altStart)
                        or (stop > altStop and start < altStop)):
                    # Merge the two entries.
                    start = min(start, altStart)
                    stop = max(stop, altStop)
                    self.sequence[i] = [start, stop]
                    didChange = True
                    # Destroy the old sequence as it's been merged with
                    # this one.
                    del self.sequence[indexToDelete]
                    indexToDelete = i
                    break

        # Sort the sequence by start time.
        self.sequence.sort(key=lambda s: s[0])
        self.startText.SetValue('')
        self.stopText.SetValue('')
        self.updateDisplay()
コード例 #2
0
 def augmentParams(self, params):
     self.saveSettings()
     params['settlingTime'] = guiUtils.tryParseNum(self.settlingTimeControl, float)
     params['startV'] = guiUtils.tryParseNum(self.startVControl, float)
     params['maxV'] = guiUtils.tryParseNum(self.maxVControl, float)
     params['vSteps'] = guiUtils.tryParseNum(self.vStepsControl)
     params['polarizerHandler'] = depot.getHandlerWithName('SI polarizer')
     return params
コード例 #3
0
 def augmentParams(self, params):
     self.saveSettings()
     params['numExposures'] = guiUtils.tryParseNum(self.responseArgs['responseMapNumExposures'])
     tokens = self.responseArgs['responseMapExposureTimes'].GetValue()
     tokens = tokens.split(',')
     params['exposureTimes'] = map(float, tokens)
     params['cosmicRayThreshold'] = guiUtils.tryParseNum(self.responseArgs['responseMapCosmicRayThreshold'])
     params['shouldPreserveIntermediaryFiles'] = self.responseArgs['responseMapShouldPreserveIntermediaryFiles'].GetValue()
     return params        
コード例 #4
0
 def augmentParams(self, params):
     self.saveSettings()
     params['numExposures'] = guiUtils.tryParseNum(
         self.correctionArgs['correctionNumExposures'])
     params['numCollections'] = guiUtils.tryParseNum(
         self.correctionArgs['correctionNumCollections'])
     params['exposureMultiplier'] = guiUtils.tryParseNum(
         self.correctionArgs['correctionExposureMultiplier'], float)
     params['maxIntensity'] = guiUtils.tryParseNum(
         self.correctionArgs['correctionMaxIntensity'])
     params['cosmicRayThreshold'] = guiUtils.tryParseNum(
         self.correctionArgs['correctionCosmicRayThreshold'], float)
     params['shouldPreserveIntermediaryFiles'] = self.correctionArgs[
         'correctionShouldPreserveIntermediaryFiles'].GetValue()
     return params
コード例 #5
0
 def augmentParams(self, params):
     self.saveSettings()
     params['numAngles'] = 3
     params['numPhases'] = 5
     params['collectionOrder'] = self.siCollectionOrder.GetStringSelection()
     params['angleHandler'] = depot.getHandlerWithName('SI angle')
     params['phaseHandler'] = depot.getHandlerWithName('SI phase')
     params['polarizerHandler'] = depot.getHandlerWithName('SI polarizer')
     params['slmHandler'] = depot.getHandler('slm', depot.EXECUTOR)
     compensations = {}
     for i, light in enumerate(self.allLights):
         val = guiUtils.tryParseNum(self.bleachCompensations[i], float)
         if val:
             # Convert from percentage to multiplier
             compensations[light] = .01 * float(val)
         else:
             compensations[light] = 0
     params['bleachCompensations'] = compensations
     return params
コード例 #6
0
    def runExperiment(self):
        # Returns True to close dialog box, None or False otherwise.
        self.saveSettings()
        # Find the Z mover with the smallest range of motion, assumed
        # to be our experiment mover.
        mover = depot.getSortedStageMovers()[2][-1]
        # Only use active cameras and enabled lights.
        # Must do list(filter) because we will iterate over the list
        # many times.
        cameras = list(
            filter(lambda c: c.getIsEnabled(),
                   depot.getHandlersOfType(depot.CAMERA)))
        if not cameras:
            wx.MessageDialog(
                self,
                message=
                "No cameras are enabled, so the experiment cannot be run.",
                style=wx.ICON_EXCLAMATION | wx.STAY_ON_TOP
                | wx.OK).ShowModal()
            return True

        exposureSettings = []
        if self.shouldExposeSimultaneously.GetValue():
            # A single exposure event with all cameras and lights.
            lightTimePairs = []
            for i, light in enumerate(self.allLights):
                if (self.allLights[i].getIsEnabled()
                        and self.lightExposureTimes[i].GetValue()):
                    lightTimePairs.append(
                        (light,
                         guiUtils.tryParseNum(self.lightExposureTimes[i],
                                              decimal.Decimal)))
            exposureSettings = [(cameras, lightTimePairs)]
        else:
            # A separate exposure for each camera.
            for camera in cameras:
                cameraSettings = self.cameraToExposureTimes[camera]
                settings = []
                for i, light in enumerate(self.allLights):
                    if not light.getIsEnabled():
                        continue
                    timeControl = cameraSettings[i]
                    if timeControl.GetValue():
                        settings.append(
                            (light,
                             guiUtils.tryParseNum(timeControl,
                                                  decimal.Decimal)))
                exposureSettings.append(([camera], settings))

        altitude = cockpit.interfaces.stageMover.getPositionForAxis(2)
        # Default to "current is bottom"
        altBottom = altitude
        zHeight = guiUtils.tryParseNum(self.stackHeight, float)
        if self.zPositionMode.GetStringSelection() == 'Current is center':
            altBottom = altitude - zHeight / 2
        elif self.zPositionMode.GetStringSelection() == 'Use saved top/bottom':
            altBottom = cockpit.interfaces.stageMover.mover.SavedBottom
            zHeight = cockpit.interfaces.stageMover.mover.SavedTop - altBottom

        sliceHeight = guiUtils.tryParseNum(self.sliceHeight, float)
        if zHeight == 0:
            # 2D mode.
            zHeight = 1e-6
            sliceHeight = 1e-6

        try:
            savePath = self.filepath_panel.GetPath()
        except Exception:
            cockpit.gui.ExceptionBox("Failed to get filename for data.",
                                     parent=self)
            return True

        params = {
            'numReps': guiUtils.tryParseNum(self.numReps),
            'repDuration': guiUtils.tryParseNum(self.repDuration, float),
            'zPositioner': mover,
            'altBottom': altBottom,
            'zHeight': zHeight,
            'sliceHeight': sliceHeight,
            'exposureSettings': exposureSettings,
            'savePath': savePath
        }
        experimentType = self.experimentType.GetStringSelection()
        module = self.experimentStringToModule[experimentType]
        if module in self.experimentModuleToPanel:
            # Add on the special parameters needed by this experiment type.
            params = self.experimentModuleToPanel[module].augmentParams(params)

        self.runner = module.EXPERIMENT_CLASS(**params)
        return self.runner.run()