Hi Robin,

There seem to be multiple things going on here. Such a simple thing is more complicated than it ought to be…

First, and correct me if I am wrong, but you want the resample to keep the original values at the original locations, exactly, is that right? Moving off grid would allow interpolation and blurring, and I expect that you do not want that.

And notably, these datasets start with an even number of voxels. This somewhat breaks what you might want.

Imagine having a 4 voxel dataset at coords -1, 0, 1, 2, that you want to downsample to a 2 voxel dataset. Clearly, one of the endpoints must go. Either you would keep coords -1,1 or 0,2.

If there were an odd number of coordinates, 3dresample could do it (without a -master). So I suggest to first use 3dZeropad to add or remove a slice (in every direction), then use 3dresample to double the dimensions.

A second point is that if some dimensions are not exactly one, that is okay. But the result still must have *exactly* twice the voxel size of the original. Note that the ‘3dinfo’ extent lines do not give you the exact voxel dimensions, they are truncated to 3 decimal places. “3dAttribute DELTA DATASET” will output the more precise sizes (which sometimes cannot even be stored or shown exactly - we cannot store 2.1 exactly in binary, for example).

A third issue might come from running 3dresample. By default, that tries to preserve the FOV. But in this case (requiring odd dimensions), you want to preserve the exact voxel centers, but double the voxel sizes. That means using ‘-bound_type SLAB’, rather than the default ‘-bound_type FOV’ (which matches the afni GUI’s behavior). Using this on an odd dimension data set, along with -dxyz with exactly double the voxel dimensions, should downsample the dataset by a factor of 2 (with an extra point) in each direction.

This would preserve the original values.

if you start with datasets on the same grid, this would need to be done only once. If they are in orig space and on different grids, life gets harder.

A last issue is obliquity. If resampling seems to move the data (in the GUI), it is oblique. That is a discrepancy between the viewer and the real coordinates. The afni GUI does not want to alter the data values shown via interpolation, so it truncates to a cardinal grid. Any 3dresample step will throw away the obliquity matrix. What to do about this depends on exactly what you plan to do with this data.

Does this seem reasonable?