Skip to content

Commit

Permalink
Changes requested by Anthony as part of Pull Request.
Browse files Browse the repository at this point in the history
This is a combination of 11 commits.

Update src/AudioAnalysisTools/Events/SpectralEvent.cs

Co-authored-by: Anthony Truskinger <[email protected]>

Update src/AudioAnalysisTools/Events/SpectralEvent.cs

Co-authored-by: Anthony Truskinger <[email protected]>

Update src/TowseyLibrary/MatrixTools.cs

Co-authored-by: Anthony Truskinger <[email protected]>

Update src/TowseyLibrary/MatrixTools.cs

Co-authored-by: Anthony Truskinger <[email protected]>

Update src/AnalysisPrograms/Recognizers/Birds/NinoxBoobook.cs

Co-authored-by: Anthony Truskinger <[email protected]>

Update src/AudioAnalysisTools/Events/SpectralEvent.cs

Co-authored-by: Anthony Truskinger <[email protected]>

Update src/AudioAnalysisTools/Events/SpectralEvent.cs

Co-authored-by: Anthony Truskinger <[email protected]>

Update src/AudioAnalysisTools/Events/SpectralEvent.cs

Co-authored-by: Anthony Truskinger <[email protected]>

Update src/AudioAnalysisTools/Events/SpectralEvent.cs

Co-authored-by: Anthony Truskinger <[email protected]>

Changes requested by Anthony as part of Pull Request.

Issue #319

Update src/AnalysisPrograms/Recognizers/Birds/NinoxBoobook.cs

Co-authored-by: Anthony Truskinger <[email protected]>
  • Loading branch information
towsey and atruskie committed May 29, 2020
1 parent 3d35263 commit f9c3388
Show file tree
Hide file tree
Showing 9 changed files with 356 additions and 355 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SegmentOverlap: 0
IgnoreHighAmplitudeClippedRecordingSegments: true

# Each of these profiles will be analyzed
# This profile is required for the species-specific recogniser and must have the current name.
Profiles:
BoobookSyllable: !ForwardTrackParameters
ComponentName: RidgeTrack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ public override RecognizerResults Recognize(
minimumEventDuration = 2.0;
}

combinedResults.NewEvents = SpectralEvent.FilterOnDuration(newEvents, minimumEventDuration, maximumEventDuration);
combinedResults.NewEvents = EventExtentions.FilterOnDuration(newEvents, minimumEventDuration, maximumEventDuration);

double average = 365;
double sd = 22;
double sigmaThreshold = 3.0;
combinedResults.NewEvents = SpectralEvent.FilterOnBandwidth(combinedResults.NewEvents, average, sd, sigmaThreshold);
combinedResults.NewEvents = EventExtentions.FilterOnBandwidth(combinedResults.NewEvents, average, sd, sigmaThreshold);

