mikexcohen / AnalyzingNeuralTimeSeries

Code for ANTS book (Cohen, 2012, MIT Press)
170 stars 76 forks source link

An empirical scaling factor #4

Open RainyMeadows opened 7 months ago

RainyMeadows commented 7 months ago

I was going through your code to see how close my tries to reconstruct the figures in the book went, and line 190 in chapter12.m caught me by surprise.

Firstly, feeding n_conv to ift is extraneous since both our inputs have been constrained to have n_conv time-points. Secondly, what explains the downscaling by a factor of 10?

mikexcohen commented 7 months ago

Hi Rainy. I probably discuss these in the book or online videos. The spectra do need to have the same lengths for the multiplication. The inverse FT does not need to be n_conv points long; that's a parameter you can set, for example if you want to upsample via sinc-interpolation. The second input to ifft defaults to the length of the spectrum, so explicitly including n_conv here is done as a reminder of the mechanics of convolution.

The scaling factor is for visualizing the wavelet and filter results in the same graph. Normalizing wavelets is a bit tricky, and I discuss it in more detail elsewhere (briefly: the best way to normalize wavelets is by max-amplitude unit normalizing in the frequency domain; I don't do that in this chapter in the interest of simplicity). Actually, normalizing filter kernels is also a bit tricky, but MATLAB handles that for us :)