diff --git a/src/AnalysisConfigFiles/IndexPropertiesConfig.ChannelIntegrity.yml b/src/AnalysisConfigFiles/IndexPropertiesConfig.ChannelIntegrity.yml index c5b58dad9..7cb3d667b 100644 --- a/src/AnalysisConfigFiles/IndexPropertiesConfig.ChannelIntegrity.yml +++ b/src/AnalysisConfigFiles/IndexPropertiesConfig.ChannelIntegrity.yml @@ -13,8 +13,6 @@ RankOrder: # AKA IndexCount NormMax: 100.0 ProjectID: Acoustic Indices Units: "" - IncludeInComboIndex: false - ComboWeight: 0.0 StartOffset: Name: Segment start time Comment: "Exact time span (total minutes) from start of recording to start of this segment." @@ -25,8 +23,6 @@ StartOffset: NormMax: 200.0 ProjectID: Acoustic Indices Units: "min" - IncludeInComboIndex: false - ComboWeight: 0.0 StartOffsetMinute: Name: Segment start minute Comment: "Total minutes from start of recording to start of this segment." @@ -37,8 +33,6 @@ StartOffsetMinute: NormMax: 200.0 ProjectID: Acoustic Indices Units: "min" - IncludeInComboIndex: false - ComboWeight: 0.0 StartOffsetSecond: Name: Segment start second Comment: "Total seconds from start of recording to start of this segment." @@ -49,8 +43,6 @@ StartOffsetSecond: NormMax: 200.0 ProjectID: Acoustic Indices Units: "sec" - IncludeInComboIndex: false - ComboWeight: 0.0 SegmentDuration: Name: Time duration of audio segment Comment: "Exact time span (total minutes) of this audio segment - typically 1.0 minutes." @@ -61,8 +53,6 @@ SegmentDuration: NormMax: 1.0 ProjectID: Acoustic Indices Units: "min" - IncludeInComboIndex: false - ComboWeight: 0.0 ZeroSignal: Name: Zero Signal Index Comment: "Indicates if signal segment is flat or zero." @@ -73,8 +63,6 @@ ZeroSignal: NormMax: 1.0 ProjectID: Acoustic Indices Units: "" - IncludeInComboIndex: false - ComboWeight: 0.0 ClippingIndex: Name: Clipping Index Comment: "Av number of clipped samples/sec i.e. where the abs. amplitude of two conscutive samples is within 4*epislon of the max signal value." @@ -85,8 +73,6 @@ ClippingIndex: NormMax: 5.0 ProjectID: Acoustic Indices Units: "avClips/s" - IncludeInComboIndex: false - ComboWeight: 0.0 ZeroCrossingFractionLeft: Name: Zero Crossing Fraction Left Comment: "" diff --git a/src/AnalysisConfigFiles/IndexPropertiesConfig.yml b/src/AnalysisConfigFiles/IndexPropertiesConfig.yml index ee451ff45..022dbe42e 100644 --- a/src/AnalysisConfigFiles/IndexPropertiesConfig.yml +++ b/src/AnalysisConfigFiles/IndexPropertiesConfig.yml @@ -2,6 +2,7 @@ # WARNING!!! The keys (i.e. root name of each object below) MUST BE EXACTLY the SAME as those # declared in the class InitialiseIndexProperties (starting at line 30). # The root object name maps to the Key property on the IndexProperties class +# and to the members in the class SummaryIndexValues:SummaryIndexBase RankOrder: Name: Rank order of audio segment @@ -13,8 +14,6 @@ RankOrder: NormMax: 240.0 ProjectID: Acoustic Indices Units: "" - IncludeInComboIndex: false - ComboWeight: 0.0 StartOffset: Name: Segment start time Comment: "Exact time span (total minutes) from start of recording to start of this segment." @@ -25,8 +24,6 @@ StartOffset: NormMax: 200.0 ProjectID: Acoustic Indices Units: "min" - IncludeInComboIndex: false - ComboWeight: 0.0 StartOffsetMinute: Name: Segment start minute Comment: "Total minutes from start of recording to start of this segment." @@ -37,8 +34,6 @@ StartOffsetMinute: NormMax: 200.0 ProjectID: Acoustic Indices Units: "min" - IncludeInComboIndex: false - ComboWeight: 0.0 StartOffsetSecond: Name: Segment start second Comment: "Total seconds from start of recording to start of this segment." @@ -49,8 +44,6 @@ StartOffsetSecond: NormMax: 200.0 ProjectID: Acoustic Indices Units: "sec" - IncludeInComboIndex: false - ComboWeight: 0.0 SegmentDuration: Name: Time duration of audio segment Comment: "Exact time span (total minutes) of this audio segment - typically 1.0 minutes." @@ -61,8 +54,6 @@ SegmentDuration: NormMax: 1.0 ProjectID: Acoustic Indices Units: "min" - IncludeInComboIndex: false - ComboWeight: 0.0 HighAmplitudeIndex: Name: High Amplitude Index Comment: "Av number of samples/sec where abs. amplitude is within 10*epislon of the max signal value." @@ -73,8 +64,6 @@ HighAmplitudeIndex: NormMax: 5.0 ProjectID: Acoustic Indices Units: "av/s" - IncludeInComboIndex: false - ComboWeight: 0.0 ZeroSignal: Name: Zero Signal Index Comment: "Indicates if signal segment is flat or zero." @@ -85,8 +74,6 @@ ZeroSignal: NormMax: 1.0 ProjectID: Acoustic Indices Units: "" - IncludeInComboIndex: false - ComboWeight: 0.0 ClippingIndex: Name: Clipping Index Comment: "Av number of clipped samples/sec i.e. where the abs. amplitude of two conscutive samples is within 4*epislon of the max signal value." @@ -97,8 +84,6 @@ ClippingIndex: NormMax: 5.0 ProjectID: Acoustic Indices Units: "avClips/s" - IncludeInComboIndex: false - ComboWeight: 0.0 AvgSignalAmplitude: Name: av Signal Ampl Comment: "Av amplitude of the signal envelope in dB." @@ -110,8 +95,6 @@ AvgSignalAmplitude: NormMax: -10.0 ProjectID: Acoustic Indices Units: "dB" - IncludeInComboIndex: false - ComboWeight: 0.0 BackgroundNoise: Name: Background Noise Comment: "Av amplitude of the noise removed from the audio segment using the method of Lamel et al." @@ -123,8 +106,6 @@ BackgroundNoise: NormMax: -10.0 ProjectID: Acoustic Indices Units: "dB" - IncludeInComboIndex: false - ComboWeight: 0.0 Snr: Name: Maximum SNR Comment: "Max amplitude of signal envelope after noise removal." @@ -135,8 +116,6 @@ Snr: NormMax: 50.0 ProjectID: Acoustic Indices Units: "dB" - IncludeInComboIndex: false - ComboWeight: 0.0 AvgSnrOfActiveFrames: Name: av SNR (Active frames) Comment: "Av amplitude of active frames in signal envelope after noise removal. Active frames are those with amplitude > threshold 3 dB." @@ -147,8 +126,6 @@ AvgSnrOfActiveFrames: NormMax: 30.0 ProjectID: Acoustic Indices Units: "dB" - IncludeInComboIndex: false - ComboWeight: 0.0 Activity: Name: Activity Comment: "% of active frames i.e. where SNR exceeds threshold = 3 dB." @@ -159,8 +136,6 @@ Activity: NormMax: 1.0 ProjectID: Acoustic Indices Units: "" - IncludeInComboIndex: false - ComboWeight: 0.0 EventsPerSecond: Name: Events per sec Comment: "Av number of events per second. An event is any consecutive sequence of active frames having duration > threshold = 100 ms." @@ -171,8 +146,6 @@ EventsPerSecond: NormMax: 5.0 ProjectID: Acoustic Indices Units: "" - IncludeInComboIndex: false - ComboWeight: 0.0 #EventsTotal: # Name: Event Count # Comment: "The total count of acoustic events per minute of recording." @@ -193,18 +166,6 @@ EventsPerSecond: # NormMax: 25 # ProjectID: Acoustic Indices # Units: "" -#AvgEventDuration: -# Name: Av Event Duration -# Comment: "Av duration in ms of the events in an audio segment." -# DataType: TimeSpan -# DefaultValue: 0.0 -# DoDisplay: false -# NormMin: 0.0 -# NormMax: 1000 -# ProjectID: Acoustic Indices -# Units: "ms" -# IncludeInComboIndex: false -# ComboWeight: 0.0 HighFreqCover: Name: hf Cover Comment: "% hf Cover 4000 Hz to 8800 Hz" @@ -215,8 +176,6 @@ HighFreqCover: NormMax: 0.5 ProjectID: Acoustic Indices Units: "" - IncludeInComboIndex: false - ComboWeight: 0.0 MidFreqCover: Name: mf Cover Comment: "% mf Cover. 500 Hz to 4000 Hz" @@ -227,8 +186,6 @@ MidFreqCover: NormMax: 0.50 ProjectID: Acoustic Indices Units: "" - IncludeInComboIndex: false - ComboWeight: 0.0 LowFreqCover: Name: lf Cover Comment: "% lf Cover. 0 - 500 Hz" @@ -239,8 +196,6 @@ LowFreqCover: NormMax: 0.50 ProjectID: Acoustic Indices Units: "" - IncludeInComboIndex: false - ComboWeight: 0.0 AcousticComplexity: Name: ACI Comment: "ACI" @@ -251,8 +206,6 @@ AcousticComplexity: NormMax: 0.7 ProjectID: Acoustic Indices Units: "" - IncludeInComboIndex: true - ComboWeight: 0.2 TemporalEntropy: Name: 1-H[t] Comment: "1-Ht is a measure of concentration of acoustic energy instead of energy dispersal." @@ -263,20 +216,6 @@ TemporalEntropy: NormMax: 0.5 ProjectID: Acoustic Indices Units: "" - IncludeInComboIndex: true - ComboWeight: 0.3 -#SqrtTempEntropy: -# Name: Sqrt(1-H[t]) -# Comment: "Sqrt(1-Ht) is an attempt to obtain more even distribution of Ht values. NormMax = sqrt(0.5)" -# DataType: double -# DefaultValue: 0.0 -# DoDisplay: true -# NormMin: 0.0 -# NormMax: 0.7 -# ProjectID: Acoustic Indices -# Units: "" -# IncludeInComboIndex: false -# ComboWeight: 0.0 LogTempEntropy: Name: Log(1-H[t]) Comment: "Log(1-Ht) is an attempt to obtain more even distribution of Ht values. NormMax = log(1 + 0.5)" @@ -287,8 +226,6 @@ LogTempEntropy: NormMax: 0.176 ProjectID: Acoustic Indices Units: "" - IncludeInComboIndex: false - ComboWeight: 0.0 EntropyOfAverageSpectrum: Name: 1-H[avg spectrum] Comment: "1-H[spectral avg] is a measure of concentration of acoustic energy in the average spectrum over one minute." @@ -299,8 +236,6 @@ EntropyOfAverageSpectrum: NormMax: 1.0 ProjectID: Acoustic Indices Units: "" - IncludeInComboIndex: false - ComboWeight: 0.0 EntropyOfVarianceSpectrum: Name: 1-H[var spectrum] Comment: "1-H[spectral var] is a measure of concentration of acoustic energy in the variance spectrum over one minute." @@ -311,8 +246,6 @@ EntropyOfVarianceSpectrum: NormMax: 1.0 ProjectID: Acoustic Indices Units: "" - IncludeInComboIndex: false - ComboWeight: 0.0 EntropyOfPeaksSpectrum: Name: 1-H[peak freq spectrum] Comment: "1-H[peak freq] is a measure of concentration of peak frequencies over one minute." @@ -323,8 +256,6 @@ EntropyOfPeaksSpectrum: NormMax: 1.0 ProjectID: Acoustic Indices Units: "" - IncludeInComboIndex: false - ComboWeight: 0.0 EntropyOfCoVSpectrum: Name: 1-H[CoV spectrum] Comment: "1-H[CoV sp] is a measure of concentration of energy in the Coeff of Variance Spectrum." @@ -335,8 +266,6 @@ EntropyOfCoVSpectrum: NormMax: 1.0 ProjectID: Acoustic Indices Units: "" - IncludeInComboIndex: false - ComboWeight: 0.0 ClusterCount: Name: Cluster Count Comment: "Number of spectral clusters in one minute audio segment as determined by a clustering algorithm." @@ -347,20 +276,6 @@ ClusterCount: NormMax: 50 ProjectID: Acoustic Indices Units: "" - IncludeInComboIndex: true - ComboWeight: 0.3 -#AvgClusterDuration: -# Name: av Cluster Duration -# Comment: "Average duration in ms of the spectrum cluster sequences." -# DataType: TimeSpan -# DefaultValue: 0.0 -# DoDisplay: true -# NormMin: 0 -# NormMax: 250 -# ProjectID: Acoustic Indices -# Units: "ms" -# IncludeInComboIndex: false -# ComboWeight: 0.0 ThreeGramCount: Name: 3-gram Count Comment: "Number of different tri-gram spectral cluster sequences." @@ -371,8 +286,6 @@ ThreeGramCount: NormMax: 1500 ProjectID: Acoustic Indices Units: "" - IncludeInComboIndex: false - ComboWeight: 0.0 SptDensity: Name: SPT density Comment: "Average number of spectral peaks tracks traversing a frame." @@ -383,32 +296,6 @@ SptDensity: NormMax: 10.0 ProjectID: Acoustic Indices Units: "" - IncludeInComboIndex: false - ComboWeight: 0.0 -#SptPerSecond: -# Name: av Tracks/Sec -# Comment: "Average number of spectral tracks per second." -# DataType: double -# DefaultValue: 0.0 -# DoDisplay: true -# NormMin: 0 -# NormMax: 50 -# ProjectID: Acoustic Indices -# Units: "" -# IncludeInComboIndex: false -# ComboWeight: 0.0 -#AvgSptDuration: -# Name: av Track Duration -# Comment: "Average duration of a spectral track." -# DataType: TimeSpan -# DefaultValue: 0.0 -# DoDisplay: true -# NormMin: 0.25 -# NormMax: 2.0 -# ProjectID: Acoustic Indices -# Units: "s" -# IncludeInComboIndex: false -# ComboWeight: 0.0 NDSI: Name: NDSI Comment: "Normalised Difference Soundscape Index) calculated from PSD - originated from Stuart Gage." @@ -419,26 +306,26 @@ NDSI: NormMax: 1.0 ProjectID: Acoustic Indices Units: "" -NDSI-LM: - Name: NDSI-LM - Comment: "Normalised Difference Soundscape Index) ratio of Mid/Low freq bands." - DataType: double - DefaultValue: 0.0 - DoDisplay: false - NormMin: -1.0 - NormMax: 1.0 - ProjectID: Acoustic Indices - Units: "" -NDSI-MH: - Name: NDSI-MH - Comment: "Normalised Difference Soundscape Index) ratio of High/Mid freq bands." - DataType: double - DefaultValue: 0.0 - DoDisplay: false - NormMin: -1.0 - NormMax: 1.0 - ProjectID: Acoustic Indices - Units: "" +#NDSI-LM: +# Name: NDSI-LM +# Comment: "Normalised Difference Soundscape Index) ratio of Mid/Low freq bands." +# DataType: double +# DefaultValue: 0.0 +# DoDisplay: false +# NormMin: -1.0 +# NormMax: 1.0 +# ProjectID: Acoustic Indices +# Units: "" +#NDSI-MH: +# Name: NDSI-MH +# Comment: "Normalised Difference Soundscape Index) ratio of High/Mid freq bands." +# DataType: double +# DefaultValue: 0.0 +# DoDisplay: false +# NormMin: -1.0 +# NormMax: 1.0 +# ProjectID: Acoustic Indices +# Units: "" FileName: Name: File Name Comment: "FILLER TO STOP WARNING MESSAGE! File Name" diff --git a/src/AnalysisPrograms/ConcatenateIndexFiles.cs b/src/AnalysisPrograms/ConcatenateIndexFiles.cs index a80e584e6..42320dfd0 100644 --- a/src/AnalysisPrograms/ConcatenateIndexFiles.cs +++ b/src/AnalysisPrograms/ConcatenateIndexFiles.cs @@ -341,9 +341,7 @@ public static void Execute(Arguments arguments) var concatenatedSummaryIndices = LdSpectrogramStitching.ConcatenateAllSummaryIndexFiles(summaryIndexFiles, resultsDir, indexGenerationData, outputFileStem); WriteSummaryIndexFile(resultsDir, outputFileStem, AcousticIndices.TowseyAcoustic, concatenatedSummaryIndices); - // Put SUMMARY indices into dictionary. TODO need to generalise a lower method - // ################# WARNING: THIS METHOD ONLY GETS A "HARD CODED" LIST OF SUMMARY INDICES. See the method. - var dictionaryOfSummaryIndices = LdSpectrogramStitching.ConvertToDictionaryOfSummaryIndices(concatenatedSummaryIndices); + var dictionaryOfSummaryIndices = SummaryIndexValues.ConvertToDictionaryOfSummaryIndices(concatenatedSummaryIndices); // REALITY CHECK - check for continuous zero indices or anything else that might indicate defective signal, // incomplete analysis of recordings, recording gaps or file joins. @@ -446,9 +444,7 @@ public static void Execute(Arguments arguments) var concatenatedSummaryIndices = LdSpectrogramStitching.ConcatenateAllSummaryIndexFiles(indexFiles, resultsDir, indexGenerationData, outputBaseName); WriteSummaryIndexFile(resultsDir, outputBaseName, AcousticIndices.TowseyAcoustic, concatenatedSummaryIndices); - // Put SUMMARY indices into dictionary. TODO need to generalise a lower method - // ################# WARNING: THIS METHOD ONLY GETS A "HARD CODED" LIST OF SUMMARY INDICES. See the method. - var summaryDict = LdSpectrogramStitching.ConvertToDictionaryOfSummaryIndices(concatenatedSummaryIndices); + var summaryDict = SummaryIndexValues.ConvertToDictionaryOfSummaryIndices(concatenatedSummaryIndices); if (summaryDict == null) { diff --git a/src/AnalysisPrograms/Sandpit.cs b/src/AnalysisPrograms/Sandpit.cs index 56a487b46..43768fd4c 100644 --- a/src/AnalysisPrograms/Sandpit.cs +++ b/src/AnalysisPrograms/Sandpit.cs @@ -325,8 +325,8 @@ public static void Audio2CsvOverOneFile() //string configPath = @"C:\Work\GitHub\audio-analysis\AudioAnalysis\AnalysisConfigFiles\Towsey.Acoustic.yml"; // Test on STANDARD 24-HOUR RECORDING - string recordingPath = @"C:\Ecoacoustics\WavFiles\LizZnidersic\TasmanIsland2015_Unit2_Mez\SM304256_0+1_20151114_051652.wav"; - string outputPath = @"C:\Ecoacoustics\Output\Test\Test24HourRecording\TasmanIslandMez\06"; + string recordingPath = @"C:\Ecoacoustics\WavFiles\LizZnidersic\TasmanIsland2015_Unit2_Mez\SM304256_0+1_20151114_061652.wav"; + string outputPath = @"C:\Ecoacoustics\Output\Test\Test24HourRecording\TasmanIslandMez\07"; string configPath = @"C:\Work\GitHub\audio-analysis\src\AnalysisConfigFiles\Towsey.Acoustic.yml"; // Ivan Campos recordings diff --git a/src/AudioAnalysisTools/Indices/IndexMatrices.cs b/src/AudioAnalysisTools/Indices/IndexMatrices.cs index 3e9576cdd..e1f02e466 100644 --- a/src/AudioAnalysisTools/Indices/IndexMatrices.cs +++ b/src/AudioAnalysisTools/Indices/IndexMatrices.cs @@ -151,35 +151,6 @@ public static List ConcatenateSummaryIndexFilesWithTimeCheck return summaryIndices; } - /// - /// WARNING: THIS METHOD ONLY GETS FIXED LIST OF INDICES. - /// Also it requires every index to be of type DOUBLE even when this is not appropriate. - /// TODO: This needs to be generalized. - /// - public static Dictionary GetDictionaryOfSummaryIndices(List summaryIndices) - { - var dictionary = new Dictionary - { - { GapsAndJoins.KeyZeroSignal, summaryIndices.Select(x => x.ZeroSignal).ToArray() }, - { "ClippingIndex", summaryIndices.Select(x => x.ClippingIndex).ToArray() }, - { "BackgroundNoise", summaryIndices.Select(x => x.BackgroundNoise).ToArray() }, - { "Snr", summaryIndices.Select(x => x.Snr).ToArray() }, - { "EventsPerSecond", summaryIndices.Select(x => x.EventsPerSecond).ToArray() }, - { "Activity", summaryIndices.Select(x => x.Activity).ToArray() }, - { "HighFreqCover", summaryIndices.Select(x => x.HighFreqCover).ToArray() }, - { "MidFreqCover", summaryIndices.Select(x => x.MidFreqCover).ToArray() }, - { "LowFreqCover", summaryIndices.Select(x => x.LowFreqCover).ToArray() }, - { "TemporalEntropy", summaryIndices.Select(x => x.TemporalEntropy).ToArray() }, - { "EntropyOfAverageSpectrum", summaryIndices.Select(x => x.EntropyOfAverageSpectrum).ToArray() }, - { "EntropyOfPeaksSpectrum", summaryIndices.Select(x => x.EntropyOfPeaksSpectrum).ToArray() }, - { "AcousticComplexity", summaryIndices.Select(x => x.AcousticComplexity).ToArray() }, - { "ClusterCount", summaryIndices.Select(x => x.ClusterCount).ToArray() }, - { "ThreeGramCount", summaryIndices.Select(x => x.ThreeGramCount).ToArray() }, - }; - - return dictionary; - } - public static Dictionary GetSpectralIndexFilesAndConcatenate( DirectoryInfo[] dirs, string analysisType, diff --git a/src/AudioAnalysisTools/Indices/InitialiseIndexProperties.cs b/src/AudioAnalysisTools/Indices/InitialiseIndexProperties.cs index d8344c602..34bbe46f7 100644 --- a/src/AudioAnalysisTools/Indices/InitialiseIndexProperties.cs +++ b/src/AudioAnalysisTools/Indices/InitialiseIndexProperties.cs @@ -60,26 +60,22 @@ public static class InitialiseIndexProperties public const string KeyHtemporal = "Htemporal"; public const string KeyHpeak = "Hpeaks"; public const string KeyHAvSpectrum = "HAvSpectrum"; - public const string KeyhVarSpectrum = "HVarSpectrum"; + public const string KeyHVarSpectrum = "HVarSpectrum"; public const string KeyAcousticComplexity = "AcousticComplexity"; public const string KeyClusterCount = "ClusterCount"; public const string KeyClusterDur = "AvClusterDuration"; public const string Key3GramCount = "3GramCount"; public const string KeySptPerSec = "SPTPerSec"; public const string KeySptDur = "AvSPTDuration"; - public const string KeyRain = "RainIndex"; - public const string KeyCicada = "CicadaIndex"; //KEYS FOR SPECTRAL INDICES - // Initialy thought these would be used but currently (Nov 2018) only use BGN, so commented the rest. + // Initially thought that these would be useful but as of February 2019 none used, so commented. //public const string KeYspectralAci = "ACI"; - ////public const string KeYspectralAvg = "AVG"; // average dB value in each frequency bin after noise removal - public const string KeySpectralBgn = "BGN"; // modal dB value in each frequency bin calculated during noise removal - + //public const string KeySpectralBgn = "BGN"; //public const string KeYspectralCls = "CLS"; //public const string KeYspectralCvr = "CVR"; - ////public const string KeYspectralEnt = "ENT"; + //public const string KeYspectralEnt = "ENT"; //public const string KeYspectralEvn = "EVN"; //public const string KeySpectralOsc = "OSC"; //public const string KeySpectralPmn = "PMN"; @@ -112,7 +108,6 @@ public static Dictionary GetDictionaryOfSummaryIndexPro { if (!ip.IsSpectralIndex) { - // summary indices are never of type double[] dict.Add(ip.Key, ip); } } diff --git a/src/AudioAnalysisTools/Indices/RainIndices.cs b/src/AudioAnalysisTools/Indices/RainIndices.cs index 6f3839448..b1927fe29 100644 --- a/src/AudioAnalysisTools/Indices/RainIndices.cs +++ b/src/AudioAnalysisTools/Indices/RainIndices.cs @@ -1,4 +1,4 @@ -// -------------------------------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- // // 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). // @@ -22,8 +22,8 @@ namespace AudioAnalysisTools.Indices public static class RainIndices { - public const string header_rain = InitialiseIndexProperties.KeyRain; - public const string header_cicada = InitialiseIndexProperties.KeyCicada; + public const string header_rain = "Rain"; + public const string header_cicada = "Cicadas"; public const string header_negative = "none"; /// diff --git a/src/AudioAnalysisTools/Indices/SummaryIndexValues.cs b/src/AudioAnalysisTools/Indices/SummaryIndexValues.cs index 519c9fb79..abf711687 100644 --- a/src/AudioAnalysisTools/Indices/SummaryIndexValues.cs +++ b/src/AudioAnalysisTools/Indices/SummaryIndexValues.cs @@ -7,11 +7,11 @@ namespace AudioAnalysisTools.Indices { using System; using System.Collections.Generic; + using System.Linq; using AnalysisBase.ResultBases; - - using StandardSpectrograms; - + using DSP; using Fasterflect; + using StandardSpectrograms; using TowseyLibrary; public class IndexCalculateResult @@ -24,8 +24,6 @@ public IndexCalculateResult( IndexCalculateConfig configuration) { TimeSpan durationOfResult = indexCalculationDuration; // subsegment TimeSpan - - // TimeSpan startOffset = analysisSettings.SegmentStartOffset.Value; // offset from beginning of source audio TimeSpan subsegmentOffsetFromStartOfSource = subsegmentOffset; // offset from beginning of source audio this.Hits = null; @@ -82,13 +80,13 @@ static SummaryIndexValues() /// /// Initializes a new instance of the class. - /// All summary indices initialised to zero except background and av Sig AMplitude both = -100 dB. + /// All summary indices initialised to zero except BackgroundNoise and AvgSignalAmplitude both = -100 dB. /// public SummaryIndexValues() { // serialization entry - this.BackgroundNoise = -100; - this.AvgSignalAmplitude = -100; + this.BackgroundNoise = SNR.MinimumDbBoundForZeroSignal; // equals -100 dB, Feb 2019; + this.AvgSignalAmplitude = SNR.MinimumDbBoundForZeroSignal; } public SummaryIndexValues(TimeSpan wavDuration, Dictionary indexProperties) @@ -110,6 +108,49 @@ public SummaryIndexValues(TimeSpan wavDuration, Dictionary ConvertToDictionaryOfSummaryIndices(List summaryIndices) + { + // Now add in derived indices i.e. NCDI etc + // Decided NOT to do this anymore + // dictionaryOfSummaryIndices = IndexMatrices.AddDerivedIndices(dictionaryOfSummaryIndices); + + // Put SUMMARY indices into dictionary. TODO need to generalise the following method + // ################# WARNING: THIS METHOD ONLY GETS A "HARD CODED" LIST OF SUMMARY INDICES. See the method. + var dictionaryOfSummaryIndices = GetDictionaryOfSummaryIndices(summaryIndices); + + // return the dictionary - it will be used later to produce an index tracks image. + return dictionaryOfSummaryIndices; + } + + /// + /// WARNING: THIS METHOD ONLY GETS FIXED LIST OF INDICES. + /// Also it requires every index to be of type DOUBLE even when htis is not appropriate. + /// TODO: This needs to be generalized. + /// + public static Dictionary GetDictionaryOfSummaryIndices(List summaryIndices) + { + var dictionary = new Dictionary + { + { GapsAndJoins.KeyZeroSignal, summaryIndices.Select(x => x.ZeroSignal).ToArray() }, + { "ClippingIndex", summaryIndices.Select(x => x.ClippingIndex).ToArray() }, + { "BackgroundNoise", summaryIndices.Select(x => x.BackgroundNoise).ToArray() }, + { "Snr", summaryIndices.Select(x => x.Snr).ToArray() }, + { "EventsPerSecond", summaryIndices.Select(x => x.EventsPerSecond).ToArray() }, + { "Activity", summaryIndices.Select(x => x.Activity).ToArray() }, + { "HighFreqCover", summaryIndices.Select(x => x.HighFreqCover).ToArray() }, + { "MidFreqCover", summaryIndices.Select(x => x.MidFreqCover).ToArray() }, + { "LowFreqCover", summaryIndices.Select(x => x.LowFreqCover).ToArray() }, + { "TemporalEntropy", summaryIndices.Select(x => x.TemporalEntropy).ToArray() }, + { "EntropyOfAverageSpectrum", summaryIndices.Select(x => x.EntropyOfAverageSpectrum).ToArray() }, + { "EntropyOfPeaksSpectrum", summaryIndices.Select(x => x.EntropyOfPeaksSpectrum).ToArray() }, + { "AcousticComplexity", summaryIndices.Select(x => x.AcousticComplexity).ToArray() }, + { "ClusterCount", summaryIndices.Select(x => x.ClusterCount).ToArray() }, + { "ThreeGramCount", summaryIndices.Select(x => x.ThreeGramCount).ToArray() }, + }; + + return dictionary; + } + public double ZeroSignal { get; set; } public double HighAmplitudeIndex { get; set; } @@ -128,10 +169,6 @@ public SummaryIndexValues(TimeSpan wavDuration, Dictionary> CachedSelectors { get; set; } } } diff --git a/src/AudioAnalysisTools/LongDurationSpectrograms/LDSpectrogramRGB.cs b/src/AudioAnalysisTools/LongDurationSpectrograms/LDSpectrogramRGB.cs index f233c051a..c73d052d4 100644 --- a/src/AudioAnalysisTools/LongDurationSpectrograms/LDSpectrogramRGB.cs +++ b/src/AudioAnalysisTools/LongDurationSpectrograms/LDSpectrogramRGB.cs @@ -614,7 +614,7 @@ public void DrawNegativeFalseColourSpectrogram(DirectoryInfo outputDirectory, st bmpNeg.Save(Path.Combine(outputDirectory.FullName, outputFileName + ".COLNEG.png")); - string key = InitialiseIndexProperties.KeySpectralBgn; + string key = "BGN"; if (!this.SpectrogramMatrices.ContainsKey(key)) { LoggedConsole.WriteLine("\nWARNING: SG {0} does not contain key: {1}", outputFileName, key); diff --git a/src/AudioAnalysisTools/LongDurationSpectrograms/LDSpectrogramStitching.cs b/src/AudioAnalysisTools/LongDurationSpectrograms/LDSpectrogramStitching.cs index b0acff44d..862b422a1 100644 --- a/src/AudioAnalysisTools/LongDurationSpectrograms/LDSpectrogramStitching.cs +++ b/src/AudioAnalysisTools/LongDurationSpectrograms/LDSpectrogramStitching.cs @@ -251,20 +251,6 @@ public static List ConcatenateAllSummaryIndexFiles( return summaryIndices; } - public static Dictionary ConvertToDictionaryOfSummaryIndices(List summaryIndices) - { - // Now add in derived indices i.e. NCDI etc - // Decided NOT to do this anymore - // dictionaryOfSummaryIndices = IndexMatrices.AddDerivedIndices(dictionaryOfSummaryIndices); - - // Put SUMMARY indices into dictionary. TODO need to generalise the following method - // ################# WARNING: THIS METHOD ONLY GETS A "HARD CODED" LIST OF SUMMARY INDICES. See the method. - var dictionaryOfSummaryIndices = IndexMatrices.GetDictionaryOfSummaryIndices(summaryIndices); - - // return the dictionary - it will be used later to produce an index tracks image. - return dictionaryOfSummaryIndices; - } - // ############################################################################################################## // ######################### ORIGINAL METHOD FOR STITCHING Gianna Pavan's DATA (10 minutes every 30 minutes) diff --git a/tests/Acoustics.Test/AudioAnalysisTools/Indices/IndexCalculateTest.cs b/tests/Acoustics.Test/AudioAnalysisTools/Indices/IndexCalculateTest.cs index 7d3d9148b..6a6f29f8d 100644 --- a/tests/Acoustics.Test/AudioAnalysisTools/Indices/IndexCalculateTest.cs +++ b/tests/Acoustics.Test/AudioAnalysisTools/Indices/IndexCalculateTest.cs @@ -79,7 +79,6 @@ public void TestOfSummaryIndices() Assert.AreEqual(0.6793287, summaryIndices.AcousticComplexity, AllowedDelta); Assert.AreEqual(0.484520, summaryIndices.Activity, AllowedDelta); - Assert.AreEqual(0.000000, summaryIndices.AvgEntropySpectrum, AllowedDelta); Assert.AreEqual(-30.946519, summaryIndices.AvgSignalAmplitude, AllowedDelta); Assert.AreEqual(11.533420, summaryIndices.AvgSnrOfActiveFrames, AllowedDelta); Assert.AreEqual(-39.740775, summaryIndices.BackgroundNoise, AllowedDelta); @@ -88,7 +87,6 @@ public void TestOfSummaryIndices() Assert.AreEqual(0.301929, summaryIndices.EntropyOfCoVSpectrum, AllowedDelta); Assert.AreEqual(0.260999, summaryIndices.EntropyOfPeaksSpectrum, AllowedDelta); Assert.AreEqual(0.522080, summaryIndices.EntropyOfVarianceSpectrum, AllowedDelta); - Assert.AreEqual(0.0, summaryIndices.EntropyPeaks, AllowedDelta); Assert.AreEqual(2.0, summaryIndices.EventsPerSecond, AllowedDelta); Assert.AreEqual(0.140306, summaryIndices.HighFreqCover, AllowedDelta); Assert.AreEqual(0.137873, summaryIndices.MidFreqCover, AllowedDelta);