diff --git a/src/AnalysisPrograms/Sandpit.cs b/src/AnalysisPrograms/Sandpit.cs index 45d052a79..0988df80d 100644 --- a/src/AnalysisPrograms/Sandpit.cs +++ b/src/AnalysisPrograms/Sandpit.cs @@ -62,7 +62,7 @@ public override Task Execute(CommandLineApplication app) Log.WriteLine("# Start Time = " + tStart.ToString(CultureInfo.InvariantCulture)); //AnalyseFrogDataSet(); - //Audio2CsvOverOneFile(); + Audio2CsvOverOneFile(); //Audio2CsvOverMultipleFiles(); // used to get files from availae for Black rail and Least Bittern papers. @@ -89,7 +89,7 @@ public override Task Execute(CommandLineApplication app) //ResourcesForRheobatrachusSilusRecogniser(); //TestAnalyseLongRecordingUsingArtificialSignal(); //TestArbimonSegmentationAlgorithm(); - TestDrawHistogram(); + //TestDrawHistogram(); //TestEigenValues(); //TestChannelIntegrity(); //TestDct(); @@ -324,8 +324,8 @@ public static void Audio2CsvOverOneFile() //string outputPath = @"G:\SensorNetworks\Output\BradLaw\Pillaga24"; //string configPath = @"C:\Work\GitHub\audio-analysis\AudioAnalysis\AnalysisConfigFiles\Towsey.Acoustic.yml"; - string recordingPath = @"C:\Ecoacoustics\WavFiles\LizZnidersic\TasmanIsland2015_Unit2_Mez\SM304256_0+1_20151114_031652.wav"; - string outputPath = @"C:\Ecoacoustics\Output\Test\Test24HourRecording\TasmanIslandMez\04"; + string recordingPath = @"C:\Ecoacoustics\WavFiles\LizZnidersic\TasmanIsland2015_Unit2_Mez\SM304256_0+1_20151114_231652.wav"; + string outputPath = @"C:\Ecoacoustics\Output\Test\Test24HourRecording\TasmanIslandMez\24"; string configPath = @"C:\Work\GitHub\audio-analysis\src\AnalysisConfigFiles\Towsey.Acoustic.yml"; // Ivan Campos recordings diff --git a/src/AudioAnalysisTools/LongDurationSpectrograms/LDSpectrogramRGB.cs b/src/AudioAnalysisTools/LongDurationSpectrograms/LDSpectrogramRGB.cs index afca1babe..f233c051a 100644 --- a/src/AudioAnalysisTools/LongDurationSpectrograms/LDSpectrogramRGB.cs +++ b/src/AudioAnalysisTools/LongDurationSpectrograms/LDSpectrogramRGB.cs @@ -467,10 +467,19 @@ public void LoadSpectrogramDictionary(Dictionary dictionary) // check if user wants to use the automated bounds. if (this.IndexStats != null) { + // get the stats for this key + var stats = this.IndexStats[key]; if (indexProperties.CalculateNormMin) { - //min = this.IndexStats[key].Mode; - minBound = this.IndexStats[key].Mode - (this.IndexStats[key].StandardDeviation * 0.1); + // By default the minimum bound is set slightly below the modal value of the index. + minBound = stats.Mode - (stats.StandardDeviation * 0.1); + + // case where mode = min. Usually this occurs when mode = 0.0. + if (stats.Mode < 0.001) + { + var binWidth = (stats.Maximum - stats.Minimum) / stats.Distribution.Length; + minBound += binWidth; + } // fix case where signal is defective &= zero. We do not want ACI min ever set too low. if (key.Equals("ACI") && minBound < 0.3) @@ -487,12 +496,12 @@ public void LoadSpectrogramDictionary(Dictionary dictionary) if (indexProperties.CalculateNormMax) { - maxBound = this.IndexStats[key].GetValueOfNthPercentile(IndexDistributions.UpperPercentileDefault); + maxBound = stats.GetValueOfNthPercentile(IndexDistributions.UpperPercentileDefault); // correct for case where max bound = zero. This can happen where ICD is very short i.e. 0.1s. if (maxBound < 0.0001) { - maxBound = this.IndexStats[key].Maximum * 0.1; + maxBound = stats.Maximum * 0.1; } } @@ -621,7 +630,7 @@ public void DrawNegativeFalseColourSpectrogram(DirectoryInfo outputDirectory, st /// /// Draw a chromeless false colour spectrogram. /// Chromeless means WITHOUT all the trimmings, such as title bar axis labels, grid lines etc. - /// However it does add in notated error segments + /// However it does add in notated error segments. /// public Image DrawFalseColourSpectrogramChromeless(string colorMode, string colorMap) { diff --git a/src/TowseyLibrary/GraphsAndCharts.cs b/src/TowseyLibrary/GraphsAndCharts.cs index c2c63920b..946e374d6 100644 --- a/src/TowseyLibrary/GraphsAndCharts.cs +++ b/src/TowseyLibrary/GraphsAndCharts.cs @@ -47,9 +47,7 @@ public static Image DrawHistogram(string label, int[] histogram, int upperPercen g.DrawLine(pen1, 0, height - 1, imageWidth, height - 1); // draw upper percentile bound - g.DrawLine(pen4, upperBound, height - 1, upperBound, 0); - - g.DrawString(label, stringFont, Brushes.Wheat, new PointF(4, 3)); + g.DrawLine(pen4, upperBound, height - 1, upperBound, height / 3); if (statistics != null) { @@ -88,8 +86,9 @@ public static Image DrawHistogram(string label, int[] histogram, int upperPercen g.FillRectangle(brush, x, height - y, barWidth, y); } - // draw mode bin - g.DrawLine(pen4, modeBin, height - 1, modeBin, 0); + // draw label and modal bin + g.DrawString(label, stringFont, Brushes.Wheat, new PointF(4, 3)); + g.DrawLine(pen4, modeBin, height - 1, modeBin, height / 3); return bmp; }