Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flying fox recognizer #239

Merged
merged 13 commits into from
Aug 28, 2019
4 changes: 2 additions & 2 deletions src/AED/AED.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\FSharp.Compiler.Tools.10.2.1\build\FSharp.Compiler.Tools.props" Condition="Exists('..\..\packages\FSharp.Compiler.Tools.10.2.1\build\FSharp.Compiler.Tools.props')" />
<Import Project="..\..\packages\FSharp.Compiler.Tools.10.2.3\build\FSharp.Compiler.Tools.props" Condition="Exists('..\..\packages\FSharp.Compiler.Tools.10.2.3\build\FSharp.Compiler.Tools.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -121,7 +121,7 @@
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
<Error Condition="!Exists('..\..\packages\FSharp.Compiler.Tools.10.2.1\build\FSharp.Compiler.Tools.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\FSharp.Compiler.Tools.10.2.1\build\FSharp.Compiler.Tools.props'))" />
<Error Condition="!Exists('..\..\packages\FSharp.Compiler.Tools.10.2.3\build\FSharp.Compiler.Tools.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\FSharp.Compiler.Tools.10.2.3\build\FSharp.Compiler.Tools.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
2 changes: 1 addition & 1 deletion src/AED/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FSharp.Compiler.Tools" version="10.2.1" targetFramework="net462" />
<package id="FSharp.Compiler.Tools" version="10.2.3" targetFramework="net462" />
<package id="FSharp.Core" version="4.3.4" targetFramework="net462" />
<package id="FSPowerPack.Community" version="3.0.0.0" targetFramework="net462" />
<package id="FSPowerPack.Core.Community" version="3.0.0.0" targetFramework="net462" />
Expand Down
4 changes: 2 additions & 2 deletions src/Acoustics.Shared.FSharp/Acoustics.Shared.FSharp.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\FSharp.Compiler.Tools.10.2.1\build\FSharp.Compiler.Tools.props" Condition="Exists('..\..\packages\FSharp.Compiler.Tools.10.2.1\build\FSharp.Compiler.Tools.props')" />
<Import Project="..\..\packages\FSharp.Compiler.Tools.10.2.3\build\FSharp.Compiler.Tools.props" Condition="Exists('..\..\packages\FSharp.Compiler.Tools.10.2.3\build\FSharp.Compiler.Tools.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -154,7 +154,7 @@
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
<Error Condition="!Exists('..\..\packages\FSharp.Compiler.Tools.10.2.1\build\FSharp.Compiler.Tools.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\FSharp.Compiler.Tools.10.2.1\build\FSharp.Compiler.Tools.props'))" />
<Error Condition="!Exists('..\..\packages\FSharp.Compiler.Tools.10.2.3\build\FSharp.Compiler.Tools.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\FSharp.Compiler.Tools.10.2.3\build\FSharp.Compiler.Tools.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
2 changes: 1 addition & 1 deletion src/Acoustics.Shared.FSharp/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<package id="Accord.Statistics" version="2.12.0.0" targetFramework="net462" />
<package id="AForge" version="2.2.5" targetFramework="net462" />
<package id="AForge.Math" version="2.2.5" targetFramework="net462" />
<package id="FSharp.Compiler.Tools" version="10.2.1" targetFramework="net462" />
<package id="FSharp.Compiler.Tools" version="10.2.3" targetFramework="net462" />
<package id="FSharp.Core" version="4.3.4" targetFramework="net462" />
<package id="FSPowerPack.Community" version="3.0.0.0" targetFramework="net462" />
<package id="FSPowerPack.Core.Community" version="3.0.0.0" targetFramework="net462" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
SpeciesName: Pteropus sp.
CommonName: Flying Fox
AbbreviatedSpeciesName: PteropusSp

#Proposed Approach:
#1. Assume that a long recording has been broken into one-minute segments.
#2. Convert each one-minute segment to a spectrogram.
#3. Obtain a noise profile for each segment. This is to be used later to remove insect chorusing.
#4. Scan the one-minute waveform and select "spike maxima" whose amplitude exceeds a decibel threshold, D.
#5. Extract a single frame (say 512 samples) centred on each spike and convert to a spike spectrum.
#6. Subtract the noise profile from the spike spectrum.
#7. Smooth the remaining spectrum.
#8. Look for evenly spaced harmonics in the smoothed spectrum.
# Typically the lowest harmonic will lie between 1200 Hz and 3000 Hz and the higher ones evenly spaced.
# This is the tricky bit due to variability but may work to use spectrum auto-correlation.
atruskie marked this conversation as resolved.
Show resolved Hide resolved

# Common settings
BgNoiseThreshold: 3.0

# Each of these profiles will be analyzed
Profiles:
#Standard: &STANDARD
#EventThreshold: 0.2
Territorial:
# min and max of the freq band to search
MinHz: 800
MaxHz: 8000
MinDuration: 0.15
MaxDuration: 0.8
DecibelThreshold: 9.0
Wingbeats:
MinHz: 200
MaxHz: 2000
# duration of DCT in seconds
DctDuration: 0.8
# minimum acceptable value of a DCT coefficient
DctThreshold: 0.5
# ignore oscillation rates below the min & above the max threshold
# A sample of four wingbeats yielded an average of 5.1 +/-0.5 beats/s.
# 95% confidence interval (2 SDs) is therefore approx 4-6 beats/s.
# OSCILLATIONS PER SECOND
MinOscilFreq: 4
MaxOscilFreq: 6
# Minimum and maximum duration for the length of a true call.
MinDuration: 1.0
MaxDuration: 10.0
# Event threshold - use this to determine FP / FN trade-off for events.
EventThreshold: 0.60
#Agonist:
# This notation means the Groote profile has all of the settings that the Standard profile has,
# however, the MinHz and MaxHz properties have been overridden.
# <<: *STANDARD
# DctDuration: 0.3

# Resample rate must be 2 X the desired Nyquist
ResampleRate: 22050

## Specifically for AnalyzeLongRecording
# SegmentDuration: units=seconds;
SegmentDuration: 60
# SegmentOverlap: units=seconds;
SegmentOverlap: 0
# Available options (case-sensitive): [False/Never | True/Always | WhenEventsDetected]
SaveIntermediateWavFiles: Never
SaveIntermediateCsvFiles: false
# Available options (case-sensitive): [False/Never | True/Always | WhenEventsDetected]
# "True" is useful when debugging but "WhenEventsDetected" is required for operational use.
# SaveSonogramImages: True
SaveSonogramImages: WhenEventsDetected
# DisplayCsvImage is obsolete - ensure it remains set to: false
DisplayCsvImage: false
## End section for AnalyzeLongRecording

# Other config files to reference

HighResolutionIndicesConfig: "../Towsey.Acoustic.HiResIndicesForRecognisers.yml"
...
1 change: 1 addition & 0 deletions src/AnalysisPrograms/AnalysisPrograms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@
<Compile Include="Recognizers\LitoriaWatjulumensis.cs" />
<Compile Include="Recognizers\LitoriaBicolor.cs" />
<Compile Include="Recognizers\PezoporusOccidentalis.cs" />
<Compile Include="Recognizers\PteropusSpecies.cs" />
<Compile Include="Recognizers\UperoleiaLithomoda.cs" />
<Compile Include="Recognizers\PlatyplectrumOrnatum.cs" />
<Compile Include="Recognizers\LimnodynastesConvex.cs" />
Expand Down
6 changes: 3 additions & 3 deletions src/AnalysisPrograms/Recognizers/LitoriaFallax.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="LitoriaFallax.cs" company="QutEcoacoustics">
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
Expand Down Expand Up @@ -201,7 +201,7 @@ private void WriteDebugImage(
bool displayDebugImage = MainEntry.InDEBUG;
if (displayDebugImage)
{
Image debugImage1 = LitoriaRothii.DisplayDebugImage(sonogram, acousticEvents, plots, hits);
Image debugImage1 = SpectrogramTools.GetSonogramPlusCharts(sonogram, acousticEvents, plots, hits);
var debugPath1 =
outputDirectory.Combine(
FilenameHelpers.AnalysisResultName(
Expand Down Expand Up @@ -231,7 +231,7 @@ private void WriteDebugImage(
this.Identifier,
"png",
"DebugSpectrogram2"));
Image debugImage2 = LitoriaRothii.DisplayDebugImage(sonogram2, acousticEvents, plots, null);
Image debugImage2 = SpectrogramTools.GetSonogramPlusCharts(sonogram2, acousticEvents, plots, null);
debugImage2.Save(debugPath2.FullName);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/AnalysisPrograms/Recognizers/LitoriaFreycineti.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="LitoriaFreycineti.cs" company="QutEcoacoustics">
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
Expand Down Expand Up @@ -195,7 +195,7 @@ private void WriteDebugImage(
bool displayDebugImage = MainEntry.InDEBUG;
if (displayDebugImage)
{
Image debugImage1 = LitoriaRothii.DisplayDebugImage(sonogram, acousticEvents, plots, hits);
Image debugImage1 = SpectrogramTools.GetSonogramPlusCharts(sonogram, acousticEvents, plots, hits);
var debugPath1 =
outputDirectory.Combine(
FilenameHelpers.AnalysisResultName(
Expand Down Expand Up @@ -225,7 +225,7 @@ private void WriteDebugImage(
this.Identifier,
"png",
"DebugSpectrogram2"));
Image debugImage2 = LitoriaRothii.DisplayDebugImage(sonogram2, acousticEvents, plots, null);
Image debugImage2 = SpectrogramTools.GetSonogramPlusCharts(sonogram2, acousticEvents, plots, null);
debugImage2.Save(debugPath2.FullName);
}
}
Expand Down
36 changes: 2 additions & 34 deletions src/AnalysisPrograms/Recognizers/LitoriaRothii.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="LitoriaRothii.cs" company="QutEcoacoustics">
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
Expand Down Expand Up @@ -223,7 +223,7 @@ public override RecognizerResults Recognize(AudioRecording recording, Config con
var lowPassPlot = new Plot("Low Pass", normalisedScores, normalisedThreshold);

var debugPlots = new List<Plot> { ampltdPlot, lowPassPlot, demeanedPlot, plot };
Image debugImage = DisplayDebugImage(sonogram, acousticEvents, debugPlots, null);
Image debugImage = SpectrogramTools.GetSonogramPlusCharts(sonogram, acousticEvents, debugPlots, null);
var debugPath = outputDirectory.Combine(FilenameHelpers.AnalysisResultName(Path.GetFileNameWithoutExtension(recording.BaseName), this.Identifier, "png", "DebugSpectrogram"));
debugImage.Save(debugPath.FullName);
}
Expand All @@ -236,37 +236,5 @@ public override RecognizerResults Recognize(AudioRecording recording, Config con
Events = acousticEvents,
};
}

public static Image DisplayDebugImage(BaseSonogram sonogram, List<AcousticEvent> events, List<Plot> scores, double[,] hits)
{
var image = new Image_MultiTrack(sonogram.GetImage(doHighlightSubband: false, add1KHzLines: true, doMelScale: false));
image.AddTrack(ImageTrack.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond));
if (scores != null)
{
foreach (var plot in scores)
{
image.AddTrack(ImageTrack.GetNamedScoreTrack(plot.data, 0.0, 1.0, plot.threshold, plot.title)); //assumes data normalised in 0,1
}
}

if (hits != null)
{
image.OverlayRainbowTransparency(hits);
}

if (events.Count > 0)
{
// set colour for the events
foreach (AcousticEvent ev in events)
{
ev.BorderColour = AcousticEvent.DefaultBorderColor;
ev.ScoreColour = AcousticEvent.DefaultScoreColor;
}

image.AddEvents(events, sonogram.NyquistFrequency, sonogram.Configuration.FreqBinCount, sonogram.FramesPerSecond);
}

return image.GetImage();
}
}
}
Loading