Source anaylsis

Robert Oostenveld r.oostenveld at FCDONDERS.RU.NL
Fri Jul 28 09:49:55 CEST 2006


Hi Juan

>   I do the freq analysis and then the source analysis. Then I can
> make another source analysis with refdip but there is always errors
> when I use refchan. I do not think is a problem of the reference ,
> cos always the program says that the  cross-spectral-density with
> the reference channel is not complete .
>
>   I have done the freq analysis making cfg.channelcmb combinations of
> all channels with only one, so i make sure that the
> cross-spectral-density is complete,but when I make source analysis
> with that channel as a reference is the same.
>
>   Searching in the code I have come up with the fact that the error
> is always the condition in line 195 of the function
> prepare_freq_matrices (version 2006/03/08). My idea is that there is
> a confussion because if we have a set of N channels and we make
> combinations with channelcombination, the result is N-1
> combinations because we do not include the combination of the
> reference with itself.

Say for simplicity that you want EMG as refchan. In freqanalysis,
cfg.channelcmb should be all with all. You need the CSD between all
EEG channels (all EEG with all EEG), and of all EEG channels with the
EMG. In prepare_freq_matrices the CSD matrix (Cf) of EEG with EEG is
made (Neeg X Neeg), the CSD vector (Cr) of all EEG channels with the
reference EMG channel (Neeg X 1), and the power of the reference
channel (Pr). Together they could also be shaped in a (Neeg+1) X (Neeg
+1) matrix in principle, but that is not done for DICS.

I have tried it out myself, and cannot reproduce your problem. Please
find my test script below. It uses some simulated EEG data. The
beginning of the script is copied from http://www2.ru.nl/fcdonders/
fieldtrip/doku.php?
id=fieldtrip:documentation:compute_forward_simulated_data_and_apply_a_di
pole_fit

The initial part generates raw EEG data, then I add a EMG channel
(with noise, but it is only to demonstrate that fieldtrip does not
give an error), then I do freqanalysis and sourceanalysis. Please try
out and compare my cfgs with yours, since I suspect your
configuration to be the problem.

best regards,
Robert


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% create a set of electrodes, randomly placed on the sphere
elec = [];
elec.pnt = randn(128,3);
dum = sqrt(sum(elec.pnt.^2,2));
elec.pnt = elec.pnt ./ [dum dum dum];  % scale them to a unit sphere
for i=1:128
    elec.label{i} = sprintf('%03d', i);
end

% create a concentric 3-sphere volume conductor, the radius is the
same as for the electrodes
vol = [];
vol.r = [0.88 0.92 1.00]; % radii of spheres
vol.c = [1 1/80 1];       % conductivity
vol.o = [0 0 0];          % center of sphere

% create a dipole simulation with one dipole and a 10Hz sine wave
cfg      = [];
cfg.vol  = vol;             % see above
cfg.elec = elec;            % see above
cfg.dip.pos = [0 0.5 0.3];
cfg.dip.mom = [1 0 0]';     % note, it should be transposed
cfg.dip.frequency = 10;
cfg.ntrials = 10;
cfg.triallength = 1;        % seconds
cfg.fsample = 250;          % Hz
raw1 = dipolesimulation(cfg);

using headmodel specified in the configuration
using electrodes specified in the configuration
selected 128 electrodes
computing simulated data
RMS value of simulated data is 0.0746553

%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% Here it starts deviating from the demo script on the wiki %%%%
%%%%%%%%%%%%%%%%%%%%%%%%

% add a fake EMG channel, containing noise
for i=1:10
   raw1.trial{i}(end+1,:) = randn(1,250);
end
raw1.label{end+1} = 'EMG'

raw1 =

       trial: {1x10 cell}
        time: {1x10 cell}
        elec: [1x1 struct]
     fsample: 250
       label: {1x129 cell}
         cfg: [1x1 struct]

cfg = []
cfg.method = 'mtmfft';
cfg.taper = 'hanning';
cfg.foilim = [2 20];
cfg.output = 'powandcsd';
cfg.channelcmb = {'all', 'all'}

cfg =

         method: 'mtmfft'
          taper: 'hanning'
         foilim: [2 20]
         output: 'powandcsd'
     channelcmb: {'all'  'all'}

freq1 = freqanalysis(cfg, raw1)
WARNING: using only one taper for specified smoothing
processing trial 1, nfft: 250 samples, taper length: 250 samples, 1
tapers
processing trial 2, nfft: 250 samples, taper length: 250 samples, 1
tapers
processing trial 3, nfft: 250 samples, taper length: 250 samples, 1
tapers
processing trial 4, nfft: 250 samples, taper length: 250 samples, 1
tapers
processing trial 5, nfft: 250 samples, taper length: 250 samples, 1
tapers
processing trial 6, nfft: 250 samples, taper length: 250 samples, 1
tapers
processing trial 7, nfft: 250 samples, taper length: 250 samples, 1
tapers
processing trial 8, nfft: 250 samples, taper length: 250 samples, 1
tapers
processing trial 9, nfft: 250 samples, taper length: 250 samples, 1
tapers
processing trial 10, nfft: 250 samples, taper length: 250 samples, 1
tapers

freq1 =
          label: {1x129 cell}
        dimord: 'chan_freq'
          freq: [2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]
     powspctrm: [129x19 double]
      labelcmb: {8256x2 cell}
     crsspctrm: [8256x19 double]
          elec: [1x1 struct]
           cfg: [1x1 struct]

cfg = [];
cfg.vol = vol;
cfg.freq = 10;
cfg.frequency = 10;
cfg.method = 'dics';
cfg.refchan = 'EMG';
cfg.grid.resolution = 0.3

cfg =
           vol: [1x1 struct]
          freq: 10
     frequency: 10
        method: 'dics'
       refchan: 'EMG'
          grid: [1x1 struct]

source1 = sourceanalysis(cfg, freq1)
using headmodel specified in the configuration
using electrodes specified in the data
selected 128 electrodes
106 dipoles inside, 237 dipoles outside brain
making tight grid
106 dipoles inside, 110 dipoles outside brain
scanning repetition 1
scanning grid
Warning: cross-spectral density matrix is rank deficient
 > In <a href="error:/Users/roberto/matlab/forwinv/beamformer.m,
270,1">beamformer at 270</a>
   In <a href="error:/Users/roberto/matlab/fieldtrip/sourceanalysis.m,
806,1">sourceanalysis at 806</a>
total time in sourceanalysis 75.4 seconds

source1 =
         xgrid: [-0.7000 -0.4000 -0.1000 0.2000 0.5000 0.8000]
         ygrid: [-0.7000 -0.4000 -0.1000 0.2000 0.5000 0.8000]
         zgrid: [-0.7000 -0.4000 -0.1000 0.2000 0.5000 0.8000]
           dim: [6 6 6]
           vol: [1x1 struct]
     frequency: 10
           pos: [216x3 double]
        inside: [1x106 double]
       outside: [1x110 double]
        method: 'average'
           avg: [1x1 struct]
           cfg: [1x1 struct]

diary off



More information about the fieldtrip mailing list