From ea1f1dbe8dffef3fd3c3614fab113385e715b5d3 Mon Sep 17 00:00:00 2001 From: towsey Date: Tue, 13 Oct 2020 21:50:39 +1100 Subject: [PATCH] Improve result on Cisticola recognizer test. Now get 19 TP detections --- .../Towsey.CisticolaExilis.yml | 4 +-- .../Recognizers/GenericRecognizer.cs | 27 ++++++++++--------- .../Recognizers/CisticolaTests.cs | 8 +++--- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.CisticolaExilis.yml b/src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.CisticolaExilis.yml index f8b14061e..8590eebd9 100644 --- a/src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.CisticolaExilis.yml +++ b/src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.CisticolaExilis.yml @@ -58,10 +58,10 @@ PostProcessing: ExpectedBandwidth: 600 BandwidthStandardDeviation: 150 - # 4: Filter the events for excess activity in their sidebands, i.e. upper and lower buffer zones + # 5: Filter the events for excess activity in their sidebands, i.e. upper and lower buffer zones SidebandActivity: LowerHertzBuffer: 0 - UpperHertzBuffer: 0 #200 + UpperHertzBuffer: 200 DecibelBuffer: 2.0 # Options to save results files diff --git a/src/AnalysisPrograms/Recognizers/GenericRecognizer.cs b/src/AnalysisPrograms/Recognizers/GenericRecognizer.cs index 116ddbf26..d40715e29 100644 --- a/src/AnalysisPrograms/Recognizers/GenericRecognizer.cs +++ b/src/AnalysisPrograms/Recognizers/GenericRecognizer.cs @@ -352,22 +352,25 @@ public override RecognizerResults Recognize( Log.Debug($"Event count after filtering on bandwidth = {allResults.NewEvents.Count}"); } - // 5: Filter events on the amount of acoustic activity in their upper and lower neighbourhoods - their buffer zone. + // 5: Filter events on the amount of acoustic activity in their upper and lower sidebands - their buffer zone. // The idea is that an unambiguous event should have some acoustic space above and below. // The filter requires that the average acoustic activity in each frame and bin of the upper and lower buffer zones should not exceed the user specified decibel threshold. var sidebandActivity = postprocessingConfig.SidebandActivity; - if (sidebandActivity.UpperHertzBuffer > 0 || sidebandActivity.LowerHertzBuffer > 0) + if (sidebandActivity != null) { - var spectralEvents2 = allResults.NewEvents.Cast().ToList(); - allResults.NewEvents = EventFilters.FilterEventsOnSidebandActivity( - spectralEvents2, - allResults.Sonogram, - sidebandActivity.LowerHertzBuffer, - sidebandActivity.UpperHertzBuffer, - segmentStartOffset, - sidebandActivity.DecibelBuffer); - - Log.Debug($"Event count after filtering on acoustic activity in upper/lower neighbourhood = {allResults.NewEvents.Count}"); + if (sidebandActivity.UpperHertzBuffer > 0 || sidebandActivity.LowerHertzBuffer > 0) + { + var spectralEvents2 = allResults.NewEvents.Cast().ToList(); + allResults.NewEvents = EventFilters.FilterEventsOnSidebandActivity( + spectralEvents2, + allResults.Sonogram, + sidebandActivity.LowerHertzBuffer, + sidebandActivity.UpperHertzBuffer, + segmentStartOffset, + sidebandActivity.DecibelBuffer); + + Log.Debug($"Event count after filtering on acoustic activity in upper/lower sidebands = {allResults.NewEvents.Count}"); + } } // Write out the events to log. diff --git a/tests/Acoustics.Test/AnalysisPrograms/Recognizers/CisticolaTests.cs b/tests/Acoustics.Test/AnalysisPrograms/Recognizers/CisticolaTests.cs index bb20d768f..14b4c6666 100644 --- a/tests/Acoustics.Test/AnalysisPrograms/Recognizers/CisticolaTests.cs +++ b/tests/Acoustics.Test/AnalysisPrograms/Recognizers/CisticolaTests.cs @@ -51,14 +51,14 @@ public void TestRecognizer() this.SaveTestOutput( outputDirectory => GenericRecognizer.SaveDebugSpectrogram(results, null, outputDirectory, Recognizer.SpeciesName)); - // this test returns 20 events with one false-positive. - Assert.AreEqual(20, events.Count); + // this test returns 19 events, all of them TP + Assert.AreEqual(19, events.Count); Assert.IsNull(scoreTrack); Assert.AreEqual(3, plots.Count); Assert.AreEqual(3747, sonogram.FrameCount); - Assert.IsInstanceOfType(events[6], typeof(CompositeEvent)); - var ev = (CompositeEvent)events[6]; + Assert.IsInstanceOfType(events[5], typeof(CompositeEvent)); + var ev = (CompositeEvent)events[5]; Assert.AreEqual(7.28, ev.EventStartSeconds); Assert.AreEqual(7.432, ev.EventEndSeconds);