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

Add support to NeuroJSON (.jnii and .bnii) files #578

Closed
wants to merge 6 commits into from

Conversation

fangq
Copy link
Contributor

@fangq fangq commented Feb 9, 2022

Dear Chris (@neurolabusc), I would like to submit a patch to enable dcm2niix to export to NeuroJSON NIfTI JSON wrappers, including

  • .jnii - lightweight JSON wrapper to NIfTI (text-based JNIfTI, see current specification)
  • .bnii - binary JSON (yet still human-readable) wrapper to NIfTI for disk/IO efficiency

The patch is fairly straightforward, including two added flags: -e j for exporting to .jnii and -e b for exporting to .bnii. Both flags are compression-aware: when -z y is given, the data segment of .jnii/.bnii will be compressed based on the compression level. In this patch, I only added a few functions (nii_savejnii, nii_savebnii) in the nii_dicom_batch.cpp unit and two additional helper units cJSON.c/h and base64.c/h, both of which have been copied from your nii2mesh code tree. The added codes should have no impact to any of the existing features.

The updated code has passed the Travis-CI automated tests, and I have also run valgrind to make sure there is no memory leakage. I also formatted the new functions to use the same tab-based indentation styles.

The bottom screenshot summarizes some of the tests I did, making sure the generated files are readily readable by my Python and MATLAB parsers. It also demonstrate additional benefits enabled by this format - including file sizes, header searchability (without decompressing files) and readability.

I hope you can take a look at this patch and let me know if it can be accepted. I am committed to supporting this feature moving forward. Look forward to hearing from you!

jnifti_patch_demo

@fangq
Copy link
Contributor Author

fangq commented Feb 9, 2022

When I did my tests, I also pulled the latest versions of the test data submodules (dcm_qa, dcm_qa_nih, dcm_qa_uih), and they also seem to appear in this PR.

The changes in these files seems to be minor (date string updated from 20210308 to 20211006). Let me know if this is a concern. I can probably revert it.

@neurolabusc
Copy link
Collaborator

  • Thanks!
  • I have made a PR to your repository with suggested changes.
  • I am rejecting this PR because it is to the master branch. All pull requests must be made against the development branch. The master branch is always the current stable release.

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