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

dwifslpreproc & mrcat: Strides fix #2806

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Lestropie
Copy link
Member

Traced issue back to here, which ties all the way back to #1541.

Was trying to diagnose an issue with improper correction of susceptibility distortions, and this is the first issue I came across (which unfortunately for me is likely not the only issue...). applytopup was doing absolutely nothing to the input data, meaning that the eddy brain mask was aligned with the distorted data, whereas the whole intention of using applytopup is to produce a processing mask that approximates where the brain will be at completion of processing. It turns out that this is because dwifslpreproc was telling applytopup that the phase encoding directions were "k" and "k-", and presumably internally applytopup is deeming this unacceptable and either zeroing out that component of the phase encoding vectors or just code branching to a straight copy-input-to-output. Unfortunately it doesn't provide any indication of this at the terminal.

The stride manipulation within concatenate<vector<Header>>() seems to have been outright incorrect, so I don't think that it should cause any problems, but before merging I might make the same change on dev and run the additional PNG tests in #2713 just to make sure it doesn't have any unintended consequences (existing CI should cover anything else).

- The strides in the aggregate header are expected to already be in absolute rather than symbolic; as such, the former manipulation was inappropriate.
- Only perform manual manipulation of axis strides relative to the hedaer of the first input image in the scenario where concatenation is adding a new axis; if concatenation is occurring across an existing axis, do not perform any manipulation.
Prior to 41c02e9, erroneous phase encoding information was being exported to applytopup:
- The padded DWI series erroneously possessed different strides to the original DWI series.
- The text files to be used by applytopup were being generated by a command that did not explicitly manipulate the strides of the image, whereas the input images provided to applytopup did involve that manipulation.
In addition, it was discovered that applytopup was not performing any manipulation of the data if the phase encoding axis was indicated to be on the third spatial axis; this turns out to have been doing nothing as opposed to an erroneous correction, but given this observation, a check has nevertheless been added to issue a warning where this occurs.
@Lestropie Lestropie requested a review from a team February 15, 2024 01:26
@Lestropie Lestropie self-assigned this Feb 15, 2024
@Lestropie Lestropie marked this pull request as draft February 15, 2024 04:02
Lestropie added a commit that referenced this pull request Feb 15, 2024
- Fix erroneous modification of strides upon header concatenation; this replicates the fix included in 41c02e9 as part of #2806, but is necessary for the suite of fixes here to work. Note that this affects mrcat in addition to multi-image format handling.
- Fix setting of strides upon PNG read.
- Expand testing of PNG handling. Evaluation of read and write functionality is performed separately, with the reference data fully visible and verifiable within the test data repository. Some previous tests bundled read and write testing together, which obscured the erroneous intermediate interpretation.
@Lestropie
Copy link
Member Author

As best as I can ascertain without spending an inordinate amount of time on it, I believe that the bug in 41c02e9 was cancelling out a bug in PNG handling, such that rectification of the former exposes the latter. Plan is to wait for merge of #2713 to master before proceeding here.

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

Successfully merging this pull request may close these issues.

1 participant