diff --git a/src/AudioAnalysisTools/Indices/IndexCalculate.cs b/src/AudioAnalysisTools/Indices/IndexCalculate.cs index f92456508..86a8ab322 100644 --- a/src/AudioAnalysisTools/Indices/IndexCalculate.cs +++ b/src/AudioAnalysisTools/Indices/IndexCalculate.cs @@ -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. diff --git a/src/AudioAnalysisTools/Indices/SpectralIndexValues.cs b/src/AudioAnalysisTools/Indices/SpectralIndexValues.cs index e11c0d057..1e3e01242 100644 --- a/src/AudioAnalysisTools/Indices/SpectralIndexValues.cs +++ b/src/AudioAnalysisTools/Indices/SpectralIndexValues.cs @@ -163,31 +163,29 @@ public static Image CreateImageOfSpectralIndices(SpectralIndexValues spectralInd /// /// Gets or sets the oscillation spectral index index. Created October 2018. + /// 6. /// 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; } - /// /// 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. /// 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 diff --git a/src/AudioAnalysisTools/SpectralPeakTracks.cs b/src/AudioAnalysisTools/SpectralPeakTracks.cs index 4c33be86b..ca1a58a0c 100644 --- a/src/AudioAnalysisTools/SpectralPeakTracks.cs +++ b/src/AudioAnalysisTools/SpectralPeakTracks.cs @@ -1,4 +1,4 @@ -// +// // 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). // @@ -16,7 +16,7 @@ namespace AudioAnalysisTools /// public class SpectralPeakTracks { - private static readonly string[] RidgeKeys = { "SPT", "RVT", "RHZ", "RPS", "RNG", "R3D" }; + private static readonly string[] RidgeKeys = { "SPT", "RVT", "RHZ", "RPS", "RNG" }; /// /// Initializes a new instance of the class. @@ -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; } @@ -69,11 +68,6 @@ public SpectralPeakTracks(double[,] dBSpectrogram, double peakThreshold) /// public double[] RngSpectrum { get; private set; } - /// - /// gets three directions ridge value - /// - public double[] R3DSpectrum { get; private set; } - public static string[] GetDefaultRidgeKeys() { return RidgeKeys; @@ -324,23 +318,6 @@ public void GetPeakTracksSpectrum(double[,] dBSpectrogram, double dBThreshold) //this.AvTrackDuration = TimeSpan.FromSeconds(avFramesPerTrack / framesPerSecond); } - /// - /// Calculates the max of the Horizontal, positive and negative slope ridges. - /// Could alternatively calculate the sum of the Horizontal, positive and negative slope ridges. - /// - 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 ######################################## /// diff --git a/tests/Acoustics.Test/AudioAnalysisTools/Indices/IndexCalculateTest.cs b/tests/Acoustics.Test/AudioAnalysisTools/Indices/IndexCalculateTest.cs index db0ca088f..e199a1236 100644 --- a/tests/Acoustics.Test/AudioAnalysisTools/Indices/IndexCalculateTest.cs +++ b/tests/Acoustics.Test/AudioAnalysisTools/Indices/IndexCalculateTest.cs @@ -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(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(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(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(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(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(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(expectedSpectrumFile); CollectionAssert.That.AreEqual(expectedVector, spectralIndices.PMN, AllowedDelta); - // R3D - expectedSpectrumFile = new FileInfo(resourcesDir + "\\R3D.bin"); - - // Binary.Serialize(expectedSpectrumFile, spectralIndices.R3D); - expectedVector = Binary.Deserialize(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(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(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(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(expectedSpectrumFile); CollectionAssert.That.AreEqual(expectedVector, spectralIndices.RVT, AllowedDelta); - // SPT + // 12:SPT expectedSpectrumFile = new FileInfo(resourcesDir + "\\SPT.bin"); // Binary.Serialize(expectedSpectrumFile, spectralIndices.SPT);