def _parse_neo_roi(self, columns): """Parses out ROI from OmeroTables columns for 'NEO' datasets.""" log.debug("Parsing %s NEO ROIs..." % (len(columns[0].values))) image_ids = columns[self.IMAGE_COL].values rois = list() # Save our file annotation to the database so we can use an unloaded # annotation for the saveAndReturnIds that will be triggered below. self.file_annotation = \ self.update_service.saveAndReturnObject(self.file_annotation) unloaded_file_annotation = \ FileAnnotationI(self.file_annotation.id.val, False) batch_no = 1 batches = dict() for i, image_id in enumerate(image_ids): unloaded_image = ImageI(image_id, False) roi = RoiI() shape = EllipseI() values = columns[6].values diameter = rdouble(float(values[i])) shape.theZ = rint(0) shape.theT = rint(0) values = columns[4].values shape.cx = rdouble(float(values[i])) values = columns[3].values shape.cy = rdouble(float(values[i])) shape.rx = diameter shape.ry = diameter roi.addShape(shape) roi.image = unloaded_image roi.linkAnnotation(unloaded_file_annotation) rois.append(roi) if len(rois) == self.ROI_UPDATE_LIMIT: self.thread_pool.add_task( self.update_rois, rois, batches, batch_no) rois = list() batch_no += 1 self.thread_pool.add_task(self.update_rois, rois, batches, batch_no) self.thread_pool.wait_completion() batch_keys = batches.keys() batch_keys.sort() for k in batch_keys: columns[self.ROI_COL].values += batches[k]