[FieldTrip] parallelizing ft_statistics_montecarlo to enhance computation speed for time-frequency data

Eelke Spaak eelke.spaak at donders.ru.nl
Fri Jul 18 08:48:31 CEST 2014


Hi Fred,

Just to add to Jörn's comment, to be entirely clear: you should not
need to edit FT code to enable using the combineClusters mex-file; the
default code should be calling it already. If it isn't, either
something is wrong, or the mex-file has not been compiled for your
platform (but I guess the latter is not the case since you're on Linux
64). Note that the 'which combineClusters' on the default command
window won't work as combineClusters is a private function.

Hope that helps.

Best,
Eelke

On 17 July 2014 15:38, "Jörn M. Horschig" <jm.horschig at donders.ru.nl> wrote:
> Hi Fred,
>
> Matlab is giving mex-files precedence over .m file as long as the mex-file
> is on the path. The easiest ways to check whether Matlab uses the mex-file
> is to type
>>> which combineClusters
> that should point to the mex file. Another way to check is to put a
> breakpoint in the beginning of the .m-file, and then call combineClusters or
> run your code. If the mex-file is executed, Matlab will not enter the
> .m-file and thus not arrive and not stop at the breakpoint.
>
> However, the files are also in FieldTrip/private, and this is the place
> where other functions that FieldTrip uses are stored. So, actually there is
> no need for you to copy the files over to a separate folder.
> FieldTrip/Matlab should execute the mex-files all by itself already.
>
> Best,
> Jörn
>
>
> On 7/16/2014 3:07 PM, Frédéric Roux wrote:
>>
>> Hi Eelke,
>>
>> thanks for your response - that sounds promising.
>>
>> I am running fieldtrip-20140527 on a 64 bit Linux server, so I'd
>> be keen to give your suggestion a try.
>>
>> This is actually the first time I am calling mex-files using Matlab,
>> but I assume that the way to go is to comment out the part of the code
>> in ft_findcluster that combines the cluster and to call the mex-file
>> instead?
>>
>> If yes, here is what I did: I copied the combineClusters.mexa64 file into
>> a spearate folder and added that folder to my Matlab path.
>>
>> % combine clusters that are connected in neighbouring channel(s)
>> % (combinations). Convert inputs to uint32 as that is required by the mex
>> % file (and the values will be positive integers anyway).
>> addpath('/path2home/mex/');
>> cluster = combineClusters(uint32(labelmat),
>> logical(spatdimneighbstructmat), uint32(total));
>>
>> I am not sure however how to call the mex function. Is this done
>> automatically or do
>> I need to add some further steps? May I ask you which approach you are
>> using?
>>
>> Best,
>> Fred
>>
>>
>>
>> Frédéric Roux
>>
>> ----- Original Message -----
>> From: "Eelke Spaak" <eelke.spaak at donders.ru.nl>
>> To: "FieldTrip discussion list" <fieldtrip at science.ru.nl>
>> Sent: Wednesday, July 16, 2014 9:39:03 AM
>> Subject: Re: [FieldTrip] parallelizing ft_statistics_montecarlo to enhance
>> computation speed for time-frequency data
>>
>> Hi Fred,
>>
>> Some time ago, I replaced parts of the clustering routine with a
>> mex-file. For me this greatly sped up the cluster stats. I guess you
>> are using a fairly recent (<1yr old) FT version? The platform you're
>> using might also be relevant, I just noticed that the mex-file
>> (private/combineClusters.mex*) is distributed in compiled form only
>> for Linux 64 and Windows 32/64 bit. If you're e.g. on a Macintosh, you
>> could compile it yourself from the src/combineClusters.cpp source
>> file.
>>
>> I know of no attempts to parallelise the clustering code.
>>
>> Best,
>> Eelke
>>
>> On 15 July 2014 17:40, Frédéric Roux <f.roux at bcbl.eu> wrote:
>>>
>>> Dear all,
>>>
>>> I would like to ask if anyone has ever tried to speed up the
>>> ft_statistics_montecarlo function
>>> by using Matlab's parallel computing toolbox ?
>>>
>>> I would like to run clusterstatistics on time-frequency data, but as a
>>> result of the large number
>>> of time and frequency bins, the function runs very slowly. So I was
>>> thinking to try and modify
>>> the code by running the loops over the frequency bins in parallel and see
>>> if that could save
>>> some time.
>>>
>>> Before starting to adapt the code on my own, however, I wanted to ask if
>>> anyone had ever tried that
>>> and also if there could be any possible reasons which would make that
>>> this is not a feasible project.
>>>
>>> Any thoughts or suggestions would be highly appreciated.
>>>
>>> Best,
>>> Fred
>>>
>>>
>>>
>>> ---------------------------------------------------------------------------
>>>
>>>
>>> _______________________________________________
>>> fieldtrip mailing list
>>> fieldtrip at donders.ru.nl
>>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>
>> _______________________________________________
>> fieldtrip mailing list
>> fieldtrip at donders.ru.nl
>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>
>> _______________________________________________
>> fieldtrip mailing list
>> fieldtrip at donders.ru.nl
>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
>
>
> --
> Jörn M. Horschig
> PhD Student
> Donders Institute for Brain, Cognition and Behaviour
> Centre for Cognitive Neuroimaging
> Radboud University Nijmegen
> Neuronal Oscillations Group
> FieldTrip Development Team
>
> P.O. Box 9101
> NL-6500 HB Nijmegen
> The Netherlands
>
> Contact:
> E-Mail: jm.horschig at donders.ru.nl
> Tel:    +31-(0)24-36-68493
> Web: http://www.ru.nl/donders
>
> Visiting address:
> Trigon, room 2.30
> Kapittelweg 29
> NL-6525 EN Nijmegen
> The Netherlands
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip




More information about the fieldtrip mailing list