Ben - <br><br>A belated 'Nice!' ... Would you like to make a pop_function pop_EEGtosound() that calls EEGtosound() and a small plugin_function plugin_EEGtosound() that creates a link to it in the EEG menu. Then anyone who downloads the 'EEGtosound plug-in' can listen to / demo their ERP brainwave of choice from the EEGLAB menu. <br>
<br>It's actually quite easy for you (or anyone) to do -- to learn how, <a href="http://sccn.ucsd.edu/wiki/A07:_Contributing_to_EEGLAB" target="_blank">read this</a>.<br><br>Scott Makeig<br><br><div class="gmail_quote">
On Fri, Apr 13, 2012 at 2:42 PM, <span dir="ltr"><<a href="mailto:BBR2@pitt.edu" target="_blank">BBR2@pitt.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">For all interested, here is a way to listen to your voltage/time data in<br>
Matlab.<br>
*(not sure if this sent the first time, if this is repeated I apologize)!<br>
-Ben<br>
<br>
*************<br>
<br>
function [] = ERPtosound(ERP,nums,docomp, doloop)<br></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
% Plays channels or components of an epoched EEG data ERP trial average </blockquote><div> % as a summed FM sound. <br></div><div> </div><div> % Inputs:<br></div><div> % EEG is an epoched EEG data structure <br>
</div>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
% nums is a list of (at most a few!) channel or component numbers<br></blockquote><div> % docomp is an indicator: 0 = play channel ERP(s)<br> % 1 = play component ERP(s)<br></div>
<div> % doloop is an indicator: 0 = play once<br> % 1 = loop until killed<br><br></div>
%Requires epochs structured in EEG.data<br> if EEG.ntrials == 1<br> printf('ERPtosound(): requires epoched data.\n');<br> return<br> end<br><div> <br>% Alter N below to change duration of the sound<br>
</div><div> N=500;<br> <br> if nargs<3<br> docomp = 0;<br> end<br> if nargs<4<br> doloop = 0;<br> end<br> if max(nums) > EEG.nbchan or min(nums) < 1<br> printf('ERPtosound(): bad channel list (0 < nums < %d)\n',EEG.nbchan);<br>
return<br> end<br><br> % Make the trial average for channel(s) nums<br>
if docomp % make component average<br> if isfield(EEG.icaact)<br>
gave=mean((EEG.icaact(nums,:,:)),3);<br>
else <br> printf('ERPtosound(): No component activations found.\n');<br> return<br> end<br> else % make channel average<br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
gave=mean((EEG.data(nums,:,:)),3);<br></blockquote><div> end <br><br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
num_cols = length(gave(1,:));<br>
newlo=min(gave(1,:));<br>
posnewlo=sqrt(min(gave(1,:)).^2);<br>
newhi=max(gave(1,:));<br>
spred=(newhi-newlo);<br>
<br></blockquote><div>% Make the sound waveform - If multiple chans/comps, their sounds are summed</div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
t=0:N;<br>
Q=zeros(1,N+1);<br>
j=0; i=0;<br>
for i=1:1:num_cols;<br>
j = sum(sin(3*pi*t*(1/(100*((gave(:,i)+posnewlo)/spred)))));<br>
B=[double(j)];<br>
Q=[Q B];<br>
end<br>
<br>
[w,c]=size(Q); % here, w == 1 <br></blockquote><div> do <br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
for n=1:1:w;<br>
sound(Q(n,:));<br>
end<br></blockquote><div> while (doloop) <br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
</blockquote></div><br><br clear="all"><br>-- <br>Scott Makeig, Research Scientist and Director, Swartz Center for Computational Neuroscience, Institute for Neural Computation; Prof. of Neurosciences (Adj.), University of California San Diego, La Jolla CA 92093-0559, <a href="http://sccn.ucsd.edu/%7Escott" target="_blank">http://sccn.ucsd.edu/~scott</a><br>