kitzeslab / opensoundscape

Open source, scalable software for the analysis of bioacoustic recordings
http://opensoundscape.org
MIT License
127 stars 14 forks source link

PCEN preprocessing! #350

Open sammlapp opened 2 years ago

sammlapp commented 2 years ago

Take a look at the paper that puts different parameter PCEN outputs on different channels - worth implementing?

sammlapp commented 2 years ago

https://arxiv.org/pdf/2102.03468.pdf

sammlapp commented 2 years ago

for now, can we write pcen(long_spectrogram? opso.signal module

sammlapp commented 2 years ago

pcen is implemented in librosa and can easily be applied to spectrograms. If you need to do pcen, simply call the librosa function: (note that you may want linear rather than log spectrogram values):

from opensoundscape.audio import Audio
from opensoundscape.spectrogram import Spectrogram
s = Spectrogram.from_audio(Audio.from_file('audio.wav'),dB_scale=False)

from librosa import pcen
new_spec = Spectrogram(pcen(s.spectrogram),s.frequencies,s.times,s.decibel_limits)

#visnualize it:
from matplotlib import pyplot as plt
plt.imshow(new_spec.spectrogram[::-1],cmap='Greys')
sammlapp commented 10 months ago

provide an example of using this in preprocessing. Consider writing a Preprocessor class implementing it, or at least an Action. The preprocessor might create a variable number of channels, each with a different pcen parameter