View in #cornerstone3d on Slack
@Jason_Hostetter: Is there any documentation of what steps are needed to convert a stored Legacy tools annotation object to a cs3d tools object? I have a bunch of annotation objects stored in a db from legacy cornerstone that I would like to bring with as I migrate to cs3d. The legacy objects are basically 2D coordinates tagged to imageIds - for a cs3d tool, its there a reliable way to map this into the world space?
@Bill_Wallace: The adapters package has adapters that will load a legacy SR into CS3D
You should be able to look there (Cornerstone not Cornerstone3D as the package name) for details on how to convert/create the equivalent CS3D instances
@Jason_Hostetter: My stored objects are not in SR format, just JSON dump of the cornerstone annotation objects. That adapter looks specific to SR?
I’m wondering if I construct an annotation object in cs3d with just like the referenced imageId and handle coordinates without the view plane/camera data, cs3d won’t be able to render that bc all the handle data is 2D, right?
I can manually convert all the handle points to 3d, but not sure what data in the annotation object are required, ie focal point, view plane, frame of reference uid etc
@Alireza_Sedghi: the real pain is previous cs stored in image coordinate system
and in cs3d we have everything in world
so you should call functions to convert to world
https://www.cornerstonejs.org/docs/migration-guides/legacy-to-3d#pagetopixel-and-pixeltocanvas
Legacy to 1.0 | Cornerstone.js
@Jason_Hostetter: So in world system the frame of reference uid is probably required?
Trying to figure out the process for converting, doubt if I have all these data I need in the legacy annotation objects, will probably need to read additional metadata so maybe best to convert in the viewer itself when metadata is cached rather than convert offline
I will tinker with it and see how it goes
@Alireza_Sedghi: yes, i forgot , but i think the previous annotation system was in x, y of image
we have utilities to convert those to world
and you can do that in your backend but they need the image object
@Jason_Hostetter: Yeah I wonder if it might be easier to convert live on demand
And just store any edited annotations in cs3d format
@Alireza_Sedghi: depend on how many are there
@Jason_Hostetter: Probably tens of thousands stored? So I think doing it in bulk offline would take a long time
Going to try just writing an annotation load adapter that converts any legacy to 3d to display, then if the user edits them the new object overwrites the legacy one
Oh just found the hydrate methods of the cs3d tools, that looks like it’ll make it super straightforward
@Alireza_Sedghi: use the one on each tool
not the utility one
@Jason_Hostetter: Ok good to know
What are the camera properties stored in tool metadata used for? Is it just to save the specific viewport properties at the time the annotation was created?
@Bill_Wallace: It allows navigating back to that annotation on both stack and volume viewports
@Jason_Hostetter: Ok, so looking at the hydrate
methods for annotation tools, shouldn’t you need to pass in a frame of reference UID or imageId or something to tell which image in a stack the annotation applies to? I see that with a volume, it could figure it out based on just the world coordinates, but for a stack with like a PA and lateral CXR, how can you set an annotation with hydrate
that applies to the right image?
Maybe hydrate is not the right way to restore saved annotations
@Alireza_Sedghi: it gets the viewportId, the rest is derived from the current image in the viewport
@Jason_Hostetter: I think i get it - hydrate
is meant to programmatically add a new annotation on the current view reference, and i found saveAnnotations
and restoreAnnotations
on the annotation manager that looks like what I need