Beispiel #1
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 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
Beispiel #3
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