<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Hello Jörn,</div><div><br></div><div>Thank you so much for responding. The suggested changes were spot on and ft_connectivityanalysis executed successfully.</div>
<div>In the end, I went with the approach of redefining the 10s epoch in 2s minitrials and performing ft_freqanalysis on these minitrials with <i>cfg.output='fourier'</i> and <i>keeptrial='yes'. </i>I then did ft_connectivityanalysis on the frequency structures resulted from processing the segmented data. This would give me connectivity matrices for each 10s epoch, which I then average to get one connectivity matrix for the subject (technically, I have a connectivity matrix for each frequency bin, but I can again average across the frequency spectrum). </div>
<div><br></div><div>I have a question on the debiased weighted phase lag index measure. The values in the matrix vary between -1 and 1 (depending if the relative phase lags or leads). When I construct the adjacency matrices, is it just a matter of taking the absolute value of these values?  </div>
<div><br></div><div>I would also like some advice on plotting connectivity matrices. I was able to plot one matrix with ft_plot_matrix, but it would be really nice if I could plot a connectivity graph where the thickness of the edges correspond to the strength of the connectivity measure. I tried ft_topoplotER with 4D148.lay as the layout file and 'gui' as refchannel, but I didn't get anything interesting. As my data is MEG, it doesn't make sense to me to choose a reference channel... </div>
<div>Ideally, I would like to combine the layout (4D148.lay) with the connectivity matrix for plotting the graph. Do you have any ideas for this? Also, do you have any other suggestions on what other plotting functions can be used with these connectivity matrices? I've looked through the tutorial, but the functions don't seem very relevant to my type of data.</div>
<div><br></div><div>Thank you for your help.</div><div><br></div><div>Regards,</div><div>Dragos Stanciu</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

Message: 9<br>
Date: Wed, 30 Jul 2014 10:28:50 +0200<br>
From: "J?rn M. Horschig" <<a href="mailto:jm.horschig@donders.ru.nl">jm.horschig@donders.ru.nl</a>><br>
To: FieldTrip discussion list <<a href="mailto:fieldtrip@science.ru.nl">fieldtrip@science.ru.nl</a>><br>
Subject: Re: [FieldTrip] Connectivity analysis after applying Welch's<br>
        method<br>
