[FieldTrip] Dipole time course

Rojas, Don Don.Rojas at ucdenver.edu
Fri Apr 1 20:15:00 CEST 2011


Andreas,

I just wrote that code snippet from memory so it figures it wouldn't work without a little clean up. I forgot what the dimensions would be of the Li and Qn variables and the dot operation has to have arrays of the same size as input. I tested an example and this correction should work for you. I also corrected a parenthetic error on the use of double in the Qn line that would not have generated an error. I added a couple of transposes here and there. But, check your sizes as follows if you have problems - often, something will just need to be transposed to get it into the proper shape. I added some info on each input and variable to hopefully clarify what I'm after in the example:

source.dip.pos: 1 x 3
orientation_vector: 1 x 3 (Fieldtrip source structure orientation is 3 x 1 per dipole, so probably need to transpose if getting from source structure)
L: nchannels x 3
Li: 3 x nchannels;
Qn: 1 x 3, then 3 x nchannels after repmat()
W: 1 x nchannels
waveform: 1 x nsamples
data: Fieldtrip timelock structure with avg field
data.avg: nchannels x nsamples
vol: volume conductor in Fieldtrip - I coded this with a single sphere model
source: source output from ft_dipolefitting()

Revised code example:

L 			= ft_compute_leadfield(source.dip.pos, data.grad,vol,'reducerank',2); % leadfield
Li 			= pinv(L); % pseudoinverse of L
Qn 			= double(orientation_vector/norm(orientation_vector)); % normed orientation vector
Qn 			= repmat(Qn,length(Li),1)'; % make Qn the same size as Li
W 		 	= dot(Li,Qn)'; % weights for projection to source space
waveform 	= dot(data.avg,repmat(W,1,size(data.avg,2))); % source waveform

Hope that helps. I'm thinking that if your gradiometer data scaling is in meters (check your grad structure) and the input data scaling to the last dot operation is in fT, then your output scale will be A-m (1e-9), but you might want to check since I didn't confirm that. I think by default the fieldtrip MEG data are in units of T so you might need to scale your input data accordingly to get your desired output scale. But then, I'm assuming MEG gradiometer data input, so if you have something else, check your function call to ft_compute_leadfield and adjust your scaling accordingly.

Don

On Apr 1, 2011, at 8:37 AM, Andreas Wollbrink wrote:

> Hi Don,
> 
> I just tried out your approach on how to achieve the source waveform 
> based on a given dipole source but failed calculating the scalar product 
> of the inverse leadfield matrix and the normed orientation vector:
> 
> W = dot(Li,Qn);
> 
> error message: A and B must be same size.
> 
> May I ask you for a suggestion?
> 
> Best,
> Andreas
> 




More information about the fieldtrip mailing list