-
Notifications
You must be signed in to change notification settings - Fork 295
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
FIX: Clarify phase encoding direction, rather than axis #2302
Conversation
fmriprep/interfaces/reports.py
Outdated
'i': 'Right-Left', | ||
'j-': 'Anterior-Posterior', | ||
'j': 'Posterior-Anterior' | ||
}.get(self.inputs.pe_direction, 'MISSING - Assuming Anterior-Posterior') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only true for LAS images. We need the orientation of the original image, to be certain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point - I've added a commit to consider LAS/RAS. How extensive do you think our support should be for different orientations?
e452abe
to
7c5867d
Compare
We can get images in any orientation. Need something like: def get_world_pedir(img, pe_direction):
axes = (("Right", "Left"),
("Anterior", "Posterior"),
("Superior", "Inferior"))
ax_idcs = {"i": 0, "j": 1, "k": 2}
ornt = ''.join(nb.aff2axcodes(img.affine))
axcode = ornt[ax_idcs[pe_direction[0]]]
inv = pe_direction[1:] == "-"
for ax in axes:
for flip in (ax, ax[::-1]):
if flip[not inv].startswith(axcode):
return "-".join(flip)
raise ValueError(f"Cannot determine world direction of phase encoding. Orientation: {ornt}; PE dir: {pe_direction}") |
Incidentally, for testing, I've recently written this, which allows you to generate an image of any orientation: def generate_image(params):
dataobj = np.zeros(params["shape"], params["dtype"])
affine = np.eye(4)
rot = ornt.inv_ornt_aff(ornt.axcodes2ornt(params["orientation"]), (1, 1, 1))
affine[:3, :3] = np.diag(params["zooms"][:3]) @ np.linalg.inv(rot[:3, :3])
return nb.Nifti1Image(dataobj, affine) (It's intended for generating datasets on the fly, which is why it's so parameterized.) |
7c5867d
to
12d21b8
Compare
26b128c
to
fd932c9
Compare
Backport of niprepsgh-2302 to 20.2.x series Co-authored-by: Mathias Goncalves <mathiasg@stanford.edu> Co-authored-by: Christopher J. Markiewicz <markiewicz@stanford.edu>
BOLD runs'
FunctionalSummary
nodes were returning PE-Axis instead of PE-Direction.