Skip to content

Commit

Permalink
Set up new unit test for Koala calls
Browse files Browse the repository at this point in the history
Issue #500 Edit the config file and construct new unit test for Koala calls. The unit test checks the three levels of returned events.
  • Loading branch information
towsey committed Nov 3, 2021
1 parent 7021502 commit 4756338
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

# Male Koala: Phascolarctos cinereus version 3.
# Resample rate must be 2 X the desired Nyquist
#ResampleRate: 20480
ResampleRate: 22050
# SegmentDuration: units=seconds;
SegmentDuration: 60
Expand All @@ -26,9 +25,9 @@ Profiles:
#Algorithm: MultiBin
ComponentName: Oscillation
FrameSize: 256
FrameStep: 100
FrameStep: 110
# min and max of the freq band to search
MinHertz: 200
MinHertz: 170
MaxHertz: 800
# Min and max durations for the length of a true event (seconds).
MinDuration: 0.2
Expand Down Expand Up @@ -62,24 +61,27 @@ PostProcessing:
CombineOverlappingEvents: false

# 2: Combine possible syllable sequences
# SyllableSequence:
# SyllableStartDifference: 1.2
# SyllableHertzGap: 2400
# FilterSyllableSequence: true
SyllableSequence:
SyllableStartDifference: 3.5
SyllableHertzGap: 200
#FilterSyllableSequence: false
# SyllableMaxCount: 3
# ExpectedPeriod: 0.1

# # # 3: Remove events whose duration lies outside 3 SDs of an expected value.
# Duration:
# ExpectedDuration: 2.5
# DurationStandardDeviation: 0.6
# 3: Remove events whose duration lies outside 3 SDs of an expected value.
# Koala calls can last for 90 seconds or more.
# The following has the effect of removing events shorter than 3 seconds & longer than 93 sec.
Duration:
ExpectedDuration: 48.0
DurationStandardDeviation: 15.0

# # 4: Remove events whose bandwidth lies outside 3 SDs of an expected value.
# # Bandwidth:
# ExpectedBandwidth: 280
# BandwidthStandardDeviation: 40

# # 5: Filter the events for excess activity in their sidebands, i.e. upper and lower buffer zones
# THis will not work for koala calls.
# SidebandActivity:
# LowerHertzBuffer: 150
# UpperHertzBuffer: 400
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public class KoalaMark3Tests : OutputDirectoryTest
/// <summary>
/// The canonical recording used for this recognizer is #############################.
/// </summary>
//private static readonly FileInfo TestAsset = PathHelper.ResolveAsset("Recordings", "koala.wav");
private static readonly FileInfo TestAsset = new FileInfo("C:\\Ecoacoustics\\WavFiles\\KoalaMale\\Jackaroo_20080715-103940.wav");
private static readonly FileInfo TestAsset = PathHelper.ResolveAsset("Recordings", "HoneymoonBay_StBees_20080905-001000.wav");
private static readonly FileInfo ConfigFile = PathHelper.ResolveConfigFile("RecognizerConfigFiles", "Towsey.PhascolarctosCinereusMark3.yml");
private static readonly PhascolarctosCinereusMark3 Recognizer = new PhascolarctosCinereusMark3();

Expand Down Expand Up @@ -63,22 +62,30 @@ public void TestKoala3Recognizer()
this.SaveTestOutput(
outputDirectory => GenericRecognizer.SaveDebugSpectrogram(results, null, outputDirectory, Recognizer.SpeciesName));

Assert.AreEqual(8, events.Count);
Assert.AreEqual(3, events.Count);
Assert.IsNull(scoreTrack);
Assert.AreEqual(3, plots.Count);
Assert.AreEqual(5888, sonogram.FrameCount);
//Assert.AreEqual(5888, sonogram.FrameCount);
Assert.AreEqual(12025, sonogram.FrameCount);

Assert.IsInstanceOfType(events[0], typeof(OscillationEvent));
Assert.IsInstanceOfType(events[0], typeof(CompositeEvent));

var ev = (OscillationEvent)events[3];

Assert.AreEqual(10.7, ev.EventStartSeconds, 0.05);
Assert.AreEqual(11.5, ev.EventEndSeconds, 0.05);
Assert.AreEqual(200, ev.LowFrequencyHertz);
var ev = (CompositeEvent)events[1];
Assert.AreEqual(73.9, ev.EventStartSeconds, 0.05);
Assert.AreEqual(98.1, ev.EventEndSeconds, 0.05);
Assert.AreEqual(170, ev.LowFrequencyHertz);
Assert.AreEqual(800, ev.HighFrequencyHertz);
Assert.AreEqual(0.62, ev.Score, 0.05);
Assert.AreEqual(0.03, ev.Periodicity, 0.005);
Assert.AreEqual(31.7, ev.OscillationRate, 0.1);

Assert.AreEqual(14, ev.ComponentEvents.Count);
var componentEv = ev.ComponentEvents[6];
Assert.IsInstanceOfType(componentEv, typeof(OscillationEvent));

Assert.AreEqual(0.71, componentEv.Score, 0.05);

var oscEv = (OscillationEvent)componentEv;
Assert.AreEqual(1.3, oscEv.EventDurationSeconds, 0.05);
Assert.AreEqual(0.0248, oscEv.Periodicity, 0.005);
Assert.AreEqual(40.24, oscEv.OscillationRate, 0.1);
}
}
}
Git LFS file not shown

0 comments on commit 4756338

Please sign in to comment.