CSC-UW / csc-eeg-tools

Set of matlab functions for EEG io, preprocessing, analysis from the Center for Sleep and Consciousness, University of Wisconsin (csc)
19 stars 7 forks source link

Discrepancy in updated fft method #2

Closed Mensen closed 8 years ago

Mensen commented 9 years ago

While checking the new version of the preprocessing script it appears that this is not exactly doing what done before in WISPIC scripts: on top of channel threshold of fft outlier there was also a sliding mean process done for epoch rejection.. see wispic script excerpt below We will try to work on this and of course add this to to do list in github

badepallch=cell(nch,1); fftNREM_SWAartest=fftNREM_SWAar; fftNREM_HFartest=fftNREM_HFar;

Epochrange=6;Factor_SWA=2;Factor_HF=5; for ch=1:nch; if badchannels(ch)>0; fftNREM_SWAartest(ch,:)=NaN; else for i=1:numepo; p99=p99all(ch); SlidingMean(i)=nanmean(fftNREM_SWAar(ch,max(i-Epochrange,1):min(i+Epochrange,numepo))); if SlidingMean(i)==NaN; continue else if fftNREM_SWAartest(ch,i)>=(1+Factor_SWA)*SlidingMean(i)||fftNREM_SWAartest(ch,i)>=p99; fftNREM_SWAartest(ch,i)=NaN; end; end end end

Mensen commented 9 years ago

I do remember trying to sort out this part of the script which is difficult considering there are no comments about what the purpose is.

However, this sliding mean is simply taking the ffts from (arbitrarily) 6 epochs back and forward and averaging the power. Thus, it is basically high pass filtering an fft response, which is basically equivalent to just using a longer epoch window (in this case 12 times the stated length) and overlapping epochs.

I did not reproduce this functionality because this sort of trick is best made explicit in its behaviour and adjusted using optional parameters and the script improvement should be on adding overlapping windows of longer epoch length. Not using an essentially hidden sliding mean approach.