Hi,
The easiest way to do this is by using fslsplit to generate individual
3D volumes and then write a script that sums 4 at a time, then
use fslmerge to put this back into a 4D volume.
The essential part of the script you'd need is:
im="myimagename"
fslsplit $im
maxn=`fslval $im dim4`;
n=0;
m=0;
while [ $n -lt $maxn ] ; do
n1=`echo $n + 1 | bc`;
n2=`echo $n + 2 | bc`;
n3=`echo $n + 3 | bc`;
fslmaths vol`zeropad $n 4` -add vol`zeropad $n1 4` -add vol`zeropad
$n2 4` -add vol`zeropad $n3 4` -div 4 newvol`zeropad $m 4`
n=`echo $n + 4 | bc`;
m=`echo $m + 1 | bc`;
done
fslmerge -t "newimagename" newvol*
Once this is done you can delete all the vol* and newvol* images.
All the best,
Mark
On 8 Dec 2008, at 16:40, Wouter Teeuwisse wrote:
> Dear all,
>
> For analysis of datasets that consist of a single slice with 900
> volumes, I want
> to average the signal over time for volume sub-sets. For example, I
> want to
> get the average of vol. 1-4, 5-8, .... , 897-900. Would be nice when
> the
> result is a single file with 225 volumes ;-)
> Is there anyone out there who can help me with this?
>
> Thanks in advance,
>
> Wouter Teeuwisse
>
|