Dear SPMers,
I was wondering why the processing of a 2nd level design with around 20 files was running very
slow on a well equipped PC with 2GB RAM. Thus, I have applied the profile function of matlab and
noticed that most of the computation time was wasted in only two lines (581/582) of spm_spm.m
(spm2 2.26) with no extensive calculations. These two lines contain the calculation of the voxel
indices (depending on the blocksize):
I = [1:blksz] + (bch - 1)*blksz; %-voxel indices
I = I(I <= xdim*ydim); %-truncate
At a first view these lines don't contain any time consuming computations. However, the
parameter blksz depends on the pre-defined maxmem parameter in spm_defaults: According to
my RAM I have set this to 2^31 and this leads to a huge blksz of around 1*e7 for 20 scans:
blksz = ceil(MAXMEM/8/nScan); %-block size
In this case of a very large blocksize the colon operation in line 581 takes a very long time. A
quick workaround is to replace lines 581/582 in spm_spm.m by:
if blksz > xdim*ydim
I = 1:(xdim*ydim);
else
I = [1:blksz] + (bch - 1)*blksz; %-voxel indices
I = I(I <= xdim*ydim); %-truncate
end
This accelerated the estimation of a 2nd level model with 20 files by a factor of 2-3 and should
generally increase speed for the estimation of 2nd level models if you have set your maxmem
value to very large values (>= 2^29). The spm_spm function in spm5 should be also affected by
this effect.
Best regards,
Christian
--
____________________________________________________________________________
Christian Gaser, Ph.D.
Assistant Professor of Computational Neuroscience
Department of Psychiatry
Friedrich-Schiller-University of Jena
Philosophenweg 3, D-07743 Jena, Germany
Tel: ++49-3641-935805 Fax: ++49-3641-935280
e-mail: [log in to unmask]
http://dbm.neuro.uni-jena.de
|