Skip to content

[ENH] Specify that dir-<label> should correspond to PhaseEncodingDirection #2097

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

effigies
Copy link
Collaborator

@effigies effigies commented Apr 4, 2025

The BIDS convention is to use dir-{AP,PA,LR,RL} for phase-encoding directions in MRI filenames, as well as PhaseEncodingDirection in JSON sidecars. This duplication has the potential for inconsistency or multiple interpretations of the meaning of AP.

This PR aims to clarify the meaning of dir-<label> when its value matches a cardinal axis, and clearly state that this meaning SHOULD be consistent with the PhaseEncodingDirection.

Comment on lines +87 to +91
If the `<label>` is `AP`, `PA`, `LR`, `RL`, `SI`, or `IS`,
then the `"PhaseEncodingDirection"` SHOULD correspond to the data
axis that most closely aligns with the cardinal direction and orientation.
For example, `dir-AP` for an image in RAS+ orientation SHOULD have
`"PhaseEncodingDirection": "j-"`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If the `<label>` is `AP`, `PA`, `LR`, `RL`, `SI`, or `IS`,
then the `"PhaseEncodingDirection"` SHOULD correspond to the data
axis that most closely aligns with the cardinal direction and orientation.
For example, `dir-AP` for an image in RAS+ orientation SHOULD have
`"PhaseEncodingDirection": "j-"`.
It is RECOMMENDED not to encode the actual phase-encoding direction
with the `<label>` to preempt conflicts with the `"PhaseEncodingDirection"`
metadata.
For example, this can be achieved by using indexes: `dir-0`, `dir-1` or
labels without specifying the direction such as `dir-reference` and `dir-reversed`.
Nonetheless, if `<label>` encodes the metadata by taking values such as
`AP`, `PA`, `LR`, `RL`, `SI`, or `IS`,
then the `"PhaseEncodingDirection"` SHOULD correspond to the data
axis that most closely aligns with the cardinal direction and orientation.
For example, `dir-AP` for an image in RAS+ orientation SHOULD have
`"PhaseEncodingDirection": "j-"`.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is introducing a new RECOMMENDation that entity values should not indicate the values of the associated metadata. This is not generally stated in BIDS, and runs counter to common usage; if you would like to make that proposal, I would probably start an issue or a mailing list thread to see if there's much support for it.

I don't want to try to introduce it here. Beyond it being out-of-scope for this fairly narrow attempt to warn on inconsistency, it would introduce a warning even when the metadata is consistent, which seems user-hostile.

That said, we can expand the previous "Please note that the <label> does not need to match the actual value of the field." into a brief discussion of non-axis-code conventions:

Suggested change
If the `<label>` is `AP`, `PA`, `LR`, `RL`, `SI`, or `IS`,
then the `"PhaseEncodingDirection"` SHOULD correspond to the data
axis that most closely aligns with the cardinal direction and orientation.
For example, `dir-AP` for an image in RAS+ orientation SHOULD have
`"PhaseEncodingDirection": "j-"`.
Labels need not follow any particular convention,
and JSON metadata MUST take precedence in interpreting an image.
Generic labels, such as `dir-reference` and `dir-reversed` avoid any possible inconsistency.
`dir-j0` and `dir-j1` can indicate `"PhaseEncodingDirection": "j"` and `"j-"` (or vice versa),
identifying the phase-encoding axis while avoiding indicating polarity.
To avoid inconsistency, if the `<label>` is `AP`, `PA`, `LR`, `RL`, `SI`, or `IS`,
then the `"PhaseEncodingDirection"` SHOULD correspond to the data
axis that most closely aligns with the cardinal direction and orientation.
For example, `dir-PA` and `dir-AP` for an image in RAS+ orientation SHOULD have
`"PhaseEncodingDirection": "j"` and `"j-"`, respectively.

issue:
code: NIFTI_PE_DIRECTION_CONSISTENCY
message: |
Phase encoding direction is inconsistent with `dir-` entity.
Copy link
Collaborator

@oesteban oesteban Apr 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not make this a confident statement:

Suggested change
Phase encoding direction is inconsistent with `dir-` entity.
Phase encoding direction may be inconsistent with `dir-` entity.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not opposed to this, but I don't understand the case where this is triggered and the direction isn't inconsistent. We can expand on this text to explain why it's inconsistent in general terms, though we don't have a way to vary the text based on the values of fields.

Copy link
Collaborator

@oesteban oesteban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great to make the situation better without introducing backward incompatible changes. I made some suggestions to be more explicit about what the problem is and providing examples, that said, the phrasing will likely require improvements.

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