def _load_data(self, mappings, channel): dtable = HmmDataTable() # XXX read region names from hdf not from settings chreg = "%s__%s" %(channel, self.ecopts.regionnames[channel]) progress = ProgressMsg(max=len(self.files)) for file_ in self.files: position = splitext(basename(file_))[0] progress.meta = meta=("loading plate: %s, file: %s" %(self.plate, file_)) progress.increment_progress() QThread.currentThread().interruption_point() self.parent().progressUpdate.emit(progress) QtCore.QCoreApplication.processEvents() try: ch5 = cellh5.CH5File(file_, "r", cached=True) for pos in ch5.iter_positions(): # only segmentation if not pos.has_classification(chreg): continue # make dtable aware of all positions, sometime they contain # no tracks and I don't want to ignore them dtable.add_position(position, mappings[position]) if not pos.has_events(): continue objidx = np.array( \ pos.get_events(not self.ecopts.ignore_tracking_branches), dtype=int) tracks = pos.get_class_label(objidx, chreg) try: probs = pos.get_prediction_probabilities(objidx, chreg) except KeyError as e: probs = None grp_coord = cellh5.CH5GroupCoordinate( \ chreg, pos.pos, pos.well, pos.plate) dtable.add_tracks(tracks, position, mappings[position], objidx, grp_coord, probs) finally: ch5.close() if dtable.is_empty(): raise RuntimeError( "No data found for plate '%s' and channel '%s' " %(self.plate, channel)) return dtable, self._load_classdef(chreg)
def _load_data(self, mappings, channel): dtable = HmmDataTable() # XXX read region names from hdf not from settings chreg = "%s__%s" % (channel, self.ecopts.regionnames[channel]) progress = ProgressMsg(max=len(self.files)) for file_ in self.files: position = splitext(basename(file_))[0] progress.meta = meta = ("loading plate: %s, file: %s" % (self.plate, file_)) progress.increment_progress() QThread.currentThread().interruption_point() self.parent().progressUpdate.emit(progress) QtCore.QCoreApplication.processEvents() try: ch5 = cellh5.CH5File(file_, "r", cached=True) for pos in ch5.iter_positions(): # only segmentation if not pos.has_classification(chreg): continue # make dtable aware of all positions, sometime they contain # no tracks and I don't want to ignore them dtable.add_position(position, mappings[position]) if not pos.has_events(): continue objidx = np.array( \ pos.get_events(not self.ecopts.ignore_tracking_branches), dtype=int) tracks = pos.get_class_label(objidx, chreg) try: probs = pos.get_prediction_probabilities(objidx, chreg) except KeyError as e: probs = None grp_coord = cellh5.CH5GroupCoordinate( \ chreg, pos.pos, pos.well, pos.plate) dtable.add_tracks(tracks, position, mappings[position], objidx, grp_coord, probs) finally: ch5.close() if dtable.is_empty(): raise RuntimeError( "No data found for plate '%s' and channel '%s' " % (self.plate, channel)) return dtable, self._load_classdef(chreg)
def __call__(self): if self.params_ec.position_labels: self._check_mapping_files() progress = ProgressMsg(max=len(self.plates), meta="Error correction...") for i, plate in enumerate(self.plates): QThread.currentThread().interruption_point() progress.text = ("Plate: '%s' (%d / %d)" %(plate, i+1, len(self.plates))) self.progressUpdate.emit(progress) ch5file = join(self._outdirs[plate], 'hdf5', "_all_positions.ch5") runner = PositionRunner(plate, self._outdirs[plate], self.params_ec, parent=self, ch5file=ch5file) runner() self.progressUpdate.emit(progress)
def __init__(self, parent, job_count, ncpu): self.parent = parent self.ncpu = ncpu self._timer = StopWatch(start=True) self.progress = ProgressMsg( max=job_count, meta=('Parallel processing %d / %d positions ' '(%d cores)' % (0, job_count, self.ncpu))) self.parent.stage_info.emit(self.progress)
def __call__(self): if self.params_ec.position_labels: self._check_mapping_files() progress = ProgressMsg(max=len(self.plates), meta="Error correction...") for i, plate in enumerate(self.plates): QThread.currentThread().interruption_point() progress.text = ("Plate: '%s' (%d / %d)" % (plate, i + 1, len(self.plates))) self.progressUpdate.emit(progress) ch5file = join(self._outdirs[plate], 'hdf5', "_all_positions.ch5") runner = PositionRunner(plate, self._outdirs[plate], self.params_ec, parent=self, ch5file=ch5file) runner() self.progressUpdate.emit(progress)
def interruption_point(self, message=None): if message is not None: prgs = ProgressMsg(meta=message) self.parent().progressUpdate.emit(prgs) QThread.currentThread().interruption_point()