Skip to content
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

Re-add zlib support and enable jpegls support #906

Merged
merged 1 commit into from
Jan 19, 2025

Conversation

hanayik
Copy link
Collaborator

@hanayik hanayik commented Jan 15, 2025

@neurolabusc , the development branch seems to have lost my changes that enabled WASM zlib support. The NPM package that is published has this support, but the make file in the repo was clobbered somehow.

I have:

  • enabled WASM zlib support in the wasm target again
  • enabled jpegls support in the new wasm-jpegls target
  • updated the npm package build to export both the jpegls and non-jpegls builds

Developers using @niivue/dcm2niix can choose which build they want to import into their apps by using one of the following:

Default, without jpegls

import { Dcm2niix } from '@niivue/dcm2niix' // default, and without jpegls
// Chris Rorden's dcm2niiX version v1.0.20241231  Clang20.0.0

With jpegls

import { Dcm2niix } from '@niivue/dcm2niix/with-jpegls'
// Chris Rorden's dcm2niiX version v1.0.20241231  (JP-LS:CharLS) Clang20.0.0

@neurolabusc
Copy link
Collaborator

neurolabusc commented Jan 15, 2025

@hanayik There are four major forms of JPEG used by DICOM:

  • dcm2niix always supports baseline JPEG (1.2.840.10008.1.2.4.50 and 1.2.840.10008.1.2.4.51) using NanoJPEG and lossless JPEG (1.2.840.10008.1.2.4.57 and 1.2.840.10008.1.2.4.70) using custom code
  • dcm2niix will support JPEG-LS (1.2.840.10008.1.2.4.80 and 1.2.840.10008.1.2.4.81) if compiled with CharLS
  • dcm2niix will support JPEG-2000 if compiled with OpenJPEG (1.2.840.10008.1.2.4.90, 1.2.840.10008.1.2.4.91 and 1.2.840.10008.1.2.4.92). If the OpenJPEG is version is 2.5.0 or later, you will also get HTJ2K support (1.2.840.10008.1.2.4.201, 1.2.840.10008.1.2.4.203).

It seems to me that we ultimately want two forms of dcm2niix for npm

  • basic NiiVue WASM that without JPEG-LS and JPEG2000
  • advanced NiiVue WASM with both JPEG-LS and JPEG2000 support.

All the source code for CharLS is included with dcm2niix, so it is easy to compile this to WASM (as you have done). However, the originating issue wants to have OpenJPEG. I think this might be a much more challenging. The make jp2 option shows you how to do this, but it does provide an explicit path to the OpenJPEG libraries (currently, the location on MacOS is you use brew install openjpeg for openjpeg 2.5.3). A challenge here is that brew installs the pre-compiled dylib not the source code, so I do not think it will work. I do think the required approach for WASM would be to download the latest stable release of the openjpeg source code and compile that all to WASM. I think this will be a lot more involved.

@neurolabusc neurolabusc merged commit 95d4321 into development Jan 19, 2025
3 checks passed
@neurolabusc neurolabusc mentioned this pull request Jan 19, 2025
8 tasks
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