Back to the main page.

Bug 1247 - beamformer_sam lacks '%lambda' functionality

Status ASSIGNED
Reported 2012-01-07 09:03:00 +0100
Modified 2012-01-18 08:51:31 +0100
Product: FieldTrip
Component: inverse
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P3 normal
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also:

Jan-Mathijs Schoffelen - 2012-01-07 09:03:59 +0100

To all, I encountered a problem with the 'sam' method for ft_sourceanalysis. It looks to me that when specifying the configuration option: cfg.sam.lambda = '5%'; i.e., lambda is a percentage, not an actual number, the beamformer_sam routine does not have comparable code as the beamformer_lcmv routine to handle that type of input. I'm wondering if simply inserting the following bit of code between lines 97 and 99 of beamformer_sam, borrowed and edited from beamformer_lcmv, will work: if ~isempty(lambda) && ischar(lambda) && lambda(end)=='%' ratio = sscanf(lambda, '%f%%'); ratio = ratio/100; lambda = ratio * trace(all_cov)/size(all_cov,1); end This seems to work okay in limited tests, but maybe I'm making a mistake here. I'm using a recent svn code version, revision 5097. Best, Don


Jan-Mathijs Schoffelen - 2012-01-10 10:08:11 +0100

I assigned this one to Don, who volunteered to change the code accordingly. I'll supervise the code change and commit it into the repository. TODO: implement a test function


Jan-Mathijs Schoffelen - 2012-01-10 10:09:12 +0100

Additional e-mail correspondence from Don is pasted below: Jan-Mathijs, In the discussion, for the sake of consistency, it would probably also be good to talk about the use of pre-computed filters in beamformer_sam. My reading of the code is that although the function states that it is using pre-computed filters when the configuration calls for it (lines 86-89), in fact it always re-computes the sam weights, ignoring the provided input filter. I've been trying, so far without success, to implement so-called event-related SAM (e.g., Cheyne et al. 2006) using the beamformer_sam routine. I believe that the only thing standing in my way is this last bit, since the noise estimate in the noise-normalized power referred to in the erSAM method is obtained by applying the sam weights to the +/- average. It looks like with that implemented, it would be easy enough to replicate the erSAM method with Fieldtrip. I'm pretty certain I could get a close approximation of it with beamformer_lcmv if necessary, however. Let me know if you'd prefer and I would be happy to revise the code myself along the lines of beamformer_lcmv and send it to you. Best, Don And: Ignore that bit about the +/- average - I'm pretty sure that the use of the smallest singular value to estimate the noise floor is already implemented. But the offer stands if you want me to take a crack at the code. I've become fairly familiar with the lcmv beamformer code and the sam code is not that different so it would not be too much work to revise the sam code to be more consistent.


Jan-Mathijs Schoffelen - 2012-01-13 08:54:53 +0100

Created attachment 215 Don's updated version of beamformer_sam


Jan-Mathijs Schoffelen - 2012-01-13 08:57:12 +0100

@robert & gareth, Hi guys, I am including you guys in the CC to this bug to let you know that Don and I are 'consistizing' beamformer_sam w.r.t. the other beamformer functions. No functionality deterioration is to be expected however ;-)


Jan-Mathijs Schoffelen - 2012-01-18 08:51:31 +0100

@Robert: neem jij deze over? Is het een idee om toch de patch maar te committen?