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

'measurement frame' should be double matrix #76

Closed
tashrifbillah opened this issue Jan 17, 2019 · 4 comments
Closed

'measurement frame' should be double matrix #76

tashrifbillah opened this issue Jan 17, 2019 · 4 comments

Comments

@tashrifbillah
Copy link
Contributor

tashrifbillah commented Jan 17, 2019

Guys, looks like we have a problem here. The measurement frame returned should be a double matrix, not integer. https://github.com/mhe/pynrrd/blob/master/nrrd/reader.py#L103

We need the exact measurement frame defined in the NRRD header. See the following returned by unu head file.nrrd:

measurement frame: (-1,0,-0.0023) (-0.00029999999999999997,-0.98850000000000005,0.1512) (-0.0022000000000000001,0.1512,0.98850000000000005)

However, due to typecasting to int, nrrd.read( ) is returning just

hdr['measurement frame']
array([[-1,  0,  0],
       [ 0,  0,  0],
       [ 0,  0,  0]])

Try out the following, you will notice the difference:

abc= np.array([[-1,0,-0.0023], [-0.00029999999999999997,-0.98850000000000005,0.1512], [-0.0022000000000000001,0.1512,0.988500000000
    ...: 00005]], dtype= 'double')

print(abc)
array([[-1.000e+00,  0.000e+00, -2.300e-03],
       [-3.000e-04, -9.885e-01,  1.512e-01],
       [-2.200e-03,  1.512e-01,  9.885e-01]])

ghi= np.array([[-1,0,-0.0023], [-0.00029999999999999997,-0.98850000000000005,0.1512], [-0.0022000000000000001,0.1512,0.988500000000
    ...: 00005]], dtype= 'int')

print(ghi)
array([[-1,  0,  0],
       [ 0,  0,  0],
       [ 0,  0,  0]])

I think we must make it a double matrix like other filed types set there.
cc: @ihnorton

@ihnorton
Copy link
Contributor

Grr. This was fixed in #47 and broken in
#57 -- the test didn't catch it because the float (identity) array still compares as equal to the int one.

@ihnorton
Copy link
Contributor

Fixing

ihnorton added a commit to ihnorton/pynrrd that referenced this issue Jan 17, 2019
@tashrifbillah
Copy link
Contributor Author

Thanks!

@addisonElliott
Copy link
Collaborator

Sorry, that's on me! I don't use the measurement frame much in my day to day, thus I didn't bother checking it. Thanks 👍

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

3 participants