Fix the GeoJSON files written by our QuPath images #390
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Modify the code that runs stardist cell detections to produce a valid geojson file.
These changes look for a
cell_detections.geojson
file in thequpath-stardist
output directory, and rewrite it if it looks necessary. Specifically, if the top-level data structure in the file is a list, it's rewritten so that the top-level structure becomesThe code was tested on the spatial-analysis tutorial slide, and seems to work as expected. As a positive side effect, the geojson file is owned by the user after this, instead of root. I haven't actually tried to load the new geojson file in geopandas yet.
On this sample slide, it takes 2-3 of minutes to read and to write the geojson file, which contains ~725,000 features.
This could be faster if we used a faster json module, or if we avoided parsing and re-composing the geojson file. I could try using
orjson
orujson
to see if they give a significant speedup.