-
Notifications
You must be signed in to change notification settings - Fork 262
Reset of qform and sform codes on save #55
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
Comments
Hi Matthew, It seems like you guys want to have
I personally think any consistency checks should be done when the affine gets modified and not on write because the following seems really unintuitive to me and I think it'll be confusing to users.
I'm willing to spend some time on this, but it would help me to know how many ways the affine on an 'image' can get changed. |
Hi Bago, On Mon, Dec 19, 2011 at 8:02 PM, MrBago
Thanks for thinking about this. The problems are two-fold: The affine is separate from the header in general. For example an We can't tell in general when the affine is modified. Consider: img = load('some_image.nii') See you, Matthew |
Ok, now I understand the scope of the problem better. I'm sure a more complete and elegant solution is possible, but maybe the simplest thing we can do is to create a keyword for the save function which will turn on/off update_header(). It's not that pretty but it'll allow a user to manually manipulate the header and make sure those values get used durring the save. Let me know what you think. |
On Wed, Dec 21, 2011 at 1:06 AM, MrBago
I'm a bit reluctant to add keywords to 'save' just on the basis that It would not be hard as things stand to prevent the affine updating |
On 12/22/2011 05:43 AM, Matthew Brett wrote:
Bago |
Shouldn't the Nifti1 update_header just harmonize the affine to the sform and not touch the qform or the codes? Let the users set these header specific bits through the header object. |
After thinking about this some more, my above suggestion does not work if the sform_code is 0 (since it would never get updated). The approach in the master branch (do nothing if the affine matches the header.get_best_affine()) seems like a good solution. I do wonder if the qform should really be getting overwritten when the affines don't match, but at least this can be avoided. |
On Tue, Feb 28, 2012 at 8:03 PM, moloney
Thanks for thinking about this. The reason it works as it does is that I imagine some situation like this:
I'm imagining then that you'd want to set both of sform and qform -
and I want to set this new affine into the image:
Now, I could mean - 'only set the sform to this affine leave the qform You can set just the sform (not the qform) with:
because then the update_header check will see that the sform and |
Unfortunately I'm still running into issues with this qform/sform stuff. Here is the issue:
I think it's happening because the affine is float64 and the sform is float32:
I've resorted to the following in order to be able to set the qform to match (as much as possible) the sform:
|
Seems like the code should be using something like numpy.allclose instead of comparing floats directly. |
On Thu, Mar 8, 2012 at 11:47 AM, moloney
Sounds reasonable - care to review : #90 ? Thanks a lot |
See discussion at #90 about how to solve sform / qform problem in a more general way. |
Closed by the pull request above |
Discussion at nipy#55. Because affine in nifti1 stored as float32, using == to check if affine has changed would give false positives, comparing to float64 input. Brendan Moloney kindly suggested allclose fix.
Andrew Connolly pointed out the following misbehavior:
The text was updated successfully, but these errors were encountered: