Skip to content

Commit

Permalink
Get tests working for drawing of Forward events.
Browse files Browse the repository at this point in the history
Issue #297 There is still some small issue to fox. The tracks are not drawn to the end as they were previously.
  • Loading branch information
towsey committed Apr 24, 2020
1 parent 20b29f0 commit fa3afbd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/AnalysisPrograms/Recognizers/GenericRecognizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ public override RecognizerResults Recognize(
segmentStartOffset);

spectralEvents = new List<SpectralEvent>(oscillationEvents);

//plots.Add(new Plot($"{profileName} (:OscillationScore)", scores, op.EventThreshold));
var plot = PreparePlot(scores, $"{profileName} (:OscillationScore)", op.EventThreshold);
plots.Add(plot);
Expand All @@ -309,6 +310,7 @@ public override RecognizerResults Recognize(
ae.FileName = audioRecording.BaseName;
ae.Name = parameters.SpeciesName;
ae.Profile = profileName;

//ae.SegmentDurationSeconds = audioRecording.Duration.TotalSeconds;
//ae.SegmentStartSeconds = segmentStartOffset.TotalSeconds;
//ae.SetTimeAndFreqScales(sonogram.FrameStep, sonogram.FrameDuration, sonogram.FBinWidth);
Expand Down Expand Up @@ -407,7 +409,7 @@ private static Plot PreparePlot(double[] array, string title, double threshold)
/// </summary>
public static void SaveDebugSpectrogram(RecognizerResults results, Config genericConfig, DirectoryInfo outputDirectory, string baseName)
{
var image3 = SpectrogramTools.GetSonogramPlusCharts(results.Sonogram, results.Events, results.Plots, null);
var image3 = SpectrogramTools.GetSonogramPlusCharts(results.Sonogram, results.NewEvents, results.Plots, null);

image3.Save(Path.Combine(outputDirectory.FullName, baseName + ".profile.png"));
}
Expand Down
9 changes: 3 additions & 6 deletions src/AudioAnalysisTools/AcousticEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace AudioAnalysisTools
using AudioAnalysisTools.Events;
using AudioAnalysisTools.Events.Drawing;
using AudioAnalysisTools.Events.Interfaces;
using AudioAnalysisTools.Events.Tracks;
using AudioAnalysisTools.StandardSpectrograms;
using CsvHelper.Configuration;
using SixLabors.ImageSharp;
Expand Down Expand Up @@ -854,6 +853,9 @@ public static void CalculateAccuracyOnOneRecording(
resultsText = sb.ToString();
}

//#################################################################################################################
//FOLLOWING TWO METHODS DEAL WITH THE OVERLAP OF EVENTS

/// <summary>
/// Returns the first event in the passed list which overlaps with this one IN THE SAME RECORDING.
/// If no event overlaps return null.
Expand All @@ -871,9 +873,6 @@ public AcousticEvent OverlapsEventInList(List<AcousticEvent> events)
return null;
}

//#################################################################################################################
//FOLLOWING TWO METHODS DEAL WITH THE OVERLAP OF EVENTS

/// <summary>
/// Determines if two events overlap in time.
/// </summary>
Expand Down Expand Up @@ -910,8 +909,6 @@ public static bool EventsOverlapInTime(AcousticEvent event1, AcousticEvent event
return false;
}



//##############################################################################################################################################
// THE NEXT THREE METHODS CONVERT AN ARRAY OF SCORE VALUES (USUALLY INTENSITY VALUES IN A SUB-BAND) TO ACOUSTIC EVENTS.

Expand Down
2 changes: 2 additions & 0 deletions src/AudioAnalysisTools/Events/Types/CompositeEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public CompositeEvent(List<SpectralEvent> events)

public List<EventCommon> ComponentEvents { get; set; } = new List<EventCommon>();

public int ComponentCount => this.ComponentEvents.Count;

public override double EventStartSeconds =>
this.ComponentEvents.Min(x => x.EventStartSeconds);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public void TestForwardTrackAlgorithm()

var segmentStartOffset = TimeSpan.Zero;
var plots = new List<Plot>();
var (acousticEvents, dBArray) = TrackExtractor.GetForwardTracks(
var (spectralEvents, dBArray) = TrackExtractor.GetForwardTracks(
spectrogram,
parameters,
segmentStartOffset);
Expand All @@ -451,7 +451,7 @@ public void TestForwardTrackAlgorithm()
};

// combine the results i.e. add the events list of call events.
allResults.NewEvents.AddRange(acousticEvents);
allResults.NewEvents.AddRange(spectralEvents);
allResults.Plots.AddRange(plots);

// effectively keeps only the *last* sonogram produced
Expand Down

0 comments on commit fa3afbd

Please sign in to comment.