Skip to content

Commit

Permalink
removed calculation of R3D
Browse files Browse the repository at this point in the history
Issue #276  Removed all references to spectral index R3D and to calculation of it.
  • Loading branch information
towsey committed Nov 25, 2019
1 parent 781d0a3 commit 96354c9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 61 deletions.
7 changes: 0 additions & 7 deletions src/AudioAnalysisTools/Indices/IndexCalculate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,6 @@ public static IndexCalculateResult Analysis(
spectralIndices.RVT = sptInfo.RvtSpectrum;
spectralIndices.RPS = sptInfo.RpsSpectrum;
spectralIndices.RNG = sptInfo.RngSpectrum;
spectralIndices.R3D = sptInfo.R3DSpectrum;

//images for debugging
//ImageTools.DrawMatrix(dspOutput3.amplitudeSpectrogram, @"C:\SensorNetworks\Output\BAC\HiResRidge\dspOutput3.amplitudeSpectrogram.png");
//ImageTools.DrawMatrix(ridgeSpectrogram, @"C:\SensorNetworks\Output\BAC\HiResRidge\ridgeSpectrogram.png");
//ImageTools.DrawMatrix(sptInfo.RvtSpectrum, @"C:\SensorNetworks\Output\BAC\HiResRidge\ridgeSpectrum.png");

summaryIndices.SptDensity = sptInfo.TrackDensity;

// these are two other indices that I tried but they do not seem to add anything of interest.
Expand Down
16 changes: 7 additions & 9 deletions src/AudioAnalysisTools/Indices/SpectralIndexValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,31 +163,29 @@ public static Image CreateImageOfSpectralIndices(SpectralIndexValues spectralInd

/// <summary>
/// Gets or sets the oscillation spectral index index. Created October 2018.
/// 6.
/// </summary>
public double[] OSC { get; set; }

// 8: Sum of Spectral Ridges in Horizontal, postive and neg slope directions (RHZ+RPS+RNG)
public double[] R3D { get; set; }

/// <summary>
/// Gets or sets PMN = Power Minus Noise.
/// PMN is measured in decibels but should replace POW as the average decibel spectrogram.
/// 7: PMN is measured in decibels but should replace POW as the average decibel spectrogram.
/// </summary>
public double[] PMN { get; set; }

// 9: Spectral Ridges Horizontal
// 8: Spectral Ridges Horizontal
public double[] RHZ { get; set; }

// 10: Spectral Ridges Vertical
// 9: Spectral Ridges Vertical
public double[] RVT { get; set; }

// 11: Spectral Ridges Positive slope
// 10: Spectral Ridges Positive slope
public double[] RPS { get; set; }

// 12: Spectral Ridges Negative Slope
// 11: Spectral Ridges Negative Slope
public double[] RNG { get; set; }

// 13: Spectral Peak Tracks
// 12: Spectral Peak Tracks
public double[] SPT { get; set; }

// This property only calculated for ACI when zooming
Expand Down
27 changes: 2 additions & 25 deletions src/AudioAnalysisTools/SpectralPeakTracks.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="SpectralPeakTracks.cs" company="QutEcoacoustics">
// <copyright file="SpectralPeakTracks.cs" company="QutEcoacoustics">
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>

Expand All @@ -16,7 +16,7 @@ namespace AudioAnalysisTools
/// </summary>
public class SpectralPeakTracks
{
private static readonly string[] RidgeKeys = { "SPT", "RVT", "RHZ", "RPS", "RNG", "R3D" };
private static readonly string[] RidgeKeys = { "SPT", "RVT", "RHZ", "RPS", "RNG" };

/// <summary>
/// Initializes a new instance of the <see cref="SpectralPeakTracks"/> class.
Expand All @@ -31,7 +31,6 @@ public SpectralPeakTracks(double[,] dBSpectrogram, double peakThreshold)
// It was changed while in Toulon to the following line which does not require a threshold.
// this.GetRidgeSpectraVersion1(dBSpectrogram, ridgeThreshold: 4.0);
this.GetRidgeSpectraVersion2(dBSpectrogram);
this.CalculateCombinationOfThreeDirections();
}

public double[,] Peaks { get; private set; }
Expand Down Expand Up @@ -69,11 +68,6 @@ public SpectralPeakTracks(double[,] dBSpectrogram, double peakThreshold)
/// </summary>
public double[] RngSpectrum { get; private set; }

/// <summary>
/// gets three directions ridge value
/// </summary>
public double[] R3DSpectrum { get; private set; }

public static string[] GetDefaultRidgeKeys()
{
return RidgeKeys;
Expand Down Expand Up @@ -324,23 +318,6 @@ public void GetPeakTracksSpectrum(double[,] dBSpectrogram, double dBThreshold)
//this.AvTrackDuration = TimeSpan.FromSeconds(avFramesPerTrack / framesPerSecond);
}

/// <summary>
/// Calculates the max of the Horizontal, positive and negative slope ridges.
/// Could alternatively calculate the sum of the Horizontal, positive and negative slope ridges.
/// </summary>
public void CalculateCombinationOfThreeDirections()
{
this.R3DSpectrum = new double[this.RhzSpectrum.Length];
for (int i = 0; i < this.RhzSpectrum.Length; i++)
{
var array = new[] { this.RhzSpectrum[i], this.RpsSpectrum[i], this.RngSpectrum[i] };
this.R3DSpectrum[i] = array.Max();

// alternatively, sum the indices
//this.R3DSpectrum[i] = this.RhzSpectrum[i] + this.RpsSpectrum[i] + this.RngSpectrum[i];
}
}

// ################################### STATIC METHODS BELOW HERE ########################################

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,93 +135,86 @@ public void TestOfSpectralIndices()
var spectralIndices = results.SpectralIndexValues;

// TEST the SPECTRAL INDICES
// After serialising the expected vector and writing to the resources directory, comment the Binary.Serialise line.
// After serializing the expected vector and writing to the resources directory, comment the Binary.Serialise line.

// ACI
// 1:ACI
var expectedSpectrumFile = new FileInfo(resourcesDir + "\\ACI.bin");

//Binary.Serialize(expectedSpectrumFile, spectralIndices.ACI);
var expectedVector = Binary.Deserialize<double[]>(expectedSpectrumFile);
CollectionAssert.That.AreEqual(expectedVector, spectralIndices.ACI, AllowedDelta);

// BGN
// 2:BGN
expectedSpectrumFile = new FileInfo(resourcesDir + "\\BGN.bin");

// Binary.Serialize(expectedSpectrumFile, spectralIndices.BGN);
expectedVector = Binary.Deserialize<double[]>(expectedSpectrumFile);
CollectionAssert.That.AreEqual(expectedVector, spectralIndices.BGN, AllowedDelta);

// CVR
// 3:CVR
expectedSpectrumFile = new FileInfo(resourcesDir + "\\CVR.bin");

// Binary.Serialize(expectedSpectrumFile, spectralIndices.CVR);
expectedVector = Binary.Deserialize<double[]>(expectedSpectrumFile);
CollectionAssert.That.AreEqual(expectedVector, spectralIndices.CVR, AllowedDelta);

// ENT
// 4:ENT
expectedSpectrumFile = new FileInfo(resourcesDir + "\\ENT.bin");

// Binary.Serialize(expectedSpectrumFile, spectralIndices.ENT);
expectedVector = Binary.Deserialize<double[]>(expectedSpectrumFile);
CollectionAssert.That.AreEqual(expectedVector, spectralIndices.ENT, AllowedDelta);

// EVN
// 5:EVN
expectedSpectrumFile = new FileInfo(resourcesDir + "\\EVN.bin");

// Binary.Serialize(expectedSpectrumFile, spectralIndices.EVN);
expectedVector = Binary.Deserialize<double[]>(expectedSpectrumFile);
CollectionAssert.That.AreEqual(expectedVector, spectralIndices.EVN, AllowedDelta);

// OSC
// 6:OSC
expectedSpectrumFile = new FileInfo(resourcesDir + "\\OSC.bin");

//Binary.Serialize(expectedSpectrumFile, spectralIndices.OSC);
expectedVector = Binary.Deserialize<double[]>(expectedSpectrumFile);
CollectionAssert.That.AreEqual(expectedVector, spectralIndices.OSC, AllowedDelta);

// PMN
// 7:PMN
expectedSpectrumFile = new FileInfo(resourcesDir + "\\PMN.bin");

// Binary.Serialize(expectedSpectrumFile, spectralIndices.PMN);
expectedVector = Binary.Deserialize<double[]>(expectedSpectrumFile);
CollectionAssert.That.AreEqual(expectedVector, spectralIndices.PMN, AllowedDelta);

// R3D
expectedSpectrumFile = new FileInfo(resourcesDir + "\\R3D.bin");

// Binary.Serialize(expectedSpectrumFile, spectralIndices.R3D);
expectedVector = Binary.Deserialize<double[]>(expectedSpectrumFile);
CollectionAssert.That.AreEqual(expectedVector, spectralIndices.R3D, AllowedDelta);

// RHZ
// 8:RHZ
expectedSpectrumFile = new FileInfo(resourcesDir + "\\RHZ.bin");

// Binary.Serialize(expectedSpectrumFile, spectralIndices.RHZ);
expectedVector = Binary.Deserialize<double[]>(expectedSpectrumFile);
CollectionAssert.That.AreEqual(expectedVector, spectralIndices.RHZ, AllowedDelta);

// RNG
// 9:RNG
expectedSpectrumFile = new FileInfo(resourcesDir + "\\RNG.bin");

// Binary.Serialize(expectedSpectrumFile, spectralIndices.RNG);
expectedVector = Binary.Deserialize<double[]>(expectedSpectrumFile);
CollectionAssert.That.AreEqual(expectedVector, spectralIndices.RNG, AllowedDelta);

// RPS
// 10:RPS
expectedSpectrumFile = new FileInfo(resourcesDir + "\\RPS.bin");

// Binary.Serialize(expectedSpectrumFile, spectralIndices.RPS);
expectedVector = Binary.Deserialize<double[]>(expectedSpectrumFile);
CollectionAssert.That.AreEqual(expectedVector, spectralIndices.RPS, AllowedDelta);

// RVT
// 11:RVT
expectedSpectrumFile = new FileInfo(resourcesDir + "\\RVT.bin");

// Binary.Serialize(expectedSpectrumFile, spectralIndices.RVT);
expectedVector = Binary.Deserialize<double[]>(expectedSpectrumFile);
CollectionAssert.That.AreEqual(expectedVector, spectralIndices.RVT, AllowedDelta);

// SPT
// 12:SPT
expectedSpectrumFile = new FileInfo(resourcesDir + "\\SPT.bin");

// Binary.Serialize(expectedSpectrumFile, spectralIndices.SPT);
Expand Down

0 comments on commit 96354c9

Please sign in to comment.