# HG changeset patch # User galaxyp # Date 1722344351 0 # Node ID 17c54a716a5bd1bf14e09689daa64dc3c47c96a2 # Parent 9f136ebf73ac5ee7b4855322157935cfb50677ac planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit e3d24f3dc7a9812f8fa4447c9391e5bd3b5d4dc6 diff -r 9f136ebf73ac -r 17c54a716a5b qupath_roi_splitter.py --- a/qupath_roi_splitter.py Fri Jul 19 14:33:40 2024 +0000 +++ b/qupath_roi_splitter.py Tue Jul 30 12:59:11 2024 +0000 @@ -22,15 +22,20 @@ 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 @@ 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 -r 9f136ebf73ac -r 17c54a716a5b qupath_roi_splitter.xml --- a/qupath_roi_splitter.xml Fri Jul 19 14:33:40 2024 +0000 +++ b/qupath_roi_splitter.xml Tue Jul 30 12:59:11 2024 +0000 @@ -1,7 +1,7 @@ Split ROI coordinates of QuPath TMA annotation by cell type (classification) - 0.3.0 + 0.3.1 0 @@ -21,7 +21,9 @@ #end for mkdir out && mv *.txt out/ + #if $optional.img && mv *.png out/ + #end if ]]> @@ -33,14 +35,15 @@ - + + optional['img'] - +