Hi Graham,
It seems that the programs that will rotate a volume do not have an
option for doing "nearest neighbor" interpolation, as you have seen.
There are two options that I can think of to try, but neither is
particularly nice. The fast but inaccurate way would be to just rotate
the volume, and then truncate every real number to an integer, via:
3dcalc -a input_dset+orig -expr 'int(a)' -prefix output_dset
But that is not accurate (if you have only 3's and 19's, then some
truncation to 8 (or whatever) gives you a value that is not in your
dataset to begin with).
The more accurate work-around, which is more difficult to do, is to
break the mask into separate bricks first, rotate each one, then set
all values in the new brick to the proper value, and then put them
together.
The hard part there (beyond writing the shell script to do the rest
of it) is putting the bricks back together. Some output voxels will
be set in more than one dataset, so you would have to decide what
value to give them. If you chose "min", for example, then you could
put them together with:
3dcalc -a d1+orig -b d2+orig .... -expr '(orstat(1,a,b,c,...))' -prefix OUT
Note that orstat() returns the ordered value of the inputs, in
ascending order. So if you have 5 inputs, a through e, then
orstat(1,a,b,c,d,e) is the minimum and orstat(5,a,b,c,d,e) is the
maximum.
Another 3dcalc function to consider is median(a,b,c,...), but then
you would probably have to worry about zeros.
Please see "3dcalc -help" for more information.
- rick