//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.
Expand Down
31 changes: 16 additions & 15 deletions src/AnalysisPrograms/Recognizers/Birds/NinoxBoobook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ public override RecognizerResults Recognize(

if (combinedResults.NewEvents.Count == 0)
{
//Console.WriteLine($"Return zero events.");
BoobookLog.Debug($"Return zero events.");
return combinedResults;
}

// 2: Combine overlapping events. If the dB threshold is set low, may get lots of little events.
combinedResults.NewEvents = CompositeEvent.CombineOverlappingEvents(chirpEvents.Cast<EventCommon>().ToList());
//Console.WriteLine($"Event count after combining overlaps = {combinedResults.NewEvents.Count}");
BoobookLog.Debug($"Event count after combining overlaps = {combinedResults.NewEvents.Count}");

// 3: Combine proximal events. If the dB threshold is set low, may get lots of little events.
if (genericConfig.CombinePossibleSyllableSequence)
Expand All @@ -129,12 +129,13 @@ public override RecognizerResults Recognize(
var startDiff = genericConfig.SyllableStartDifference;
var hertzDiff = genericConfig.SyllableHertzGap;
combinedResults.NewEvents = CompositeEvent.CombineProximalEvents(spectralEvents1, TimeSpan.FromSeconds(startDiff), (int)hertzDiff);
//Console.WriteLine($"Event count after combining proximals = {combinedResults.NewEvents.Count}");
BoobookLog.Debug($"Event count after combining proximals = {combinedResults.NewEvents.Count}");
}

// Get the BoobookSyllable config.
var configuration = (GenericRecognizerConfig)genericConfig;
var chirpConfig = (ForwardTrackParameters)configuration.Profiles["BoobookSyllable"];
const string profileName = "BoobookSyllable";
var configuration = (NinoxBoobookConfig)genericConfig;
var chirpConfig = (ForwardTrackParameters)configuration.Profiles[profileName];

// 4: Filter events on the amount of acoustic activity in their upper and lower neighbourhoods - their buffer zone.
// The idea is that an unambiguous event should have some acoustic space above and below.
Expand All @@ -152,27 +153,27 @@ public override RecognizerResults Recognize(
if (upperHertzBuffer > 0 || lowerHertzBuffer > 0)
{
var spectralEvents2 = combinedResults.NewEvents.Cast<SpectralEvent>().ToList();
combinedResults.NewEvents = SpectralEvent.FilterEventsOnNeighbourhood(
combinedResults.NewEvents = EventExtentions.FilterEventsOnNeighbourhood(
spectralEvents2,
combinedResults.Sonogram,
lowerHertzBuffer,
upperHertzBuffer,
segmentStartOffset,
neighbourhoodDbThreshold);

//Console.WriteLine($"Event count after filtering on neighbourhood = {combinedResults.NewEvents.Count}");
BoobookLog.Debug($"Event count after filtering on neighbourhood = {combinedResults.NewEvents.Count}");
}

if (combinedResults.NewEvents.Count == 0)
{
//Console.WriteLine($"Return zero events.");
BoobookLog.Debug($"Return zero events.");
return combinedResults;
}

// 5: Filter on COMPONENT COUNT in Composite events.
int maxComponentCount = 2;
combinedResults.NewEvents = SpectralEvent.FilterEventsOnCompositeContent(combinedResults.NewEvents, maxComponentCount);
//Console.WriteLine($"Event count after filtering on component count = {combinedResults.NewEvents.Count}");
combinedResults.NewEvents = EventExtentions.FilterEventsOnCompositeContent(combinedResults.NewEvents, maxComponentCount);
BoobookLog.Debug($"Event count after filtering on component count = {combinedResults.NewEvents.Count}");

// 6: Filter the events for duration in seconds
var minimumEventDuration = chirpConfig.MinDuration;
Expand All @@ -183,15 +184,15 @@ public override RecognizerResults Recognize(
maximumEventDuration *= 1.5;
}

combinedResults.NewEvents = SpectralEvent.FilterOnDuration(combinedResults.NewEvents, minimumEventDuration.Value, maximumEventDuration.Value);
//Console.WriteLine($"Event count after filtering on duration = {combinedResults.NewEvents.Count}");
combinedResults.NewEvents = EventExtentions.FilterOnDuration(combinedResults.NewEvents, minimumEventDuration.Value, maximumEventDuration.Value);
BoobookLog.Debug($"Event count after filtering on duration = {combinedResults.NewEvents.Count}");

// 7: Filter the events for bandwidth in Hertz
double average = 280;
double sd = 40;
double sigmaThreshold = 3.0;
combinedResults.NewEvents = SpectralEvent.FilterOnBandwidth(combinedResults.NewEvents, average, sd, sigmaThreshold);
//Console.WriteLine($"Event count after filtering on bandwidth = {combinedResults.NewEvents.Count}");
combinedResults.NewEvents = EventExtentions.FilterOnBandwidth(combinedResults.NewEvents, average, sd, sigmaThreshold);
BoobookLog.Debug($"Event count after filtering on bandwidth = {combinedResults.NewEvents.Count}");

//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.
Expand Down Expand Up @@ -322,4 +323,4 @@ public class NinoxBoobookConfig : GenericRecognizerConfig, INamedProfiles<object
public double SyllableHertzGap { get; set; } = 200;
}
}
}
}
Loading

0 comments on commit f9c3388

Please sign in to comment.