-
Notifications
You must be signed in to change notification settings - Fork 105
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
New feature that save mask as geojson format #306
base: master
Are you sure you want to change the base?
Conversation
Hi @jacksonjacobs1, Please review it. |
not quite, i think there was a miscommunication here. the module should be in the config file, and should be dynamic, such that the user can add it at any point during the pipeline, or even multiple times, with a tag specifying the mask to be written out. coding wise should be similar to the classification pen marking work |
…on option in HistoQC module
Hi @choosehappy and @jacksonjacobs1, I created a new function called |
yea, much closer! 1 point left: i think " s["img_mask_use"]) " should actually be accepted as a variable with the name of the mask to save --- "img_mask_use" can and should be the default, but if someone is interested in saving e.g., the pen detector or blur mask they should be able to as well do you see what I mean? |
Hi @choosehappy and @jacksonjacobs1, I added an option called 'mask_name' to let the user point out what mask to save. |
great, looks good to me. no remaining points on my side- will let @jacksonjacobs1 code review and comment as needed, if not merge |
btw, i quick note - we can as well easily read/write gzip compressed json (an example is in my blog). normally compressed json is about 33% the size of the uncompressed. i suspect the ones that we have here are small enough that we don't need to worry about it, and its "nicer" to be able to easily see the json, but its something to keep in mind in case we have more "serious" file sizes |
Just in case, the current implementation use measures.find_contour, which typically finds both the inner and outer rings. In that case, your geojson output will consider the inner and outer ring as individual polygons, if I understand it correctly. This might be relevant: |
Agree with @CielAl The geojson template will need to be updated to the multipolygon specification: https://stackoverflow.com/questions/43645172/geojson-multipolygon-with-multiple-holes I would also recommend testing whether qupath correctly renders multi-polygons imported from geojson. |
Hi @jacksonjacobs1, completed correctly showing the inner and outer rings as individual polygons. Please review the code. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall! I left a couple of comments
the followings are helper functions for generating geojson | ||
''' | ||
|
||
feature_template = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using dicts to model json data is error prone. I think it would be better to use types provided by the geojson
library:
https://python-geojson.readthedocs.io/en/latest/
I think it's worth spending a little more time to make this method robust because we may want to use it outside of histoqc in our lab.
By the way, did you get the chance to try out this python package? I remember mentioning it in a Friday meeting but do not remember if you found an issue with it.
https://pypi.org/project/cv2geojson/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right. I will use python-geojson and cv2geojson. I will let you know if there is any issue with using them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! note though that we want to avoid adding dependencies unless necessary.
I would argue that the geojson
library is the right tool for the job in this case, but I'm not sure yet with cv2geojson
- do you think this second library has much added value for HistoQC?
Also, do you have a sense of how large these packages are?
Add a
--geojson
option into HistoQC. The default value of geojson is False. Test the result and import intp Qupath.This feature is associate with issue #298