Beispiel #1
0
        } // HiRes1()

        /// <summary>
        /// HERVE GLOTIN: This is used to analyse the BIRD50 data set.
        /// Draws HIres spectrogram images AFTER indices have been calculated.
        /// This method does NOT produce acoustic indices.
        /// That is, only call this method if hires1() has already been used to produce the indices.
        /// </summary>
        public static void HiRes2()
        {
            string histoDir = @"C:\SensorNetworks\Output\BIRD50";
            string histoPath = Path.Combine(histoDir, "TrainingRecordingDurations.png");

            //string histoPath = Path.Combine(histoDir, "TestingRecordingDurations.png");
            // set up  histogram of recording durations
            int histogramWidth = 600; // equivalent to ten minutes at 0.1 second resolution
            int[] recordingDurations = new int[histogramWidth];

            // set up IP and OP directories
            string inputDir = @"C:\SensorNetworks\Output\BIRD50\Training";
            string imageOutputDir = @"C:\SensorNetworks\Output\BIRD50\TrainingImages";

            //string imageOutputDir = @"C:\SensorNetworks\Output\BIRD50\TestingRidgeImages";
            string indexPropertiesConfig = @"C:\Work\GitHub\audio-analysis\AudioAnalysis\AnalysisConfigFiles\IndexPropertiesConfigHiRes.yml";

            // comment next two lines when debugging a single recording file
            var inputDirInfo = new DirectoryInfo(inputDir);

            //string match = @"*.wav";
            //DirectoryInfo[] directories = inputDirInfo.GetDirectories(match, SearchOption.AllDirectories);
            DirectoryInfo[] directories = inputDirInfo.GetDirectories();
            int count = directories.Length;

            //count = 3;

            //string fileStem = "ID0003";      //\ID0001\Towsey.Acoustic\
            string fileStemFormatString = "ID{0:d4}"; // for training files

            //string fileStemFormatString = "ID1{0:d3}"; // for testing files

            for (int i = 0; i < count; i++)
            {
                string fileStem = string.Format(fileStemFormatString, i + 1);
                string dataDir = directories[i].FullName + @"\Towsey.Acoustic\";

                var ldfcSpectrogramArguments = new DrawLongDurationSpectrograms.Arguments
                {
                    // use the default set of index properties in the AnalysisConfig directory.
                    InputDataDirectory = dataDir,
                    OutputDirectory = imageOutputDir,
                    IndexPropertiesConfig = indexPropertiesConfig,
                };

                // there are two possible tasks
                // 1: draw the aggregated grey scale spectrograms
                int secDuration = DrawLongDurationSpectrograms.DrawAggregatedSpectrograms(ldfcSpectrogramArguments, fileStem);

                // 2: draw the coloured ridge spectrograms
                DrawLongDurationSpectrograms.DrawRidgeSpectrograms(ldfcSpectrogramArguments, fileStem);

                if (secDuration >= recordingDurations.Length)
                {
                    secDuration = recordingDurations.Length - 1;
                }

                recordingDurations[secDuration]++;
            }

            string title = "Recording Duration: Width = " + histogramWidth + "secs";
            Image histoImage = GraphsAndCharts.DrawHistogram(title, recordingDurations, 95, null, histogramWidth, 50);
            histoImage.Save(histoPath);
        } // HiRes2() produces spectrogram images