JSON: import simple array as a single header entry#1771
JSON: import simple array as a single header entry#1771jdtournier wants to merge 2 commits intomasterfrom
Conversation
With #1735 (specifically here) and #1738 I found that in order to have the JSON export operate as intended for slice timing information extracted from DICOM, such array data needed to be saved as space-separated rather than comma-separated in the header. If it's comma-separated, the JSON |
|
This is all based on on-going discussions with Finn Lennartsson - might be worth involving him in the discussion, but I don't think he has a GitHub account... In any case, this is what And on the current Using the direct DICOM import all within MRtrix3, this ends up as a single comma-separated list of values in a single entry: I guess #1735 and #1738 will definitely interact here, but I'm unsure about the details... |
|
I suspect there's a number of gremlins arising from the fact that I hurriedly got the JSON handling working well enough to be able to produce and process data that looked like BIDS, but wasn't cross-checked for compatibility with other packages. #1735 is a fairly gross deviation from what the data should have been, for which I put a hack into #1738 better demonstrates the fundamental issue: JSON supports multiple data types and hierarchical data, whereas we internally store any non-compulsory header data as a In terms of this specific case, one might ask: Given these data contain one entry per volume, and other header entries containing one entry per volume (e.g. Ideally we should have a unit test that imports a pre-prepared JSON file (with as many nasties as we wish to support) to an empty header, exports it, then raw diffs the JSON contents. |
|
Aborting; given magnitude of issues with JSON data handling, will not be resolving such on |
Extracted changes from #1735 in order to apply to dev. In dwifslpreproc, perform a robust parsing of slice timing information from the image header. During DICOM import, separate slice timings by space rather than comma; although the results of JSON export should be the same following #1771 / #1843, use of space delimiter for vector data is more consistent with other multi-dimensional data handling in image headers.
Apparently converting data via
dcm2niixand converting tomifwith a JSON import results in the slice timings being represented as multiple separate header entries, rather than the single entry with a comma-separated list that a directmrconvertcall produces. This means a call todwipreprocfails when used with slice to vol, with error message:Note there's another fix here for that python error...
This pull request modifies the handling of the import of JSON arrays, so that:
That last behaviour might need to be revised depending on whether there are any instances where we would reasonably be expected to handle a mix of elements and arrays. Alternatives are:
But I'll admit I don't know enough about BIDS to make an informed decision here. I just expect that if we ever encounter a BIDS entry that consists of such a mix, we'll have trouble interpreting it correctly anyway...