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

Grab Readout Dir from a more intuitive JSON field #91

Open
audreymhoughton opened this issue Apr 21, 2023 · 0 comments
Open

Grab Readout Dir from a more intuitive JSON field #91

audreymhoughton opened this issue Apr 21, 2023 · 0 comments

Comments

@audreymhoughton
Copy link
Contributor

audreymhoughton commented Apr 21, 2023

def get_readoutdir(metadata):
    """
    get readout direction from bids metadata.  !!Note that this method only
    applies where the nifti orientation is RAS!!
    :param metadata: grabbids metadata dict.
    :return: unwarp dir in cartesian (world) coordinates.
    """
    iopd = metadata['ImageOrientationPatientDICOM']
    ped = metadata['InPlanePhaseEncodingDirectionDICOM']
    # readout direction is opposite the in plane phase encoding direction
    if ped == 'ROW':
        readoutvec = iopd[3:]
    elif ped == 'COL':
        readoutvec = iopd[:3]
    else:
        raise ValueError('phase encoding direction not recognized: ' + ped)

    # convert 3-vector to symbolic unit vector
    i = max([0, 1, 2], key=lambda x: abs(readoutvec[x]))
    readoutdir = ['x', 'y', 'z'][i]
    # TODO: Fix readoutdir algorithm. Arbitratily switched pos to neg for ABCD.
    if readoutvec[i] > 0:
        readoutdir += '-'

    return readoutdir

There should be a field in the sidecar JSONs that just has this information instead of determining it in this roundabout way. We need it to be grabbed from elsewhere for HCP-YA.

Comment from @ericfeczko: If you have the phase encoding direction and the in plane axis, the readout direction can be inferred from the two.

@audreymhoughton audreymhoughton changed the title Grab Readout Dir from the proper JSON field Grab Readout Dir from a more intuitive JSON field Apr 21, 2023
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

No branches or pull requests

1 participant