alexis-roche/nipy — pull request #2 by bpinsard (2013-03-20 08:39:36+00:00)
Title: Bug/groupwise registration

It seems that the way time interpolation is carried is wrong for interleaved at least.
So if I got it right, what we want from this function (mainly for scanner_time in Image4D) is an offset in time coordinates for sampling using 4D cubic splines.
here is an example of what it does:
```
>tr=3
>n_slices=48
>slice_order=range(0,n_slices,2)+range(1,n_slices,2)
>interp = gr.interp_slice_order(np.arange(0,n_slices),slice_order)
>interp
array([ 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32,
34, 36, 38, 40, 42, 44, 46, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19,
21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47])
>interp*float(n_slices)
array([ 0. , 0.04166667, 0.08333333, 0.125 , 0.16666667,
0.20833333, 0.25 , 0.29166667, 0.33333333, 0.375 ,
0.41666667, 0.45833333, 0.5 , 0.54166667, 0.58333333,
0.625 , 0.66666667, 0.70833333, 0.75 , 0.79166667,
0.83333333, 0.875 , 0.91666667, 0.95833333, 0.02083333,
0.0625 , 0.10416667, 0.14583333, 0.1875 , 0.22916667,
0.27083333, 0.3125 , 0.35416667, 0.39583333, 0.4375 ,
0.47916667, 0.52083333, 0.5625 , 0.60416667, 0.64583333,
0.6875 , 0.72916667, 0.77083333, 0.8125 , 0.85416667,
0.89583333, 0.9375 , 0.97916667])
```
which means that the second slice for example, acquired at half tr is applied a very small offset.
with this fix it gives:
```
>interp = gr.interp_slice_order(np.arange(0,n_slices),slice_order)
>interp
array([ 0, 24, 1, 25, 2, 26, 3, 27, 4, 28, 5, 29, 6, 30, 7, 31, 8,
32, 9, 33, 10, 34, 11, 35, 12, 36, 13, 37, 14, 38, 15, 39, 16, 40,
17, 41, 18, 42, 19, 43, 20, 44, 21, 45, 22, 46, 23, 47])
>interp/float(n_slices)
Out[207]:
array([ 0. , 0.5 , 0.02083333, 0.52083333, 0.04166667,
0.54166667, 0.0625 , 0.5625 , 0.08333333, 0.58333333,
0.10416667, 0.60416667, 0.125 , 0.625 , 0.14583333,
0.64583333, 0.16666667, 0.66666667, 0.1875 , 0.6875 ,
0.20833333, 0.70833333, 0.22916667, 0.72916667, 0.25 ,
0.75 , 0.27083333, 0.77083333, 0.29166667, 0.79166667,
0.3125 , 0.8125 , 0.33333333, 0.83333333, 0.35416667,
0.85416667, 0.375 , 0.875 , 0.39583333, 0.89583333,
0.41666667, 0.91666667, 0.4375 , 0.9375 , 0.45833333,
0.95833333, 0.47916667, 0.97916667])
```
which seems more correct.

also interpolation between 2 slices having half tr offset
```
>interp = gr.interp_slice_order(np.arange(0,1.1,.1),slice_order)
>interp/float(n_slices)
array([ 0. , 0.05, 0.1 , 0.15, 0.2 , 0.25, 0.3 , 0.35, 0.4 ,
0.45, 0.5 ])
```
is this correct?