[FieldTrip] DICS in fieldtrip: Hermitian vs not Hermitian spectral matrix computations - Multiple frequencies
Schoffelen, J.M. (Jan Mathijs)
janmathijs.schoffelen at donders.ru.nl
Fri Apr 4 13:14:53 CEST 2025
Dear Enrico,
I don’t understand what you meant with creating the CSD with 200 trials @ 120 Hz, 300 trials @ 145 Hz. etc.? Do you mean that the final CSD matrix is an average of CSD matrices across frequencies? Why would you do that?
I am not sure whether we are talking about different things altogether.
Let’s take a step back, and think about the 2 conceptual steps that are taking place when you do a DICS (or generally a beamformer or other type of source reconstruction step):
- step 1: create an inverse operator, in beamformer speak a.k.a. spatial filter, which in this case is computed using an algorithm that requires a data covariance/CSD matrix, and intends to create a spatial passband of unit gain at the location of interest, while suppressing uncorrelated contributions (to the signal that is used for the filter computation) that originates from elsewhere. Typically, the covariance matrices used are already pre-filtered in a certain frequency band (LCMV) or Fourier transformed (DICS) to a priori discard signal components outside the bandwidth of interest.
- step 2: filter the data (in this case multiply the sensor level data with the spatial filter coefficients, where the sensor level data is a Nchan x something else matrix, where the content of this matrix can be Fourier coefficients).
Let's now take the analogy of a frequency domain filter, where we (step 2) apply a filter ((created in step 1), typically constructed without making use of the actual data, but for the sake of the argument it’s not relevant here) to a time series. The first step (filter creation) basically defines the requirements of the filter, for instance the frequency passband for a bandpassfilter. Let’s say this has been specified for the 8-12 Hz frequency band.
In analogy to what you described, we then apply the filter to data that has already been bandpassfiltered (e.g. in the 15-25 Hz frequency band). This will obviously lead to suboptimal results.
Best wishes,
Jan-Mathijs
On 1 Apr 2025, at 15:35, Enrico Sozza via fieldtrip <fieldtrip at science.ru.nl> wrote:
Hello Jan-Mathijs,
Thank you very much for your reply, I really appreciate that time you took to read and answer to my email. If I may size the opportunity of having your attention, with the aim of not abusing of your time, I'd like to clarify some aspects related to my second question.
Regarding the first, I happened to realize it the very same day with further search, as clearly the 'deep dive' I first did was not so deep or at least not enough aware (I let you imagine how embarrassed I felt!).
Regarding the second, more relevant question, I see your point and agree with that, although it's not exactly what I meant to do.
I am pre-computing the filter with data from activity + baseline together (let's call it 'freq'), and what I input is the output of ft_freqanalysis (fourier) so that I have freq.fourierspctrm with nTtrials x nChann (only 1 frequency). The caveat here is that the fourier spectra that I input in DICS has apparently only 1 frequency, but the fourier coeffrcients in each trial is computed at a specific, different, frequency (integers with range 120-220).
So, the result is that I compute the filter with (e.g.,) 200 trials with CSDs at 120Hz, 300 trials with 145Hz and so on. I then apply this filter to compute the source power of activity and contrasting it with baseline.
My theoretical justification is the neurobiological assumption for which I expect the same dipoles to be responsible for generating neural activity at these different frequencies (and this is not the part I am questioning). What I am questioning is instead what would be the reliability and stability of the estimated spatial filter since I am averaging CSDs computed at different frequencies.
To summarize, while I have strong basis to motivate the neurobiological assumption, I don't know if the computation of the filter in such way results as mathematically incorrect or hardly interpretable.
Honestly, apart from you guys, I don't know who could provide me with valuable insights in such a highly specific and integrated field, this is why I asked and why I really value your help.
Thank you so so much again for your attention and help in this matter.
Kind regards
Enrico Sozza, PhD Student
Brainlab – Cognitive Neuroscience Research Group
Department of Clinical Psychology and Psychobiology
Institute of Neurosciences
University of Barcelona
P. Vall d'Hebron 171, 08035 Barcelona, Catalonia-Spain
Tel: +34 933 125 058 – Fax: +24 934 021 584
http://www.ub.edu/brainlab/team-post/enrico-sozza<https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.ub.edu%2Fbrainlab%2Fteam-post%2Fenrico-sozza&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cd4056d720cf44a29bd8108dd7369ecf6%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638793620951218558%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=Gt0RJvCli3FRaDeQBklezpzFv%2FxP9ChPyU09i6rcEUA%3D&reserved=0>
http://www.neurociencies.ub.edu<https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.neurociencies.ub.edu%2F&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cd4056d720cf44a29bd8108dd7369ecf6%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638793620951243826%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=6liit5JuUmbxvWUO6Dua%2FGNcz%2F96AH7bJmqANYpQvAk%3D&reserved=0>
________________________________
From: fieldtrip <fieldtrip-bounces at science.ru.nl<mailto:fieldtrip-bounces at science.ru.nl>> on behalf of Schoffelen, J.M. (Jan Mathijs) via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>
Sent: 29 March 2025 13:11
To: FieldTrip discussion list <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>
Cc: Schoffelen, J.M. (Jan Mathijs) <janmathijs.schoffelen at donders.ru.nl<mailto:janmathijs.schoffelen at donders.ru.nl>>
Subject: Re: [FieldTrip] DICS in fieldtrip: Hermitian vs not Hermitian spectral matrix computations - Multiple frequencies
Hi Enrico,
Nice that you dove into the code so deeply. With respect to your worries about computing the CSD-matrix from a matrix with Fourier coefficients as per the matlab syntax tmp*tmp’ I hope I can take these away by saying that the “ ‘ “ operator (the apostrophe) acutally DOES a complex conjugate transposition of the matrix. (as opposed to “ .’ “, i.e. a dot followed by an apostrophe, which is a ’normal’ transpose)
Regarding your second question: I am not sure whether I fully understand, but I assume that you mean to ask about applying previously computed spatial filters optimized for frequency band X, to data that quantifies frequency band Y (where Y is not contained by the frequency band X)? I follow your reasoning, but I would say that this is somewhat suboptimal, even indeed as you say that different frequency components might have the same (at least at the spatial resolution permitted by the measurement technique) neurobiological origins. The reason for this is that the idea that underlies the mathematics of the beamformers is not only that it aims to not distort activity originating from the current location of interest (i.e. the dipole source that you considering for a given iteration of the scanning loop across all potential dipole positions in your source model), but that it also aims at suppressing potentially distortive effects of uncorrelated sources outside the current location of interest. Thus, a spatial filter for a particular dipole location does not only reflect properties of the (possibly present) neural source at that location, but also implicitly reflects the other sources of the overall signal at frequency band X.
Best wishes,
Jan-Mathijs
On 27 Mar 2025, at 16:17, Enrico Sozza via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:
Hello FieldTrip community allies,
I come to seek your help in a field that goes way deeper than what my background allows me to understand, so forgive me beforehand if my questions come as no-sense or missing solid theoretical bases.
I am trying to source localize oscillatory EEG data through DICS beamforming and I came across some theoretical/methodological doubts that I couldn't clarify through the available documentation.
The first is related to the 'equivalence' of the output of ft_sourceanalysis with method DICS depending on what type of data you input: for what I read, it seems you can feed it with frequency data as output of ft_freqanalysis with either output 'fourier' or 'powandcsd' and expect the same computation.
Yet, after a deep dive into the functions, it seems that in ft_checkdata, with freq.fourierspctrm as input, computes just a symmetrical matrix (Cf, to be inverted later on) but not the Hermitan transpose with the complex conjugates (Actual CSD matrix), which seems to be critical for an adequate estimation of spectral properties and spatial relationship. So, I would say it is not actually the same, and I would say is mathematically 'invalid' (?). If so, why is it implemented in FieldTrip? Why does it compute
data.fourierspctrm = reshape(data.fourierspctrm, [nrpt nchn nfrq*ntim]);
crsspctrm = complex(zeros(nchn,nchn,nfrq*ntim));
for k = 1:nfrq*ntim
tmp = transpose(data.fourierspctrm(:,:,k));
tmp(~isfinite(tmp)) = 0;
n = sum(tmp~=0,2);
crsspctrm(:,:,k) = tmp*tmp'./n(1);
end
instead of:
crsspctrm(:,:,k) = tmp*conj(tmp')./n(1);
I guess manually changing the function it is somehow not suggested, otherwise it would have been coded as such since the beginning, but I am still left with quite a bit of uncertainty in such regard.
My other question is:
I know DICS is implemented to computing spatial filters tailored to a specific frequency, due to the process of averaging CSDs across trials before computing the inverse. Yet, I also saw that at the end with 'cfg.realfilter = yes' it only works with the real part of the matrix, keeping only the information regarding near zero-lag correlated signal and ignoring any phase-related relationship.
Keeping this into consideration, and assuming neurobiologically that activity ad different frequencies come from the same neural generators, would it be mathematically inappropriate or impossible to interpret to compute DICS feeding it with fft coefficients computed at different frequencies across trials? Again, bearing in mind that the goal is source localizing oscillatory activity (i.e., power) at those different frequencies in different trials, assuming they come from the same sources.
I am learning so much about this in-depth physics of signal processing and it's quite exciting, but my resources are quite limited, and I therefore would really value and appreciate any insight from you guys, hoping that I am not already blindingly hitting a wall.
Thank you very much in advance for the time you took to read this email and for your help.
Best of luck with your work
Regards
Enrico Sozza, PhD Student
Brainlab – Cognitive Neuroscience Research Group
Department of Clinical Psychology and Psychobiology
Institute of Neurosciences
University of Barcelona
P. Vall d'Hebron 171, 08035 Barcelona, Catalonia-Spain
Tel: +34 933 125 058 – Fax: +24 934 021 584
http://www.ub.edu/brainlab/team-post/enrico-sozza<https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.ub.edu%2Fbrainlab%2Fteam-post%2Fenrico-sozza&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cd4056d720cf44a29bd8108dd7369ecf6%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638793620951256342%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=rNoNPouGZlWd1FWnmXnBfmj3FdtpBNyh4deJYR41FuA%3D&reserved=0>
http://www.neurociencies.ub.edu<https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.neurociencies.ub.edu%2F&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cd4056d720cf44a29bd8108dd7369ecf6%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638793620951268774%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=QEoExbsNrX2zXRRKCTYH3x9ukUmcW1OFPa%2BnvkdNzEE%3D&reserved=0>
Aquest missatge, i els fitxers adjunts que hi pugui haver, pot contenir informació confidencial o protegida legalment i s’adreça exclusivament a la persona o entitat destinatària. Si no consteu com a destinatari final o no teniu l’encàrrec de rebre’l, no esteu autoritzat a llegir-lo, retenir-lo, modificar-lo, distribuir-lo, copiar-lo ni a revelar-ne el contingut. Si l’heu rebut per error, informeu-ne el remitent i elimineu del sistema tant el missatge com els fitxers adjunts que hi pugui haver.
Este mensaje, y los ficheros adjuntos que pueda incluir, puede contener información confidencial o legalmente protegida y está exclusivamente dirigido a la persona o entidad destinataria. Si usted no consta como destinatario final ni es la persona encargada de recibirlo, no está autorizado a leerlo, retenerlo, modificarlo, distribuirlo o copiarlo, ni a revelar su contenido. Si lo ha recibido por error, informe de ello al remitente y elimine del sistema tanto el mensaje como los ficheros adjuntos que pueda contener.
This email message and any attachments it carries may contain confidential or legally protected material and are intended solely for the individual or organization to whom they are addressed. If you are not the intended recipient of this message or the person responsible for processing it, then you are not authorized to read, save, modify, send, copy or disclose any part of it. If you have received the message by mistake, please inform the sender of this and eliminate the message and any attachments it carries from your account.
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cd4056d720cf44a29bd8108dd7369ecf6%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638793620951280506%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=2wLNC2E4jeqO7UbdYRBN131jnorzbh0Ul0NnXI3oUug%3D&reserved=0>
https://doi.org/10.1371/journal.pcbi.1002202<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cd4056d720cf44a29bd8108dd7369ecf6%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638793620951292054%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=1jcQujgSNezpkPDtrwRcDx8lJzucN6gpyp53q1EhtIw%3D&reserved=0>
Aquest missatge, i els fitxers adjunts que hi pugui haver, pot contenir informació confidencial o protegida legalment i s’adreça exclusivament a la persona o entitat destinatària. Si no consteu com a destinatari final o no teniu l’encàrrec de rebre’l, no esteu autoritzat a llegir-lo, retenir-lo, modificar-lo, distribuir-lo, copiar-lo ni a revelar-ne el contingut. Si l’heu rebut per error, informeu-ne el remitent i elimineu del sistema tant el missatge com els fitxers adjunts que hi pugui haver.
Este mensaje, y los ficheros adjuntos que pueda incluir, puede contener información confidencial o legalmente protegida y está exclusivamente dirigido a la persona o entidad destinataria. Si usted no consta como destinatario final ni es la persona encargada de recibirlo, no está autorizado a leerlo, retenerlo, modificarlo, distribuirlo o copiarlo, ni a revelar su contenido. Si lo ha recibido por error, informe de ello al remitente y elimine del sistema tanto el mensaje como los ficheros adjuntos que pueda contener.
This email message and any attachments it carries may contain confidential or legally protected material and are intended solely for the individual or organization to whom they are addressed. If you are not the intended recipient of this message or the person responsible for processing it, then you are not authorized to read, save, modify, send, copy or disclose any part of it. If you have received the message by mistake, please inform the sender of this and eliminate the message and any attachments it carries from your account.
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cd4056d720cf44a29bd8108dd7369ecf6%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638793620951303771%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=BfuUpULga7E4kNwPSv3AVO9T4uuwajmuJsRRpEnKIg8%3D&reserved=0>
https://doi.org/10.1371/journal.pcbi.1002202<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cd4056d720cf44a29bd8108dd7369ecf6%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638793620951315524%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=ZrXNAE9XP93wh7VhPF%2BPm0LA%2B1en6D%2B%2BpqIIunxmPhA%3D&reserved=0>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20250404/f3ea46e2/attachment.htm>
More information about the fieldtrip
mailing list