Skip to content

Add new -J flag for enhanced DICOM metadata extraction#959

Closed
hanayik wants to merge 4 commits intodevelopmentfrom
hanayik/more-dicom-metadata
Closed

Add new -J flag for enhanced DICOM metadata extraction#959
hanayik wants to merge 4 commits intodevelopmentfrom
hanayik/more-dicom-metadata

Conversation

@hanayik
Copy link
Collaborator

@hanayik hanayik commented Jul 5, 2025

Add new -J flag for enhanced DICOM metadata extraction

Summary

This PR introduces a new -J command-line option to dcm2niix that enables more DICOM metadata extraction to JSON format, going beyond the standard BIDS sidecar fields.

@hanayik hanayik requested a review from neurolabusc July 5, 2025 09:56
@neurolabusc
Copy link
Collaborator

@hanayik this is an interesting PR. It has an elegantly minimal implementation and can extract a lot of code. However, I do not think it should be included in the main distribution, or if it is it should only be bundled with a compiler directive. A few comments:

  • It makes pretty strong assumptions about the DICOM data being valid, and will falter with several violations of the standard that are common in the wild.
  • The behavior for implicit VR data is particularly poor: without a DICOM dictionary or any vendor specific details it generates invalid JSON files (e.g. repeated keys).
  • The style of JSON is inconsistent with the other JSON export (e.g. double spaces instead of tabs for white space).
  • In general, JSON is a a poor choice for large amounts of meta data. While it is human readable the parsing is slow and the use of ASCII for floating point numbers is both slow and lossy. Given that a lot of BIDS datasets are part of huge analyses, I would keep the main JSON lean with minimal extra details.
  • Now that the BIDS steering committee has an established method for improving the specification, I would prefer if new JSON tags are first ratified by that organization before being introduced into only a single software implementation. I do not think I should be gatekeeper for determining what key:value pairs are required.
  • In particular, your tool seems to generate repeated keys with varying values for nested DICOM tags, common in enhanced DICOM. I think there needs to be some way to preserve the structure of this information, not merely the names.

I do think this is a situation where using pydicom with its robust DICOM handling and actively maintained DICOM dictionaries might be the optimal solution. I like the idea of saving these as a JSON file, but maybe not the same JSON used as a BIDS sidecar.

@hanayik hanayik closed this Oct 21, 2025
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