mikexcohen / AnalyzingNeuralTimeSeries

Code for ANTS book (Cohen, 2012, MIT Press)
178 stars 77 forks source link

Figure 14.9 Unused Variable #3

Open kylmcgr opened 10 months ago

kylmcgr commented 10 months ago

The variable final_filt_result gets defined but is never used in chapter 14. I assume that it is supposed to be plotted after it is calculated in Figure 14.9 instead of reverse_filt. It looks like reverse_filt is close enough to symmetrical that there isn't a visible effect on the plot itself, but thought I would still mention it anyways. Thanks!

mikexcohen commented 9 months ago

Hi Kyle. First of all, my apologies for taking so long to get to this.

I apologize for the confusion in the code. In fact, final_filt_result (the output of filter(), reversing, filter() again, then reversing again) is the same as the output of filtfilt(). If you have the signal processing toolbox, you can just use filtfilt(); if you don't have the signal processing toolbox, you'd use filter() twice to get the variable final_filt_result. I put it in the code for people to see how to apply a zero-phase-shift filter without the signal processing toolbox.

kylmcgr commented 8 months ago

No worries, and that makes sense! Correct me if I'm wrong, but it looks like reverse_filt is just filter(), reversing, and filter() without the second reversal. Super minor and doesn't really effect the plot, but it seems like it did mean to be final_filt_result plotted instead in Figure 14.9? I put the relevant code snippet below.

forward_filt = filter(filterweights,1,wavelet);
reverse_filt = filter(filterweights,1,forward_filt(end:-1:1));
final_filt_result = reverse_filt(end:-1:1); % must reverse time again!

figure
plot(wavelet)
hold on
plot(forward_filt,'r')
plot(reverse_filt,'m')