Esempio n. 1
0
        public static EventCommon[] CallAed(BaseSonogram sonogram, AedConfiguration aedConfiguration, TimeSpan segmentStartOffset, TimeSpan segmentDuration)
        {
            Log.Info("AED start");

            var aedOptions = new AedOptions(sonogram.Configuration.NyquistFreq)
            {
                IntensityThreshold = aedConfiguration.IntensityThreshold,
                SmallAreaThreshold = aedConfiguration.SmallAreaThreshold,
                DoNoiseRemoval     = aedConfiguration.NoiseReductionType == NoiseReductionType.None,
            };

            if (aedConfiguration.BandpassMinimum.HasValue && aedConfiguration.BandpassMaximum.HasValue)
            {
                var bandPassFilter =
                    Tuple.Create(
                        (double)aedConfiguration.BandpassMinimum.Value,
                        (double)aedConfiguration.BandpassMaximum.Value);
                aedOptions.BandPassFilter = new FSharpOption <Tuple <double, double> >(bandPassFilter);
            }

            IEnumerable <Oblong> oblongs = AcousticEventDetection.detectEvents(aedOptions, sonogram.Data);

            Log.Info("AED finished");

            var unitConverters = new UnitConverters(
                segmentStartOffset.TotalSeconds,
                sonogram.SampleRate,
                sonogram.Configuration.WindowSize,
                sonogram.Configuration.WindowOverlap);

            var events = oblongs.Select(
                o =>
            {
                var blob = new BlobEvent()
                {
                    SegmentDurationSeconds = segmentDuration.TotalSeconds,
                    Name = "AED Event",
                };

                unitConverters.SetBounds(blob, o);

                if (aedConfiguration.IncludeHitElementsInOutput)
                {
                    o.HitElements
                    .Select(p => unitConverters.ConvertPointToSpectralPoint(p, 1.0))
                    .ForEach(sp => blob.Points.Add(sp));
                }

                return(blob);
            });

            return(events.ToArray());
        }
Esempio n. 2
0
        public static AcousticEvent[] CallAed(BaseSonogram sonogram, AedConfiguration aedConfiguration, TimeSpan segmentStartOffset, TimeSpan segmentDuration)
        {
            Log.Info("AED start");

            var aedOptions = new AedOptions(sonogram.Configuration.NyquistFreq)
            {
                IntensityThreshold = aedConfiguration.IntensityThreshold,
                SmallAreaThreshold = aedConfiguration.SmallAreaThreshold,
                DoNoiseRemoval     = aedConfiguration.NoiseReductionType == NoiseReductionType.None,
            };

            if (aedConfiguration.BandpassMinimum.HasValue && aedConfiguration.BandpassMaximum.HasValue)
            {
                var bandPassFilter =
                    Tuple.Create(
                        (double)aedConfiguration.BandpassMinimum.Value,
                        (double)aedConfiguration.BandpassMaximum.Value);
                aedOptions.BandPassFilter = new FSharpOption <Tuple <double, double> >(bandPassFilter);
            }

            IEnumerable <Oblong> oblongs = AcousticEventDetection.detectEvents(aedOptions, sonogram.Data);

            Log.Info("AED finished");

            var events = oblongs.Select(
                o =>
            {
                if (!aedConfiguration.IncludeHitElementsInOutput)
                {
                    o.HitElements = null;
                }

                return(new AcousticEvent(
                           segmentStartOffset,
                           o,
                           sonogram.NyquistFrequency,
                           sonogram.Configuration.FreqBinCount,
                           sonogram.FrameDuration,
                           sonogram.FrameStep,
                           sonogram.FrameCount)
                {
                    BorderColour = aedConfiguration.AedEventColor,
                    HitColour = aedConfiguration.AedHitColor,
                    SegmentDurationSeconds = segmentDuration.TotalSeconds,
                });
            }).ToArray();

            return(events);
        }