def OnCycleStart(): print "Back to start." print "Cube 2." microscope.MoveCubeToPosition(2) microscope.WaitForCube(0.0, 10.0) microscope.VisitPoints() print "Cube 3." microscope.MoveCubeToPosition(3) microscope.WaitForCube(0.0, 10.0) microscope.VisitPoints()
def OnNewPoint(x, y, z, position): microscope.MoveOpticalPathToPosition(2) microscope.MoveCubeToPosition(1) microscope.WaitForCube(0.0, 10.0) # print "Moving Stage ", (x, y, z) microscope.SetStagePosition(x, y, z) # wait for stage to finish moving (additional delay=0.1 seconds, time out = 1.0 seconds) microscope.WaitForStage(0.0, 1.0) filename = microscope.ParseSequenceFilename(output[1], position) path = output[0] + filename print "Performing AutoFocus" #microscope.PerformSoftwareAutoFocus(path) #microscope.SnapAndSaveImage(path) microscope.MoveOpticalPathToPosition(4) microscope.MoveCubeToPosition(2) microscope.WaitForCube(0.0, 10.0) print "Performing SPC" microscope.StartSPC(path)
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 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 OnNewPoint(x, y, z, position): global cubes for cube in cubes: print "Snapping Image ", (x, y) pos = cube['Position'] print "Moving cube to position: ", pos, "\n" microscope.MoveCubeToPosition(pos) time.sleep(3) microscope.SnapImage()
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 # Move to first cube to perform autofocus. microscope.MoveCubeToPosition(1) SetExposureAndGain(0) # AutoFocus Once for each new point (centre point) #print "Performing AutoFocus" #microscope.PerformSoftwareAutoFocus() DoRegionScan(x, y, z, position) core = core + 1
def DoRegionScan(x, y, z, position): global aborted global output global cube_data global action if aborted: return rs_points = [] rs_points.append((x - xoffset, y - yoffset)) rs_points.append((x, y - yoffset)) rs_points.append((x + xoffset, y - yoffset)) rs_points.append((x + xoffset, y)) rs_points.append((x, y)) rs_points.append((x - xoffset, y)) rs_points.append((x - xoffset, y + yoffset)) rs_points.append((x, y + yoffset)) rs_points.append((x + xoffset, y + yoffset)) rs_point_count = 1 # Loop region scan points for rs_point in rs_points: if aborted: return for cube in cubes: if aborted: return microscope.MoveCubeToPosition(cube) SetExposureAndGain(cube - 1) if cube == 1: Move(rs_point[0], rs_point[1], z, cube - 1) # We are on the first cube so we do an autofocus print "Performing AutoFocus" microscope.PerformSoftwareAutoFocus() SnapAndSave(cube - 1, rs_point_count) rs_point_count = rs_point_count + 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()