From 093551edc60d7d49f9ddea5199bac1f14d5e003a Mon Sep 17 00:00:00 2001 From: Michael Towsey Date: Fri, 12 Jun 2020 16:38:52 +1000 Subject: [PATCH] Remove unneeded code Update src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.AnthusNovaeseelandiae.yml Co-authored-by: Anthony Truskinger Update src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.BotaurusPoiciloptilus.yml Co-authored-by: Anthony Truskinger Update src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.CisticolaExilis.yml Co-authored-by: Anthony Truskinger Update tests/Acoustics.Test/AnalysisPrograms/Recognizers/AustBitternTests.cs Co-authored-by: Anthony Truskinger Update tests/Acoustics.Test/AnalysisPrograms/Recognizers/AustralPipitTests.cs Co-authored-by: Anthony Truskinger Update src/AnalysisPrograms/Recognizers/Birds/AnthusNovaeseelandiae.cs Co-authored-by: Anthony Truskinger Update src/AnalysisPrograms/Recognizers/Birds/AnthusNovaeseelandiae.cs Co-authored-by: Anthony Truskinger Update src/AnalysisPrograms/Recognizers/Birds/CisticolaExilis.cs Co-authored-by: Anthony Truskinger Update src/AnalysisPrograms/Recognizers/Birds/CisticolaExilis.cs Co-authored-by: Anthony Truskinger Update src/AnalysisPrograms/Recognizers/Birds/CisticolaExilis.cs Co-authored-by: Anthony Truskinger Update src/AnalysisPrograms/Recognizers/Birds/BotaurusPoiciloptilus.cs Co-authored-by: Anthony Truskinger Update src/AnalysisPrograms/Recognizers/Birds/NinoxBoobook.cs Co-authored-by: Anthony Truskinger Update src/AnalysisPrograms/Recognizers/Birds/AnthusNovaeseelandiae.cs Co-authored-by: Anthony Truskinger Update AnthusNovaeseelandiae.cs Issue #321 Removed unused method. --- .../Towsey.AnthusNovaeseelandiae.yml | 12 +-- .../Towsey.BotaurusPoiciloptilus.yml | 12 --- .../Towsey.CisticolaExilis.yml | 12 +-- .../Birds/AnthusNovaeseelandiae.cs | 80 +------------------ .../Birds/BotaurusPoiciloptilus.cs | 1 - .../Recognizers/Birds/CisticolaExilis.cs | 15 ---- .../Recognizers/Birds/NinoxBoobook.cs | 1 - .../Recognizers/AustBitternTests.cs | 6 +- .../Recognizers/AustralPipitTests.cs | 4 +- 9 files changed, 10 insertions(+), 133 deletions(-) diff --git a/src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.AnthusNovaeseelandiae.yml b/src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.AnthusNovaeseelandiae.yml index 73761f0f3..e557d3e22 100644 --- a/src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.AnthusNovaeseelandiae.yml +++ b/src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.AnthusNovaeseelandiae.yml @@ -58,14 +58,4 @@ DisplayCsvImage: false # Other config files to reference HighResolutionIndicesConfig: "../Towsey.Acoustic.HiResIndicesForRecognisers.yml" -################################################################################ -# Common settings -#Standard: &STANDARD -#EventThreshold: 0.2 -#BgNoiseThreshold: 3.0 - -# This notation means the a profile has all of the settings that the Standard profile has, -# however, the DctDuration parameter has been overridden. -# <<: *STANDARD -# DctDuration: 0.3 -... \ No newline at end of file +... diff --git a/src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.BotaurusPoiciloptilus.yml b/src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.BotaurusPoiciloptilus.yml index bda07129e..85250e3eb 100644 --- a/src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.BotaurusPoiciloptilus.yml +++ b/src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.BotaurusPoiciloptilus.yml @@ -57,15 +57,3 @@ DisplayCsvImage: false # Other config files to reference HighResolutionIndicesConfig: "../Towsey.Acoustic.HiResIndicesForRecognisers.yml" -... - -################################################################################ -# Common settings -#Standard: &STANDARD -#EventThreshold: 0.2 -#BgNoiseThreshold: 3.0 - -# This notation means the a profile has all of the settings that the Standard profile has, -# however, the DctDuration parameter has been overridden. -# <<: *STANDARD -# DctDuration: 0.3 \ No newline at end of file diff --git a/src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.CisticolaExilis.yml b/src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.CisticolaExilis.yml index 14f300049..36dc72890 100644 --- a/src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.CisticolaExilis.yml +++ b/src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.CisticolaExilis.yml @@ -58,14 +58,4 @@ DisplayCsvImage: false # Other config files to reference HighResolutionIndicesConfig: "../Towsey.Acoustic.HiResIndicesForRecognisers.yml" -################################################################################ -# Common settings -#Standard: &STANDARD -#EventThreshold: 0.2 -#BgNoiseThreshold: 3.0 - -# This notation means the a profile has all of the settings that the Standard profile has, -# however, the DctDuration parameter has been overridden. -# <<: *STANDARD -# DctDuration: 0.3 -... \ No newline at end of file +... diff --git a/src/AnalysisPrograms/Recognizers/Birds/AnthusNovaeseelandiae.cs b/src/AnalysisPrograms/Recognizers/Birds/AnthusNovaeseelandiae.cs index db70e7f76..1c70b0e3e 100644 --- a/src/AnalysisPrograms/Recognizers/Birds/AnthusNovaeseelandiae.cs +++ b/src/AnalysisPrograms/Recognizers/Birds/AnthusNovaeseelandiae.cs @@ -93,9 +93,6 @@ public override RecognizerResults Recognize( imageWidth); // ################### POST-PROCESSING of EVENTS ################### - // Following two commented lines are different ways of casting lists. - //var newEvents = spectralEvents.Cast().ToList(); - //var spectralEvents = events.Select(x => (SpectralEvent)x).ToList(); if (combinedResults.NewEvents.Count == 0) { @@ -118,15 +115,6 @@ public override RecognizerResults Recognize( combinedResults.NewEvents = FilterEventsOnFrequencyProfile(combinedResults.NewEvents); - //foreach (var ev in whistleEvents) - //{ - // // Calculate frequency profile score for event - // SetFrequencyProfileScore((WhistleEvent)ev); - //} - - //UNCOMMENT following line if you want special debug spectrogram, i.e. with special plots. - // NOTE: Standard spectrograms are produced by setting SaveSonogramImages: "True" or "WhenEventsDetected" in UserName.SpeciesName.yml config file. - //GenericRecognizer.SaveDebugSpectrogram(territorialResults, genericConfig, outputDirectory, audioRecording.BaseName); return combinedResults; } @@ -158,6 +146,9 @@ public static List FilterEventsOnFrequencyProfile(List var componentEvents = ev.ComponentEvents; var points = EventExtentions.GetCompositeTrack(componentEvents).ToArray(); + // Uncomment this line when want to see the composite track profile. + //WriteFrequencyProfile(points); + // For Pipit require minimum of four frames duration. var length = points.Length; if (length < 4) @@ -165,8 +156,6 @@ public static List FilterEventsOnFrequencyProfile(List continue; } - //WriteFrequencyProfile(points); - // Only select events having strong downward slope in spectrogram. var avFirstTwoEvents = (points[0].Hertz.Minimum + points[0].Hertz.Minimum) / 2; var avLastTwoEvents = (points[length - 1].Hertz.Minimum + points[length - 2].Hertz.Minimum) / 2; @@ -179,70 +168,8 @@ public static List FilterEventsOnFrequencyProfile(List return returnEvents; } - /// - /// The Boobook call syllable is shaped like an inverted "U". Its total duration is close to 0.15 seconds. - /// The rising portion lasts for 0.06s, followed by a turning portion, 0.03s, followed by the decending portion of 0.06s. - /// The constants for this method were obtained from the calls in a Gympie recording obtained by Yvonne Phillips. - /// - /// An event containing at least one forward track i.e. a chirp. - public static void SetFrequencyProfileScore(ChirpEvent ev) - { - const double risingDuration = 0.06; - const double gapDuration = 0.03; - const double fallingDuration = 0.06; - - var track = ev.Tracks.First(); - var profile = track.GetTrackFrequencyProfile().ToArray(); - - // get the first point - var firstPoint = track.Points.First(); - var frameDuration = firstPoint.Seconds.Maximum - firstPoint.Seconds.Minimum; - var risingFrameCount = (int)Math.Floor(risingDuration / frameDuration); - var gapFrameCount = (int)Math.Floor(gapDuration / frameDuration); - var fallingFrameCount = (int)Math.Floor(fallingDuration / frameDuration); - - var startSum = 0.0; - if (profile.Length >= risingFrameCount) - { - for (var i = 0; i <= risingFrameCount; i++) - { - startSum += profile[i]; - } - } - - int startFrame = risingFrameCount + gapFrameCount; - int endFrame = startFrame + fallingFrameCount; - var endSum = 0.0; - if (profile.Length >= endFrame) - { - for (var i = startFrame; i <= endFrame; i++) - { - endSum += profile[i]; - } - } - - // set score to 1.0 if the profile has inverted U shape. - double score = 0.0; - if (startSum > 0.0 && endSum < 0.0) - { - score = 1.0; - } - - ev.FrequencyProfileScore = score; - } - - /// - /// . - /// - /// List of spectral points. public static void WriteFrequencyProfile(ISpectralPoint[] points) { - /* Here are the frequency profiles of some events. - * Note that the first five frames (0.057 seconds) have positive slope and subsequent frames have negative slope. - * The final frames are likely to be echo and to be avoided. - * Therefore take the first 0.6s to calculate the positive slope, leave a gap of 0.025 seconds and then get negative slope from the next 0.6 seconds. - */ - if (points != null) { var str = $"Track({points[0].Seconds.Minimum:F2}):"; @@ -273,7 +200,6 @@ public override void SummariseResults( } */ - /// /> public class PipitConfig : GenericRecognizerConfig, INamedProfiles { } diff --git a/src/AnalysisPrograms/Recognizers/Birds/BotaurusPoiciloptilus.cs b/src/AnalysisPrograms/Recognizers/Birds/BotaurusPoiciloptilus.cs index ddcb0da5e..02a868fde 100644 --- a/src/AnalysisPrograms/Recognizers/Birds/BotaurusPoiciloptilus.cs +++ b/src/AnalysisPrograms/Recognizers/Birds/BotaurusPoiciloptilus.cs @@ -155,7 +155,6 @@ public override void SummariseResults( } */ - /// /> public class BotaurusPoiciloptilusConfig : GenericRecognizerConfig, INamedProfiles { } diff --git a/src/AnalysisPrograms/Recognizers/Birds/CisticolaExilis.cs b/src/AnalysisPrograms/Recognizers/Birds/CisticolaExilis.cs index 858ef05f9..34f20b9ba 100644 --- a/src/AnalysisPrograms/Recognizers/Birds/CisticolaExilis.cs +++ b/src/AnalysisPrograms/Recognizers/Birds/CisticolaExilis.cs @@ -60,16 +60,6 @@ public override AnalyzerConfig ParseConfig(FileInfo file) throw new ConfigFileException("CisticolaExilis expects one and only one UpwardTrack algorithm.", file); } - /// - /// This method is called once per segment (typically one-minute segments). - /// - /// one minute of audio recording. - /// config file that contains parameters used by all profiles. - /// when recording starts. - /// not sure what this is. - /// where the recognizer results can be found. - /// assuming ????. - /// recognizer results. public override RecognizerResults Recognize( AudioRecording audioRecording, Config config, @@ -91,10 +81,6 @@ public override RecognizerResults Recognize( imageWidth); // ################### POST-PROCESSING of EVENTS ################### - // Following two commented lines are different ways of casting lists. - //var newEvents = spectralEvents.Cast().ToList(); - //var spectralEvents = events.Select(x => (SpectralEvent)x).ToList(); - if (combinedResults.NewEvents.Count == 0) { CisticolaLog.Debug($"Return zero events."); @@ -144,7 +130,6 @@ public override void SummariseResults( } */ - /// /> public class CisticolaExilisConfig : GenericRecognizerConfig, INamedProfiles { } diff --git a/src/AnalysisPrograms/Recognizers/Birds/NinoxBoobook.cs b/src/AnalysisPrograms/Recognizers/Birds/NinoxBoobook.cs index 2dec4eeca..488d1abad 100644 --- a/src/AnalysisPrograms/Recognizers/Birds/NinoxBoobook.cs +++ b/src/AnalysisPrograms/Recognizers/Birds/NinoxBoobook.cs @@ -266,7 +266,6 @@ public override void SummariseResults( } */ - /// /> public class NinoxBoobookConfig : GenericRecognizerConfig, INamedProfiles { } diff --git a/tests/Acoustics.Test/AnalysisPrograms/Recognizers/AustBitternTests.cs b/tests/Acoustics.Test/AnalysisPrograms/Recognizers/AustBitternTests.cs index 08587a799..7962248cc 100644 --- a/tests/Acoustics.Test/AnalysisPrograms/Recognizers/AustBitternTests.cs +++ b/tests/Acoustics.Test/AnalysisPrograms/Recognizers/AustBitternTests.cs @@ -71,8 +71,8 @@ public void TestRecognizer() Assert.AreEqual(12.224, onlyEvent.EventEndSeconds); Assert.AreEqual(105, onlyEvent.LowFrequencyHertz); Assert.AreEqual(180, onlyEvent.HighFrequencyHertz); - Assert.AreEqual(24.076815193551525, onlyEvent.Score, 0.01); - Assert.AreEqual(0.476507384367336, onlyEvent.ScoreNormalized, 0.01); + Assert.AreEqual(24.076815193551525, onlyEvent.Score, TestHelper.AllowedDelta); + Assert.AreEqual(0.476507384367336, onlyEvent.ScoreNormalized, TestHelper.AllowedDelta); } } -} \ No newline at end of file +} diff --git a/tests/Acoustics.Test/AnalysisPrograms/Recognizers/AustralPipitTests.cs b/tests/Acoustics.Test/AnalysisPrograms/Recognizers/AustralPipitTests.cs index 68b3c2a2b..5da5c9539 100644 --- a/tests/Acoustics.Test/AnalysisPrograms/Recognizers/AustralPipitTests.cs +++ b/tests/Acoustics.Test/AnalysisPrograms/Recognizers/AustralPipitTests.cs @@ -80,7 +80,7 @@ public void TestRecognizer() var points = EventExtentions.GetCompositeTrack(componentEvents).ToArray(); Assert.AreEqual(16.672, points[1].Seconds.Minimum); Assert.AreEqual(5425, points[1].Hertz.Minimum); - Assert.AreEqual(23.71245325, points[1].Value, 0.001); + Assert.AreEqual(23.71245325, points[1].Value, TestHelper.AllowedDelta); } } -} \ No newline at end of file +}