-
Notifications
You must be signed in to change notification settings - Fork 338
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
initial commit for fixing video segmentations #1828
base: main
Are you sure you want to change the base?
initial commit for fixing video segmentations #1828
Conversation
✅ Deploy Preview for cornerstone-3d-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
f1392ee
to
8355ad4
Compare
…g/video-segmentation
@sedghi i pushed new changes wrt the to discussion we had in last office hours. |
{ | ||
skipCreateBuffer: true, | ||
onCacheAdd: csUtils.VoxelManager.addInstanceToImage, | ||
getDerivedImageId: (referenceImageId, index) => { |
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.
Please use the multiframe utilities to update the frame reference.
Also, there is no need to use a random uid, you can use the original uid with derived in front of it, but updating the frame index so that every time you generate the same uids.
Finally, this derivation should probably go into the core code so that the handling is consistent and can be done from things like OHIF.
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.
@sedghi - should we add a vewport call 'getDerivedImageIds' It could take a range request to allow getting a sub-range of it.
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.
cornerstone3D/packages/core/src/loaders/imageLoader.ts
Lines 340 to 371 in 0b67f91
export function createAndCacheDerivedImages( | |
referencedImageIds: string[], | |
options: DerivedImageOptions & { | |
getDerivedImageId?: (referencedImageId: string) => string; | |
targetBuffer?: { | |
type: PixelDataTypedArrayString; | |
}; | |
voxelRepresentation?: VoxelManagerEnum; | |
} = {} | |
): IImage[] { | |
if (referencedImageIds.length === 0) { | |
throw new Error( | |
'createAndCacheDerivedImages: parameter imageIds must be list of image Ids' | |
); | |
} | |
const derivedImageIds = []; | |
const images = referencedImageIds.map((referencedImageId, index) => { | |
const newOptions: DerivedImageOptions = { | |
imageId: | |
options?.getDerivedImageId?.(referencedImageId) || | |
`derived:${uuidv4()}`, | |
...options, | |
}; | |
derivedImageIds.push(newOptions.imageId); | |
return createAndCacheDerivedImage(referencedImageId, { | |
...newOptions, | |
instanceNumber: index + 1, | |
}); | |
}); | |
return images; | |
} |
line 360 is creating a derivedImageId using a random uuid anyway if we don't implement getDerivedImageId
. so i am little confused.
here's a trace:
createAndCacheDerivedLabelmapImages
createAndCacheDerivedImages
line 360
hene i assumed i was not doing anything drastically different reg the creation of a derivedImageId. i thought getDerivedImageId
lets the user create a derviedImageId in a format they want, which is why i used it to append frames to the id.
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.
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.
Could you at least move the create derived images into a specialized method in imageLoaders.ts that takes a type argument that can be video/stack/volume/wsi and returns the right type of response? It should take the same type of argument as the rendering engine create does. That way the same code can be re-used more generally, and we can update it to use non-random uids if we choose, or continue as is.
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.
that makes more sense. on it.
Context
Video segmentations are broken in cornerstone3d. Well sort of. They are working but they are not properly tied to a frame. Rather they persist across frames which is not ideal.
They used to work in 3d 1.0
Changes & Results
I sense that the mappings of derivedImageId and the currentImageId are not proper, and I confirmed that for every imageId, the mapped derivedImageId is same, which is why these labelmaps are being carried forward.
working demo after changes
compressed-video.mp4
Testing
run the videosegmentation example
Checklist
PR
semantic-release format and guidelines.
Code
[] My code has been well-documented (function documentation, inline comments,
etc.)
[] I have run the
yarn build:update-api
to update the API documentation, and havecommitted the changes to this PR. (Read more here https://www.cornerstonejs.org/docs/contribute/update-api)
Public Documentation Updates
additions or removals.
Tested Environment