/// <summary>
        /// Overlays the spectral cluster IDs on a spectrogram from which the clusters derived.
        /// </summary>
        public static Image DrawClusterSpectrogram(BaseSonogram sonogram, ClusterInfo clusterInfo, TrainingDataInfo data, int lowerBinBound)
        {
            using (var img = sonogram.GetImage(doHighlightSubband: false, add1KHzLines: true, doMelScale: false))
                using (var image = new Image_MultiTrack(img))
                {
                    //image.AddTrack(ImageTrack.GetScoreTrack(DataTools.Bool2Binary(clusterInfo.selectedFrames),0.0, 1.0, 0.0));
                    //add time scale
                    image.AddTrack(ImageTrack.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond));
                    image.AddTrack(ImageTrack.GetSegmentationTrack(sonogram));

                    // add cluster track, show ID of cluster of each frame
                    string label  = string.Format(clusterInfo.ClusterCount + " Clusters");
                    var    scores = new Plot(label, DataTools.normalise(clusterInfo.ClusterHits2), 0.0); // location of cluster hits
                    image.AddTrack(ImageTrack.GetNamedScoreTrack(scores.data, 0.0, 1.0, scores.threshold, scores.title));

                    // overlay cluster hits on spectrogram
                    int[,] hits = AssembleClusterSpectrogram(sonogram.Data, lowerBinBound, clusterInfo, data);
                    image.OverlayDiscreteColorMatrix(hits);

                    return(image.GetImage());
                }// using
        }
        public static Image DrawSonogram(BaseSonogram sonogram, Plot scores, List <AcousticEvent> poi, double eventThreshold, double[,] overlay)
        {
            Image_MultiTrack image = new Image_MultiTrack(sonogram.GetImage(doHighlightSubband: false, add1KHzLines: false, doMelScale: false));

            image.AddTrack(ImageTrack.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond));
            image.AddTrack(ImageTrack.GetSegmentationTrack(sonogram));
            if (scores != null)
            {
                image.AddTrack(ImageTrack.GetNamedScoreTrack(scores.data, 0.0, 1.0, scores.threshold, scores.title));
            }

            if (poi != null && poi.Count > 0)
            {
                image.AddEvents(poi, sonogram.NyquistFrequency, sonogram.Configuration.FreqBinCount, sonogram.FramesPerSecond);
            }

            if (overlay != null)
            {
                var m = MatrixTools.ThresholdMatrix2Binary(overlay, 0.5);
                image.OverlayDiscreteColorMatrix(m);
            }

            return(image.GetImage());
        }