Skip to content

Commit

Permalink
Remove unneeded code
Browse files Browse the repository at this point in the history
Update src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.AnthusNovaeseelandiae.yml

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

Update src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.BotaurusPoiciloptilus.yml

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

Update src/AnalysisConfigFiles/RecognizerConfigFiles/Towsey.CisticolaExilis.yml

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

Update tests/Acoustics.Test/AnalysisPrograms/Recognizers/AustBitternTests.cs

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

Update tests/Acoustics.Test/AnalysisPrograms/Recognizers/AustralPipitTests.cs

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Update AnthusNovaeseelandiae.cs

Issue #321 Removed unused method.
  • Loading branch information
towsey authored and atruskie committed Jun 12, 2020
1 parent 36f47b8 commit 093551e
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
...
...
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
...
...
80 changes: 3 additions & 77 deletions src/AnalysisPrograms/Recognizers/Birds/AnthusNovaeseelandiae.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<EventCommon>().ToList();
//var spectralEvents = events.Select(x => (SpectralEvent)x).ToList();

if (combinedResults.NewEvents.Count == 0)
{
Expand All @@ -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;
}

Expand Down Expand Up @@ -158,15 +146,16 @@ public static List<EventCommon> FilterEventsOnFrequencyProfile(List<EventCommon>
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)
{
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;
Expand All @@ -179,70 +168,8 @@ public static List<EventCommon> FilterEventsOnFrequencyProfile(List<EventCommon>
return returnEvents;
}

/// <summary>
/// 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.
/// </summary>
/// <param name="ev">An event containing at least one forward track i.e. a chirp.</param>
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;
}

/// <summary>
/// .
/// </summary>
/// <param name="points">List of spectral points.</param>
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}):";
Expand Down Expand Up @@ -273,7 +200,6 @@ public override void SummariseResults(
}
*/

/// <inheritdoc cref="PipitConfig"/> />
public class PipitConfig : GenericRecognizerConfig, INamedProfiles<object>
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ public override void SummariseResults(
}
*/

/// <inheritdoc cref="BotaurusPoiciloptilusConfig"/> />
public class BotaurusPoiciloptilusConfig : GenericRecognizerConfig, INamedProfiles<object>
{
}
Expand Down
15 changes: 0 additions & 15 deletions src/AnalysisPrograms/Recognizers/Birds/CisticolaExilis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,6 @@ public override AnalyzerConfig ParseConfig(FileInfo file)
throw new ConfigFileException("CisticolaExilis expects one and only one UpwardTrack algorithm.", file);
}

/// <summary>
/// This method is called once per segment (typically one-minute segments).
/// </summary>
/// <param name="audioRecording">one minute of audio recording.</param>
/// <param name="config">config file that contains parameters used by all profiles.</param>
/// <param name="segmentStartOffset">when recording starts.</param>
/// <param name="getSpectralIndexes">not sure what this is.</param>
/// <param name="outputDirectory">where the recognizer results can be found.</param>
/// <param name="imageWidth"> assuming ????.</param>
/// <returns>recognizer results.</returns>
public override RecognizerResults Recognize(
AudioRecording audioRecording,
Config config,
Expand All @@ -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<EventCommon>().ToList();
//var spectralEvents = events.Select(x => (SpectralEvent)x).ToList();

if (combinedResults.NewEvents.Count == 0)
{
CisticolaLog.Debug($"Return zero events.");
Expand Down Expand Up @@ -144,7 +130,6 @@ public override void SummariseResults(
}
*/

/// <inheritdoc cref="CisticolaExilisConfig"/> />
public class CisticolaExilisConfig : GenericRecognizerConfig, INamedProfiles<object>
{
}
Expand Down
1 change: 0 additions & 1 deletion src/AnalysisPrograms/Recognizers/Birds/NinoxBoobook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ public override void SummariseResults(
}
*/

/// <inheritdoc cref="NinoxBoobookConfig"/> />
public class NinoxBoobookConfig : GenericRecognizerConfig, INamedProfiles<object>
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}

0 comments on commit 093551e

Please sign in to comment.