Skip to content

Conversation

@imadselka
Copy link

This pull request refactors the Cornerstone DICOM viewer app to improve compatibility with server-side rendering (SSR) and enhance modularity. The main changes involve dynamically importing all Cornerstone-related modules at runtime, updating image loading and rendering logic, and improving the polysegmentation workflow with better state management and user experience.

SSR Compatibility and Dynamic Imports

  • All Cornerstone modules (@cornerstonejs/core, @cornerstonejs/tools, and @cornerstonejs/dicom-image-loader) are now imported dynamically within React components to prevent SSR-related issues. This change is applied in both app/page.tsx and app/polyseg/page.tsx. [1] [2] [3] [4] [5]

Image Loading and Rendering Logic

  • The main viewer (app/page.tsx) now provides clear examples for loading local DICOM files and remote DICOM series, and refactors the volume/stack loading logic to be more modular and easier to switch between modes. [1] [2]
  • The helper function createImageIdsAndCacheMetaData in lib/createImageIdsAndCacheMetaData.ts now dynamically imports the DICOM image loader and returns both image IDs and metadata, improving SSR safety and modularity. [1] [2]

Polysegmentation Workflow Improvements

  • In app/polyseg/page.tsx, segmentation tool state is managed using React's useState and useCallback, and the "Convert to 3D" button is disabled until the viewer is ready, improving user experience. The segmentation conversion logic is moved to a dedicated callback. [1] [2] [3]

Code Cleanup and Type Safety

  • Unused static imports are removed and replaced with dynamic imports, and type annotations are added for better clarity and maintainability. [1] [2]

Configuration Updates

  • The remote WADO-RS DICOM server URL is updated for remote volume loading in the main viewer example.

Let me know if you have questions about any specific part of the refactor!

- Convert Cornerstone3D static imports to dynamic imports to avoid SSR errors
- Update DICOM server URL to working endpoint
- Replace volume viewer with faster stack viewport for local files
- Increase web worker threads for better decoding performance
- Add local DICOM example with commented remote WADO-RS reference
- Convert Cornerstone3D static imports to dynamic imports to avoid SSR errors
- Update DICOM server URL to working endpoint
- Replace volume viewer with faster stack viewport for local files
- Increase web worker threads for better decoding performance
- Add local DICOM example with commented remote WADO-RS reference
@imadselka
Copy link
Author

imadselka commented Nov 26, 2025

@sedghi would you mind reviewing the pr?

@sedghi
Copy link
Member

sedghi commented Nov 26, 2025

sure i will review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants