From: Zachary Cohen on
Hello Matlab Users,
I am running a permutation test on some scalp EEG data, which for every subject I run requires from 1000 - 5000 permutations. Each permutation includes a call to 'glmfit.m' , which accounts for about 98% of the runtime. Given that 1000 permutations for 1 subject takes about 17 hours, I was wondering if there was anything I can do to speed up glmfit.m? I've taken care of the basic stuff, preallocating memory, vectorization, etc, but I'm wondering if anyone has gotten into the guts of 'glmfit.m' and sped it up?
Best,
- Zachary Cohen
Computational Memory Lab, Vanderbilt University
From: Peter Perkins on
On 3/4/2010 12:47 PM, Zachary Cohen wrote:
> Hello Matlab Users,
> I am running a permutation test on some scalp EEG data, which for every
> subject I run requires from 1000 - 5000 permutations. Each permutation
> includes a call to 'glmfit.m' , which accounts for about 98% of the
> runtime. Given that 1000 permutations for 1 subject takes about 17
> hours, I was wondering if there was anything I can do to speed up
> glmfit.m? I've taken care of the basic stuff, preallocating memory,
> vectorization, etc, but I'm wondering if anyone has gotten into the guts
> of 'glmfit.m' and sped it up? Best,

It sounds like what you want to do is use the profiler to determine if the overhead of argument processing and error checking and so on in GLMFIT is contributing significantly to the execution time. My guess is probably not, but if it turns out that it is, you can make yourself a local copy of GLMFIT and strip out all the error checking and so on that you don't want.

The guts of GLMFIT is the standard iterated reweighted least squares GLM algorithm, and I don't know of a faster algorithm, except perhaps for providing improved starting points. It's conceivable that profiling may identify a small number of lines in GLMFIT that take the bulk of the time, and that can be modified to run faster.

Hope this helps.