<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Yes, this sounds like a good solution.<div>When using STUDY, if you want to plot ERP for a given cluster, you may simply add the ERP of all components from the same subjects. The code below will do that and merge components if there are several per subject.</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Courier; font-size: 13px; ">clust   = 10;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Courier; font-size: 13px; ">STUDY = std_erpplot(STUDY,ALLEEG,<span style="color: #b547ea">'clusters'</span>,clust);</div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Courier; min-height: 11px; font-size: 13px; "> <br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Courier; font-size: 13px; ">erpData  = STUDY.cluster(clust).erpdata;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Courier; font-size: 13px; ">erpTimes = STUDY.cluster(clust).erptimes;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Courier; font-size: 13px; ">setInds  = STUDY.cluster(clust).setinds;</div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Courier; min-height: 11px; font-size: 13px; "> <br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Courier; color: rgb(24, 153, 64); font-size: 13px; ">% scan design</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Courier; font-size: 13px; "><span style="color: #253af5">for</span> iCell = 1:length(setInds(:))</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Courier; color: rgb(24, 153, 64); font-size: 13px; "><span style="color: #000000">    </span>% scan subjects</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Courier; font-size: 13px; ">    uniqueSubj = unique(setInds{iCell});</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Courier; font-size: 13px; ">    <span style="color: #253af5">for</span> iSubj = 1:length(uniqueSubj)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Courier; font-size: 13px; ">        subjInd    = setInds{iCell} == uniqueSubj(iSubj);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Courier; font-size: 13px; ">        erpData2{iCell}(:,iSubj) = sum( erpData{iCell}(:,subjInd), 2);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Courier; font-size: 13px; ">    <span style="color: #253af5">end</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Courier; color: rgb(37, 58, 245); font-size: 13px; ">end<span style="color: #000000">;</span></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Courier; min-height: 11px; font-size: 13px; "> <br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 9px/normal Courier; font-size: 13px; ">std_plotcurve(erpTimes, erpData2);</div><div><br></div><div>Best,</div><div><br></div><div>Arno</div><div><br><div><div>On 15 Mar 2013, at 01:24, Tarik S Bel-Bahar wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hello,<br>Here below is an example of some code that used to work when I had to<br>merge ICs in the past,<br>So I am not sure if it still works.<br>A standardized solution would be useful.<br>If possible, any followup thoughts from Makoto or Arno would be nice.<br>For the time being, I hope it's a step in the right direction.<br><br><br>IC1=1;IC2=3;<br>% normalize scalp maps (columns of W^-1) to have same sign<br>    sgn = sign(corr(EEG.icawinv(:,IC1),EEG.icawinv(:,IC2)));<br><br>% average the scalp maps<br><br>EEG.icawinv(:,IC1) = (EEG.icawinv(:,IC1) + sgn*EEG.icawinv(:,IC2))/2;<br>EEG.icawinv(:,IC2) = [];<br><br> % recompute weights and sphering matrix % note that we assume<br>icaweights= W*Q where Q is the "true" sphering % matrix (who's<br>information is already contained in icawinv = W^-1=A)<br><br>EEG.icaweights = pinv(EEG.icawinv); EEG.icasphere = eye(EEG.nbchan);<br><br>% recompute ICA activations (S = W*X)<br><br>EEG.icaact = EEG.icaweights*EEG.data(:,:); EEG.icaact =<br>reshape(EEG.icaact,size(EEG.icaact,1),EEG.pnts,EEG.trials);<br>[ALLEEG, EEG, CURRENTSET] = eeg_store( ALLEEG, EEG, 2 ); eeglab redraw<br>_______________________________________________<br>Eeglablist page: <a href="http://sccn.ucsd.edu/eeglab/eeglabmail.html">http://sccn.ucsd.edu/eeglab/eeglabmail.html</a><br>To unsubscribe, send an empty email to <a href="mailto:eeglablist-unsubscribe@sccn.ucsd.edu">eeglablist-unsubscribe@sccn.ucsd.edu</a><br>For digest mode, send an email with the subject "set digest mime" to <a href="mailto:eeglablist-request@sccn.ucsd.edu">eeglablist-request@sccn.ucsd.edu</a><br></div></blockquote></div><br></div></div></body></html>