コード例 #1
0
        private void PlotNormalisedSignals()
        {
            List <List <double> > Normalised = GetNormalisedData();

            List <double> X = new List <double>();

            for (int i = 0; i < Normalised[0].Count; i++)
            {
                X.Add(i);
            }

            GraphPane pane1 = ZDC_ColorMap.GraphPane;

            pane1.XAxis.Title.Text = "Время (мс)";
            pane1.YAxis.Title.Text = "Номер нейрона";

            pane1.CurveList.Clear();
            //pane1.XAxis.Scale.Max = X.Count + 5;
            pane1.XAxis.Scale.Max = X.Count + 5;

            pane1.YAxis.Scale.Max = 1;

            for (int i = 0; i < Normalised.Count; i++)
            {
                PointPairList list1    = new PointPairList(X.ToArray(), Normalised[i].ToArray());
                LineItem      myCurve1 = pane1.AddCurve("", list1, Plotter.Colors.waveToColor(i * (740 - 380) / Normalised.Count + 380), SymbolType.None);


                //bp1.Save(Path_toSave + filename + ".png");
            }
            //Image bp1 = ZDC_ColorMap.GetImage();

            ZDC_ColorMap.AxisChange();
            ZDC_ColorMap.Invalidate();
        }
コード例 #2
0
        private void Form2_Load(object sender, EventArgs e)
        {
            ZedGraph.MasterPane masterPane = ZDC_ColorMap.MasterPane;
            ZDC_ColorMap.IsSynchronizeXAxes = true;
            ZDC_ColorMap.IsSynchronizeYAxes = false;


            //masterPane.PaneList.Clear();
            masterPane.Add(ZDC_OpticalPlot.GraphPane);

            using (Graphics g = CreateGraphics())
            {
                // Графики будут размещены в один столбец друг под другом
                masterPane.SetLayout(g, PaneLayout.SingleColumn);
            }

            int   topMargin    = 0;
            int   leftMargin   = 25;
            int   bottomMargin = 25;
            int   rightMargin  = 25;
            int   spacingY     = 1;
            float labelGapY    = 1;
            float labelGapX    = 1;


            //masterPane[0].Chart.Rect = new RectangleF(leftMargin, topMargin, ZDC_ColorMap.Width - leftMargin - rightMargin, ZDC_ColorMap.Height / 2 - topMargin - spacingY);
            //masterPane[1].Chart.Rect = new RectangleF(leftMargin, ZDC_ColorMap.Height / 2 + spacingY, ZDC_ColorMap.Width - leftMargin - rightMargin, ZDC_ColorMap.Height / 2 - spacingY - bottomMargin);

            masterPane[0].Margin.Top    = 0.0f;
            masterPane[0].Margin.Left   = 0.0f;
            masterPane[0].Margin.Right  = 20.0f; //20
            masterPane[0].Margin.Bottom = 0.0f;

            masterPane[1].Margin.Top    = 10.0f; //10
            masterPane[1].Margin.Left   = 0.0f;
            masterPane[1].Margin.Right  = 0.0f;
            masterPane[1].Margin.Bottom = 0.0f;

            masterPane[0].XAxis.Title.IsVisible = false;
            masterPane[0].YAxis.Title.IsVisible = false;
            masterPane[0].Title.IsVisible       = false;
            masterPane[0].XAxis.Scale.IsVisible = false;
            masterPane[0].XAxis.Scale.LabelGap  = labelGapY;
            masterPane.InnerPaneGap             = 0.0f;
            masterPane[1].XAxis.Title.IsVisible = false;
            masterPane[1].YAxis.Title.IsVisible = false;
            masterPane[1].Title.IsVisible       = false;
            masterPane[1].XAxis.Scale.LabelGap  = labelGapX;
            masterPane[1].YAxis.Scale.LabelGap  = labelGapY;
            ZDC_ColorMap.AxisChange();
            ZDC_ColorMap.Invalidate();

            //masterPane.Margin.Bottom = 5;
            int        rr   = (int)masterPane[0].Chart.Rect.Width;
            RectangleF rect = masterPane.Rect;

            ZDC_OpticalPlot.GraphPane.AxisChangeEvent += GraphPane_AxisChangeEvent;
        }
