Skip to content

DOC: Add units for SAT similarity features to docstrings #172

Open

Description

@ralphpeterson

I'm using vocalpy.feature.sat.similarity_features() to compute some features. Do you know where I can find the units for these features?

Activity

  1. NickleDave commented on Jun 25, 2024

    @NickleDave
    Contributor

    Hi @ralphpeterson -- sorry I haven't been able to get you an answer sooner.
    Here's an initial answer, I will come back and edit this a little more.

    Do you know where I can find the units for these features?

    Short answer: well, we should probably have them in our docs, or at least the docstrings.

    The real source would be the SAP docs (http://soundanalysispro.com/manual/chapter-4-the-song-features-of-sap2) and the original paper describing the method using a similar set of features (https://citeseerx.ist.psu.edu/document?repid=rep1&type=pdf&doi=77e7e76f1706d6aa73e7dc9464c1817dc978926e). Note, though, that vocalpy implements the features from Sound Analysis Toolbox, that is written in Matlab, and as far as I know does not have any documentation besides this page: http://soundanalysispro.com/matlab-sat

    I'll do my best to write down what I can gather from those sources here, for the list of features returned by feature.sat.similarity_features.

    amplitude

    is in decibels; note that we copy exactly what SAT/SAP do (according to the SAT code and the SAP docs):

    This is different from the SAP paper, that describes amplitude as "unitless", although they point out you can convert to decibels given a reference amplitude. The way I'm used to seeing it done is with a factor of 20 under the assumption we are working with the signal's amplitude (see http://msp.ucsd.edu/techniques/v0.08/book-html/node6.html and https://dspillustrations.com/pages/posts/misc/decibel-conversion-factor-10-or-factor-20.html) Basically you would take the values and convert it with amp_dBs = 20 * np.log10(amp / amp_ref) but we instead multiply by 10. Not sure what detail I'm missing though, maybe because we are summing energy in the columns of the spectrogram to get the amplitude?

    pitch

    we are using the librosa implementation of the YIN algorithm (http://audition.ens.fr/adc/pdf/2002_JASA_YIN.pdf), a good enough approximation of SAT using (IIRC) the original C implementation of YIN that they vendor, or something like that. So, here "pitch" is really fundamental frequency, and as such I think it should be given in Hertz.

    goodness of pitch

    http://soundanalysispro.com/manual/chapter-4-the-song-features-of-sap2/goodness-of-pitch
    The SAP docs say "Units are comparable to amplitude and can be converted to dB by subtracting a baseline and converting to log scale (not implemented in current version)."

    SAT is basically taking the max of the cepstrum, in units of quefrencies, which I think should be "seconds", although the way we end up back at seconds is weird if you are doing dimensional analysis, see https://en.wikipedia.org/wiki/Cepstrum#Related_concepts

    frequency modulation

    See http://soundanalysispro.com/manual/chapter-4-the-song-features-of-sap2/frequency-amplitude-modulation
    "FM is the angular component of the squared time and frequency derivatives" ... so I think that means it's in radians.

    amplitude modulation

    See again http://soundanalysispro.com/manual/chapter-4-the-song-features-of-sap2/frequency-amplitude-modulation

    "Units of AM are 1/t"

    entropy

    The SAP docs say "Wiener entropy is a pure number, , that is, it does not have units"
    http://soundanalysispro.com/manual/chapter-4-the-song-features-of-sap2/wiener-entropy
    but I see other sources saying you can convert it to dBs (https://en.wikipedia.org/wiki/Spectral_flatness#Formulation).
    The vocalpy code does what SAT does, which I think is leaving it as a "pure number", i.e. just treating the spectrum as a probability distribution, basically

    Hope that helps! Happy to hear any feedback on if we should put this in the docs, try to add units with xarray, etc

  2. ralphpeterson commented on Jun 26, 2024

    @ralphpeterson
    ContributorAuthor

    Thanks David! I think units in the docstring + somewhere else in the documentation would be good for users reporting these features in papers

  3. changed the title [-]units for similarity features[/-] [+]DOC: Add units for SAT similarity features to docstrings[/+] on Jun 26, 2024
  4. NickleDave commented on Jun 26, 2024

    @NickleDave
    Contributor

    Agreed, good idea. Changed the issue title and will put this on the to-do list. Thank you @ralphpeterson

  5. added
    DOC: documentation
    on Jun 26, 2024
  6. self-assigned this
    on Jun 26, 2024
  7. added this to vocalpy-0.11.0 and removed this from vocalpy-0.10.0on Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

DOC: documentation

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions