From 2e214f9a8e0f9268de4235d66cb839e2c487307e Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Tue, 9 Jan 2024 21:51:33 +0000 Subject: [PATCH 01/21] bump actions/checkout to v4 --- .github/workflows/omero_plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/omero_plugin.yml b/.github/workflows/omero_plugin.yml index 455b4b231..40b601e9e 100644 --- a/.github/workflows/omero_plugin.yml +++ b/.github/workflows/omero_plugin.yml @@ -23,7 +23,7 @@ jobs: env: STAGE: scripts steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Checkout omero-test-infra uses: actions/checkout@master with: From 09a19d490ea1b784689beacb3f9911c21c878290 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Tue, 9 Jan 2024 21:53:05 +0000 Subject: [PATCH 02/21] point to own branch --- .github/workflows/omero_plugin.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/omero_plugin.yml b/.github/workflows/omero_plugin.yml index 40b601e9e..cbe925e9c 100644 --- a/.github/workflows/omero_plugin.yml +++ b/.github/workflows/omero_plugin.yml @@ -27,8 +27,9 @@ jobs: - name: Checkout omero-test-infra uses: actions/checkout@master with: - repository: ome/omero-test-infra + repository: jburel/omero-test-infra path: .omero - ref: ${{ secrets.OMERO_TEST_INFRA_REF }} + #ref: ${{ secrets.OMERO_TEST_INFRA_REF }} + ref: update - name: Build and run OMERO tests run: .omero/docker $STAGE From 80ebe42b02b8f80016ca001ab1716208c8b90db4 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Tue, 9 Jan 2024 22:04:15 +0000 Subject: [PATCH 03/21] set python version --- .github/workflows/publish_pypi.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 81eccda37..c0418dfda 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -9,6 +9,8 @@ jobs: steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 + with: + python-version: '3.9' - name: Build a binary wheel and a source tarball run: | python -mpip install wheel From cb2d445e768c6efe19f8900358b488156860a203 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Tue, 9 Jan 2024 22:04:46 +0000 Subject: [PATCH 04/21] bump actions/checkout to v4 --- .github/workflows/publish_pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index c0418dfda..f412a8e28 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -7,7 +7,7 @@ jobs: name: Build and publish Python distribution to PyPI runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: '3.9' From d12b86ff3ab4a70753b264ce8c45f5fcbffa7ab6 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Wed, 10 Jan 2024 10:58:44 +0000 Subject: [PATCH 05/21] point to ome repo --- .github/workflows/omero_plugin.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/omero_plugin.yml b/.github/workflows/omero_plugin.yml index cbe925e9c..40b601e9e 100644 --- a/.github/workflows/omero_plugin.yml +++ b/.github/workflows/omero_plugin.yml @@ -27,9 +27,8 @@ jobs: - name: Checkout omero-test-infra uses: actions/checkout@master with: - repository: jburel/omero-test-infra + repository: ome/omero-test-infra path: .omero - #ref: ${{ secrets.OMERO_TEST_INFRA_REF }} - ref: update + ref: ${{ secrets.OMERO_TEST_INFRA_REF }} - name: Build and run OMERO tests run: .omero/docker $STAGE From 12a5dba0ef1396f0055f260e618ea3b53787bae0 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Wed, 10 Jan 2024 11:18:30 +0000 Subject: [PATCH 06/21] fix flake8 issue --- omero/analysis_scripts/Kymograph.py | 10 ++++----- omero/analysis_scripts/Kymograph_Analysis.py | 4 ++-- omero/analysis_scripts/Plot_Profile.py | 20 +++++++++--------- omero/annotation_scripts/KeyVal_to_csv.py | 6 +++--- omero/export_scripts/Make_Movie.py | 4 ++-- omero/figure_scripts/Movie_Figure.py | 2 +- omero/figure_scripts/Movie_ROI_Figure.py | 2 +- omero/figure_scripts/ROI_Split_Figure.py | 4 ++-- omero/figure_scripts/Split_View_Figure.py | 2 +- omero/util_scripts/Dataset_To_Plate.py | 2 +- omero/util_scripts/Images_From_ROIs.py | 2 +- omero/util_scripts/Move_Annotations.py | 22 ++++++++++---------- 12 files changed, 40 insertions(+), 40 deletions(-) diff --git a/omero/analysis_scripts/Kymograph.py b/omero/analysis_scripts/Kymograph.py index 4e650a108..573317ea4 100644 --- a/omero/analysis_scripts/Kymograph.py +++ b/omero/analysis_scripts/Kymograph.py @@ -175,9 +175,9 @@ def plane_gen(): line_data = [] points = shape['points'] the_z = shape['theZ'] - for l in range(len(points)-1): - x1, y1 = points[l] - x2, y2 = points[l+1] + for point in range(len(points)-1): + x1, y1 = points[point] + x2, y2 = points[point+1] ld = get_line_data(image, x1, y1, x2, y2, line_width, the_z, the_c, the_t) line_data.append(ld) @@ -334,7 +334,7 @@ def process_images(conn, script_params): z = the_z # TODO: Add some filter of shapes. E.g. text? / 'lines' only # etc. - if type(s) == omero.model.LineI: + if isinstance(s, omero.model.LineI): x1 = s.getX1().getValue() x2 = s.getX2().getValue() y1 = s.getY1().getValue() @@ -342,7 +342,7 @@ def process_images(conn, script_params): lines[t] = {'theZ': z, 'x1': x1, 'y1': y1, 'x2': x2, 'y2': y2} - elif type(s) == omero.model.PolylineI: + elif isinstance(s, omero.model.PolylineI): v = s.getPoints().getValue() points = roi_utils.points_string_to_xy_list(v) polylines[t] = {'theZ': z, 'points': points} diff --git a/omero/analysis_scripts/Kymograph_Analysis.py b/omero/analysis_scripts/Kymograph_Analysis.py index 079231b6f..1af783232 100644 --- a/omero/analysis_scripts/Kymograph_Analysis.py +++ b/omero/analysis_scripts/Kymograph_Analysis.py @@ -86,7 +86,7 @@ def process_images(conn, script_params): for s in roi.copyShapes(): if s is None: continue # seems possible in some situations - if type(s) == omero.model.LineI: + if isinstance(s, omero.model.LineI): table_data += "\nLine ID: %s" % s.getId().getValue() x1 = s.getX1().getValue() x2 = s.getX2().getValue() @@ -103,7 +103,7 @@ def process_images(conn, script_params): [str(x) for x in (y1, x1, y2, x2, dy, dx, dx_per_y, speed)]) - elif type(s) == omero.model.PolylineI: + elif isinstance(s, omero.model.PolylineI): table_data += "\nPolyline ID: %s" % s.getId().getValue() v = s.getPoints().getValue() points = roi_utils.points_string_to_xy_list(v) diff --git a/omero/analysis_scripts/Plot_Profile.py b/omero/analysis_scripts/Plot_Profile.py index 815997b02..be04db1e6 100644 --- a/omero/analysis_scripts/Plot_Profile.py +++ b/omero/analysis_scripts/Plot_Profile.py @@ -57,9 +57,9 @@ def process_polylines(conn, script_params, image, polylines, line_width, fout): points = pl['points'] for the_c in the_cs: ldata = [] - for l in range(len(points)-1): - x1, y1 = points[l] - x2, y2 = points[l+1] + for point in range(len(points)-1): + x1, y1 = points[point] + x2, y2 = points[point+1] if round(x1 - x2) == 0 and round(y1 - y2) == 0: continue ld = roi_utils.get_line_data( @@ -103,11 +103,11 @@ def process_lines(conn, script_params, image, lines, line_width, fout): pixels = image.getPrimaryPixels() the_cs = script_params['Channels'] - for l in lines: - the_t = l['theT'] - the_z = l['theZ'] - roi_id = l['id'] - if round(l['x1'] - l['x2']) == 0 and round(l['y1'] - l['y2']) == 0: + for line in lines: + the_t = line['theT'] + the_z = line['theZ'] + roi_id = line['id'] + if round(line['x1'] - line['x2']) == 0 and round(line['y1'] - line['y2']) == 0: continue for the_c in the_cs: line_data = [] @@ -192,7 +192,7 @@ def process_images(conn, script_params): z = the_z # TODO: Add some filter of shapes e.g. text? / 'lines' only # etc. - if type(s) == omero.model.LineI: + if isinstance(s, omero.model.LineI): x1 = s.getX1().getValue() x2 = s.getX2().getValue() y1 = s.getY1().getValue() @@ -200,7 +200,7 @@ def process_images(conn, script_params): lines.append({'id': roi_id, 'theT': t, 'theZ': z, 'x1': x1, 'y1': y1, 'x2': x2, 'y2': y2}) - elif type(s) == omero.model.PolylineI: + elif isinstance(s, omero.model.PolylineI): v = s.getPoints().getValue() points = roi_utils.points_string_to_xy_list(v) polylines.append({'id': roi_id, 'theT': t, 'theZ': z, diff --git a/omero/annotation_scripts/KeyVal_to_csv.py b/omero/annotation_scripts/KeyVal_to_csv.py index fbab07b12..b29314081 100644 --- a/omero/annotation_scripts/KeyVal_to_csv.py +++ b/omero/annotation_scripts/KeyVal_to_csv.py @@ -39,7 +39,7 @@ def get_existing_map_annotions(obj): ord_dict = OrderedDict() for ann in obj.listAnnotations(): - if(isinstance(ann, omero.gateway.MapAnnotationWrapper)): + if isinstance(ann, omero.gateway.MapAnnotationWrapper): kvs = ann.getValue() for k, v in kvs: if k not in ord_dict: @@ -152,8 +152,8 @@ def run_script(): # remove the csv if it exists for ann in ds.listAnnotations(): - if(isinstance(ann, omero.gateway.FileAnnotationWrapper)): - if(ann.getFileName() == csv_name): + if isinstance(ann, omero.gateway.FileAnnotationWrapper): + if ann.getFileName() == csv_name: # if the name matches delete it try: delete = Delete2( diff --git a/omero/export_scripts/Make_Movie.py b/omero/export_scripts/Make_Movie.py index 4c0e3e1a9..f886135a3 100644 --- a/omero/export_scripts/Make_Movie.py +++ b/omero/export_scripts/Make_Movie.py @@ -486,8 +486,8 @@ def write_movie(command_args, conn): c_windows = [] c_colours = [] for c in command_args["ChannelsExtended"]: - m = re.match('^(?P\d+)(\|(?P\d+)' + - '\:(?P\d+))?(\$(?P.+))?$', c) + m = re.match('^(?P\\d+)(\\|(?P\\d+)' + + '\\:(?P\\d+))?(\\$(?P.+))?$', c) if m is not None: c_range.append(int(m.group('i'))-1) c_windows.append([float(m.group('ws')), float(m.group('we'))]) diff --git a/omero/figure_scripts/Movie_Figure.py b/omero/figure_scripts/Movie_Figure.py index 29dc4814f..815badda2 100644 --- a/omero/figure_scripts/Movie_Figure.py +++ b/omero/figure_scripts/Movie_Figure.py @@ -311,7 +311,7 @@ def add_left_labels(panel_canvas, image_labels, row_index, width, spacer): labels = image_labels[row_index] py = left_text_height - text_gap # start at bottom - for l, label in enumerate(labels): + for count, label in enumerate(labels): py = py - text_height # find the top of this row w = textdraw.textsize(label, font=font)[0] inset = int((left_text_width - w) / 2) diff --git a/omero/figure_scripts/Movie_ROI_Figure.py b/omero/figure_scripts/Movie_ROI_Figure.py index 4142035fe..0c02dbee9 100644 --- a/omero/figure_scripts/Movie_ROI_Figure.py +++ b/omero/figure_scripts/Movie_ROI_Figure.py @@ -589,7 +589,7 @@ def get_tags(name, tags_list, pd_list): try: height = int(h) except ValueError: - log("Invalid height: %s Using default value" % (str(h), size_y)) + log("Invalid height: %s Using default value %s" % (str(h), size_y)) log("Image dimensions for all panels (pixels): width: %d height: %d" % (width, height)) diff --git a/omero/figure_scripts/ROI_Split_Figure.py b/omero/figure_scripts/ROI_Split_Figure.py index 681b98a8e..0b0f61a37 100644 --- a/omero/figure_scripts/ROI_Split_Figure.py +++ b/omero/figure_scripts/ROI_Split_Figure.py @@ -320,7 +320,7 @@ def get_rectangle(roi_service, image_id, roi_label): roi_count += 1 # go through all the shapes of the ROI for shape in roi.copyShapes(): - if type(shape) == omero.model.RectangleI: + if isinstance(shape, omero.model.RectangleI): the_t = unwrap(shape.getTheT()) the_z = unwrap(shape.getTheZ()) t = 0 @@ -660,7 +660,7 @@ def get_tags(name, tags_list, pd_list): try: height = int(h) except ValueError: - log("Invalid height: %s Using default value" % (str(h), size_y)) + log("Invalid height: %s Using default value: %d" % (str(h), size_y)) log("Image dimensions for all panels (pixels): width: %d height: %d" % (width, height)) diff --git a/omero/figure_scripts/Split_View_Figure.py b/omero/figure_scripts/Split_View_Figure.py index 720871dc8..971343765 100644 --- a/omero/figure_scripts/Split_View_Figure.py +++ b/omero/figure_scripts/Split_View_Figure.py @@ -404,7 +404,7 @@ def make_split_view_figure(conn, pixel_ids, z_start, z_end, split_indexes, image_labels.reverse() for row in image_labels: py = left_text_width - text_gap # start at bottom - for l, label in enumerate(row): + for count, label in enumerate(row): py = py - text_height # find the top of this row w = textdraw.textsize(label, font=font)[0] inset = int((height - w) // 2) diff --git a/omero/util_scripts/Dataset_To_Plate.py b/omero/util_scripts/Dataset_To_Plate.py index 88183b078..f6c060fff 100644 --- a/omero/util_scripts/Dataset_To_Plate.py +++ b/omero/util_scripts/Dataset_To_Plate.py @@ -63,7 +63,7 @@ def add_images_to_plate(conn, images, plate_id, column, row, remove_from=None): for image in images: if remove_from is not None: links = list(image.getParentLinks(remove_from.id)) - link_ids = [l.id for l in links] + link_ids = [link.id for link in links] conn.deleteObjects('DatasetImageLink', link_ids) return True diff --git a/omero/util_scripts/Images_From_ROIs.py b/omero/util_scripts/Images_From_ROIs.py index 465252e9c..e5f1d0108 100644 --- a/omero/util_scripts/Images_From_ROIs.py +++ b/omero/util_scripts/Images_From_ROIs.py @@ -140,7 +140,7 @@ def get_rectangles(conn, image_id): # note x and y for every T, to track moving object xy_by_time = {} for shape in roi.copyShapes(): - if type(shape) == omero.model.RectangleI: + if isinstance(shape, omero.model.RectangleI): # check t range and z range for every rectangle # t and z (and c) for shape is optional # https://www.openmicroscopy.org/site/support/omero5.2/developers/Model/EveryObject.html#shape diff --git a/omero/util_scripts/Move_Annotations.py b/omero/util_scripts/Move_Annotations.py index 625aeb83a..d3f76dce8 100644 --- a/omero/util_scripts/Move_Annotations.py +++ b/omero/util_scripts/Move_Annotations.py @@ -62,11 +62,11 @@ def move_well_annotations(conn, well, ann_type, remove_anns, ns): ns=ns, params=params)) # Filter by type - old_links = [l for l in old_links + old_links = [link for link in old_links if (ann_type is None or (l.child.__class__.__name__ == ann_type))] - link_ids = [l.id for l in old_links] + link_ids = [link.id for link in old_links] def get_key(ann_link, with_owner=False): # We use ann's 'key' to avoid adding duplicate annotations @@ -76,28 +76,28 @@ def get_key(ann_link, with_owner=False): links_dict = {} # Remove duplicate annotations according to get_key(l) - for l in old_links: - links_dict[get_key(l, conn.isAdmin())] = l + for link in old_links: + links_dict[get_key(link, conn.isAdmin())] = link old_links = links_dict.values() # Find existing links on Well so we don't try to duplicate them existing_well_links = list(conn.getAnnotationLinks('Well', [well.id], ns=ns, params=params)) - existing_well_keys = [get_key(l) for l in existing_well_links] + existing_well_keys = [get_key(l) for link in existing_well_links] new_links = [] - for l in old_links: - if get_key(l) in existing_well_keys: + for link in old_links: + if get_key(link) in existing_well_keys: continue - log(" Annotation: %s %s" % (l.child.id.val, - l.child.__class__.__name__)) + log(" Annotation: %s %s" % (link.child.id.val, + link.child.__class__.__name__)) link = WellAnnotationLinkI() link.parent = WellI(well.id, False) - link.child = l.child + link.child = link.child # If Admin, the new link Owner is same as old link Owner if conn.isAdmin(): - owner_id = l.details.owner.id.val + owner_id = link.details.owner.id.val link.details.owner = ExperimenterI(owner_id, False) new_links.append(link) try: From df8830f8bde4ad7c2d4e55d1c0d3d282465c4596 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Wed, 10 Jan 2024 11:33:48 +0000 Subject: [PATCH 07/21] another round of flake8 --- omero/analysis_scripts/Plot_Profile.py | 9 +++++---- omero/export_scripts/Make_Movie.py | 2 +- omero/figure_scripts/ROI_Split_Figure.py | 2 +- omero/util_scripts/Move_Annotations.py | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/omero/analysis_scripts/Plot_Profile.py b/omero/analysis_scripts/Plot_Profile.py index be04db1e6..4d2cabaab 100644 --- a/omero/analysis_scripts/Plot_Profile.py +++ b/omero/analysis_scripts/Plot_Profile.py @@ -107,13 +107,14 @@ def process_lines(conn, script_params, image, lines, line_width, fout): the_t = line['theT'] the_z = line['theZ'] roi_id = line['id'] - if round(line['x1'] - line['x2']) == 0 and round(line['y1'] - line['y2']) == 0: + if round(line['x1'] - line['x2']) == 0 and round(line['y1'] - line['y2']) == 0: # noqa continue for the_c in the_cs: line_data = [] - line_data = roi_utils.get_line_data(pixels, l['x1'], l['y1'], - l['x2'], l['y2'], line_width, - the_z, the_c, the_t) + line_data = roi_utils.get_line_data(pixels, line['x1'], line['y1'], + line['x2'], line['y2'], + line_width, the_z, the_c, + the_t) if script_params['Sum_or_Average'] == 'Sum': output_data = line_data.sum(axis=0) diff --git a/omero/export_scripts/Make_Movie.py b/omero/export_scripts/Make_Movie.py index f886135a3..b4dec6bd5 100644 --- a/omero/export_scripts/Make_Movie.py +++ b/omero/export_scripts/Make_Movie.py @@ -594,7 +594,7 @@ def write_movie(command_args, conn): movie_name = "%s.%s" % (movie_name, ext) # spaces etc in file name cause problems - movie_name = re.sub("[$&\;|\(\)<>' ]", "", movie_name) + movie_name = re.sub("[$&\\;|\\(\\)<>' ]", "", movie_name) frames_per_sec = 2 if "FPS" in command_args: frames_per_sec = command_args["FPS"] diff --git a/omero/figure_scripts/ROI_Split_Figure.py b/omero/figure_scripts/ROI_Split_Figure.py index 0b0f61a37..c2cff9aee 100644 --- a/omero/figure_scripts/ROI_Split_Figure.py +++ b/omero/figure_scripts/ROI_Split_Figure.py @@ -660,7 +660,7 @@ def get_tags(name, tags_list, pd_list): try: height = int(h) except ValueError: - log("Invalid height: %s Using default value: %d" % (str(h), size_y)) + log("Invalid height: %s Using default value: %d" % (str(h), size_y)) # noqa log("Image dimensions for all panels (pixels): width: %d height: %d" % (width, height)) diff --git a/omero/util_scripts/Move_Annotations.py b/omero/util_scripts/Move_Annotations.py index d3f76dce8..e2d2258ae 100644 --- a/omero/util_scripts/Move_Annotations.py +++ b/omero/util_scripts/Move_Annotations.py @@ -64,7 +64,7 @@ def move_well_annotations(conn, well, ann_type, remove_anns, ns): # Filter by type old_links = [link for link in old_links if (ann_type is None - or (l.child.__class__.__name__ == ann_type))] + or (link.child.__class__.__name__ == ann_type))] link_ids = [link.id for link in old_links] @@ -84,7 +84,7 @@ def get_key(ann_link, with_owner=False): # Find existing links on Well so we don't try to duplicate them existing_well_links = list(conn.getAnnotationLinks('Well', [well.id], ns=ns, params=params)) - existing_well_keys = [get_key(l) for link in existing_well_links] + existing_well_keys = [get_key(link) for link in existing_well_links] new_links = [] for link in old_links: From ab5df602e36e2a838edcb9427999e023cf7020dc Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Wed, 10 Jan 2024 12:28:48 +0000 Subject: [PATCH 08/21] replace getsize by getbbox --- omero/figure_scripts/Movie_Figure.py | 6 +++--- omero/figure_scripts/Movie_ROI_Figure.py | 6 +++--- omero/figure_scripts/ROI_Split_Figure.py | 10 +++++----- omero/figure_scripts/Split_View_Figure.py | 8 ++++---- omero/figure_scripts/Thumbnail_Figure.py | 14 +++++++------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/omero/figure_scripts/Movie_Figure.py b/omero/figure_scripts/Movie_Figure.py index 815badda2..b8a4438a3 100644 --- a/omero/figure_scripts/Movie_Figure.py +++ b/omero/figure_scripts/Movie_Figure.py @@ -192,7 +192,7 @@ def createmovie_figure(conn, pixel_ids, t_indexes, z_start, z_end, width, col_count = min(max_col_count, len(rendered_images)) row_count = int(math.ceil(len(rendered_images) / col_count)) font = image_utils.get_font(width // 12) - font_height = font.getsize("Textq")[1] + font_height = font.getbbox("Textq")[3] canvas_width = ((width + spacer) * col_count) + spacer canvas_height = row_count * (spacer // 2 + font_height + spacer + height) @@ -211,7 +211,7 @@ def createmovie_figure(conn, pixel_ids, t_indexes, z_start, z_end, width, if t_index >= size_t: continue time = time_labels[t] - text_w = font.getsize(time)[0] + text_w = font.getbbox(time)[2] inset = (width - text_w) // 2 textdraw = ImageDraw.Draw(canvas) textdraw.text((text_x+inset, text_y), time, font=font, @@ -295,7 +295,7 @@ def add_left_labels(panel_canvas, image_labels, row_index, width, spacer): mode = "RGB" white = (255, 255, 255) font = image_utils.get_font(width/12) - text_height = font.getsize("Sampleq")[1] + text_height = font.getbbox("Sampleq")[3] text_gap = spacer / 2 # find max number of labels diff --git a/omero/figure_scripts/Movie_ROI_Figure.py b/omero/figure_scripts/Movie_ROI_Figure.py index 0c02dbee9..69c51596d 100644 --- a/omero/figure_scripts/Movie_ROI_Figure.py +++ b/omero/figure_scripts/Movie_ROI_Figure.py @@ -203,7 +203,7 @@ def get_roi_movie_view(re, query_service, pixels, time_shape_map, row_count += 1 col_count = max_columns font = image_utils.get_font(font_size) - text_height = font.getsize("Textq")[1] + text_height = font.getbbox("Textq")[3] # no spaces around panels canvas_width = ((panel_width + spacer) * col_count) - spacer row_height = rendered_images[0].size[1] + spacer + text_height @@ -221,7 +221,7 @@ def get_roi_movie_view(re, query_service, pixels, time_shape_map, col = 0 for i, img in enumerate(rendered_images): label = time_labels[i] - indent = (panel_width - (font.getsize(label)[0])) // 2 + indent = (panel_width - (font.getbbox(label)[2])) // 2 draw.text((px+indent, text_y), label, font=font, fill=(0, 0, 0)) image_utils.paste_image(img, canvas, px, panel_y) if col == (col_count - 1): @@ -381,7 +381,7 @@ def get_split_view(conn, image_ids, pixel_ids, merged_indexes, merged_colours, elif width > 200: font_size = 16 font = image_utils.get_font(font_size) - text_height = font.getsize("Textq")[1] + text_height = font.getbbox("Textq")[3] max_count = 0 for row in image_labels: max_count = max(max_count, len(row)) diff --git a/omero/figure_scripts/ROI_Split_Figure.py b/omero/figure_scripts/ROI_Split_Figure.py index c2cff9aee..3e56dd85c 100644 --- a/omero/figure_scripts/ROI_Split_Figure.py +++ b/omero/figure_scripts/ROI_Split_Figure.py @@ -224,7 +224,7 @@ def get_roi_split_view(re, pixels, z_start, z_end, split_indexes, # now assemble the roi split-view canvas font = image_utils.get_font(fontsize) - text_height = font.getsize("Textq")[1] + text_height = font.getbbox("Textq")[3] top_spacer = 0 if show_top_labels: if merged_names: @@ -247,7 +247,7 @@ def get_roi_split_view(re, pixels, z_start, z_end, split_indexes, draw = ImageDraw.Draw(canvas) for i, index in enumerate(split_indexes): label = channel_names.get(index, index) - indent = (panel_width - (font.getsize(label)[0])) // 2 + indent = (panel_width - (font.getbbox(label)[2])) // 2 # text is coloured if channel is not coloured AND in the merged image rgb = (0, 0, 0) if index in merged_colours: @@ -275,12 +275,12 @@ def get_roi_split_view(re, pixels, z_start, z_end, split_indexes, name = channel_names[index] else: name = str(index) - comb_text_width = font.getsize(name)[0] + comb_text_width = font.getbbox(name)[2] inset = int((panel_width - comb_text_width) / 2) draw.text((px + inset, text_y), name, font=font, fill=rgb) text_y = text_y - text_height else: - comb_text_width = font.getsize("Merged")[0] + comb_text_width = font.getbbox("Merged")[2] inset = int((panel_width - comb_text_width) / 2) draw.text((px + inset, text_y), "Merged", font=font, fill=(0, 0, 0)) @@ -431,7 +431,7 @@ def get_split_view(conn, image_ids, pixel_ids, split_indexes, channel_names, elif width > 200: fontsize = 16 font = image_utils.get_font(fontsize) - text_height = font.getsize("Textq")[1] + text_height = font.getbbox("Textq")[3] max_count = 0 for row in image_labels: max_count = max(max_count, len(row)) diff --git a/omero/figure_scripts/Split_View_Figure.py b/omero/figure_scripts/Split_View_Figure.py index 971343765..afa612673 100644 --- a/omero/figure_scripts/Split_View_Figure.py +++ b/omero/figure_scripts/Split_View_Figure.py @@ -386,7 +386,7 @@ def make_split_view_figure(conn, pixel_ids, z_start, z_end, split_indexes, font = image_utils.get_font(fontsize) mode = "RGB" white = (255, 255, 255) - text_height = font.getsize("Textq")[1] + text_height = font.getbbox("Textq")[3] # if adding text to the left, write the text on horizontal canvas, then # rotate to vertical (below) @@ -442,7 +442,7 @@ def make_split_view_figure(conn, pixel_ids, z_start, z_end, split_indexes, py = top_text_height + spacer - (text_height + text_gap) for index in split_indexes: # calculate the position of the text, centered above the image - w = font.getsize(channel_names[index])[0] + w = font.getbbox(channel_names[index])[2] inset = int((width - w) // 2) # text is coloured if channel is grey AND in the merged image rgba = (0, 0, 0, 255) @@ -465,12 +465,12 @@ def make_split_view_figure(conn, pixel_ids, z_start, z_end, split_indexes, if rgba == (255, 255, 255, 255): # if white (unreadable) rgba = (0, 0, 0, 255) # needs to be black! name = channel_names[index] - comb_text_width = font.getsize(name)[0] + comb_text_width = font.getbbox(name)[2] inset = int((width - comb_text_width) // 2) draw.text((px + inset, py), name, font=font, fill=rgba) py = py - text_height else: - comb_text_width = font.getsize("Merged")[0] + comb_text_width = font.getbbox("Merged")[2] inset = int((width - comb_text_width) // 2) px = px + inset draw.text((px, py), "Merged", font=font, fill=(0, 0, 0)) diff --git a/omero/figure_scripts/Thumbnail_Figure.py b/omero/figure_scripts/Thumbnail_Figure.py index d303dcdf3..1dbbe1f18 100644 --- a/omero/figure_scripts/Thumbnail_Figure.py +++ b/omero/figure_scripts/Thumbnail_Figure.py @@ -144,10 +144,10 @@ def paint_thumbnail_grid(thumbnail_store, length, spacing, pixel_ids, fontsize = (length // 10) + 5 font = get_font(fontsize) if left_label: - text_width, text_height = font.getsize(left_label) + text_width, text_height = font.getbbox(left_label)[2:] left_space = spacing + text_height + spacing if top_label: - text_width, text_height = font.getsize(top_label) + text_width, text_height = font.getbbox(top_label)[2:] top_space = spacing + text_height + spacing min_width = left_space + text_width + spacing @@ -168,7 +168,7 @@ def paint_thumbnail_grid(thumbnail_store, length, spacing, pixel_ids, label_size = (label_canvas_width, label_canvas_height) text_canvas = Image.new(mode, label_size, bg) draw = ImageDraw.Draw(text_canvas) - text_width = font.getsize(left_label)[0] + text_width = font.getbbox(left_label)[2] text_x = (label_canvas_width - text_width) // 2 draw.text((text_x, spacing), left_label, font=font, fill=text_color) vertical_canvas = text_canvas.rotate(90) @@ -297,7 +297,7 @@ def paint_dataset_canvas(conn, images, title, tag_ids=None, # set-up fonts fontsize = length/7 + 5 font = get_font(fontsize) - text_height = font.getsize("Textq")[1] + text_height = font.getbbox("Textq")[3] top_spacer = spacing + text_height left_spacer = spacing + text_height @@ -372,11 +372,11 @@ def paint_dataset_canvas(conn, images, title, tag_ids=None, 'showSubsetLabels': show_subset_labels}) # Find the indent we need - max_tag_name_width = max([font.getsize(ts['tagText'])[0] + max_tag_name_width = max([font.getbbox(ts['tagText'])[2] for ts in toptag_sets]) if show_untagged: max_tag_name_width = max(max_tag_name_width, - font.getsize("Not Tagged")[0]) + font.getbbox("Not Tagged")[2]) tag_sub_panes = [] @@ -435,7 +435,7 @@ def make_tagset_canvas(tag_string, tagset_pix_ids, show_subset_labels): p_y += pane.size[1] if tag_text is not None: draw = ImageDraw.Draw(tag_canvas) - tt_w, tt_h = font.getsize(tag_text) + tt_w, tt_h = font.getbbox(tag_text)[2:] h_offset = (total_height - tt_h)/2 draw.text((spacing, h_offset), tag_text, font=font, fill=(50, 50, 50)) From 46081bba7fa28cd62f6b58314c1bf80accffa232 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Wed, 10 Jan 2024 13:20:33 +0000 Subject: [PATCH 09/21] replace textsize by textbbox --- omero/figure_scripts/Movie_Figure.py | 2 +- omero/figure_scripts/Split_View_Figure.py | 2 +- omero/figure_scripts/Thumbnail_Figure.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/omero/figure_scripts/Movie_Figure.py b/omero/figure_scripts/Movie_Figure.py index b8a4438a3..d84f8b7a9 100644 --- a/omero/figure_scripts/Movie_Figure.py +++ b/omero/figure_scripts/Movie_Figure.py @@ -313,7 +313,7 @@ def add_left_labels(panel_canvas, image_labels, row_index, width, spacer): py = left_text_height - text_gap # start at bottom for count, label in enumerate(labels): py = py - text_height # find the top of this row - w = textdraw.textsize(label, font=font)[0] + w = textdraw.textbbox(label, font=font)[2] inset = int((left_text_width - w) / 2) textdraw.text((inset, py), label, font=font, fill=(0, 0, 0)) py = py - text_gap # add space between rows diff --git a/omero/figure_scripts/Split_View_Figure.py b/omero/figure_scripts/Split_View_Figure.py index afa612673..2998760df 100644 --- a/omero/figure_scripts/Split_View_Figure.py +++ b/omero/figure_scripts/Split_View_Figure.py @@ -406,7 +406,7 @@ def make_split_view_figure(conn, pixel_ids, z_start, z_end, split_indexes, py = left_text_width - text_gap # start at bottom for count, label in enumerate(row): py = py - text_height # find the top of this row - w = textdraw.textsize(label, font=font)[0] + w = textdraw.textbbox(label, font=font)[2] inset = int((height - w) // 2) textdraw.text((px+inset, py), label, font=font, fill=(0, 0, 0)) diff --git a/omero/figure_scripts/Thumbnail_Figure.py b/omero/figure_scripts/Thumbnail_Figure.py index 1dbbe1f18..7fdd6e93d 100644 --- a/omero/figure_scripts/Thumbnail_Figure.py +++ b/omero/figure_scripts/Thumbnail_Figure.py @@ -476,8 +476,8 @@ def make_tagset_canvas(tag_string, tagset_pix_ids, show_subset_labels): # figureDate = "%s - %s" % (firstdate, lastdate) draw = ImageDraw.Draw(full_canvas) - # dateWidth = draw.textsize(figureDate, font=font)[0] - # titleWidth = draw.textsize(title, font=font)[0] + # dateWidth = draw.textbbox(figureDate, font=font)[2] + # titleWidth = draw.textbbox(title, font=font)[2] # dateX = fullCanvas.size[0] - spacing - dateWidth # title draw.text((left_spacer, spacing), title, font=font, fill=(0, 0, 0)) From 10ba321cf39dec06a2a0fe0a22cd78aef7bc5be9 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Wed, 10 Jan 2024 13:23:22 +0000 Subject: [PATCH 10/21] replace ANTIALIAS by LANCZOS --- omero/export_scripts/Batch_Image_Export.py | 4 ++-- omero/export_scripts/Make_Movie.py | 2 +- omero/figure_scripts/ROI_Split_Figure.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/omero/export_scripts/Batch_Image_Export.py b/omero/export_scripts/Batch_Image_Export.py index 6f1ec1d28..f4fdd4747 100644 --- a/omero/export_scripts/Batch_Image_Export.py +++ b/omero/export_scripts/Batch_Image_Export.py @@ -123,7 +123,7 @@ def save_plane(image, format, c_name, z_range, project_z, t=0, channel=None, w, h = plane.size fraction = (float(zoom_percent) / 100) plane = plane.resize((int(w * fraction), int(h * fraction)), - Image.ANTIALIAS) + Image.LANCZOS) if format == "PNG": img_name = make_image_name( @@ -572,7 +572,7 @@ def run_script(): scripts.String( "Zoom", grouping="7", values=zoom_percents, description="Zoom (jpeg, png or tiff) before saving with" - " ANTIALIAS interpolation", default="100%"), + " LANCZOS interpolation", default="100%"), scripts.String( "Format", grouping="8", diff --git a/omero/export_scripts/Make_Movie.py b/omero/export_scripts/Make_Movie.py index b4dec6bd5..bd3c096eb 100644 --- a/omero/export_scripts/Make_Movie.py +++ b/omero/export_scripts/Make_Movie.py @@ -355,7 +355,7 @@ def reshape_to_fit(image, size_x, size_y, bg=(0, 0, 0)): # scale ratio = min(float(size_x) / image_w, float(size_y) / image_h) image = image.resize(map(lambda x: int(x*ratio), image.size), - Image.ANTIALIAS) + Image.LANCZOS) # paste bg = Image.new("RGBA", (size_x, size_y), (0, 0, 0)) # black bg ovlpos = (size_x-image.size[0]) / 2, (size_y-image.size[1]) / 2 diff --git a/omero/figure_scripts/ROI_Split_Figure.py b/omero/figure_scripts/ROI_Split_Figure.py index 3e56dd85c..db84e30bf 100644 --- a/omero/figure_scripts/ROI_Split_Figure.py +++ b/omero/figure_scripts/ROI_Split_Figure.py @@ -180,7 +180,7 @@ def get_roi_split_view(re, pixels, z_start, z_end, split_indexes, # hoping that when we zoom, don't zoom fullImage if roi_zoom != 1: new_size = (int(roi_width*roi_zoom), int(roi_height*roi_zoom)) - roi_image = roi_image.resize(new_size, Image.ANTIALIAS) + roi_image = roi_image.resize(new_size, Image.LANCZOS) rendered_images.append(roi_image) panel_width = roi_image.size[0] re.setActive(index, False) # turn the channel off again! @@ -213,7 +213,7 @@ def get_roi_split_view(re, pixels, z_start, z_end, split_indexes, if roi_zoom != 1: new_size = (int(roi_width*roi_zoom), int(roi_height*roi_zoom)) - roi_merged_image = roi_merged_image.resize(new_size, Image.ANTIALIAS) + roi_merged_image = roi_merged_image.resize(new_size, Image.LANCZOS) if channel_mismatch: log(" WARNING channel mismatch: The current image has fewer channels" From 030a841623272e78613d6e59447232bb69ad5257 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Wed, 10 Jan 2024 15:25:15 +0000 Subject: [PATCH 11/21] use textlength --- omero/figure_scripts/Movie_Figure.py | 2 +- omero/figure_scripts/Split_View_Figure.py | 2 +- omero/figure_scripts/Thumbnail_Figure.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/omero/figure_scripts/Movie_Figure.py b/omero/figure_scripts/Movie_Figure.py index d84f8b7a9..9dfd21f82 100644 --- a/omero/figure_scripts/Movie_Figure.py +++ b/omero/figure_scripts/Movie_Figure.py @@ -313,7 +313,7 @@ def add_left_labels(panel_canvas, image_labels, row_index, width, spacer): py = left_text_height - text_gap # start at bottom for count, label in enumerate(labels): py = py - text_height # find the top of this row - w = textdraw.textbbox(label, font=font)[2] + w = textdraw.textlength(label, font=font) inset = int((left_text_width - w) / 2) textdraw.text((inset, py), label, font=font, fill=(0, 0, 0)) py = py - text_gap # add space between rows diff --git a/omero/figure_scripts/Split_View_Figure.py b/omero/figure_scripts/Split_View_Figure.py index 2998760df..eb06da484 100644 --- a/omero/figure_scripts/Split_View_Figure.py +++ b/omero/figure_scripts/Split_View_Figure.py @@ -406,7 +406,7 @@ def make_split_view_figure(conn, pixel_ids, z_start, z_end, split_indexes, py = left_text_width - text_gap # start at bottom for count, label in enumerate(row): py = py - text_height # find the top of this row - w = textdraw.textbbox(label, font=font)[2] + w = textdraw.textlength(label, font=font) inset = int((height - w) // 2) textdraw.text((px+inset, py), label, font=font, fill=(0, 0, 0)) diff --git a/omero/figure_scripts/Thumbnail_Figure.py b/omero/figure_scripts/Thumbnail_Figure.py index 7fdd6e93d..025d67087 100644 --- a/omero/figure_scripts/Thumbnail_Figure.py +++ b/omero/figure_scripts/Thumbnail_Figure.py @@ -476,8 +476,8 @@ def make_tagset_canvas(tag_string, tagset_pix_ids, show_subset_labels): # figureDate = "%s - %s" % (firstdate, lastdate) draw = ImageDraw.Draw(full_canvas) - # dateWidth = draw.textbbox(figureDate, font=font)[2] - # titleWidth = draw.textbbox(title, font=font)[2] + # dateWidth = draw.textlength(figureDate, font=font) + # titleWidth = draw.textlength(title, font=font) # dateX = fullCanvas.size[0] - spacing - dateWidth # title draw.text((left_spacer, spacing), title, font=font, fill=(0, 0, 0)) From cd7f4a3e86cce35280cdef36d941034066c35123 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Thu, 11 Jan 2024 07:55:30 +0000 Subject: [PATCH 12/21] use branch --- .github/workflows/omero_plugin.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/omero_plugin.yml b/.github/workflows/omero_plugin.yml index 40b601e9e..e70759e87 100644 --- a/.github/workflows/omero_plugin.yml +++ b/.github/workflows/omero_plugin.yml @@ -27,8 +27,9 @@ jobs: - name: Checkout omero-test-infra uses: actions/checkout@master with: - repository: ome/omero-test-infra + repository: jburel/omero-test-infra path: .omero - ref: ${{ secrets.OMERO_TEST_INFRA_REF }} + ref: test_omero-py + # ref: ${{ secrets.OMERO_TEST_INFRA_REF }} - name: Build and run OMERO tests run: .omero/docker $STAGE From f9a6048ea7423f349864c393b4d43fef2c78f29f Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Thu, 11 Jan 2024 11:42:00 +0000 Subject: [PATCH 13/21] use getbbox to determine size --- omero/figure_scripts/Movie_Figure.py | 9 +++++--- omero/figure_scripts/Movie_ROI_Figure.py | 9 +++++--- omero/figure_scripts/ROI_Split_Figure.py | 15 ++++++++----- omero/figure_scripts/Split_View_Figure.py | 12 ++++++---- omero/figure_scripts/Thumbnail_Figure.py | 27 +++++++++++++++-------- 5 files changed, 48 insertions(+), 24 deletions(-) diff --git a/omero/figure_scripts/Movie_Figure.py b/omero/figure_scripts/Movie_Figure.py index 9dfd21f82..8593e1979 100644 --- a/omero/figure_scripts/Movie_Figure.py +++ b/omero/figure_scripts/Movie_Figure.py @@ -192,7 +192,8 @@ def createmovie_figure(conn, pixel_ids, t_indexes, z_start, z_end, width, col_count = min(max_col_count, len(rendered_images)) row_count = int(math.ceil(len(rendered_images) / col_count)) font = image_utils.get_font(width // 12) - font_height = font.getbbox("Textq")[3] + box = font.getbbox("Textq") + font_height = box[3] - box[1] canvas_width = ((width + spacer) * col_count) + spacer canvas_height = row_count * (spacer // 2 + font_height + spacer + height) @@ -211,7 +212,8 @@ def createmovie_figure(conn, pixel_ids, t_indexes, z_start, z_end, width, if t_index >= size_t: continue time = time_labels[t] - text_w = font.getbbox(time)[2] + box = font.getbbox(time) + text_w = box[2] - box[0] inset = (width - text_w) // 2 textdraw = ImageDraw.Draw(canvas) textdraw.text((text_x+inset, text_y), time, font=font, @@ -295,7 +297,8 @@ def add_left_labels(panel_canvas, image_labels, row_index, width, spacer): mode = "RGB" white = (255, 255, 255) font = image_utils.get_font(width/12) - text_height = font.getbbox("Sampleq")[3] + box = font.getbbox("Sampleq") + text_height = box[3] - box[1] text_gap = spacer / 2 # find max number of labels diff --git a/omero/figure_scripts/Movie_ROI_Figure.py b/omero/figure_scripts/Movie_ROI_Figure.py index 69c51596d..dc2e97597 100644 --- a/omero/figure_scripts/Movie_ROI_Figure.py +++ b/omero/figure_scripts/Movie_ROI_Figure.py @@ -203,7 +203,8 @@ def get_roi_movie_view(re, query_service, pixels, time_shape_map, row_count += 1 col_count = max_columns font = image_utils.get_font(font_size) - text_height = font.getbbox("Textq")[3] + box = font.getbbox("Textq") + text_height = box[3] - box[1] # no spaces around panels canvas_width = ((panel_width + spacer) * col_count) - spacer row_height = rendered_images[0].size[1] + spacer + text_height @@ -221,7 +222,8 @@ def get_roi_movie_view(re, query_service, pixels, time_shape_map, col = 0 for i, img in enumerate(rendered_images): label = time_labels[i] - indent = (panel_width - (font.getbbox(label)[2])) // 2 + box = font.getbbox(label) + indent = (panel_width - (box[2] - box[0])) // 2 draw.text((px+indent, text_y), label, font=font, fill=(0, 0, 0)) image_utils.paste_image(img, canvas, px, panel_y) if col == (col_count - 1): @@ -381,7 +383,8 @@ def get_split_view(conn, image_ids, pixel_ids, merged_indexes, merged_colours, elif width > 200: font_size = 16 font = image_utils.get_font(font_size) - text_height = font.getbbox("Textq")[3] + box = font.getbbox("Textq") + text_height = box[3] - box[1] max_count = 0 for row in image_labels: max_count = max(max_count, len(row)) diff --git a/omero/figure_scripts/ROI_Split_Figure.py b/omero/figure_scripts/ROI_Split_Figure.py index db84e30bf..5c534719a 100644 --- a/omero/figure_scripts/ROI_Split_Figure.py +++ b/omero/figure_scripts/ROI_Split_Figure.py @@ -224,7 +224,8 @@ def get_roi_split_view(re, pixels, z_start, z_end, split_indexes, # now assemble the roi split-view canvas font = image_utils.get_font(fontsize) - text_height = font.getbbox("Textq")[3] + box = font.getbbox("Textq") + text_height = box[3] - box[1] top_spacer = 0 if show_top_labels: if merged_names: @@ -247,7 +248,8 @@ def get_roi_split_view(re, pixels, z_start, z_end, split_indexes, draw = ImageDraw.Draw(canvas) for i, index in enumerate(split_indexes): label = channel_names.get(index, index) - indent = (panel_width - (font.getbbox(label)[2])) // 2 + box = font.getbbox(label) + indent = (panel_width - (box[2] - box[0])) // 2 # text is coloured if channel is not coloured AND in the merged image rgb = (0, 0, 0) if index in merged_colours: @@ -275,12 +277,14 @@ def get_roi_split_view(re, pixels, z_start, z_end, split_indexes, name = channel_names[index] else: name = str(index) - comb_text_width = font.getbbox(name)[2] + box = font.getbbox(name) + comb_text_width = box[2] - box[0] inset = int((panel_width - comb_text_width) / 2) draw.text((px + inset, text_y), name, font=font, fill=rgb) text_y = text_y - text_height else: - comb_text_width = font.getbbox("Merged")[2] + box = font.getbbox("Merged") + comb_text_width = box[2] - box[0] inset = int((panel_width - comb_text_width) / 2) draw.text((px + inset, text_y), "Merged", font=font, fill=(0, 0, 0)) @@ -431,7 +435,8 @@ def get_split_view(conn, image_ids, pixel_ids, split_indexes, channel_names, elif width > 200: fontsize = 16 font = image_utils.get_font(fontsize) - text_height = font.getbbox("Textq")[3] + box = font.getbbox("Textq") + text_height = box[3] - box[1] max_count = 0 for row in image_labels: max_count = max(max_count, len(row)) diff --git a/omero/figure_scripts/Split_View_Figure.py b/omero/figure_scripts/Split_View_Figure.py index eb06da484..293a6dcaa 100644 --- a/omero/figure_scripts/Split_View_Figure.py +++ b/omero/figure_scripts/Split_View_Figure.py @@ -386,7 +386,8 @@ def make_split_view_figure(conn, pixel_ids, z_start, z_end, split_indexes, font = image_utils.get_font(fontsize) mode = "RGB" white = (255, 255, 255) - text_height = font.getbbox("Textq")[3] + box = font.getbbox("Textq") + text_height = box[3] - box[1] # if adding text to the left, write the text on horizontal canvas, then # rotate to vertical (below) @@ -442,7 +443,8 @@ def make_split_view_figure(conn, pixel_ids, z_start, z_end, split_indexes, py = top_text_height + spacer - (text_height + text_gap) for index in split_indexes: # calculate the position of the text, centered above the image - w = font.getbbox(channel_names[index])[2] + box = font.getbbox(channel_names[index]) + w = box[2] - box[0] inset = int((width - w) // 2) # text is coloured if channel is grey AND in the merged image rgba = (0, 0, 0, 255) @@ -465,12 +467,14 @@ def make_split_view_figure(conn, pixel_ids, z_start, z_end, split_indexes, if rgba == (255, 255, 255, 255): # if white (unreadable) rgba = (0, 0, 0, 255) # needs to be black! name = channel_names[index] - comb_text_width = font.getbbox(name)[2] + box = font.getbbox(name) + comb_text_width = box[2] - box[0] inset = int((width - comb_text_width) // 2) draw.text((px + inset, py), name, font=font, fill=rgba) py = py - text_height else: - comb_text_width = font.getbbox("Merged")[2] + box = font.getbbox("Merged") + comb_text_width = box[2] - box[0] inset = int((width - comb_text_width) // 2) px = px + inset draw.text((px, py), "Merged", font=font, fill=(0, 0, 0)) diff --git a/omero/figure_scripts/Thumbnail_Figure.py b/omero/figure_scripts/Thumbnail_Figure.py index 025d67087..95fc6e978 100644 --- a/omero/figure_scripts/Thumbnail_Figure.py +++ b/omero/figure_scripts/Thumbnail_Figure.py @@ -144,10 +144,14 @@ def paint_thumbnail_grid(thumbnail_store, length, spacing, pixel_ids, fontsize = (length // 10) + 5 font = get_font(fontsize) if left_label: - text_width, text_height = font.getbbox(left_label)[2:] + box = font.getbbox(left_label) + text_width = box[2] - box[0] + text_height = box[3] - box[1] left_space = spacing + text_height + spacing if top_label: - text_width, text_height = font.getbbox(top_label)[2:] + box = font.getbbox(top_label) + text_width = box[2] - box[0] + text_height = box[3] - box[1] top_space = spacing + text_height + spacing min_width = left_space + text_width + spacing @@ -168,7 +172,8 @@ def paint_thumbnail_grid(thumbnail_store, length, spacing, pixel_ids, label_size = (label_canvas_width, label_canvas_height) text_canvas = Image.new(mode, label_size, bg) draw = ImageDraw.Draw(text_canvas) - text_width = font.getbbox(left_label)[2] + box = font.getbbox(left_label) + text_width = box[2] - box[0] text_x = (label_canvas_width - text_width) // 2 draw.text((text_x, spacing), left_label, font=font, fill=text_color) vertical_canvas = text_canvas.rotate(90) @@ -297,7 +302,8 @@ def paint_dataset_canvas(conn, images, title, tag_ids=None, # set-up fonts fontsize = length/7 + 5 font = get_font(fontsize) - text_height = font.getbbox("Textq")[3] + box = font.getbbox("Textq") + text_height = box[3] - box[1] top_spacer = spacing + text_height left_spacer = spacing + text_height @@ -372,11 +378,12 @@ def paint_dataset_canvas(conn, images, title, tag_ids=None, 'showSubsetLabels': show_subset_labels}) # Find the indent we need - max_tag_name_width = max([font.getbbox(ts['tagText'])[2] - for ts in toptag_sets]) + for ts in toptag_sets: + box = font.getbbox(ts['tagText']) + max_tag_name_width = max(box[2] - box[0]) if show_untagged: - max_tag_name_width = max(max_tag_name_width, - font.getbbox("Not Tagged")[2]) + box = font.getbbox("Not Tagged") + max_tag_name_width = max(max_tag_name_width, (box[2] - box[0])) tag_sub_panes = [] @@ -435,7 +442,9 @@ def make_tagset_canvas(tag_string, tagset_pix_ids, show_subset_labels): p_y += pane.size[1] if tag_text is not None: draw = ImageDraw.Draw(tag_canvas) - tt_w, tt_h = font.getbbox(tag_text)[2:] + box = font.getbbox(tag_text) + tt_w = box[2] - box[0] + tt_h = box[3] - box[1] h_offset = (total_height - tt_h)/2 draw.text((spacing, h_offset), tag_text, font=font, fill=(50, 50, 50)) From b26d67a20908f754fca2467b42da04d2b5035edf Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Wed, 17 Jan 2024 11:16:41 +0000 Subject: [PATCH 14/21] use branch --- .github/workflows/omero_plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/omero_plugin.yml b/.github/workflows/omero_plugin.yml index e70759e87..72635a09c 100644 --- a/.github/workflows/omero_plugin.yml +++ b/.github/workflows/omero_plugin.yml @@ -29,7 +29,7 @@ jobs: with: repository: jburel/omero-test-infra path: .omero - ref: test_omero-py + ref: use_latest_omero_py # ref: ${{ secrets.OMERO_TEST_INFRA_REF }} - name: Build and run OMERO tests run: .omero/docker $STAGE From c651c496000386bbb23f6bd449a935d62dd25e16 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Thu, 1 Feb 2024 15:30:45 +0000 Subject: [PATCH 15/21] use the main branch --- .github/workflows/omero_plugin.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/omero_plugin.yml b/.github/workflows/omero_plugin.yml index 72635a09c..40b601e9e 100644 --- a/.github/workflows/omero_plugin.yml +++ b/.github/workflows/omero_plugin.yml @@ -27,9 +27,8 @@ jobs: - name: Checkout omero-test-infra uses: actions/checkout@master with: - repository: jburel/omero-test-infra + repository: ome/omero-test-infra path: .omero - ref: use_latest_omero_py - # ref: ${{ secrets.OMERO_TEST_INFRA_REF }} + ref: ${{ secrets.OMERO_TEST_INFRA_REF }} - name: Build and run OMERO tests run: .omero/docker $STAGE From 85c3c0c9534e081bbf8c5679be3d1336edec5c71 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Thu, 1 Feb 2024 15:35:02 +0000 Subject: [PATCH 16/21] remove unused variable --- omero/figure_scripts/Thumbnail_Figure.py | 1 - 1 file changed, 1 deletion(-) diff --git a/omero/figure_scripts/Thumbnail_Figure.py b/omero/figure_scripts/Thumbnail_Figure.py index 95fc6e978..b06f76b50 100644 --- a/omero/figure_scripts/Thumbnail_Figure.py +++ b/omero/figure_scripts/Thumbnail_Figure.py @@ -443,7 +443,6 @@ def make_tagset_canvas(tag_string, tagset_pix_ids, show_subset_labels): if tag_text is not None: draw = ImageDraw.Draw(tag_canvas) box = font.getbbox(tag_text) - tt_w = box[2] - box[0] tt_h = box[3] - box[1] h_offset = (total_height - tt_h)/2 draw.text((spacing, h_offset), tag_text, font=font, From e1407cce7658d69ab7f6f00517ae6f579c841c04 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Thu, 1 Feb 2024 15:58:05 +0000 Subject: [PATCH 17/21] add missing value --- omero/figure_scripts/Thumbnail_Figure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omero/figure_scripts/Thumbnail_Figure.py b/omero/figure_scripts/Thumbnail_Figure.py index b06f76b50..9abd2c504 100644 --- a/omero/figure_scripts/Thumbnail_Figure.py +++ b/omero/figure_scripts/Thumbnail_Figure.py @@ -380,7 +380,7 @@ def paint_dataset_canvas(conn, images, title, tag_ids=None, # Find the indent we need for ts in toptag_sets: box = font.getbbox(ts['tagText']) - max_tag_name_width = max(box[2] - box[0]) + max_tag_name_width = max(max_tag_name_width, box[2] - box[0]) if show_untagged: box = font.getbbox("Not Tagged") max_tag_name_width = max(max_tag_name_width, (box[2] - box[0])) From 06984bf63d28cd975e9022916f6bcc401ac28fd8 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Thu, 1 Feb 2024 16:04:38 +0000 Subject: [PATCH 18/21] set default --- omero/figure_scripts/Thumbnail_Figure.py | 1 + 1 file changed, 1 insertion(+) diff --git a/omero/figure_scripts/Thumbnail_Figure.py b/omero/figure_scripts/Thumbnail_Figure.py index 9abd2c504..0f905b1c5 100644 --- a/omero/figure_scripts/Thumbnail_Figure.py +++ b/omero/figure_scripts/Thumbnail_Figure.py @@ -378,6 +378,7 @@ def paint_dataset_canvas(conn, images, title, tag_ids=None, 'showSubsetLabels': show_subset_labels}) # Find the indent we need + max_tag_name_width = 0 for ts in toptag_sets: box = font.getbbox(ts['tagText']) max_tag_name_width = max(max_tag_name_width, box[2] - box[0]) From f7f368d8223fd8080cb20cd352b782f841b3ee8d Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Thu, 1 Feb 2024 16:59:53 +0000 Subject: [PATCH 19/21] exclude script for now --- test/integration/test_util_scripts.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/integration/test_util_scripts.py b/test/integration/test_util_scripts.py index 63a716ddd..42b7cb53d 100644 --- a/test/integration/test_util_scripts.py +++ b/test/integration/test_util_scripts.py @@ -198,6 +198,7 @@ def test_dataset_to_plate(self, image_names): images_in_plate.sort() assert images_in_plate == image_ids + @pytest.mark.skip(reason="Issue with moving annotation on well") @pytest.mark.parametrize("remove", [True, False]) @pytest.mark.parametrize("script_runner", ['user', 'admin']) def test_move_annotations(self, remove, script_runner): From e5853229d30cf262ddfb0386f799a3f8133d3b1f Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Thu, 1 Feb 2024 20:11:47 +0000 Subject: [PATCH 20/21] fix parameter --- omero/util_scripts/Move_Annotations.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/omero/util_scripts/Move_Annotations.py b/omero/util_scripts/Move_Annotations.py index e2d2258ae..a57583905 100644 --- a/omero/util_scripts/Move_Annotations.py +++ b/omero/util_scripts/Move_Annotations.py @@ -87,17 +87,17 @@ def get_key(ann_link, with_owner=False): existing_well_keys = [get_key(link) for link in existing_well_links] new_links = [] - for link in old_links: - if get_key(link) in existing_well_keys: + for old_link in old_links: + if get_key(old_link) in existing_well_keys: continue - log(" Annotation: %s %s" % (link.child.id.val, - link.child.__class__.__name__)) + log(" Annotation: %s %s" % (old_link.child.id.val, + old_link.child.__class__.__name__)) link = WellAnnotationLinkI() link.parent = WellI(well.id, False) - link.child = link.child + link.child = old_link.child # If Admin, the new link Owner is same as old link Owner if conn.isAdmin(): - owner_id = link.details.owner.id.val + owner_id = old_link.details.owner.id.val link.details.owner = ExperimenterI(owner_id, False) new_links.append(link) try: From 92d3bd19e713dd4fe70b53d9697ab192bc5254cd Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Thu, 1 Feb 2024 20:12:15 +0000 Subject: [PATCH 21/21] enable test --- test/integration/test_util_scripts.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/integration/test_util_scripts.py b/test/integration/test_util_scripts.py index 42b7cb53d..63a716ddd 100644 --- a/test/integration/test_util_scripts.py +++ b/test/integration/test_util_scripts.py @@ -198,7 +198,6 @@ def test_dataset_to_plate(self, image_names): images_in_plate.sort() assert images_in_plate == image_ids - @pytest.mark.skip(reason="Issue with moving annotation on well") @pytest.mark.parametrize("remove", [True, False]) @pytest.mark.parametrize("script_runner", ['user', 'admin']) def test_move_annotations(self, remove, script_runner):