[FieldTrip] Optimizing leadfield computation

Bruno L. Giordano brungio at gmail.com
Fri Aug 12 15:10:00 CEST 2016


Hi Jan-Mathijs,

thanks. I will check what I can do then. Leadfield computation becomes 
quite lengthy when one has a large number of blocks for a large number 
of participants, and would like to have finer than usual grids ;-) And 
yes, I compute them only once.

I understand the philosophy of the development team, it makes perfect 
sense. Indeed, optimized code can be at times not very transparent. 
However, the most important aspect of the optimization would simply 
require replacing loops through the dipoles with mtimesx-based matrix 
multiplications. If you guys are interested, I can send the functions I 
have written, so that you can see how they operate.

Cheers,

	Bruno

On 12/08/2016 13:16, Schoffelen, J.M. (Jan Mathijs) wrote:
> Hi Bruno,
>
> I don’t know about the low-level details of the computation in meg_forward, but I’d take your word on that it allows for multiple positions simultaneously.
>
> With respect to the leadfield calculation as such, we typically recommend to pre-compute them once (and store them for later use), and input a source-model with these pre-computed leadfields in ft_sourceanalysis. This typically works if you keep the signal subspace for which you computed your leadfields consistent with the signal subspace of the sensor-data.
>
> We are aware that apart from this FT's beamformer code is relatively slow (even with precomputed leadfields), but at some point in the past we decided to go for code clarity and correctness, rather than to go for computational speed. Doing all computations vectorized will make the code quite opaque (and moreover is not really straightforward if one would like to stay flexible with respect to location specific dimensions of vector leadfields (e.g. regional sources). Given all other steps in typical data processing pipelines, the beamformer step is usually not the time limiting one.
>
> Best,
> Jan-Mathijs
>
>> On 12 Aug 2016, at 13:52, Bruno L. Giordano <brungio at gmail.com> wrote:
>>
>> Hi,
>>
>> I wonder whether the leadfield computation (singleshell) can be made faster by avoiding loops through the dipoles (e.g., avoiding dipole loops makes the beamformer >20 times faster).
>>
>> It seems like the most time consuming part of the leadfield computation is meg_forward.m Am I correct in concluding that this function accepts multiple dipoles in input?
>>
>> Thank you,
>>
>> 	Bruno
>>
>>
>> --
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> Bruno L. Giordano, PhD
>> Institute of Neuroscience and Psychology
>> 58 Hillhead Street, University of Glasgow
>> Glasgow, G12 8QB, Scotland
>> T +44 (0) 141 330 5484
>> Www: http://www.brunolgiordano.net
>> Email charter: http://www.emailcharter.org/
>> _______________________________________________
>> fieldtrip mailing list
>> fieldtrip at donders.ru.nl
>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Bruno L. Giordano, PhD
Institute of Neuroscience and Psychology
58 Hillhead Street, University of Glasgow
Glasgow, G12 8QB, Scotland
T +44 (0) 141 330 5484
Www: http://www.brunolgiordano.net
Email charter: http://www.emailcharter.org/



More information about the fieldtrip mailing list