Example #1
0
def OnNewPoint(x, y, z, position):
    global rs
    global count
    global output
    global action
    global current_cube_index
    global aborted

    if aborted:
        pass

    output_directory = output[0]
    filename = output[1]
    filename_ext = output[2]
    subdir = '%s\\Cube%d\\Region%d\\' % (output_directory,
                                         cubes[current_cube_index], count)

    try:
        os.makedirs(subdir)
    except (OSError):
        print 'os.makedirs(' + subdir + ') FAILED'

    print z
    print focus_offsets[current_cube_index]
    microscope.SetStagePosition(x, y, z + focus_offsets[current_cube_index])

    # Wait for stage to finish moving (additional delay=0.1 seconds, time out = 1.0 seconds)
    microscope.WaitForStage(0.0, 5.0)
    rs.SetRelativeRoi(x_size, y_size)
    rs.Start(action, subdir, filename, filename_ext)
    count = count + 1
Example #2
0
def OnNewPoint(x, y, z, position):

    global current_cube_index
    global aborted

    z_centre = z + focus_offsets[current_cube_index]

    dir = output[0] + 'Point' + str(position)

    if not os.path.exists(dir):
        os.mkdir(dir)

    for z_current_step in range(-z_images_below, z_images_above +
                                1):  # +1 ensures the last point is aquired

        if aborted:
            break

        z_current = z_centre + z_step * z_current_step

        print "Capturing image at (z = ", str(z_current), ")"
        microscope.SetStagePosition(x, y, z_current)
        microscope.WaitForStage(0.0, 1.0)

        filename = microscope.ParseSequenceFilename(output[1], position)

        zpos = '%(#)02d' % {"#": (z_current_step + z_images_below)}
        filename = microscope.InsertTextIntoFilename(filename, "z" + zpos)
        filename = microscope.InsertCubeIntoFilename(filename,
                                                     cubes[current_cube_index])
        path = dir + os.sep + filename
        microscope.SnapAndSaveImage(path)
def Move(x, y, z, cube_index):
    print "Moving to (%d,%d)" % (x, y)
    # Apply focus offset
    microscope.SetStagePosition(x, y, z + focus_offsets[cube_index])

    # Wait for stage to finish moving (additional delay=0.1 seconds, time out = 1.0 seconds)
    microscope.WaitForStage(0.0, 5.0)
Example #4
0
def OnNewPoint(x, y, z, position):
    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)

    microscope.SnapImage()
Example #5
0
def OnNewPoint(x, y, z, position):
    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
    microscope.SnapAndSaveImage(path)
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 current_cube_index
    microscope.SetStagePosition(x, y, z + focus_offsets[current_cube_index])

    # 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
    microscope.SnapAndSaveImage(path)
Example #8
0
def OnNewPoint(x, y, z, position):

    #    print "Moving Stage ", (x, y, z)
    microscope.SetStagePosition(x, y, z)

    #print "Moved Stage to ", microscope.MicroscopeGetStagePosition()

    # wait for stage to finish moving (additional delay=0.1 seconds, time out = 1.0 seconds)
    microscope.WaitForStage(0.0, 1.0)

    #print "Snapping Image"
    microscope.SnapImage()
