Raven Help Forum  

Go Back   Raven Help Forum > Raven Pro > Raven - Help and Discussion
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-07-2017, 03:49 PM
mx52 mx52 is offline
Junior Member
 
Join Date: Feb 2017
Posts: 4
Default normalize and export power spectrum

Hi,

I'm really new to sound analysis and Raven. I would like to generate normalized power spectra from pulses of two different cricket species, and calculate how much the two power spectra overlap. In trying to do this in Raven, I have two questions:
1. Is there a way to generate a normalized power spectrum in RavenPro (I have 1.4)? Alternatively, should I normalize my sound recordings first before input into Raven?
2. How do I get the frequencies of the output power values?

Thank you very much!
Reply With Quote
  #2  
Old 03-08-2017, 12:16 PM
Michael Pitzrick Michael Pitzrick is offline
Administrator
 
Join Date: Sep 2008
Posts: 233
Default Re: normalize and export power spectrum

Quote:
Originally Posted by mx52 View Post
Hi,

I'm really new to sound analysis and Raven. I would like to generate normalized power spectra from pulses of two different cricket species, and calculate how much the two power spectra overlap. In trying to do this in Raven, I have two questions:
1. Is there a way to generate a normalized power spectrum in RavenPro (I have 1.4)? Alternatively, should I normalize my sound recordings first before input into Raven?
2. How do I get the frequencies of the output power values?

Thank you very much!
Hi mx52,

It sounds like you might be interested in exploring Raven Pro's "Correlation" feature, which can be configured to compare normalized spectrograms. Check out Chapter 9 of the Raven Pro User's Manual, which you can open from the Help menu in Raven.

Regarding the determination of the frequency where most of the power occurs, you may be interested in investigating Raven's "Spectrogram Slice" and "Selection Spectrum" views, which you can read about in Chapter 5 of the Manual. You may also be interested in the Raven "Measurement" feature, especially the "Peak Freq", "Center Freq", "Peak Frequency Contour", and "Frequency Contour 50%ile" measurements, as described in Chapter 6 of the Manual and in What's New in Raven Pro.

-Mike
Reply With Quote
  #3  
Old 03-08-2017, 03:53 PM
mx52 mx52 is offline
Junior Member
 
Join Date: Feb 2017
Posts: 4
Default Re: normalize and export power spectrum

Hi Mike,

Many thanks for your response! Maybe I didn't explain what I want to do clearly enough. What I want to compare are the average power spectra of the two species without the time dimension, i.e., what proportion of the area under the power spectrum curves overlap between the two species. For this purpose I don't think cross correlation is the appropriate measurement. We can imagine two pulses that are the mirror images along the time axis but have exactly the same power spectrum. They would have low correlation coefficient but 100% overlap for the power spectrum.

