<p>Small modification:<br>
Go the line that starts with v2,<br>
And change the v near the end of this line of code to v2. Cheers</p>
<div class="gmail_quote">On Feb 26, 2012 9:37 PM, "Tarik S Bel-Bahar" <<a href="mailto:tarikbelbahar@gmail.com">tarikbelbahar@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Guy, due to your time urgency, and current level of awareness of eeglab and matlab, <div>perhaps the following code derived for your situation may help. Do let us know of your final solution please.</div><div>This solution uses spectopo to compute info for a specific component at a specific frequency for a series of files, components, and frequencies.</div>

<div>See annotations for what to change or modify. You should end up with unique and easily addressable variables </div><div>in your workspace, one for each "file, component, and frequency combination".<br></div>

<div>Averaging and computing scores within and across participants I leave to you. Check the brief notes in the code.</div><div>Best wishes, Tarik </div><div>[just paste the below to your matlab editor, modify, and give it a go] [if there is a hiccup when attempting to run, let me know].</div>

<div><br></div><div><br></div><div><div>*************************BEGIN SAMPLE CODE<br><br></div><div><div><font size="1"><br></font></div><div><font size="1">%this should run on epoched and unepoched files</font></div>
<div><font size="1">%I did not modify settings further, nor examine function specifications</font></div><div><font size="1"><br></font></div><div><font size="1">clear</font></div><div><font size="1">clc</font></div><div>
<font size="1">eeglab</font></div>
<div><font size="1">cd ( '/Homedirectory/DirectoryNameYouwantTouseThatHasTheFiles/'); %directory should already exist and have all EEGLAB files</font></div><div><font size="1">filepath = pwd; %makes filepath the same as the directory with the files</font></div>

<div><font size="1">%here you set up your lists of components, files, and frequencies to loop through</font></div><div><font size="1">myListofComponents = [1,2,3,4,5];</font></div><div><font size="1">myListofFiles = ['file1.set','file2.set','file3.set'];</font></div>

<div><font size="1">myListOfFrequencies = [5,10,20]</font></div><div><font size="1">percentageofFiletoAnalyze = 2; </font></div><div><font size="1">for LoopThroughFiles = 1: length(myListofFiles) </font></div><div><font size="1">    %begin file loop</font></div>

<div><font size="1">currentfilename = myListofFiles(LoopThroughFiles);</font></div><div><font size="1">EEG = pop_loadset('filename','currenfilename','filepath',currentfilepath);</font></div><div><font size="1">[ALLEEG, EEG, CURRENTSET] = eeg_store( ALLEEG, EEG, 1 );</font></div>

<div><font size="1"> for LoopThroughComponents = 1: length(myListofComponents) </font></div><div><font size="1">     %begin component loop</font></div><div><font size="1">currentcompA = myListofComponents(LoopThroughComponents);</font></div>

<div><font size="1">%set number of component of interest in current single subject single session file</font></div><div><font size="1">for LoopThroughFrequencies = 1: length(myListofFrequencies) </font></div><div><font size="1">    %begin frequency loop</font></div>

<div><font size="1">currentfrequency = myListOfFrequencies(LoopThroughComponents); </font></div><div><font size="1">% set current frequency of interest</font></div><div><font size="1">figure;  [spectra freqs speccomp] = pop_spectopo(EEG, 0, [0      EEG.xmax *1000], 'EEG' ...</font></div>

<div><font size="1"> , 'freq', [currentfrequency], 'plotchan', 0, 'percent', percentageofFiletoAnalyze, 'icacomps', [currentcompA]...</font></div><div><font size="1">, 'nicamaps', 1, 'icamaps', [1], 'icamode',  'normal',  'freqrange',[8 12],'electrodes','off'); close(gcf);  </font></div>

<div><font size="1">%ignore figure I could not manage to turn it off</font></div><div><font size="1">%freqs returns a column of numbers (freqs1),  %freqs(2), etc.... which specify the Hz for %each column in speccomp</font></div>

<div><font size="1">newspecs=speccomp;newfreqs=freqs; %dump output to dummy holding variables</font></div><div><font size="1">currentfilename1=currentfilename(1:5); %take first n characters of each filename</font></div><div>

<font size="1">currentcompA1= num2str(currentcompA);</font></div><div><font size="1"> v = genvarname([ 'speccomp' currentfilename1 currentcompA1 'hz']); eval([v ' = newspecs']);</font></div><div><font size="1">v2 = genvarname([ 'speccomp' currentfilename1 currentcompA1 'hz']); eval([v ' = newfreqs']);</font></div>

<div><font size="1">end %end frequency loop</font></div><div><font size="1">end %end component loop</font></div><div><font size="1">end %end file loop</font></div><div><font size="1"><br></font></div><div><font size="1">%NOTES TO GUY</font></div>

<div><font size="1">%the above should provide a file in the workspace named [FileName_Component Number_ Frequency]</font></div><div><font size="1">%the top row of each "speccompfileXhz" file contains the output for that</font></div>

<div><font size="1">%component at that particular frequency for that particular file</font></div><div><font size="1">%you should be able to find the columns in this one row that</font></div><div><font size="1">%represent alpha (try plotting that one row)</font></div>

<div><font size="1">%then take an average of the values in those columns of the one row</font></div><div><font size="1">%and save them out as a new variable or add them to a statistics speadsheet</font></div><div><font size="1">%am not sure about getting frequency bands, but the dirty way</font></div>

<div><font size="1">%would be to simply have run the code for all sub-frequencies of interest</font></div><div><font size="1">%and average up from there. Also, apologies, but I can't speak to or</font></div><div><font size="1">%provide caveats about function settings, </font></div>

<div><font size="1">% nor about power vs. amplitude, or using newtimef, or using non-eeglab</font></div><div><font size="1">% computation options. Good luck and let us know </font></div><div><font size="1">%what solution ends up working best for you</font></div>

</div></div>
</blockquote></div>