test_against_matlab_results fails with current nibabel master #150

Closed
yarikoptic opened this Issue Apr 27, 2012 · 4 comments

Projects

None yet

2 participants

Owner
(mismatch 100.0%)
 x: array([ 3626.27917834,  3626.69771242,  3630.80532213,  3645.35550887,
        3654.78221289,  3644.59570495,  3638.56652661,  3633.89402428,
        3637.71031746,  3636.67600373,  3642.13865546,  3637.66036415,...
 y: array([ 3626.28062776,  3626.69561251,  3630.80490506,  3645.35619694,
        3654.78326495,  3644.59424156,  3638.56654222,  3633.8924367 ,
        3637.70911359,  3636.67404558,  3642.1392554 ,  3637.66151778,...

(Pdb) 
 77         yield assert_array_almost_equal(
 78             results['volume_means'],
 79  ->         tsd_results['g'])
 80         yield assert_array_almost_equal(
 81             results['volume_mean_diff2'],
 82             tsd_results['imgdiff'])
 83         yield assert_array_almost_equal(
 84             results['slice_mean_diff2'],
 85             tsd_results['slicediff'])
 86         # next tests are from saved, reloaded volumes at 16 bit integer
 87         # precision, so are not exact, but very close, given that the mean


(Pdb) print x
[ 3626.27917834  3626.69771242  3630.80532213  3645.35550887  3654.78221289
  3644.59570495  3638.56652661  3633.89402428  3637.71031746  3636.67600373
  3642.13865546  3637.66036415  3645.53594771  3640.20564893  3635.80462185
  3635.37441643  3635.86204482  3638.71778711  3631.18137255  3630.3181606 ]
(Pdb) print y
[ 3626.28062776  3626.69561251  3630.80490506  3645.35619694  3654.78326495
  3644.59424156  3638.56654222  3633.8924367   3637.70911359  3636.67404558
  3642.1392554   3637.66151778  3645.53475163  3640.20711904  3635.80922411
  3635.37452511  3635.8637199   3638.71975003  3631.18384092  3630.31958271]
(Pdb) print x-y
[ -1.44942084e-03   2.09990419e-03   4.17070396e-04  -6.88070788e-04
  -1.05206606e-03   1.46338964e-03  -1.56129113e-05   1.58757762e-03
   1.20386751e-03   1.95815817e-03  -5.99933494e-04  -1.15363877e-03
   1.19608201e-03  -1.47011823e-03  -4.60225711e-03  -1.08677188e-04
  -1.67508035e-03  -1.96291792e-03  -2.46836842e-03  -1.42211306e-03]

Owner

Yes, I changed the nibabel default scaling of integer arrays to use float32 (as stored in the header) instead of float64. SPM uses float64, and this is a check against SPM. It's still np.allclose close though. I persuaded myself that float32 scaling was at least as accurate for float -> integer on disk -> loading from disk round trips, but I will go back over that before signing off on this one.

Owner

I checked - there's a very small advantage for float64 in round trip. The checks also revealed a minor inconsistency in the way nibabel chose the scaling type; fixed here:

nipy/nibabel#114

Because of another careless choice in nibabel much earlier on, this pull request accidentally restored float64 scaling and makes this test pass again. That's fine I think.

Owner

is this still alive?

Owner

Nope - thanks for reminding me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment