public static Image DrawTStatisticSpectrogramsOfSingleIndex(string key, LDSpectrogramRGB cs1, LDSpectrogramRGB cs2, double tStatThreshold) { var image1 = cs1.DrawGreyscaleSpectrogramOfIndex(key); var image2 = cs2.DrawGreyscaleSpectrogramOfIndex(key); if (image1 == null || image2 == null) { Console.WriteLine("WARNING: From method ColourSpectrogram.DrawTStatisticGreyscaleSpectrogramOfIndex()"); Console.WriteLine(" Null image returned with key: {0}", key); return(null); } //frame image 1 int nyquist = cs1.SampleRate / 2; int herzInterval = 1000; string title = $"{key} SPECTROGRAM for: {cs1.FileName}. (scale:hours x kHz)"; var titleBar = LDSpectrogramRGB.DrawTitleBarOfGrayScaleSpectrogram(title, image1.Width); image1 = LDSpectrogramRGB.FrameLDSpectrogram(image1, titleBar, cs1, nyquist, herzInterval); //frame image 2 title = $"{key} SPECTROGRAM for: {cs2.FileName}. (scale:hours x kHz)"; titleBar = LDSpectrogramRGB.DrawTitleBarOfGrayScaleSpectrogram(title, image2.Width); image2 = LDSpectrogramRGB.FrameLDSpectrogram(image2, titleBar, cs1, nyquist, herzInterval); //get matrices required to calculate matrix of t-statistics double[,] avg1 = cs1.GetSpectrogramMatrix(key); if (key.Equals("ENT")) { avg1 = MatrixTools.SubtractValuesFromOne(avg1); } double[,] std1 = cs1.GetStandarDeviationMatrix(key); double[,] avg2 = cs2.GetSpectrogramMatrix(key); if (key.Equals("ENT")) { avg2 = MatrixTools.SubtractValuesFromOne(avg2); } double[,] std2 = cs2.GetStandarDeviationMatrix(key); //draw a spectrogram of t-statistic values //double[,] tStatMatrix = SpectrogramDifference.GetTStatisticMatrix(avg1, std1, cs1.SampleCount, avg2, std2, cs2.SampleCount); //Image image3 = SpectrogramDifference.DrawTStatisticSpectrogram(tStatMatrix); //titleBar = SpectrogramDifference.DrawTitleBarOfTStatisticSpectrogram(cs1.BaseName, cs2.BaseName, image1.Width, titleHt); //image3 = ColourSpectrogram.FrameSpectrogram(image3, titleBar, minOffset, cs2.X_interval, cs2.Y_interval); //draw a difference spectrogram derived from by thresholding a t-statistic matrix var image4 = DrawDifferenceSpectrogramDerivedFromSingleTStatistic(key, cs1, cs2, tStatThreshold, ColourGain); title = string.Format("{0} DIFFERENCE SPECTROGRAM (thresholded by t-statistic={3}) for: {1} - {2}. (scale:hours x kHz)", key, cs1.FileName, cs2.FileName, tStatThreshold); titleBar = LDSpectrogramRGB.DrawTitleBarOfGrayScaleSpectrogram(title, image2.Width); image4 = LDSpectrogramRGB.FrameLDSpectrogram(image4, titleBar, cs2, nyquist, herzInterval); var combinedImage = ImageTools.CombineImagesVertically(image1, image2, image4); return(combinedImage); }
public static double[,] GetTStatisticMatrix(string key, LDSpectrogramRGB cs1, LDSpectrogramRGB cs2) { double[,] avg1 = cs1.GetSpectrogramMatrix(key); if (key.Equals("TEN")) { avg1 = MatrixTools.SubtractValuesFromOne(avg1); } double[,] std1 = cs1.GetStandarDeviationMatrix(key); double[,] avg2 = cs2.GetSpectrogramMatrix(key); if (key.Equals("TEN")) { avg2 = MatrixTools.SubtractValuesFromOne(avg2); } double[,] std2 = cs2.GetStandarDeviationMatrix(key); double[,] tStatMatrix = GetTStatisticMatrix(avg1, std1, cs1.SampleCount, avg2, std2, cs2.SampleCount); return(tStatMatrix); }