Skip to content

Fixes to slice timing handling#1735

Closed
Lestropie wants to merge 7 commits intomasterfrom
slice_timing_fix
Closed

Fixes to slice timing handling#1735
Lestropie wants to merge 7 commits intomasterfrom
slice_timing_fix

Conversation

@Lestropie
Copy link
Member

It seems a bit of a mess has accumulated with respect to JSON data and the handling thereof, which is now having downstream effects at bids-apps/MRtrix3_connectome#59.

In addition to this fix for master, further modifications will be required on dev to get JSON data handling working properly:

  • The behaviour of mrinfo -json_keyval / mrinfo -json_all and mrconvert -json_export differs; the latter handles rotation of phase encoding / slice encoding directions while the former do not.

  • While mrinfo -json_all appropriately writes basic header information in their native data format (e.g. numerical matrix for header transform), the contents of keyval() are all written as strings. mrinfo was intended to convert numerical matrix data appropriately, but that seems to not be working right now. It's also the case that simple things like integer values may be better written to JSON as integer values rather than the string representations thereof.

- DICOM import: Write slice timing data using space as delimiter rather than comma; also restrict floating-point precision to that of the precision of the data provided.
- dwipreproc: When importing slice timing data, make various attempts to coerce the data into a list of floats.
@Lestropie Lestropie added the bug label Sep 25, 2019
@Lestropie Lestropie requested a review from a team September 25, 2019 02:00
@Lestropie Lestropie self-assigned this Sep 25, 2019
This was referenced Sep 25, 2019
jdtournier and others added 2 commits November 20, 2019 12:44
Rather than setting up 'basestring' depending on Python 2 or 3 in order to test whether or not a variable is of string type, rely on the 'six' module.
jdtournier
jdtournier previously approved these changes Dec 4, 2019
@jdtournier
Copy link
Member

I have to admit I've not had a chance to get my head around these issues to comment meaningfully. I assume this fix is necessary to fix issues on master. But presumably this doesn't fix #1771...?

@Lestropie
Copy link
Member Author

But presumably this doesn't fix #1771...?

Trouble is that there's three different PRs (#1735, #1738, #1771), all dealing with a common underlying fundamental issue but at different levels and with different scopes. Since #1771 is not mine I don't 100% understand exactly what the overlap is there, and there's also the issue of master vs. dev changes. So I'll see how far I can get here in disentangling them.

  • This PR is specifically about handling of slice timing data; in particular for dwipreproc to be able to handle JSON data that were not generated by MRtrix3. On current master, the slice timing information extracted from DICOM is not written in the appropriate format, but dwipreproc was programmed to read the data from this inappropriate format; hence the incompatibility with other DICOM converters. So this change does two things:

    • Fix specifically the saving of slice timing information from DICOM into the file header, so that it is then formatted correctly when written to JSON.

    • Make the import of slice timing information in dwipreproc as robust as possible, so that it is maximally likely to be able to correctly import such information no matter what software or version of such it was generated from.

  • JSON handling changes #1738 is intended to be a more all-encompassing "fix" of JSON import and export. It's not addressing any specific observation of any particular erroneous behaviour, but trying to make the import / export "behave as expected" in all scenarios.

  • JSON: import simple array as a single header entry #1771 is where I get slightly stuck:

    • It's not clear whether the issue reported there is over and above what was rectified in JSON handling changes #1738. I did quite a bit of testing for that one, so would be slightly surprised if there was still an outstanding issue after that changeset.

    • If it is purely a matter of 1D array data being transposed, then I don't think there is any issue with collapsing into a single header entry. But I would want test data to run against JSON handling changes #1738 to confirm such, since I already had to muck about quite a bit there with how string header data and JSON import / export interact.

    • I do think there is an issue with using comma delimiters to write such data to the header at import stage. Comma-delimited slice timing information in the header gets exported to JSON as a list of lists, not a 1D numerical data array.

I suspect we need to have some exemplar data, on which we can test both dev and master, in order to determine whether or not there are further changes that need to be pushed to master to fix outright bad behaviour, as well as whether #1771 provides a necessary change to dev over and above #1738.

@Lestropie Lestropie mentioned this pull request Dec 11, 2019
@Lestropie
Copy link
Member Author

Aborting; given magnitude of issues with JSON data handling, will not be resolving such on master, instead relying on imminent tag update that will include changes in #1843.

@Lestropie Lestropie closed this Jan 8, 2020
@Lestropie Lestropie deleted the slice_timing_fix branch January 11, 2020 09:21
Lestropie added a commit that referenced this pull request Feb 5, 2020
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants