def OnNewPoint(x, y, z, position): global aborted, spc print "Point: ", position if aborted: break print "Set Fluorescence Mode" microscope.MicroscopeSetMode(0) for cube in cube_data: print "Selecting Cube ", cube['Position'], ": ", cube['Name'] microscope.MoveCubeToPosition(cube['Position']) options = microscope.GetCubeOptions( cube['Position']) # camera exposure, gain and focus offset print "Setting camera exposure to ", options[0] microscope.SetExposure(options[0]) print "Setting camera gain to ", options[1] microscope.SetGain(options[1]) # store the focus offset offset = options[2] if aborted: break print "Moving to (%0.1f, %0.1f, %0.1f)" % (x, y, z + offset) microscope.SetStagePosition(x, y, z + offset) # Wait for stage to finish moving (additional delay seconds, time out seconds) microscope.WaitForStage(0.0, 1.0) output_directory = output[0] filename = output[1] filename = microscope.ParseSequenceFilename(filename, position) filename = microscope.InsertCubeIntoFilename(filename, cube['Position']) path = output_directory + filename print "Acquire with FL cube: ", path microscope.SnapAndSaveImage(path) if aborted: pass print "Set Laser Scanning Mode" microscope.MicroscopeSetMode(2) # Laser Scanning spc.ClearBoardMemory() filename = microscope.ParseSequenceFilename(output[1], position) filename = microscope.InsertTextIntoFilename(filename, "spc") path = output[0] + filename print "Acquire with SPC: ", path spc.AcquireAndSaveToFileUsingUIValues(1, path)
def OnCycleStart(): global current_cube_index current_cube_index = 0 for cube in cubes: print "Moving to cube position ", cube microscope.MoveCubeToPosition(cube) print "Setting camera exposure to ", exposures[current_cube_index] microscope.SetExposure(exposures[current_cube_index]) microscope.VisitPoints() current_cube_index = current_cube_index + 1
def OnNewPoint(x, y, z, position): global core global output global cube_data output_directory = output[0] filename = output[1] filename_ext = output[2] # Move to first cube to perform autofocus. microscope.MoveCubeToPosition(1) # AutoFocus Once for each new point (centre point) print "Performing AutoFocus" microscope.PerformSoftwareAutoFocus() for cube in cubes: if aborted: return; print "Setting camera exposure to ", exposures[cube - 1] microscope.SetExposure(exposures[cube - 1]) print "Setting camera gain to ", gains[cube - 1] microscope.SetGain(gains[cube - 1]) cube_details = cube_data[cube - 1] print "Moving to cube position ", cube microscope.MoveCubeToPosition(cube) print "Moving to (%d,%d)" % (x, y) # Apply focus offset microscope.SetStagePosition(x, y, z + focus_offsets[cube - 1]) # Wait for stage to finish moving (additional delay=0.1 seconds, time out = 1.0 seconds) microscope.WaitForStage(0.0, 5.0) filepath = '%s\\%s_Core%d_%s%s' % (output_directory, filename, core, cube_details["Name"], filename_ext) print "Saving file: ", filepath microscope.SnapAndSaveImage(filepath) core = core + 1
def OnCycleStart(): global current_cube_index, camera_acq current_cube_index = 0 print "Fluorescence Mode" microscope.MicroscopeSetMode(0) # FLuorescence camera_acq = 1 # do the widefield camera images now for cube in cubes: print "Moving to cube position ", cube microscope.MoveCubeToPosition(cube) print "Setting camera exposure to ", exposures[current_cube_index] microscope.SetExposure(exposures[current_cube_index]) microscope.VisitPoints() current_cube_index = current_cube_index + 1 print "Laser Scanning Mode" camera_acq = 0 # do the flim images now microscope.MicroscopeSetMode(2) # Laser Scanning microscope.VisitPoints()
def OnCycleStart(): global cube_data, cube, aborted, offset for cube in cube_data: if aborted: break print "Selecting Cube ", cube['Position'], ": ", cube['Name'] microscope.MoveCubeToPosition(cube['Position']) options = microscope.GetCubeOptions( cube['Position']) # camera exposure, gain and focus offset print "Setting camera exposure to ", options[0] microscope.SetExposure(options[0]) print "Setting camera gain to ", options[1] microscope.SetGain(options[1]) # store the focus offset offset = options[2] microscope.VisitPoints()
def OnNewPoint(x, y, z, position): global aborted, cube_data print "Point: ", position if aborted: pass output_directory = output[0] filename_ext = output[2] subdir = '%sRegion%d\\' % ( output_directory, position ) # all cubes in one folder for Mosaic to make a composite RGB mosaic #subdir = '%s\\Region%d_%s\\' % (output_directory, position, time.strftime("%d%b%Y_%Hh%Mm%Ss", time.localtime(time.time()))) # use this to time stamp each region mosaic try: os.makedirs(subdir) except (OSError): print 'os.makedirs(' + subdir + ') FAILED - folder may exist already.' for cube in cube_data: if aborted: break print "Moving to region centre (%d,%d)" % (x, y) microscope.SetStagePosition( x, y, z) # no need to apply z offset here, use it below # Wait for stage to finish moving (additional delay seconds, time out seconds) microscope.WaitForStage(0.0, 1.0) print "Selecting Cube ", cube['Position'], ": ", cube['Name'] microscope.MoveCubeToPosition(cube['Position']) options = microscope.GetCubeOptions( cube['Position']) # camera exposure, gain and focus offset print "Setting camera exposure to ", options[0] microscope.SetExposure(options[0]) print "Setting camera gain to ", options[1] microscope.SetGain(options[1]) #filename = output[1] #filename = microscope.InsertCubeIntoFilename(filename, cube['Position']) # do not use this here as filename from the simple select dialog does not have an extension, safer is the following filename = output[1] + "_" + cube['Name'] print filename # individual folders for cubes #subdir = '%sCube%d\\Region%d\\' % (output_directory, cube['Position'], position) #try: # os.makedirs(subdir) #except (OSError): # print 'os.makedirs(' + subdir + ') FAILED' # get the focal plane options for this region and transfer to the region scan module print "Offset focal plane by ", options[2] rs.SetFocalPlaneOptions(microscope.GetFocalPlaneOptions() ) # timelapse based focal plane/options rs.SetFocalPlaneOffset(options[2]) # cube based offset # Set region scan with the region width and height print "Scanning Region" rs.SetRelativeRoiFromTimelapse(microscope.GetTimeLapseRegion()) rs.Start(action, subdir, filename, filename_ext) rs.Hide()
def SetExposure(self, exposure): microscope.SetExposure(exposure)
def SetExposureAndGain(cube_index): print "Setting camera exposure to ", exposures[cube_index] microscope.SetExposure(exposures[cube_index]) print "Setting camera gain to ", gains[cube_index] microscope.SetGain(gains[cube_index])