-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
accept a ROI as a geojson #108
Comments
the ROI would be in geojson format. it could include multiple regions potentially. here's a tentative plan:
def get_patches_in_rois(geojson_path: str, coords: np.ndarray, patch_size: int):
with open(geojson_path) as f:
geo = geojson.load(f)
num_rois = len(geo["features"])
print(f"Processing {num_rois} rois")
for roi in geo["features"]:
assert roi.is_valid, "an ROI geometry is not valid"
# Each geom is a shapely Polygon type.
geoms_rois = [shape(roi["geometry"]) for roi in geo["features"]]
boxes = [box(x, y, x+patch_size, y+patch_size) for x, y in coords]
tree = shapely.STRtree(boxes)
_, intersecting_ids = tree.query([geom, geom], predicate="intersects")
intersecting_ids = np.sort(np.unique(intersecting_ids))
return coords[intersecting_ids] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use case here is in qupath. one would be in qupath and would annotate a region of interest. this roi would be run by wsinfer.
the roi would be encoded as geojson. we can check if the patches overlap with the ROI and apply the model to those patches.
The text was updated successfully, but these errors were encountered: