Specifying the frequency range using vak


I have worked through the vak tutorials and got everything up and running - kudos to the developers! I could not find any information or tutorials on how to change the frequency range or limits of the spectrogram, or even what the default frequency range is for creating the spectrograms. Any information or insight on this would be great, as I would like to focus on a relatively narrow frequency range! Thanks.

1 Like

Hi @denajane13, welcome to the forum and thanks for your kind words on the tutorials. Glad to hear you were able to get everything up and running.

You can set a frequency range for the spectrograms by using the option freq_cutoffs in the SPECT_PARAMS section of the configuration file.

This applies a bandpass filter at those frequency ranges, and also “crops” the computed spectrogram so it only includes those frequencies, as in the function here: https://github.com/vocalpy/vak/blob/3c6393d0c0f3db5a32a1501363b44a7f7cda93f4/src/vak/prep/spectrogram_dataset/spect.py#L95

If for any reason you would prefer to use your own spectrograms that you generate outside of vak, you can do so as described here:

Looking at that page again, I am realizing it would probably be helpful to have an example script there. I’m happy to write one, test that it works as intended, and post it here for you if it would help.

Longer term, we can add other functionality to help with this.
One way would be to allow a transform that crops when loading spectrogram files using the saved frequency bin vectors.
Another way would be to allow you to use your own spectrogram function but not have to write a script to make the spectrograms. I’ve been thinking about this anyway, I just raised an issue to add it here:

Let me know if that helps!