Many papers I read use customized program to do this but i'm not very good with programming so I'm trying to see if I can do this with existing functions in Raven. If Raven can give me a txt file for the frequencies and power values of a power spectrum from a selection, then I would do this for all individuals of both species, calculate an average power spectrum for each species, and obtain % overlap by summing up the %overlap of power value at each frequency (so it's an approximation of the area under the curve).

I can now get Raven to export power values for a power spectrum of a selection but I want to know for each power value in the exported txt file, what is the frequency associated with it (otherwise I can't plot it). Is there a way to know that given the frequency resolution I choose? So to get back to your response, I'm not interested in measuring central or peak frequency here.

I also noticed that Raven can normalize power spectra when we calculate cross correlation. I wonder if there is such a normalization function for power spectrum of a single selection. If not, maybe I should normalize my recordings before I import them into Raven?

Do these make sense to you? Can you help me? I really appreciate any input you have!
Reply With Quote
  #4  
Old 03-08-2017, 07:46 PM
Michael Pitzrick Michael Pitzrick is offline
Administrator
 
Join Date: Sep 2008
Posts: 233
Default Re: normalize and export power spectrum

Quote:
Originally Posted by mx52 View Post
Hi Mike,

Many thanks for your response! Maybe I didn't explain what I want to do clearly enough. What I want to compare are the average power spectra of the two species without the time dimension, i.e., what proportion of the area under the power spectrum curves overlap between the two species. For this purpose I don't think cross correlation is the appropriate measurement. We can imagine two pulses that are the mirror images along the time axis but have exactly the same power spectrum. They would have low correlation coefficient but 100% overlap for the power spectrum.

Many papers I read use customized program to do this but i'm not very good with programming so I'm trying to see if I can do this with existing functions in Raven. If Raven can give me a txt file for the frequencies and power values of a power spectrum from a selection, then I would do this for all individuals of both species, calculate an average power spectrum for each species, and obtain % overlap by summing up the %overlap of power value at each frequency (so it's an approximation of the area under the curve).

I can now get Raven to export power values for a power spectrum of a selection but I want to know for each power value in the exported txt file, what is the frequency associated with it (otherwise I can't plot it). Is there a way to know that given the frequency resolution I choose? So to get back to your response, I'm not interested in measuring central or peak frequency here.

I also noticed that Raven can normalize power spectra when we calculate cross correlation. I wonder if there is such a normalization function for power spectrum of a single selection. If not, maybe I should normalize my recordings before I import them into Raven?

Do these make sense to you? Can you help me? I really appreciate any input you have!
Hi mx52,

It sounds like you've figured out how to export an average spectrum for any sound selection you choose. When you say "normalize" the spectrum, I would ask normalize relative to what exactly? If you mean normalize relative to the maximum spectrum bin for a selection, you can do that using Excel or some other application. Excel or another application can also be used for subtracting the normalized values of two spectra. It is critical to compare only spectra for which the same selection spectrum parameters were used.

Note that the "spectral power" values in Raven are really "power spectral density" values. These two terms are frequently conflated in the literature.

You can easily see the frequency bounds of the spectrum bins if you disable spectrum smoothing using the View menu. Bin width is equal to the "Grid Spacing" in the Spectrogram parameters you use for the selection spectrum, except for the first and last bins which are 50% of Grid Spacing.

-Mike
Reply With Quote
  #5  
Old 03-09-2017, 02:50 PM
Michael Pitzrick Michael Pitzrick is offline
Administrator
 
Join Date: Sep 2008
Posts: 233
Default Re: normalize and export power spectrum

Quote:
Originally Posted by mx52 View Post
Hi,

I'm really new to sound analysis and Raven. I would like to generate normalized power spectra from pulses of two different cricket species, and calculate how much the two power spectra overlap. In trying to do this in Raven, I have two questions:
1. Is there a way to generate a normalized power spectrum in RavenPro (I have 1.4)? Alternatively, should I normalize my sound recordings first before input into Raven?
2. How do I get the frequencies of the output power values?

Thank you very much!
Hi mx52,

I sent your question on to Dean, who knows a lot about signal processing. Here is his response, in which he describes specific methods for normalizing your selection spectra and estimating the similarity between them.

-Mike


It sounds like the user wants to have a measure of similarity between two power spectra. You can define the probability of information in the signal x as a function of frequency Pr(x,f) as PSD(f)/sum(PSD(f)), and likewise for signal y.

From there one has a choice of how to measure the distance between the 2 probability distributions. The most simple metrics are the Bhattacharyya coefficient and the symmetrized Kullback-Leibler divergence. The Bhattacharyya coefficient, BC, is just sum_over_f( sqrt(Pr(x,f)*Pr(y,f) ). The symmetrized KL divergence, KL_sym, is given by 1/2 *( sum_over_f( Pr(x,f)*ln( Pr(x,f)/Pr(y,f) ) + sum_over_f( Pr(y,f)*ln( Pr(y,f)/Pr(x,f) ) ).

Raven does not provide these measurements out of the box; one would have to export the selection spectrum values, normalize them, and then calculate the metrics. BC and KL_sym have different interpretations: if the distributions are identical, the BC is 1 and KL_sym is 0. If Pr(x) is non-zero only at places where Pr(y) is zero, i.e. the distributions have nothing in common, the BC is 0 and the KL_sym is infinity. My guess is that BC is a better choice for the user because it is bounded between 0 and 1.
Reply With Quote
  #6  
Old 03-09-2017, 06:14 PM
mx52 mx52 is offline
Junior Member
 
Join Date: Feb 2017
Posts: 4
Default Re: normalize and export power spectrum

Hi Mike,

Thank you and Dean for your help! I just have one more question. When I export selection spectrum values, I get a txt file of only power values sorted from max to min but I don't know what is the frequency associate with each power value. Is there a way of knowing that? I'm so sorry that I have a lot of questions. Thank you ahead!
Reply With Quote
  #7  
Old 03-09-2017, 06:23 PM
Michael Pitzrick Michael Pitzrick is offline
Administrator
 
Join Date: Sep 2008
Posts: 233
Default Re: normalize and export power spectrum

Quote:
Originally Posted by mx52 View Post
Hi Mike,

Thank you and Dean for your help! I just have one more question. When I export selection spectrum values, I get a txt file of only power values sorted from max to min but I don't know what is the frequency associate with each power value. Is there a way of knowing that? I'm so sorry that I have a lot of questions. Thank you ahead!
Hi mx52,

You can easily see the frequency bounds of the spectrum bins if you disable spectrum smoothing using the View menu. Bin width is equal to the "Grid Spacing" in the Spectrogram parameters you use for the selection spectrum, except for the first and last bins which are 50% of Grid Spacing.

-Mike
Reply With Quote
  #8  
Old 03-09-2017, 06:54 PM
Michael Pitzrick Michael Pitzrick is offline
Administrator
 
Join Date: Sep 2008
Posts: 233
Default Re: normalize and export power spectrum

Quote:
Originally Posted by mx52 View Post
Hi,

I'm really new to sound analysis and Raven. I would like to generate normalized power spectra from pulses of two different cricket species, and calculate how much the two power spectra overlap. In trying to do this in Raven, I have two questions:
1. Is there a way to generate a normalized power spectrum in RavenPro (I have 1.4)? Alternatively, should I normalize my sound recordings first before input into Raven?
2. How do I get the frequencies of the output power values?

Thank you very much!
Hi mx52,

Raven does *not* sort power spectral values from max to min. The sound energy distribution you describe is quite usual for ambient noise, which may well have more energy than the energy from your crickets.

-Mike
Reply With Quote
  #9  
Old 03-10-2017, 10:28 AM
mx52 mx52 is offline
Junior Member
 
Join Date: Feb 2017
Posts: 4
Default Re: normalize and export power spectrum

Hi Mike,

Many thanks for your answer again! And you are right, the values are not sorted.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 01:28 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.