Example #9
0
def OnNewPoint(x, y, z, position):
    global aborted, point_list

    print "Point: ", position
    print("input: x %f, y %f, z %f" % (x, y, z))
    print "list:  ", point_list[position - 1][2]

    # Adjust z to last autofocus position, first time round these two will be the same
    z = point_list[position - 1][2]
    print "Adjust z to last autofocus position: z=", z

    if aborted:
        pass

    microscope.SetStagePosition(x, y, z)
    # 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_ext = output[2]

    #filename = microscope.ParseSequenceFilename(filename, position)
    #filename = microscope.InsertCubeIntoFilename(filename, current_cube_index+1)

    #subdir = '%s\\Cube%d\\Region%d\\' % (output_directory, cubes[current_cube_index], position)
    #subdir = '%s\\Region%d\\' % (output_directory, position)
    subdir = '%s\\Region%d_%s\\' % (output_directory, position,
                                    time.strftime("%d%b%Y_%Hh%Mm%Ss",
                                                  time.localtime(time.time())))

    try:
        os.makedirs(subdir)
    except (OSError):
        print 'os.makedirs(' + subdir + ') FAILED'

    print "Autofocus"
    microscope.PerformSoftwareAutoFocus()
    autoFocusedZPosition = microscope.GetStagePosition()[2]
    point_list[position - 1][2] = autoFocusedZPosition
    print "Auto focused position stored:", point_list[position - 1][2]

    # get the focal plane options for this region and transfer to the region scan module, correct for the autofocus
    rs.SetFocalPlaneOptions(microscope.GetFocalPlaneOptions())
    rs.SetFocalPlaneOffsetFromXYZ(x, y, autoFocusedZPosition)

    # Set region scan with the region width and height
    rs.SetRelativeRoiFromTimelapse(microscope.GetTimeLapseRegion())
    rs.Start(action, subdir, filename, filename_ext)
    rs.Hide()
def OnNewPoint(x, y, z, position):
    global spc
    microscope.SetStagePosition(x, y, z)
    # microscope.SetStagePosition(x, y, (z+11.50))
    # 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 SPC"
    microscope.MicroscopeSetMode(2)   # Laser Scanning
    spc.ClearBoardMemory()
    spc.AcquireAndSaveToFileUsingUIValues(1, path)
    microscope.MicroscopeSetMode(0)   # FLuorescence
    filename = microscope.ParseSequenceFilename(output[1], position) 
    path = output[0] + filename
    microscope.SnapAndSaveImage(path)
Example #11
0
def OnNewPoint(x, y, z, position):

    global current_cube_index, camera_acq
    microscope.SetStagePosition(x, y, z + focus_offsets[current_cube_index])

    # 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

    if camera_acq == 1:
        print "Camera image: ", position
        microscope.SnapAndSaveImage(path)
    else:
        print "Performing SPC: ", position
        spc.ClearBoardMemory()
        spc.AcquireAndSaveToFileUsingUIValues(1, path)
Example #12
0
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)
Example #13
0
def OnNewPoint(x, y, z, position):

#    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
    microscope.PerformSoftwareAutoFocus(path)
    microscope.SnapAndSaveImage(path)
          
    #mrowley - 081209 - recording the software auto focus determined focal point for the given well
    xf, yf, zf = microscope.GetStagePosition()
    filenameautopts = 'AutoFocusedPlane.pts'
    path = output[0] + filenameautopts
    fileautopts = open(path, 'a')
    fileautopts.write('%.2f' %xf + '\t' + '%.2f' %yf + '\t' + '%.2f' %zf + '\n')
    fileautopts.close()
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
Example #15
0
def OnNewPoint(x, y, z, position):
    global aborted, cube, offset

    print "Point: ", position

    if aborted:
        pass

    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 and save ", path
    microscope.SnapAndSaveImage(path)
Example #16
0
def OnNewPoint(x, y, z, position):
    global aborted

    print "Point: ", position

    if aborted:
        pass

    microscope.SetStagePosition(x, y, z)
    # 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_ext = output[2]

    #filename = microscope.ParseSequenceFilename(filename, position) 
    #filename = microscope.InsertCubeIntoFilename(filename, current_cube_index+1)

    #subdir = '%s\\Cube%d\\Region%d\\' % (output_directory, cubes[current_cube_index], position)
    #subdir = '%s\\Region%d\\' % (output_directory, position)
    subdir = '%s\\Region%d_%s\\' % (output_directory, position, time.strftime("%d%b%Y_%Hh%Mm%Ss", time.localtime(time.time())))

    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
    rs.SetFocalPlaneOptions(microscope.GetFocalPlaneOptions())

    # Set region scan with the region width and height
    rs.SetRelativeRoiFromTimelapse(microscope.GetTimeLapseRegion())
    rs.Start(action, subdir, filename, filename_ext)
    rs.Hide()
    
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()