def core_helper(plate, settings_dict, imagecontainer, position, version, mode="r+", redirect=True): """Embedds analysis of a positon in a single function""" # see http://stackoverflow.com/questions/3288595/ # multiprocessing-using-pool-map-on-a-function-defined-in-a-class logger = logging.getLogger(str(os.getpid())) try: # FIXME numpy 1.11 does not have ._dotblas import numpy.core._dotblas reload(numpy.core._dotblas) except ImportError as e: pass try: settings = ConfigSettings() settings.from_dict(settings_dict) settings.set('General', 'constrain_positions', True) settings.set('General', 'positions', position) environ = CecogEnvironment(version, redirect=redirect) analyzer = PlateAnalyzer(plate, settings, imagecontainer, mode=mode) analyzer() return plate, position except Exception as e: errortxt = "Plate: %s, Site: %s\n" %(plate, position) errortxt = "".join([errortxt] + \ traceback.format_exception(*sys.exc_info())) logger.error(errortxt) raise type(e)(errortxt)
def core_helper(plate, settings_dict, imagecontainer, position, version, redirect=True, debug=False): """Embeds analysis of a positon in a single function""" # see http://stackoverflow.com/questions/3288595/ # multiprocessing-using-pool-map-on-a-function-defined-in-a-class logger = logging.getLogger(str(os.getpid())) import numpy reload(numpy.core._dotblas) try: settings = ConfigSettings() settings.from_dict(settings_dict) settings.set('General', 'constrain_positions', True) settings.set('General', 'positions', position) environ = CecogEnvironment(version, redirect=redirect, debug=debug) if debug: environ.pprint() analyzer = AnalyzerCore(plate, settings, imagecontainer) post_hdf5_link_list = analyzer.processPositions() return plate, position, copy.deepcopy(post_hdf5_link_list) except Exception as e: errortxt = "plate: %s, position: %s\n" %(plate, position) errortxt = "".join([errortxt] + \ traceback.format_exception(*sys.exc_info())) logger.error(errortxt) raise e.__class__(errortxt)
def core_helper(plate, settings_dict, imagecontainer, position, version, redirect=True, debug=False): """Embeds analysis of a positon in a single function""" # see http://stackoverflow.com/questions/3288595/ # multiprocessing-using-pool-map-on-a-function-defined-in-a-class logger = logging.getLogger(str(os.getpid())) import numpy reload(numpy.core._dotblas) try: settings = ConfigSettings() settings.from_dict(settings_dict) settings.set('General', 'constrain_positions', True) settings.set('General', 'positions', position) environ = CecogEnvironment(version, redirect=redirect, debug=debug) if debug: environ.pprint() analyzer = AnalyzerCore(plate, settings, imagecontainer) post_hdf5_link_list = analyzer.processPositions() return plate, position, copy.deepcopy(post_hdf5_link_list) except Exception as e: errortxt = "plate: %s, position: %s\n" % (plate, position) errortxt = "".join([errortxt] + \ traceback.format_exception(*sys.exc_info())) logger.error(errortxt) raise e.__class__(errortxt)
def core_helper(plate_id, settings_str, imagecontainer, position): settings = ConfigSettings(SECTION_REGISTRY) settings.from_string(settings_str) settings.set(SECTION_NAME_GENERAL, 'constrain_positions', True) settings.set(SECTION_NAME_GENERAL, 'positions', position) try: analyzer = AnalyzerCore(plate_id, settings, imagecontainer) result = analyzer.processPositions() except Exception: traceback.print_exc() raise return plate_id, position, copy.deepcopy(result['post_hdf5_link_list'])
def core_helper(plate, settings_dict, imagecontainer, position, version, mode="r+", redirect=True): """Embedds analysis of a positon in a single function""" # see http://stackoverflow.com/questions/3288595/ # multiprocessing-using-pool-map-on-a-function-defined-in-a-class logger = logging.getLogger(str(os.getpid())) try: # FIXME numpy 1.11 does not have ._dotblas import numpy.core._dotblas reload(numpy.core._dotblas) except ImportError as e: pass try: settings = ConfigSettings() settings.from_dict(settings_dict) settings.set('General', 'constrain_positions', True) settings.set('General', 'positions', position) environ = CecogEnvironment(version, redirect=redirect) analyzer = PlateAnalyzer(plate, settings, imagecontainer, mode=mode) analyzer() return plate, position except Exception as e: errortxt = "Plate: %s, Site: %s\n" % (plate, position) errortxt = "".join([errortxt] + \ traceback.format_exception(*sys.exc_info())) logger.error(errortxt) raise type(e)(errortxt)
parser.error("Batch size requires a cluster index.") # select slice of positions according to index and batch size positions = positions[(index*batch_size) : ((index+1)*batch_size)] # index alone was specified elif index is not None: positions = [positions[index]] logger.info('Final list of position: %s' % positions) # redefine the image write to disc if create_images is not None: logger.info('Overwrite image creation from settings by %s' % create_images) for rendering in ['rendering_labels_discwrite', 'rendering_class_discwrite', 'rendering_contours_discwrite']: settings.set(SECTION_NAME_OUTPUT, rendering, create_images) # group positions by plate plates = {} for item in positions: compound = item.split('___') if len(compound) == 2: plate_id, pos = compound elif len(compound) == 1: if not multiple_plates: plate_id = os.path.split(path_input)[1] pos = compound[0] else: parser.error("Position must be of the form 'plateid___position'. Found '%s' instead." % item) else: parser.error("Position must be of the form 'position' or 'plateid___position'. Found '%s' instead." % item)
def set(self, section_name, trait_name, value): ConfigSettings.set(self, section_name, trait_name, value) if not self._parent is None and self._notify_change: self._parent.settings_changed(True)
# group positions by plate plates = defaultdict(list) for p in positions: plate, pos = p.split(PLATESEP) plates[plate].append(pos) # HDF file lock does not work on different cluster nodes (no shared memory) # only storage is shared time.sleep(random.random()*30) for plate, positions in plates.iteritems(): # redefine output path in case of mulitplate analyis if settings('General', 'has_multiple_plates'): settings.set('General', 'pathout', os.path.join(settings('General', 'pathout'), plate)) # redefine the positions settings.set('General', 'constrain_positions', True) settings.set('General', 'positions', ','.join(positions)) print "Processing site %s - %s" % (plate, ", ".join(positions)) analyzer = PlateAnalyzer(plate, settings, imagecontainer, mode="a") analyzer() ch5file = analyzer.h5f n_sites = len(glob.glob(os.path.join(settings("General", "pathout"), "cellh5", "*.tmp"))) n_total = len(imagecontainer.get_meta_data().positions) posflag = settings("General", "constrain_positions") # compare the number of processed positions with the number