From d3594126199f315cad8135bfa900a330030c246b Mon Sep 17 00:00:00 2001 From: npinter Date: Tue, 30 Jul 2024 12:27:57 +0200 Subject: [PATCH 1/3] Fix for LMD data --- .../qupath_roi_splitter.py | 23 +++++++++++-------- .../qupath_roi_splitter.xml | 5 ++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/tools/qupath_roi_splitter/qupath_roi_splitter.py b/tools/qupath_roi_splitter/qupath_roi_splitter.py index 1091d5af1..3a410dcc6 100644 --- a/tools/qupath_roi_splitter/qupath_roi_splitter.py +++ b/tools/qupath_roi_splitter/qupath_roi_splitter.py @@ -22,15 +22,20 @@ def collect_roi_coords(input_roi, feature_index): else: coord_index = 0 for sub_roi in input_roi["geometry"]["coordinates"]: - # Polygon with holes or MultiPolygon - if not isinstance(sub_roi[0][0], list): - all_coords.extend(collect_coords(sub_roi, feature_index, coord_index)) - coord_index += len(sub_roi) + if len(sub_roi) == 2: + # Special case: LMD data + all_coords.extend(collect_coords([sub_roi], feature_index, coord_index)) + coord_index += 1 else: - # MultiPolygon with holes - for sub_coord in sub_roi: - all_coords.extend(collect_coords(sub_coord, feature_index, coord_index)) - coord_index += len(sub_coord) + # Polygon with holes or MultiPolygon + if not isinstance(sub_roi[0][0], list): + all_coords.extend(collect_coords(sub_roi, feature_index, coord_index)) + coord_index += len(sub_roi) + else: + # MultiPolygon with holes + for sub_coord in sub_roi: + all_coords.extend(collect_coords(sub_coord, feature_index, coord_index)) + coord_index += len(sub_coord) return all_coords @@ -103,7 +108,7 @@ def split_qupath_roi(in_roi): parser = argparse.ArgumentParser(description="Split ROI coordinates of QuPath TMA annotation by cell type (classification)") parser.add_argument("--qupath_roi", default=False, help="Input QuPath annotation (GeoJSON file)") parser.add_argument("--fill", action="store_true", required=False, help="Fill pixels in ROIs (order of coordinates will be lost)") - parser.add_argument('--version', action='version', version='%(prog)s 0.3.0') + parser.add_argument('--version', action='version', version='%(prog)s 0.3.1') parser.add_argument("--all", action="store_true", required=False, help="Extracts all ROIs") parser.add_argument("--img", action="store_true", required=False, help="Generates image of ROIs") args = parser.parse_args() diff --git a/tools/qupath_roi_splitter/qupath_roi_splitter.xml b/tools/qupath_roi_splitter/qupath_roi_splitter.xml index 6cd8b0169..bc7d3ec10 100644 --- a/tools/qupath_roi_splitter/qupath_roi_splitter.xml +++ b/tools/qupath_roi_splitter/qupath_roi_splitter.xml @@ -1,7 +1,7 @@ Split ROI coordinates of QuPath TMA annotation by cell type (classification) - 0.3.0 + 0.3.1 0 @@ -33,9 +33,10 @@ - + + img From ccb87f9bce4c768a2e016ded981e20f62ba44816 Mon Sep 17 00:00:00 2001 From: npinter Date: Tue, 30 Jul 2024 12:36:39 +0200 Subject: [PATCH 2/3] Fix png output --- tools/qupath_roi_splitter/qupath_roi_splitter.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/qupath_roi_splitter/qupath_roi_splitter.xml b/tools/qupath_roi_splitter/qupath_roi_splitter.xml index bc7d3ec10..cd5da2d22 100644 --- a/tools/qupath_roi_splitter/qupath_roi_splitter.xml +++ b/tools/qupath_roi_splitter/qupath_roi_splitter.xml @@ -21,7 +21,9 @@ #end for mkdir out && mv *.txt out/ + #if $optional.img && mv *.png out/ + #end if ]]> @@ -36,7 +38,7 @@ - img + optional['img'] From 8c14af3adc6275f98d5bedbdb77e5cfca7a04f5d Mon Sep 17 00:00:00 2001 From: npinter Date: Tue, 30 Jul 2024 13:56:00 +0200 Subject: [PATCH 3/3] Fix test --- tools/qupath_roi_splitter/qupath_roi_splitter.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qupath_roi_splitter/qupath_roi_splitter.xml b/tools/qupath_roi_splitter/qupath_roi_splitter.xml index cd5da2d22..963b23cbc 100644 --- a/tools/qupath_roi_splitter/qupath_roi_splitter.xml +++ b/tools/qupath_roi_splitter/qupath_roi_splitter.xml @@ -43,7 +43,7 @@ - +