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

Support more datatypes #4

Open
neurolabusc opened this issue Nov 20, 2023 · 0 comments
Open

Support more datatypes #4

neurolabusc opened this issue Nov 20, 2023 · 0 comments

Comments

@neurolabusc
Copy link
Contributor

As noted here, this repo says to support dataypes 2,4,16 but does not. This can be observed with dragging and dropping the images of different datatypes from the niivue float32 (fslmean.nii.gz) and niivue-demo-images int16 (CT_Philips.nii.gz).

The solution is to add .buffer to read the bytes rather than convert them:

      case processedImage.DT_UNSIGNED_CHAR:
        processedImage.img = new Uint8Array(imageBytes);
        break;
      case processedImage.DT_SIGNED_SHORT:
        processedImage.img = new Int16Array(imageBytes.buffer);
        break;
      case processedImage.DT_FLOAT:
        processedImage.img = new Float32Array(imageBytes.buffer);
        break;
      case processedImage.DT_DOUBLE:
        throw "datatype " + processedImage.hdr.datatypeCode + " not supported";
      case processedImage.DT_RGB:
        processedImage.img = new Uint8Array(imageBytes.buffer);
        break;
      case processedImage.DT_UINT16:
        processedImage.img = new Uint16Array(imageBytes.buffer);
        break;
      case processedImage.DT_RGBA32:
        processedImage.img = new Uint8Array(imageBytes.buffer);
        break;
      default:
        throw "datatype " + processedImage.hdr.datatypeCode + " not supported";
    }
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

No branches or pull requests

1 participant