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

Calculate PatientOrientation #1027

Open
FlMart opened this issue Jun 17, 2021 · 2 comments
Open

Calculate PatientOrientation #1027

FlMart opened this issue Jun 17, 2021 · 2 comments

Comments

@FlMart
Copy link

FlMart commented Jun 17, 2021

Hi everyone!

When converting a NIFTI to a valid DICOM, header fields have to be set and it would be nice to have a function to calculate a DICOM's PatientOrientation attribute given its ImageOrientationPatient attribute. Alternatively, according to your documentation, an affine matrix could also be used as input.

I haven't found such a method in Nibabel yet but I figured it would fit quite well alongside the nibabel.orientations methods. Is this something that you would consider worth implementing? Am I missing an already existing way of creating this string?

@effigies
Copy link
Member

I think you probably want aff2axcodes. Unless I'm misunderstanding...

@FlMart
Copy link
Author

FlMart commented Jun 17, 2021

As far as I understood it, the PatientOrientation requires multiple letters if the vector lies right between two axes, so with RAS labeling, a vector of x = [1,1,0] should return RA, which does not seem to be case for me. With the following code, what I get is ('R', 'A', 'S') while I would expect ('RI', 'RA', 'PS'):

aff1 = np.asarray([
    [1, 1, 0, 0],
    [0, 1, -1, 0],
    [-1, 0, 1, 0],
    [0, 0, 0, 1],
])
print(nib.aff2axcodes(aff1, (("L", "R"), ("P", "A"), ("I", "S"))))

Edit: There is a resource for C++ code that seems to provide the functionality that I want along with some better explanation.

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

2 participants