cornerstonejs / cornerstone3D

Cornerstone is a set of JavaScript libraries that can be used to build web-based medical imaging applications. It provides a framework to build radiology applications such as the OHIF Viewer.
https://cornerstonejs.org
MIT License
528 stars 271 forks source link

[Feature Request] Unregister image loader #897

Open sgielen opened 9 months ago

sgielen commented 9 months ago

What feature or change would you like to see made?

Currently, it is possible to register Cornerstone image loaders, but not to unregister them, except unregistering all of them at the same time. I would like to register an image loader temporarily (so that I can read bytes into cornerstone images and metadata), but the API does not provide for this.

Why should we prioritize this feature?

It's easy to implement:

export function unregisterImageLoader(
  scheme: string,
): void {
  delete imageLoaders[scheme];
}

Then it allows for easy cleanup, especially if the image loader still references a large block of memory you'd like to free. Now, I need to write my image loaders in such a way that I can "deactivate" them, thereby dereferencing that memory, while still allowing them to be called.

sedghi commented 9 months ago

makes sense, do you want to add a PR?