def test_reorder_input(): incs, outcs, map, inv = voxel_to_world() cm = CoordinateMap(map, incs, outcs, inv) recm = reorder_input(cm, 'jki') yield assert_equal, recm.input_coords.coord_names, ('j', 'k', 'i') yield assert_equal, recm.output_coords.coord_names, outcs.coord_names yield assert_equal, recm.input_coords.name, incs.name+'-reordered' yield assert_equal, recm.output_coords.name, outcs.name # default reverse reorder recm = reorder_input(cm) yield assert_equal, recm.input_coords.coord_names, ('k', 'j', 'i') # reorder with order as indices recm = reorder_input(cm, [2,0,1]) yield assert_equal, recm.input_coords.coord_names, ('k', 'i', 'j')
def test_iter(): img = load_image(funcfile) # flip to time first version so this makes sense from nipy.core.reference.coordinate_map import reorder_input arr = np.asarray(img).T coordmap = reorder_input(img.coordmap) img_t1 = Image(arr, coordmap) slice_shape = (arr.shape[0],) + arr.shape[2:] j = 0 for i, d in fmri_generator(img_t1): j += 1 yield nose.tools.assert_equal, d.shape, slice_shape del(i); gc.collect() yield nose.tools.assert_equal, j, 3