Ejemplo n.º 1
0
def main(argv=None):
    global curr_averageimgnum
    global num_to_average
    
    if argv is None:
        argv = sys.argv
    # end if
    argc = len(argv)
    if argc < 2:
        show_usage()
        sys.exit(-1)
    # end if
    filename = argv[1]
    if argc > 2:
        autolevel = argv[2]
    # end if

    mf = maestro.MaestroFunctions()
    img_buffer_cpy = numpy.empty(data_size, dtype=np.uint16)

    TOTAL_FCS = 1
    first_average_image = 1

    auto_exposure = 0
    
    base_dir = "%s/polonator/G.007/acquisition" % (os.environ["HOME"])
    log_dir =  "%s/logs" % (base_dir)
    command_buffer =  "mkdir -p %s" % log_dir
    system(command_buffer)

    logfilename = log_dir + "/" + config.get("Log", "logfilename") + \
                    "." + argv[1] + ".log"
    PL.start_logger(logfilename, 1)
    
    TOTAL_IMGS = int(config.get("Flowcell", "imgs_per_array"))

    image_timeout = int(config.get("Motion", "image_timeout"))

    PHX_buffersize = int(config.get("Camera", "PHX_buffersize"))

    proc_portnum = int(config.get("Processor", "proc_portnum"))

    PHX_configfilename  = polpath + "/config_files/" + \
                                config.get("Camera", "PHX_configfilename")

    auto_exposure = int(config.get("Stage_Align", "auto_exposure"))

    argc = len(argv)
    if argc == 7:
        # number of images to average was specified 
        log_string = "%s called with %d args: <%s> <%d> <%d> <%d> <%d> <%d>" %
                        (argv[0], argc-1, argv[1], \
                        int(argv[2]), int(argv[3]), int(argv[4]),\
                        int(argv[5]), int(argv[6]) )
        PL.p_log(log_string)
        # num_to_avg consecutive images should be averaged together, 
        # then transmitted
        num_to_average = int(argv[6]) 
        if num_to_average == 1:
            num_to_average = 0
Ejemplo n.º 2
0
 def writeMappingFile(self):
     """
         This function writes a mapping function after it has been generated
         within the class and is in memory
         To a file
     """
     MF = self.MF
     # write mapping to file
     PL.p_log("Status:\tMF: writing camera to DMD map to file")
     mapping_file = open('camera_to_DMD.map', 'w')
     mapping_file.write('#This is the mapping file for the camera to DMD\n')
     mapping_file.write( '#Generated on: ' \
                         +  time.strftime("%Y-%m-%d %H:%M:%S") + '\n')
     mapping_file.write('#A0\tA1\tA2\tA3\tA4\tA5\tA6\tA7\tA8\tA9\n')
     mapping_file.write( str(MF.A_map[0]) + \
                         '\t' + str(MF.A_map[1]) + \
                         '\t' + str(MF.A_map[2]) + \
                         '\t' + str(MF.A_map[3]) + \
                         '\t' + str(MF.A_map[4]) + \
                         '\t' + str(MF.A_map[5]) + \
                         '\t' + str(MF.A_map[6]) + \
                         '\t' + str(MF.A_map[7]) + \
                         '\t' + str(MF.A_map[8]) + \
                         '\t' + str(MF.A_map[9]) + '\n' )
     mapping_file.close()
Ejemplo n.º 3
0
    def __init__(self):
        """
        This configures the class by loading key parameters from a
        configuration file

        """
        PL.p_log("STATUS:\tMappingFunctions: initializing")

        self.MF.config = ConfigParser.ConfigParser()
        self.MF.config_dir = os.environ['POLONATOR_PATH'] + \
                                        '/config_files'
        self.MF.config_path = self.MF.config_dir \
                                            + '/camera_to_DMD_params.config'
        self.MF.A_map = numpy.empty(10,dtype=numpy.float)
        # make sure something is in the file
        if self.MF.config.read(self.MF.config_path) == []:
            self.defaultConfigFile()
            self.MF.config.read(self.MF.config_path)
        #end if
        elif not self.MF.config.has_section('Main'):
            print "No main"
            self.defaultConfigFile()
        # end elif
        self.MF.IlluminateWidth = \
            int(self.MF.config.get(  'Main', 'IlluminateWidth'))
        self.MF.IlluminateHeight = \
            int(self.MF.config.get(  'Main', 'IlluminateHeight'))
        self.MF.CameraWidth = \
            int(self.MF.config.get(  'Main',  'CameraWidth'))
        self.MF.CameraHeight = \
            int(self.MF.config.get(  'Main', 'CameraHeight'))
        self.MF.ImageExposure = \
            float(self.MF.config.get('Main', 'ImageExposure'))
        self.MF.ImageGain = \
            int(self.MF.config.get(  'Main', 'ImageGain'))
        self.MF.ImageColor = \
            self.MF.config.get(      'Main', 'ImageColor')
        self.MF.ImageFilename = \
            self.MF.config.get(      'Main', 'ImageFilename')
        self.MF.ImageCCD_BytesPerPixel = \
            int(self.MF.config.get(  'Main', 'ImageCCD_BytesPerPixel'))
        self.MF.MaestroF = PM.MaestroFunctions()
        self.MF.mask_number0 = 0
        self.MF.mask_radius0 = 1
        self.MF.mask_number1 = 1
        self.MF.mask_radius1 = 0
        self.MF.mask_number2 = 2
        self.MF.mask_radius2 = 1
        self.MF.mask_number3 = 3
        self.MF.mask_radius3 = 3
        self.MF.expose = 0.25
        self.MF.gain = 200
        self.illumInit()
Ejemplo n.º 4
0
    def mapReinit(self):
        """
        This configures the class by loading key parameters from a
        configuration file
        
        """
        # read in the config file.  must be formated correctly
        PL.p_log("STATUS:\tMappingFunctions: initializing")
        
        MF = self.MF
        MF.config = ConfigParser.ConfigParser()
        MF.config_dir = os.environ['POLONATOR_PATH'] + '/config_files'
        MF.config_path = MF.config_dir + '/camera_to_DMD_params.config'

        # make sure something is in the file
        if MF.config.read(MF.config_path) == []:
            self.defaultConfigFile()
            MF.config.read(MF.config_path)
        #end if
        elif not MF.config.has_section('Main'):
            print "No main"
            MF.defaultConfigFile()
        # end elif
        MF.IlluminateWidth = int(MF.config.get( 'Main', \
                                                'IlluminateWidth'))
        MF.IlluminateHeight = int(MF.config.get('Main', \
                                                'IlluminateHeight'))
        MF.CameraWidth = int(MF.config.get(     'Main', \
                                                'CameraWidth'))
        MF.CameraHeight = int(MF.config.get(    'Main', \
                                                'CameraHeight'))
        MF.ImageExposure = float(MF.config.get( 'Main', \
                                                'ImageExposure'))
        MF.ImageGain = int(MF.config.get(       'Main', \
                                                'ImageGain'))
        MF.ImageColor = MF.config.get(          'Main', \
                                                'ImageColor')
        MF.ImageFilename = MF.config.get(       'Main', \
                                                'ImageFilename')
        MF.ImageCCD_BytesPerPixel = \
            int(MF.config.get('Main', 'ImageCCD_BytesPerPixel'))
Ejemplo n.º 5
0
 def readMappingFile(self): 
     """
         This reads a mapping data from file into memory.  Assumes the
         mapping file already exists
         TODO: Should add exception in the case the file does not exist
     """
     MF = self.MF
     PL.p_log("Status:\tMF: reading camera to DMD map to file")
     mapping_file = open('camera_to_DMD.map', 'r')
     for line in mapping_file:
         # the mapping data starts on the first line without a # to start it
         if line[0] != '#':  
             map_line = line.split()
             for i in range(len(map_line)):
                 MF.A_map[i] = float(map_line[i]);
                 print MF.A_map[i]
             # end for
             break;
         # end if
     # end for
     mapping_file.close()
Ejemplo n.º 6
0
def send_initial_raw_images(num_array):
    #Network transfer declarations
    # int serv_sock; # socket for the server (this machine)
    i = 0
    global datasize

    # prepare the network connection and send
    # open the port, and wait for processor to connect
    net.py_network_startserver(proc_portnum)

    while i < num_array:
        # read and send the auto_exposure raw images
        stagealign_rawimgfilename = "%s/polonator/G.007/acquisition/stagealign/stagealign-image0_%d.raw" % (os.environ["HOME"], i)
        PL.p_log_simple(stagealign_rawimgfilename)

        log_string =  "STATUS:\t 1try to send the autoexposure images %s to processor, port %d..." % (stagealign_rawimgfilename, proc_portnum)
        PL.p_log(log_string)

        baseimage = numpy.fromfile(file=stagealign_rawimgfilename, dtype=np.uint16)

        log_string = "STATUS:\t 2try to send the autoexposure images %s to processor, port %d..." % (stagealign_rawimgfilename, proc_portnum)
        PL.p_log(log_string)

        blank_image = numpy.copy(baseimage)

        log_string =  "STATUS:\t 3try to send the autoexposure images %s to processor, port %d..." % (stagealign_rawimgfilename, proc_portnum)
        PL.p_log(log_string)

        while net.py_network_waitforsend() != 1:
            log_string = "Waiting to send the autoexposure images"
            PL.p_log(log_string)
        # end while
        log_string = "Trying to send autoexposure images %d" %  (i)
        PL.p_log_simple(log_string)
        net.py_network_sendimage( 0, 0, i, blank_image)
        log_string = "Sent autoexposure images %d" % (i)
        PL.p_log_simple(log_string)

        i += 1
Ejemplo n.º 7
0
def send_FL_images(mystring, num_array):
    # prepare the network connection and send
    # open the port, and wait for processor to connect
    net.py_network_startserver(proc_portnum)

    string1 = mystring + len(mystring) - 1
    PL.p_log(string1)

    log_string = "string1 length %d" % (len(string1))
    PL.p_log(log_string)

    if string1 == "G":
        log_string = "success_%d.raw" % (0)
        PL.p_log(log_string)

        stagealign_dir_name = "%s/polonator/G.007/acquisition/autoexp_FL_images/fam/" % (os.environ["HOME"])
        PL.p_log(stagealign_dir_name)
    elif string1 == "A":
        log_string = "success_%d.raw" % (0)
        PL.p_log(log_string)

        stagealign_dir_name = "%s/polonator/G.007/acquisition/autoexp_FL_images/cy3/" % (os.environ["HOME"])
        PL.p_log(stagealign_dir_name)
    # elif

    elif string1 == "C":
        log_string = "success_%d.raw" % (0)
        PL.p_log(log_string)
        stagealign_dir_name = "%s/polonator/G.007/acquisition/autoexp_FL_images/txred/" % (os.environ["HOME"])
        PL.p_log(stagealign_dir_name)
    # end elif

    elif string1 == "T":
        log_string =  "success_%d.raw" % (0)
        PL.p_log(log_string)

        stagealign_dir_name = "%s/polonator/G.007/acquisition/autoexp_FL_images/cy5/" % (os.environ["HOME"])
        PL.p_log(stagealign_dir_name)
    # end elif
    
    i = 0
    while i < num_array:
        # read and send the FL autoe images

        stagealign_rawimgfilename = "%simage_%d.raw" % (stagealign_dir_name, 60+i*10)
        log_string =  "STATUS:\t 1try to send the autoexposure images %s to processor, port %d..." % (stagealign_rawimgfilename, proc_portnum)
        PL.p_log(log_string)
        baseimage = numpy.fromfile(file=stagealign_rawimgfilename, dtype=np.uint16)
        
        log_string = "STATUS:\t 2try to send the autoexposure images %s to processor, port %d..." % (stagealign_rawimgfilename, proc_portnum)
        PL.p_log(log_string)

        blank_image = numpy.copy(baseimage)
        
        log_string =  "STATUS:\t 3try to send the autoexposure images %s to processor, port %d..." % (stagealign_rawimgfilename, proc_portnum)
        PL.p_log(log_string) 

        while net.py_network_waitforsend() != 1:
            log_string = "Waiting to send the autoexposure images"
            PL.p_log(log_string)
        # end while
        
        log_string = "Trying to send autoexposure FL images %d" % (i)
        PL.p_log_simple(log_string)
        net.py_network_sendimage(0, 0, i, blank_image)
        log_string = "Sent autoexposure FL images %d" % i
        PL.p_log_simple(log_string)
        i += 1
    # end while

    
    i = 0
    while i < 2:
        i = net.py_network_waitforsend()
        log_string = "waiting to receive the gain value back"
        PL.p_log(log_string)
    # end while
    gain = (i - 97)*10 + 60

    log_string = "the autoexposure gain to use will be %d" %  (gain)
    PL.p_log_simple(log_string)

    return gain
Ejemplo n.º 8
0
                        (argv[0], argc-1, argv[1], \
                        int(argv[2]), int(argv[3]), int(argv[4]),\
                        int(argv[5]), int(argv[6]) )
        PL.p_log(log_string)
        # num_to_avg consecutive images should be averaged together, 
        # then transmitted
        num_to_average = int(argv[6]) 
        if num_to_average == 1:
            num_to_average = 0
    elif argc == 6:
        # number of images to average was not specified; assume no averaging 
        log_string = "%s called with %d args: <%s> <%d> <%d> <%d> <%d>" % \
                        (argv[0], argc-1, argv[1], \
                        int(argv[2]), int(argv[3]), \
                        int(argv[4]), int(argv[5]) )
        PL.p_log(log_string)
        num_to_average = 0 # don't do image averaging
    else:
        print "ERROR: %s called with %d args, must be called as\n" % (argv[0], argc-1)
        print "       %s <cycle_name> <integration time in seconds> <EM gain> <flowcell number> <number of arrays>        <num_imgs_to_average>  OR\n" % (argv[0])
        print "       %s <cycle_name> <integration time in seconds> <EM gain> <flowcell number> <number of arrays> IF no image averaging desired.\n" % (argv[0])
        sys.exit(1)
    fcnum = int(argv[4])
    TOTAL_ARRAYS = int(argv[5])

    # CAMERA SETUP
    # configure framegrabber
    exposure = float(argv[2])
    gain = int(arg[3])
    PC.camera_initAcq(0, exposure, gain)