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 (cleaned) #580

merged 9 commits into from
Feb 11, 2022


Copy link

@fangq fangq commented Feb 10, 2022

Here is the resubmission of #579 after cleaning the commit history using cherry-pick, as suggested by @ningfei

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!


Copy link

@fangq I am happy with this PR. @ningfei you looked at this in more detail than me. If you are also happy with this, and you please merge it?

Copy link

ningfei commented Feb 11, 2022

Cool! Looks good to me.

@ningfei ningfei merged commit 5b50245 into rordenlab:development Feb 11, 2022
Copy link
Contributor Author

fangq commented Feb 11, 2022

terrific! thank you both for your help and feedback, it was very helpful! look forward to working with you more as my project continues to grow

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

Successfully merging this pull request may close these issues.

None yet

3 participants