def getListOfExperiments(self): settings = ConfigSettings(SECTION_REGISTRY) settings.read(self.oBatchSettings.settingsFilename) settings.set_section(SECTION_NAME_GENERAL) settings.set2('pathin', self.oBatchSettings.baseInDir) settings.set2('pathout', self.oBatchSettings.baseOutDir) imagecontainer = ImageContainer() imagecontainer.import_from_settings(settings) if self.oBatchSettings.plates is None: plates = imagecontainer.plates else: plates = self.oBatchSettings.plates lstExperiments = [] for plate in plates: meta_data = imagecontainer.get_meta_data(plate) positions = meta_data.positions if self.oBatchSettings.omit_processed_positions: finished_pos = [os.path.splitext(x)[0].split('__')[0] for x in os.listdir(os.path.join(self.oBatchSettings.baseOutDir, plate, 'log', '_finished'))] positions = filter(lambda x: x not in finished_pos, positions) lstExperiments.extend([(x,y) for x,y in zip([plate for i in positions], positions) ]) return lstExperiments
def load_image_container_from_settings(settings): imagecontainer = ImageContainer() infos = imagecontainer.iter_check_plates(settings) scan_plates = dict((info[0], False) for info in infos) import_iter = imagecontainer.iter_import_from_settings( settings, scan_plates) for idx, info in enumerate(import_iter): pass if len(imagecontainer.plates) > 0: plate = imagecontainer.plates[0] imagecontainer.set_plate(plate) return imagecontainer
def _load_image_container(self, plate_infos, scan_plates=None, show_dlg=True): self._clear_browser() imagecontainer = ImageContainer() self._imagecontainer = imagecontainer if scan_plates is None: scan_plates = dict((info[0], False) for info in plate_infos) def load(dlg): iter = imagecontainer.iter_import_from_settings(self._settings, scan_plates) for idx, info in enumerate(iter): dlg.targetSetValue.emit(idx + 1) if len(imagecontainer.plates) > 0: plate = imagecontainer.plates[0] imagecontainer.set_plate(plate) self.dlg = waitingProgressDialog('Please wait until the input structure is scanned\n' 'or the structure data loaded...', self, load, (0, len(scan_plates))) self.dlg.exec_(passDialog=True) if len(imagecontainer.plates) > 0: imagecontainer.check_dimensions() channels = imagecontainer.channels # do not report value changes to the main window self._settings.set_notify_change(False) self.set_image_crop_size() problems = [] for prefix in ['primary', 'secondary', 'tertiary']: trait = self._settings.get_trait(SECTION_NAME_OBJECTDETECTION, '%s_channelid' % prefix) if trait.set_list_data(channels) is None: problems.append(prefix) self._tabs[1].get_widget('%s_channelid' % prefix).update() # report problems about a mismatch between channel IDs found in the data and specified by the user if len(problems) > 0: critical(self, "Selected channel IDs not valid", "The selected channel IDs for %s are not valid.\nValid IDs are %s." % (", ".join(["'%s Channel'" % s.capitalize() for s in problems]), ", ".join(["'%s'" % s for s in channels]))) # a mismatch between settings and data will cause changed settings self.settings_changed(True) trait = self._settings.get_trait(SECTION_NAME_TRACKING, 'tracking_duration_unit') # allow time-base tracking durations only if time-stamp # information is present meta_data = imagecontainer.get_meta_data() if meta_data.has_timestamp_info: result = trait.set_list_data(TRACKING_DURATION_UNITS_TIMELAPSE) else: result = trait.set_list_data(TRACKING_DURATION_UNITS_DEFAULT) if result is None: critical(self, "Could not set tracking duration units", "The tracking duration units selected to match the load data. Please check your settings.") # a mismatch between settings and data will cause changed settings self.settings_changed(True) # activate change notification again self._settings.set_notify_change(True) self.set_modules_active(state=True) if show_dlg: information(self, "Plate(s) successfully loaded", "%d plates loaded successfully." % len(imagecontainer.plates)) else: critical(self, "No valid image data found", "The naming schema provided might not fit your image data" "or the coordinate file is not correct.\n\nPlease modify " "the values and scan the structure again.")
else: path_input = settings.get2('pathin') if path_output is not None: settings.set2('pathout', path_output) logger.info('Overwrite output path by %s' % path_output) else: path_output = settings.get2('pathout') if multiple_plates is None: multiple_plates = settings.get(SECTION_NAME_GENERAL, 'has_multiple_plates') else: logger.info('Overwrite has_multiple_plates by %s' % multiple_plates) imagecontainer = ImageContainer() imagecontainer.import_from_settings(settings) # FIXME: Could be more generally specified. SGE is setting the job item index via an environment variable if index is None: pass elif index.isdigit(): index = int(index) else: if index == ENV_INDEX_SGE: logger.info("Using SGE job item index: environment variable '%s'" % index) if index not in os.environ: parser.error("SGE environment variable '%s' not defined.") index = int(os.environ[index]) # decrement index (index is in range of 1..n for SGE)
def _load_image_container(self, plate_infos=None, scan_plates=None, show_dialog=True): self._clear_browser() if plate_infos is None: plate_infos = list(ImageContainer.iter_check_plates( self._settings)) imagecontainer = ImageContainer() self._imagecontainer = imagecontainer if scan_plates is None: scan_plates = dict((info[0], False) for info in plate_infos) def load(emitter, icontainer, settings, splates): iter_ = icontainer.iter_import_from_settings(settings, scan_plates=splates) for idx, info in enumerate(iter_): emitter.setValue.emit(idx) emitter.setLabelText.emit("checking dimensions...") emitter.setRange.emit(0, 0) QtCore.QCoreApplication.processEvents() if len(icontainer.plates) > 0: icontainer.set_plate(icontainer.plates[0]) icontainer.check_dimensions() label = ('Please wait until the input structure is scanned\n' 'or the structure data loaded...') self._dlg = ProgressDialog(label, None, 0, len(scan_plates), self) emitter = ProgressObject() emitter.setRange.connect(self._dlg.setRange) emitter.setValue.connect(self._dlg.setValue) emitter.setLabelText.connect(self._dlg.setLabelText) try: func = lambda: load(emitter, imagecontainer, self._settings, scan_plates) self._dlg.exec_(func, (emitter, )) except ImportError as e: # structure file from versions older than 1.3 contain pdk which is # removed if 'pdk' in str(e): QMessageBox.critical( self, "Error", ("Your structure file format is outdated.\n" "You have to rescan the plate(s)")) else: QMessageBox.critical(self, "Error", traceback.format_exc()) return except Exception as e: QMessageBox.critical(self, "Error", str(e)) try: # I hate lookup tables! self._tab_lookup['Cluster'][1].set_imagecontainer(imagecontainer) except KeyError: pass if len(imagecontainer.plates) > 0: channels = imagecontainer.channels # do not report value changes to the main window self._settings.set_notify_change(False) self.set_image_crop_size() problems = [] for prefix in ['primary', 'secondary', 'tertiary']: trait = self._settings.get_trait(SECTION_NAME_OBJECTDETECTION, '%s_channelid' % prefix) if trait.set_list_data(channels) is None: problems.append(prefix) self._tabs[1].get_widget('%s_channelid' % prefix).update() # report problems about a mismatch between channel IDs found in the data # and specified by the user if len(problems) > 0: # a mismatch between settings and data will cause changed settings self.settings_changed(True) trait = self._settings.get_trait(SECTION_NAME_EVENT_SELECTION, 'duration_unit') # allow time-base tracking durations only if time-stamp # information is present meta_data = imagecontainer.get_meta_data() if meta_data.has_timestamp_info: result = trait.set_list_data(TimeConverter.units) else: result = trait.set_list_data([TimeConverter.FRAMES]) if result is None: QMessageBox.critical( self, "Could not set tracking duration units", ("The tracking duration units selected to match the " "load data. Please check your settings.")) # a mismatch between settings and data will cause changed settings self.settings_changed(True) # activate change notification again self._settings.set_notify_change(True) self.set_modules_active(state=True) if show_dialog: QMessageBox.information( self, "Information", "%d plate(s) successfully loaded." % len(imagecontainer.plates)) else: QMessageBox.critical( self, "Error", ("No images found\n" "Verifiy your nameing scheme and rescan the data."))