<br>
Hi Dragos,<br>
<br>
while quickly browisng through your mail, it appears to me that you<br>
simply need to set single_epoch_freq.dimord = 'rpt_chan_freq'. FieldTrip<br>
is using the dimord field to infer the order of the dimensions<br>
(*dim*ension *ord*er). The actual dimensions of powspctrm and crsspctrm<br>
are now inconsistent with the dimord specifications.<br>
<br>
Best,<br>
J?rn<br>
<br>
<br>
On 7/30/2014 1:18 AM, Dragos Stanciu wrote:<br>
> Dear FieldTrippers,<br>
><br>
> I'm Dragos Stanciu and I'm working on my MSc in Neuroinformatics<br>
> dissertation at the University of Edinburgh. My project involves<br>
> analysis of resting-state functional connectivity using graph theory<br>
> in Alzheimer's disease based on MEG data.<br>
><br>
> Each of my subjects has a number of 10s epochs (trials) associated<br>
> with him/her. I was able to compute the coherence and weighted phase<br>
> lag index measures (with /ft_freqanalysis /and<br>
> /ft_connectivityanalysis) /by treating my 10s epochs as trials, but<br>
> now I would like to reduce the amount of noise in the estimation of<br>
> the frequency spectrum by employing Welch's method.<br>
><br>
> For this, I split each 10s epoch in 2s segments (minitrials) with 50%<br>
> overlap:<br>
><br>
>     [sep_epoch_data] = ft_redefinetrial(cfg_cut, single_epoch_data)/. /<br>
><br>
><br>
> I then apply /ft_preprocessing /on the minitrials:<br>
><br>
>      [processed_single_epoch] = ft_preprocessing(cfg, sep_epoch_data);<br>
><br>
> I then do frequency analysis on the preprocessed segmented data:<br>
><br>
>     [single_epoch_freq] = ft_freqanalysis(cfg_freq,<br>
>     processed_single_epoch);<br>
><br>
> where<br>
><br>
>     display(cfg_freq)<br>
>             method: 'mtmfft'<br>
>              taper: 'hanning'<br>
>             foilim: [0.5000 4]<br>
>             output: 'powandcsd'<br>
>            channel: {148x1 cell}    % 148 channels labelled from A1 to<br>
>     A148<br>
>          keeptrial: 'no'     % don't keep the minitrials, as we want<br>
>     to average them<br>
>         keeptapers: 'no'<br>
><br>
> Please note that I average the minitrials (/keeptrial = 'no'/) as I<br>
> want to get an average of the frequencies.<br>
><br>
> The resulting /single_epoch_freq/ structure looks like:<br>
><br>
>     display(single_epoch_freq)<br>
>     label: {148x1 cell}<br>
>            dimord: 'chan_freq'<br>
>              freq: [0.5001 1.0002 1.5004 2.0005 2.5006 3.0007 3.5008<br>
>     4.0009]<br>
>         powspctrm: [148x8 double]<br>
>          labelcmb: {10878x2 cell}     % channel combinations (148*147/2)<br>
>         crsspctrm: [10878x8 double]<br>
>               cfg: [1x1 struct]<br>
><br>
><br>
> The last step is to append the averaged frequency structures of each<br>
> 10s epoch together and perform connectivity analysis on the main 10s<br>
> epochs. I do the concatenation like so:<br>
> freq_avgs_powspctrm = [freq_avgs_powspctrm;<br>
> permute(single_epoch_freq.powspctrm, [3,1,2])];<br>
><br>
> freq_avgs_crsspctrm = [freq_avgs_crsspctrm;<br>
> permute(single_epoch_freq.crsspctrm, [3,1,2])];<br>
><br>
> The idea behind /permute(..., [3, 1, 2])/ is that I want the first<br>
> dimension to represent trials, the second dimension channel<br>
> combinations and the third dimension frequencies, as this is needed<br>
> for the input of /ft_connectivity_wpli /(Repetitions x<br>
> Channelcombination (x Frequency)).<br>
><br>
> I then call stat_conn = ft_connectivityanalysis(cfg_conn, freq_avgs);<br>
> where:<br>
><br>
>     display(cfg_conn)<br>
>          method: 'wpli_debiased'<br>
>         channel: {148x1 cell}<br>
><br>
> and<br>
><br>
>     display(freq_avgs)<br>
>          powspctrm: [4x148x8 double]      % as I have 4 ten second epochs<br>
>         crsspctrm: [4x10878x8 double]     % as I have 4 ten second epochs<br>
>             label: {148x1 cell}<br>
>            dimord: 'chan_freq'<br>
>              freq: [0.5001 1.0002 1.5004 2.0005 2.5006 3.0007 3.5008<br>
>     4.0009]<br>
>          labelcmb: {10878x2 cell}<br>
>               cfg: [1x1 struct]<br>
><br>
><br>
> The error that I get when running /ft_connectivityanalysis/ is:<br>
><br>
>     Error using cat<br>
>     CAT arguments dimensions are not consistent.<br>
>     Error in ft_checkdata>fixcsd (line 1170)<br>
>         data.crsspctrm = cat(catdim, data.powspctrm, data.crsspctrm);<br>
><br>
><br>
> When debugging, /catdim/ is equal to 1. The error occurs because the<br>
> 2nd dimension of data.powspctrm and data.crsspctrm are not equal<br>
> (former is 148, latter is 10878). Do you have any suggestions on<br>
> getting around this problem? Should I construct /freq_avgs /(data<br>
> input to ft_connectivityanalysis) differently? I'm also open to<br>
> different approaches to working out Welch's method in FieldTrip.<br>
><br>
> Please download this archive that contains my test script and 4<br>
> example 10s epochs of a subject:<br>
> <a href="https://www.dropbox.com/s/js7pztai02f5p27/Welch_fieldtrip.zip" target="_blank">https://www.dropbox.com/s/js7pztai02f5p27/Welch_fieldtrip.zip</a> The code<br>
> should make things clearer (or the opposite).<br>
> Observations: I thought about using /ft_freqanalysis_mtmwelch/, but<br>
> apparently it's deprecated.<br>
><br>
> Thank you all in advance for your feedback.<br>
><br>
> Kind regards,<br>
> Dragos Stanciu<br>
><br>
<br>
<br>
--<br>
J?rn M. Horschig<br>
PhD Student<br>
Donders Institute for Brain, Cognition and Behaviour<br>
Centre for Cognitive Neuroimaging<br></blockquote></div></div></div>