コード例 #3
0
        private void DrawGray()
        {
            double[] IntensityData        = NeuronDataManager.Neurons[0].IntensityCleanData.ToArray();
            int      L                    = NeuronDataManager.Neurons[0].IntensityCleanData.Count;
            int      N                    = NeuronDataManager.Neurons.Count;
            List <List <double> > AllData = GetNormalisedData();
            //List<List<List<PointD>>> TMP = GetNormalisedSparkles();


            GraphPane pane = ZDC_ColorMap.GraphPane;

            pane.CurveList.Clear();
            pane.XAxis.Scale.Max = L + 50;
            PointPairList list;
            LineItem      myCurve = new LineItem("");

            myCurve.Line.Width = 1.0F;
            double lambda;

            //Grays
            double [] indexes;
            int       Left  = 0;
            int       Right = 1;

            for (int i = 0; i < N; i++)
            {
                // точки до первой вспышки
                list = new PointPairList();
                myCurve.Line.Width = 2.0F;
                IntensityData      = AllData[i].ToArray();
                for (int k = 0; k <= NeuronDataManager.Neurons[i].SparkleIndexes[0][0]; k++)
                {
                    list.Add(k, IntensityData[k]);
                }
                list.Add(PointPairBase.Missing, PointPairBase.Missing);
                myCurve = pane.AddCurve("", list, Color.Gray, SymbolType.None);

                //

                lambda = i * (740 - 380) / N + 380;
                for (int j = 1; j < NeuronDataManager.Neurons[i].SparkleIndexes.Count; j++)
                {
                    myCurve.Line.Width = 1.0F;
                    list    = new PointPairList();
                    indexes = NeuronDataManager.Neurons[i].SparkleIndexes[j - 1];
                    Left    = (int)indexes[0];
                    Right   = (int)indexes[1];
                    for (int k = Left; k <= Right && (k < L); k++)
                    {
                        list.Add(k, IntensityData[k]);
                    }
                    list.Add(PointPairBase.Missing, PointPairBase.Missing);
                    myCurve = pane.AddCurve("", list, Colors.waveToColor(lambda), SymbolType.None);

                    myCurve.Line.Width = 2.0F;
                    list    = new PointPairList();
                    indexes = NeuronDataManager.Neurons[i].SparkleIndexes[j];
                    Left    = (int)indexes[0];
                    //Right = (int)indexes[0];
                    for (int k = Right + 1; k < Left && (k < L); k++)
                    {
                        list.Add(k, IntensityData[k]);
                    }
                    list.Add(PointPairBase.Missing, PointPairBase.Missing);
                    myCurve = pane.AddCurve("", list, Color.Gray, SymbolType.None);
                }
            }
            ZDC_ColorMap.AxisChange();
            ZDC_ColorMap.Invalidate();
        }
コード例 #4
0
        private void Correlate(Tuple <double[], double[]> electro_sigXY)
        {
            List <double>         res_corr_values = new List <double>();
            List <List <double> > Normalised      = GetNormalisedData();

            double corrVal;

            corrVal = 0;


            List <double> sign_tmp;
            List <double> electro_sig = new List <double>(electro_sigXY.Item2);

            double m = electro_sig.Max();

            for (int i = 0; i < electro_sig.Count; i++)
            {
                electro_sig[i] /= m;
            }


            List <double> tmp = new List <double>();

            double img_height = 0;

            double[] x = new double[250];
            for (int i = 0; i < 250; i++)
            {
                x[i] = -250 + i;
            }

            /*
             * for (int i = 0; i < Normalised.Count; i++)
             * tmp.Add(Tools.Statistics.crossCorrelation(electro_sig.ToArray(), Normalised[i].ToArray(), true));
             */



            GraphPane pane1 = ZDC_ColorMap.GraphPane;

            pane1.XAxis.Title.Text = "Время (с)";
            pane1.YAxis.Title.Text = "Номер нейрона";

            pane1.CurveList.Clear();

            // для всех нейронов
            for (int i = 0; i < Normalised.Count; i++)
            {
                tmp.Clear();
                // осуществляем сдвиги и ищем на каждом корреляцию

                /*
                 * int maxShift = (int)(Math.Min(pattern.Length, signal.Length) * .20);
                 * double corr;
                 * double maxCorr = double.MinValue;
                 * double selfCorr1 = 0;
                 * double selfCorr2 = 0;
                 * int ShiftofMax = 0;
                 * for (int i = 0; i < pattern.Length; i++)
                 * {
                 * selfCorr1 += pattern[i] * pattern[i];
                 * }
                 * for (int i = 0; i < signal.Length; i++)
                 * {
                 * selfCorr2 += signal[i] * signal[i];
                 * }
                 * selfCorr1 = Math.Max(selfCorr1, selfCorr2);
                 * maxCorr = 0;
                 * for (int shift = 0; shift < maxShift; shift++)
                 * {
                 * corr = 0;
                 * for (int i = 0; i < pattern.Length && i + shift < signal.Length; i++)
                 * {
                 * corr += pattern[i] * signal[i + shift];
                 * }
                 *
                 * if (corr > maxCorr)
                 * {
                 * maxCorr = corr;
                 * ShiftofMax = shift;
                 * }
                 * corr = 0;
                 * for (int i = 0; i + shift < pattern.Length && i < signal.Length; i++)
                 * {
                 * corr += pattern[i + shift] * signal[i];
                 * }
                 *
                 * if (corr > maxCorr)
                 * {
                 * maxCorr = corr;
                 * ShiftofMax = -shift;
                 * }
                 *
                 *
                 *
                 */



                //записываем в список
                tmp.Add(corrVal);
            }

            //рисуем график
            img_height = (img_height > tmp.Max()) ? img_height : tmp.Max();
            PointPairList list1 = new PointPairList(x, tmp.ToArray());

            //LineItem myCurve1 = pane1.AddCurve("", list1, Plotter.Colors.waveToColor(i * (740 - 380) / Normalised.Count + 380), SymbolType.None);

            pane1.XAxis.Scale.Max = 250 + 5;
            pane1.YAxis.Scale.Max = img_height * 1.05;
            ZDC_ColorMap.AxisChange();
            ZDC_ColorMap.Invalidate();
            //pane1.GetImage().Save(@"C:\Users\Admin\Desktop\Антон\EXPERIMENTS\correlations" + i.ToString() + ".png");
        }