<div dir="ltr">Dear Community,<div><br></div><div>I <span class="" id=":xw.134" tabindex="-1" style="">preprocessed</span> my EEG data in <span class="" id=":xw.135" tabindex="-1" style="">EEGlab</span> and now I would like to run a time frequency analysis using <span class="" id=":xw.136" tabindex="-1" style="">FielTrip</span>. I start by <span class="" id=":xw.137" tabindex="-1" style="">saying</span> that I am new with the time frequency analysis, <span class="" id=":xw.138" tabindex="-1" style="">matlab</span> and <span class="" id=":xw.139" tabindex="-1" style="">fieldtrip</span>, so I say sorry in advance for my ignorance. </div><div>For each of my <span class="" id="gmail-:xw.142" tabindex="-1" style="">experiment</span> conditions (experimental design 2*2 within-subjects), I tried to run a wavelet <span class="" id=":xw.140" tabindex="-1" style="">tranformation</span> and a <span class="" id="gmail-:xw.141" tabindex="-1" style="">grandavarage across all subjects</span>. However, the values of the gandAverage <span class="" id=":xw.144" tabindex="-1" style="">powspctrm</span> in two out of four conditions are only <span class="" id=":xw.146" tabindex="-1" style="">NaNs</span> and I can not figure out why that is happening. Indeed, the code has been structurally the same for all conditions. In addition, the object of the ft_
<span class="" id=":xw.147" tabindex="-1" style="">freqgrandaverage</span> in these two problematic conditions do not contain the reasonable amount of NaNs to justify the values in the gandaverage. Could someone help me to undertand where the problem could be? </div><div>Below the example of code I used for each condition:</div><div><br></div><div>%%%%% <span class="" id=":xw.148" tabindex="-1" style="">oggPain</span> <span class="" id=":xw.149" tabindex="-1" style="">COONDITION</span> 1<br><br><span class="" id=":xw.150" tabindex="-1" style="">TFreqAv</span>_<span class="" id=":xw.151" tabindex="-1" style="">oggPain</span> = cell(1,<span class="" id=":xw.152" tabindex="-1" style="">nSubjs</span>);<br>for i = 1:<span class="" id=":xw.153" tabindex="-1" style="">nSubjs</span><br> <br> subs = subjects{i};<br> <span class="" id=":xw.154" tabindex="-1" style="">fileName</span> = '_data.mat';<br> <span class="" id=":xw.155" tabindex="-1" style="">dataSet</span> = <span class="" id=":xw.156" tabindex="-1" style="">strcat</span>('C:\Users\<span class="" id=":xw.157" tabindex="-1" style="">bia</span>\Desktop\<span class="" id=":xw.158" tabindex="-1" style="">dati</span> <span class="" id=":xw.159" tabindex="-1" style="">carlotta</span>\', subs, <span class="" id=":xw.160" tabindex="-1" style="">fileName</span>);<br> %<span class="" id=":xw.161" tabindex="-1" style="">dataSet</span> = <span class="" id=":xw.162" tabindex="-1" style="">fullfile</span>(<span class="" id=":xw.163" tabindex="-1" style="">dataPath</span>,subjects{i},<span class="" id=":xw.164" tabindex="-1" style="">fileName</span>);<br> load(<span class="" id=":xw.165" tabindex="-1" style="">dataSet</span>); % loading the variable 'data'<br> <br> %%%%%%%%% Computing time-frequency representation for each trial<br> <span class="" id=":xw.166" tabindex="-1" style="">cfg</span> = [];<br> <span class="" id=":xw.167" tabindex="-1" style="">cfg</span>.method = 'wavelet';<br> <span class="" id=":xw.168" tabindex="-1" style="">cfg</span>.<span class="" id=":xw.169" tabindex="-1" style="">foi</span> = 4:1:30; <br> <span class="" id=":xw.170" tabindex="-1" style="">cfg</span>.<span class="" id=":xw.171" tabindex="-1" style="">toi</span> = -0.8:0.01:1.5;<br> <span class="" id=":xw.172" tabindex="-1" style="">cfg</span>.width = 7; <br> %<span class="" id=":xw.173" tabindex="-1" style="">cfg</span>.<span class="" id=":xw.174" tabindex="-1" style="">keeptrials</span> = 'yes';<br> <span class="" id=":xw.175" tabindex="-1" style="">cfg</span>.channel = 'all';<br> <span class="" id=":xw.176" tabindex="-1" style="">cfg</span>.trials = find(<span class="" id=":xw.177" tabindex="-1" style="">celltomat</span>(data.<span class="" id=":xw.178" tabindex="-1" style="">trialinfo</span>(:,1)) == 7 | <span class="" id=":xw.179" tabindex="-1" style="">celltomat</span>(data.<span class="" id=":xw.180" tabindex="-1" style="">trialinfo</span>(:,1)) == 8 | <span class="" id=":xw.181" tabindex="-1" style="">celltomat</span>(data.<span class="" id=":xw.182" tabindex="-1" style="">trialinfo</span>(:,1)) == 11 | <span class="" id=":xw.183" tabindex="-1" style="">celltomat</span>(data.<span class="" id=":xw.184" tabindex="-1" style="">trialinfo</span>(:,1)) == 12); %numbers differ according to exp. condition<br> <span class="" id=":xw.185" tabindex="-1" style="">cfg</span>.<span class="" id=":xw.186" tabindex="-1" style="">outputfile</span> = <span class="" id=":xw.187" tabindex="-1" style="">strcat</span>('C:\Users\<span class="" id=":xw.188" tabindex="-1" style="">bia</span>\Desktop\<span class="" id=":xw.189" tabindex="-1" style="">dati</span> <span class="" id=":xw.190" tabindex="-1" style="">carlotta</span>\', subs,'_oggPain');<br> <span class="" id=":xw.191" tabindex="-1" style="">TFreqAv</span>_<span class="" id=":xw.192" tabindex="-1" style="">oggPain</span>{i}= ft_<span class="" id=":xw.193" tabindex="-1" style="">freqanalysis</span>(<span class="" id=":xw.194" tabindex="-1" style="">cfg</span>,data);<br> clear data<br>end<br>save <span class="" id=":xw.195" tabindex="-1" style="">TFreqAv</span>_<span class="" id=":xw.196" tabindex="-1" style="">oggPain</span>.mat <span class="" id=":xw.197" tabindex="-1" style="">TFreqAv</span>_<span class="" id=":xw.198" tabindex="-1" style="">oggPain</span><br><br><span class="" id=":xw.199" tabindex="-1" style="">bslnTFreqAv</span>_<span class="" id=":xw.200" tabindex="-1" style="">oggPain</span> = cell(1,<span class="" id=":xw.201" tabindex="-1" style="">nSubjs</span>);<br>for i = 1:<span class="" id=":xw.202" tabindex="-1" style="">nSubjs</span><br> <br> subs = subjects{i};<br> <span class="" id=":xw.203" tabindex="-1" style="">fileName</span> = '_<span class="" id=":xw.204" tabindex="-1" style="">oggPain</span>.mat';<br> <span class="" id=":xw.205" tabindex="-1" style="">dataSet</span> = <span class="" id=":xw.206" tabindex="-1" style="">strcat</span>('C:\Users\<span class="" id=":xw.207" tabindex="-1" style="">bia</span>\Desktop\<span class="" id=":xw.208" tabindex="-1" style="">dati</span> <span class="" id=":xw.209" tabindex="-1" style="">carlotta</span>\', subs, <span class="" id=":xw.210" tabindex="-1" style="">fileName</span>);<br> load(<span class="" id=":xw.211" tabindex="-1" style="">dataSet</span>); % loading the variable 'freq'<br> <br> %%%%%%%%% Computing the change relative to a baseline<br> <span class="" id=":xw.212" tabindex="-1" style="">cfg</span> = [];<br> <span class="" id=":xw.213" tabindex="-1" style="">cfg</span>.<span class="" id=":xw.214" tabindex="-1" style="">baselinetype</span> = 'relchange'; <br> <span class="" id=":xw.215" tabindex="-1" style="">cfg</span>.baseline = [-0.05 -0.02];<br> <span class="" id=":xw.216" tabindex="-1" style="">bslnTFreqAv</span>_<span class="" id=":xw.217" tabindex="-1" style="">oggPain</span>{i} = ft_<span class="" id=":xw.218" tabindex="-1" style="">freqbaseline</span>(<span class="" id=":xw.219" tabindex="-1" style="">cfg</span>,freq);<br> clear freq<br>end<br>save <span class="" id=":xw.220" tabindex="-1" style="">bslnTFreqAv</span>_<span class="" id=":xw.221" tabindex="-1" style="">oggPain</span>.mat <span class="" id=":xw.222" tabindex="-1" style="">bslnTFreqAv</span>_<span class="" id=":xw.223" tabindex="-1" style="">oggPain</span><br><br>%% Grand average time-frequency data<br>cfg = [];<br>gAvgTFreq_oggPain = ft_freqgrandaverage(cfg,TFreqAv_oggPain{:});<br>save gAvgTFreq_oggPain.mat gAvgTFreq_oggPain<br>gAvgBslnTFreq_oggPain = ft_freqgrandaverage(cfg,bslnTFreqAv_oggPain{:});<br>save gAvgBslnTFreq_oggPain.mat gAvgBslnTFreq_oggPain<br></div><div><br></div><div>Thank for any kind of tips,</div><div><br></div><div>Gina</div><div><br></div></div>