Add support to NeuroJSON (.jnii and .bnii) files (cleaned) #580
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 (http://neurojson.org) 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 efficiencyThe 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 thenii_dicom_batch.cpp
unit and two additional helper unitscJSON.c/h
andbase64.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!