Skip to content
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

MeasurementList is ignored for some objects when importing from GeoJSON #845

Closed
petebankhead opened this issue Nov 20, 2021 · 0 comments · Fixed by #846
Closed

MeasurementList is ignored for some objects when importing from GeoJSON #845

petebankhead opened this issue Nov 20, 2021 · 0 comments · Fixed by #846
Assignees
Labels
Milestone

Comments

@petebankhead
Copy link
Member

Bug report

Describe the bug
See #835 from @jameshball

In summary, measurement lists are only included by PathObjectTypeAdapters when deserialising detection objects, as can be seen in the code from https://github.com/qupath/qupath/blob/v0.3.0/qupath-core/src/main/java/qupath/lib/io/PathObjectTypeAdapters.java#L412

A second, more subtle bug is that when measurement lists are retained, their type can be changed. This is not expected to have any major effect beyond efficiency, but could potentially be important in some situations.

To Reproduce
Run the following script:

def roi = ROIs.createRectangleROI(0, 10, 20, 30, ImagePlane.getDefaultPlane())
def annotation = PathObjects.createAnnotationObject(roi)
annotation.setName("Original")
annotation.setPathClass(getPathClass("My custom class"))
annotation.getMeasurementList().addMeasurement("First measurement", 1.0)
annotation.getMeasurementList().addMeasurement("Second measurement", -2.0)

def json = GsonTools.getInstance(true).toJson(annotation)

// Print original annotation, class and measurement list
println "ORIGINAL"
println annotation
println annotation.getPathClass()
println annotation.getMeasurementList().class
println annotation.getMeasurementList()
println "----------------"

// Print deserialized annotation, class and measurement list
def newAnnotation = GsonTools.getInstance().fromJson(json, PathObject)
println "FROM JSON"
println newAnnotation
println newAnnotation.getPathClass()
println newAnnotation.getMeasurementList().class
println newAnnotation.getMeasurementList()

The new annotation does not have any measurements in QuPath v0.3.0.

Moreover, switching to use PathObjects.createDetectionObject(roi) reveals that the measurements are retained, but the class of the measurement list is changed from FloatList to DoubleList - requiring more memory.

Expected behavior
As much information as possible is retained when serialising to/from GeoJSON.

Desktop (please complete the following information):

  • QuPath v0.3.0
@petebankhead petebankhead added this to the v0.3.1 milestone Nov 20, 2021
@petebankhead petebankhead self-assigned this Nov 20, 2021
petebankhead added a commit to petebankhead/qupath that referenced this issue Nov 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant