cornerstone3D icon indicating copy to clipboard operation
cornerstone3D copied to clipboard

RFC for v2.x

Open sedghi opened this issue 2 years ago โ€ข 38 comments

Cornerstone3D beta distribution tag is now live in npm ๐ŸŽ‰, and the beta branch will publish to it.

image

We are excited ๐Ÿ˜ƒ to open this RFC for version 2.x of Cornerstone3D. Our vision for these changes includes:

  • ~~Removal of cjs in favor of esm and umd: we don't really need all three ๐Ÿงน~~.
  • ~~Dropping ES5 support and targeting newer ES2022: Aligning with the latest standards ๐Ÿš€~~.
  • ~~Upgrade of TypeScript to 5.x: Enhancing the type safety and developer experience ๐Ÿ’ป~~.
  • ~~Rework of the web workers with comlink: Modernizing this critical aspect for better performance and maintainability ๐Ÿ› ๏ธ~~.

These changes are intended to make Cornerstone3D more modern and efficient. However, we recognize that they might also lead to breaking changes, particularly in the API ๐Ÿ˜ฌ.

If there is any part of the API that doesn't make sense to you, or if you have a better idea that you couldn't propose before due to it being a breaking change, now is the time โฐ. We value your input, and we're eager to hear your thoughts ๐Ÿ’ญ.

How to Propose Changes:

  • Create an issue in the GitHub and describe your suggestion or concern in detail ๐Ÿ“.
  • Post the issue link here as a mention ๐Ÿ“Ž.

sedghi avatar Aug 01 '23 21:08 sedghi

https://github.com/cornerstonejs/cornerstone3D/pull/514 - DONE

sedghi avatar Aug 01 '23 21:08 sedghi

https://github.com/cornerstonejs/cornerstone3D/issues/697 - DONE

sedghi avatar Aug 01 '23 21:08 sedghi

Would the rafactor of dicom-image-loader be part of this version?

Since this version is mainly trying to catch up with the modern DX, I'd love to see that the web worker files can be loaded in a more general way, which could makes it possible to be bundled by other modern bundlers like vite. By saying a more general way, I mean the loading path should be implemented with import.meta.url or something like this.

For now I believe users have to manually copy all the worker files from within the dicom-image-loader package into somewhere their bundlers can read and put the files into a path that the dicom-image-loader code can read and load, which is exactly is what you suggested here. Though it definitely works, I think it could be better.

This is what almost 'blocks' me from using this great library the first time, with a project set up by vite.

shunia avatar Aug 29 '23 06:08 shunia

Thanks for your comment @shunia Yes, it would be ideally what you are recommending here. Although I have not tried cornerstone3D with vite . Do you have a simple repo with cs3d and default setup of the vite so that I try to make sure in 2.x it is resolved?

sedghi avatar Aug 29 '23 17:08 sedghi

Thanks for your comment @shunia Yes, it would be ideally what you are recommending here. Although I have not tried cornerstone3D with vite . Do you have a simple repo with cs3d and default setup of the vite so that I try to make sure in 2.x it is resolved?

I would love to and did try to create a repo for this, but after some digging I find it becoming harder to implement a simple viewer now because of the API change, you have to create an image loader or the viewport will just not work and complains with errors.

If you are interested in how to setup a basic vite project, I think you can simply follow the command:

npm create vite@latest 

And because of the failed experience, I believe the 'image loader' concept should be improved too. I don't have enough time to dig deeper now, but I think the signature of registerImageLoader function is quite intuitive: the second parameter with type ImageLoaderFn is not documented well, and even after reading some of the source codes I still have no clue what should be returned for the promise since it's a Record<string, any> type.

shunia avatar Aug 30 '23 04:08 shunia

I hoped the custom image loader how-to-guide adds some guidance on how to write your loaders

https://www.cornerstonejs.org/docs/how-to-guides/custom-image-loader

sedghi avatar Aug 30 '23 13:08 sedghi

DONE

imageCoordinate -> worldCoordinate

function getDataInTime( dynamicVolume: Types.IDynamicImageVolume, options: { frameNumbers?; maskVolumeId?; imageCoordinate?; } ): number[] | number[][] {~~

sedghi avatar Oct 18 '23 02:10 sedghi

DONE

I think there is an inconsistency with how a volume or stack triggers the NEW_VOLUME or NEW_STACK events. In BaseVolumeViewport.ts, the VOLUME_VIEWPORT_NEW_VOLUME event is triggered on the viewport element whereas in StackViewport.ts, the STACK_VIEWPORT_NEW_STACK event is triggered on the cornerstone eventTarget. Is this intentional? Relevant lines below: https://github.com/cornerstonejs/cornerstone3D/blob/c527923a8a1afd65e76f9335ac4cc0bc3a0e924b/packages/core/src/RenderingEngine/BaseVolumeViewport.ts#L779 https://github.com/cornerstonejs/cornerstone3D/blob/c527923a8a1afd65e76f9335ac4cc0bc3a0e924b/packages/core/src/RenderingEngine/StackViewport.ts#[โ€ฆ]2

sedghi avatar Oct 25 '23 13:10 sedghi

I hoped the custom image loader how-to-guide adds some guidance on how to write your loaders

https://www.cornerstonejs.org/docs/how-to-guides/custom-image-loader

I believe the most important part is omitted in the example code:

// Request succeeded, Create an image object (logic omitted)
const image = createImageObject(oReq.response);

What is the actual return type?

shunia avatar Oct 31 '23 03:10 shunia

DONE

camera rotation should be on the camera not properties

sedghi avatar Nov 01 '23 13:11 sedghi

remove STACK_NEW_IMAGE and VOLUME_NEW_IMAGE after merging the NEW_IMAGE

sedghi avatar Nov 21 '23 02:11 sedghi

DONE

getCalibratedLengthUnits and getCalibratedAreaUnits arugment order

sedghi avatar Dec 04 '23 14:12 sedghi

DONE

resetCamera(resetPan, ....)

sedghi avatar Dec 05 '23 15:12 sedghi

decache, convertToImages etc. in streaming

sedghi avatar Dec 20 '23 14:12 sedghi

DONE

referenceId vs referencedId vs referencedImageId vs referenceImageId

sedghi avatar Dec 20 '23 20:12 sedghi

DONE

export function triggerAnnotationRenderForViewportIds( renderingEngine: Types.IRenderingEngine, viewportIdsToRender: string[] ): void {

Should be rendering engine Id

sedghi avatar Jan 04 '24 14:01 sedghi

DONE

VOLUME_SCROLL_OUT_OF_BOUNDS is VOLUME_VIEWPORT_SCROLL_OUT_OF_BOUNDS

sedghi avatar Jan 08 '24 14:01 sedghi

DONE

createAndCacheVolume might be better to name createAndCacheEmptyVolume

sedghi avatar Jan 11 '24 15:01 sedghi

getSegmentationRepresentationByUID requires toolGroupId which does not makes sense

sedghi avatar Jan 11 '24 18:01 sedghi

getAllSegmentationRepresentations should be array instead of object

sedghi avatar Jan 11 '24 19:01 sedghi

drawpath vs drawpolyline

sedghi avatar Jan 30 '24 17:01 sedghi

Increase line width to 100, OHIF dev experience is much better

sedghi avatar Feb 06 '24 15:02 sedghi

setSegmentationRepresentationSpecificConfig

should not rely on toolGroupId as UIDs should be uids

sedghi avatar Feb 12 '24 13:02 sedghi

drawRect, drawRectByCoordinates,

sedghi avatar May 15 '24 20:05 sedghi

I can see the types for dicomImageLoader is missing. I've been trying to fix it on main branch but I ended up with issue with @cornerstonejs/core and other types used in the image loader. As you are using monorepo I would expect to use composite tsc feature but thats not the case. I'm happy to contribute if necessary as the image loader is a huge part of our project. https://www.typescriptlang.org/tsconfig/#composite

kresli avatar May 22 '24 14:05 kresli

@kresli I know it is a pain, we will work on it soon hopefully

sedghi avatar May 23 '24 15:05 sedghi

We are not following the lps definition in our slices, volview does it correctly

sedghi avatar May 31 '24 19:05 sedghi

Update the volume API to use single slices on browser side and combined slice data on volume side so that the memory is shared between single frames and multiple frames and large volume allocation works. This should allow 2 memory regions on the webGL side to be treated as a single volume for rendering so that larger volumes can be created. This would involve removing all the destination volume code where the offset to store to is included in the imageio, and the imageio would no longer need to use shared memory.

wayfarer3130 avatar Jun 04 '24 16:06 wayfarer3130

We might want to consider the API for resizing of windows - there is CSS which automatically selects the right aspect ratio, and will allow resizing the window using the browser native resize so it is really smooth, followed by automatic updates. Unfortunately, it changes the API for the element containing the viewport a tiny bit - the old ones work, but need to be fixed just a bit to work more smoothly, but the new element styling is NOT backwards compatible.

wayfarer3130 avatar Jun 04 '24 16:06 wayfarer3130

DONE

We should enable the prescale always to true

sedghi avatar Jun 07 '24 14:06 sedghi