예제 #1
0
        public double Asquare(cExtendedList data)
        {
            double A = 0;
            double Mean1 = data.Mean();
            double STD = data.Std();
            double varianceb = Math.Sqrt(2 * STD * STD);
            double err = 0;
            int cpt = 0;
            for (int i = 0; i < data.Count; i++)
            {
                cpt++;
                err += ((2 * cpt - 1) * (Math.Log(CDF(data[i], Mean1, varianceb)) + Math.Log(1 - CDF(data[data.Count - 1 - i], Mean1, varianceb))));
            }
            A = -data.Count - err / data.Count;

            return A;
        }
예제 #2
0
        public cWindowToDisplayHisto(cScreening CompleteScreening0, cExtendedList RawValues0)
        {
            this.CompleteScreening = CompleteScreening0;

            this.parametersToolStripMenuItem.Click += new System.EventHandler(this.parametersToolStripMenuItem_Click);

            RequestWindow.label3.Text = "Bin Number";

            this.RawValues = RawValues0;

            CurrentChartArea = new ChartArea();
            CurrentChartArea.BorderColor = Color.Black;

            this.chartForSimpleForm.ChartAreas.Add(CurrentChartArea);
            CurrentChartArea.Axes[0].MajorGrid.Enabled = false;
            if(CompleteScreening!=null)
                CurrentChartArea.Axes[0].Title = CompleteScreening.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptorIdx].GetName();
            CurrentChartArea.Axes[1].Title = "Sum";
            CurrentChartArea.AxisX.LabelStyle.Format = "N2";

            this.chartForSimpleForm.TextAntiAliasingQuality = TextAntiAliasingQuality.High;

            if (CompleteScreening != null)
                CurrentChartArea.BackColor = Color.White;

            this.chartForSimpleForm.ChartAreas[0].CursorX.IsUserEnabled = true;
            this.chartForSimpleForm.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
            this.chartForSimpleForm.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
            this.chartForSimpleForm.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;

            if ((CompleteScreening != null) && (cGlobalInfo.OptionsWindow.FFAllOptions.checkBoxHistoDisplayStats.Checked))
            {
                StripLine AverageLine = new StripLine();
                AverageLine.BackColor = Color.Black;
                AverageLine.IntervalOffset = RawValues.Mean();
                AverageLine.StripWidth = double.Epsilon;
                CurrentChartArea.AxisX.StripLines.Add(AverageLine);
                AverageLine.Text = String.Format("{0:0.###}", AverageLine.IntervalOffset);

                StripLine StdLine = new StripLine();
                StdLine.BackColor = Color.FromArgb(64, Color.Black);
                double Std = RawValues.Std();
                StdLine.IntervalOffset = AverageLine.IntervalOffset - 0.5 * Std;
                StdLine.StripWidth = Std;
                CurrentChartArea.AxisX.StripLines.Add(StdLine);
                AverageLine.StripWidth = 0.0001;
            }

            SerieForHisto = new Series();
            SerieForHisto.ShadowOffset = 1;
            SerieForHisto.ChartType = SeriesChartType.Column;
            if (CompleteScreening != null)
            SerieForHisto.Color = cGlobalInfo.ListWellClasses[1].ColourForDisplay;

            List<double[]> HistoPos = RawValues.CreateHistogram(this.BinNumber, false);
            if (HistoPos.Count == 0) return;

            for (int IdxValue = 0; IdxValue < HistoPos[0].Length; IdxValue++)
            {
                SerieForHisto.Points.AddXY(HistoPos[0][IdxValue], HistoPos[1][IdxValue]);
                SerieForHisto.Points[IdxValue].ToolTip = HistoPos[1][IdxValue].ToString();
                if (CompleteScreening != null)
                {
                    if (CompleteScreening.SelectedClass == -1)
                        SerieForHisto.Points[IdxValue].Color = Color.Black;
                    else
                        SerieForHisto.Points[IdxValue].Color = cGlobalInfo.ListWellClasses[CompleteScreening.SelectedClass].ColourForDisplay;
                }
            }
            this.chartForSimpleForm.Series.Add(SerieForHisto);
        }
예제 #3
0
파일: cWell.cs 프로젝트: cyrenaique/HCS
        private void DisplayHisto(object sender, EventArgs e)
        {
            if ((Parent.ListDescriptors == null) || (Parent.ListDescriptors.Count == 0)) return;

            cExtendedList Pos = new cExtendedList();

            cWell TempWell;

            int NumberOfPlates = Parent.GlobalInfo.PlateListWindow.listBoxPlateNameToProcess.Items.Count;

            // loop on all the plate
            for (int PlateIdx = 0; PlateIdx < NumberOfPlates; PlateIdx++)
            {
                cPlate CurrentPlateToProcess = Parent.ListPlatesActive.GetPlate((string)Parent.GlobalInfo.PlateListWindow.listBoxPlateNameToProcess.Items[PlateIdx]);

                for (int row = 0; row < Parent.Rows; row++)
                    for (int col = 0; col < Parent.Columns; col++)
                    {
                        TempWell = CurrentPlateToProcess.GetWell(col, row, false);
                        if (TempWell == null) continue;
                        else
                        {
                            if (TempWell.GetClass() == this.ClassForClassif)
                                Pos.Add(TempWell.ListDescriptors[Parent.ListDescriptors.CurrentSelectedDescriptor].GetValue());
                        }
                    }
            }

            if (Pos.Count == 0)
            {
                MessageBox.Show("No well of class " + Parent.SelectedClass + " selected !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            List<double[]> HistoPos = Pos.CreateHistogram((int)Parent.GlobalInfo.OptionsWindow.numericUpDownHistoBin.Value);
            if (HistoPos == null) return;
            SimpleForm NewWindow = new SimpleForm();

            Series SeriesPos = new Series();
            SeriesPos.ShadowOffset = 1;

            if (HistoPos.Count == 0) return;

            for (int IdxValue = 0; IdxValue < HistoPos[0].Length; IdxValue++)
            {
                SeriesPos.Points.AddXY(HistoPos[0][IdxValue], HistoPos[1][IdxValue]);
                SeriesPos.Points[IdxValue].ToolTip = HistoPos[1][IdxValue].ToString();

                if (this.ClassForClassif == -1)
                    SeriesPos.Points[IdxValue].Color = Color.Black;
                else
                    SeriesPos.Points[IdxValue].Color = Parent.GlobalInfo.GetColor(this.ClassForClassif);
            }

            ChartArea CurrentChartArea = new ChartArea();
            CurrentChartArea.BorderColor = Color.Black;

            NewWindow.chartForSimpleForm.ChartAreas.Add(CurrentChartArea);
            CurrentChartArea.Axes[0].MajorGrid.Enabled = false;
            CurrentChartArea.Axes[0].Title = Parent.ListDescriptors[Parent.ListDescriptors.CurrentSelectedDescriptor].GetName();
            CurrentChartArea.Axes[1].Title = "Sum";
            CurrentChartArea.AxisX.LabelStyle.Format = "N2";

            NewWindow.chartForSimpleForm.TextAntiAliasingQuality = TextAntiAliasingQuality.High;
            CurrentChartArea.BackGradientStyle = GradientStyle.TopBottom;
            CurrentChartArea.BackColor = Parent.GlobalInfo.OptionsWindow.panel1.BackColor;
            CurrentChartArea.BackSecondaryColor = Color.White;

            SeriesPos.ChartType = SeriesChartType.Column;
            // SeriesPos.Color = Parent.GetColor(1);
            NewWindow.chartForSimpleForm.Series.Add(SeriesPos);

            NewWindow.chartForSimpleForm.ChartAreas[0].CursorX.IsUserEnabled = true;
            NewWindow.chartForSimpleForm.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
            NewWindow.chartForSimpleForm.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
            NewWindow.chartForSimpleForm.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;

            StripLine AverageLine = new StripLine();
            AverageLine.BackColor = Color.Red;
            AverageLine.IntervalOffset = this.ListDescriptors[Parent.ListDescriptors.CurrentSelectedDescriptor].GetValue();
            AverageLine.StripWidth = 0.0001;
            AverageLine.Text = String.Format("{0:0.###}", this.ListDescriptors[Parent.ListDescriptors.CurrentSelectedDescriptor].GetValue());
            CurrentChartArea.AxisX.StripLines.Add(AverageLine);

            if (Parent.GlobalInfo.OptionsWindow.checkBoxDisplayHistoStats.Checked)
            {
                StripLine NAverageLine = new StripLine();
                NAverageLine.BackColor = Color.Black;
                NAverageLine.IntervalOffset = Pos.Mean();
                NAverageLine.StripWidth = 0.0001;// double.Epsilon;
                CurrentChartArea.AxisX.StripLines.Add(NAverageLine);
                NAverageLine.Text = String.Format("{0:0.###}", NAverageLine.IntervalOffset);

                StripLine StdLine = new StripLine();
                StdLine.BackColor = Color.FromArgb(64, Color.Black);
                double Std = Pos.Std();
                StdLine.IntervalOffset = NAverageLine.IntervalOffset - 0.5 * Std;
                StdLine.StripWidth = Std;
                CurrentChartArea.AxisX.StripLines.Add(StdLine);
                //NAverageLine.StripWidth = 0.01;
            }

            Title CurrentTitle = new Title(this.StateForClassif + " - " + Parent.ListDescriptors[Parent.ListDescriptors.CurrentSelectedDescriptor].GetName() + " histogram.");
            CurrentTitle.Font = new System.Drawing.Font("Arial", 11, FontStyle.Bold);
            NewWindow.chartForSimpleForm.Titles.Add(CurrentTitle);

            NewWindow.Text = CurrentTitle.Text;
            NewWindow.Show();
            NewWindow.chartForSimpleForm.Update();
            NewWindow.chartForSimpleForm.Show();
            NewWindow.Controls.AddRange(new System.Windows.Forms.Control[] { NewWindow.chartForSimpleForm });

            return;
        }
예제 #4
0
        private void NegativeBasedNormalization()
        {
            System.Windows.Forms.DialogResult Res = MessageBox.Show("By applying this process, data will be definitively modified ! Proceed ?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (Res == System.Windows.Forms.DialogResult.No) return;

            richTextBoxInfoForNormalization.Clear();

            int NumberOfPlates = CompleteScreening.ListPlatesActive.Count;

            int NumberOfProcessedPlates = 0;
            // loop on all the plate
            for (int PlateIdx = 0; PlateIdx < NumberOfPlates; PlateIdx++)
            {
                cPlate CurrentPlateToProcess = CompleteScreening.ListPlatesActive.GetPlate(CompleteScreening.ListPlatesActive[PlateIdx].Name);
             //   GlobalInfo.ConsoleWriteLine("Plate: " + CurrentPlateToProcess.Name);

                if (CurrentPlateToProcess.GetNumberOfWellOfClass(comboBoxNormalizationNegativeCtrl.SelectedIndex) == 0)
                {
                    richTextBoxInfoForNormalization.AppendText("\n"+ CurrentPlateToProcess.Name + " does not contain well of the selected class. Plate skipped.");
                    continue;
                }

                cExtendedList Neg = new cExtendedList();

                int NumDesc = CompleteScreening.ListDescriptors.Count;

                cWell TempWell;
                // loop on all the desciptors
                for (int Desc = 0; Desc < NumDesc; Desc++)
                {
                    Neg.Clear();

                    if (CompleteScreening.ListDescriptors[Desc].IsActive() == false) continue;

                    for (int row = 0; row < CompleteScreening.Rows; row++)
                        for (int col = 0; col < CompleteScreening.Columns; col++)
                        {
                            TempWell = CurrentPlateToProcess.GetWell(col, row, true);
                            if (TempWell == null) continue;
                            if (TempWell.GetClass() == comboBoxNormalizationNegativeCtrl.SelectedIndex) Neg.Add(TempWell.ListDescriptors[Desc].GetValue());

                        }

                    double CurrentMean = Neg.Mean();
                    GlobalInfo.ConsoleWriteLine(CompleteScreening.ListDescriptors[Desc].GetName() + ", average = " + CurrentMean);

                    if (CurrentMean == 0)
                    {
                        richTextBoxInfoForNormalization.AppendText("\n" + CurrentPlateToProcess.Name + " / " + CompleteScreening.ListDescriptors[Desc].GetName() + " average is null!\n");
                        richTextBoxInfoForNormalization.AppendText("\nNormalization skipped.");
                        continue;
                    }

                    for (int row = 0; row < CompleteScreening.Rows; row++)
                        for (int col = 0; col < CompleteScreening.Columns; col++)
                        {
                            TempWell = CurrentPlateToProcess.GetWell(col, row, true);
                            if (TempWell == null) continue;
                            for (int i = 0; i < TempWell.ListDescriptors[Desc].GetAssociatedType().GetBinNumber(); i++)
                            {
                                double Val = TempWell.ListDescriptors[Desc].Getvalue(i);
                                Val /= CurrentMean;
                                TempWell.ListDescriptors[Desc].SetHistoValues(i,Val*100);
                            }

                            TempWell.ListDescriptors[Desc].UpDateDescriptorStatistics();
                        }

                    CurrentPlateToProcess.UpDataMinMax();

                }
                richTextBoxInfoForNormalization.AppendText("\n" + CurrentPlateToProcess.Name + " successfully normalized.");
                NumberOfProcessedPlates++;
            }
            richTextBoxInfoForNormalization.AppendText("\n" + NumberOfProcessedPlates + " / " + NumberOfPlates + " successfully normalized.");
        }
예제 #5
0
        private SimpleForm BuildCV(int Desc, int Class)
        {
            cExtendedList ListValue = new cExtendedList();
            //  List<double> Neg = new List<double>();
            List<cSimpleSignature> CVFactorList = new List<cSimpleSignature>();

            cWell TempWell;
            int NumberOfPlates = CompleteScreening.ListPlatesActive.Count;

            // loop on all the plate
            for (int PlateIdx = 0; PlateIdx < NumberOfPlates; PlateIdx++)
            {
                cPlate CurrentPlateToProcess = CompleteScreening.ListPlatesActive.GetPlate(CompleteScreening.ListPlatesActive[PlateIdx].Name);

                ListValue.Clear();

                for (int row = 0; row < CompleteScreening.Rows; row++)
                    for (int col = 0; col < CompleteScreening.Columns; col++)
                    {
                        TempWell = CurrentPlateToProcess.GetWell(col, row, true);
                        if (TempWell == null) continue;
                        else
                        {
                            if (TempWell.GetClass() == Class)
                                ListValue.Add(TempWell.ListDescriptors[Desc].GetValue());
                        }
                    }

                double CVScore = ListValue.Std() / ListValue.Mean();
                GlobalInfo.ConsoleWriteLine(CurrentPlateToProcess.Name + ", Coeff. of Variation = " + CVScore);
                cSimpleSignature TmpDesc = new cSimpleSignature(CurrentPlateToProcess.Name, CVScore);
                CVFactorList.Add(TmpDesc);
            }

            Series CurrentSeries = new Series();
            CurrentSeries.ChartType = SeriesChartType.Column;
            CurrentSeries.ShadowOffset = 1;

            Series SeriesLine = new Series();
            SeriesLine.Name = "SeriesLine";
            SeriesLine.ShadowOffset = 1;
            SeriesLine.ChartType = SeriesChartType.Line;

            int RealIdx = 0;
            for (int IdxValue = 0; IdxValue < CVFactorList.Count; IdxValue++)
            {
                if (CVFactorList[IdxValue].AverageValue.ToString() == "NaN") continue;

                CurrentSeries.Points.Add(CVFactorList[IdxValue].AverageValue);
                CurrentSeries.Points[RealIdx].Label = string.Format("{0:0.###}", CVFactorList[IdxValue].AverageValue);
                CurrentSeries.Points[RealIdx].Font = new Font("Arial", 10);
                CurrentSeries.Points[RealIdx].ToolTip = CVFactorList[IdxValue].Name;
                CurrentSeries.Points[RealIdx].AxisLabel = CVFactorList[IdxValue].Name;
                CurrentSeries.Points[RealIdx].Color = CompleteScreening.GlobalInfo.GetColor(Class);

                SeriesLine.Points.Add(CVFactorList[IdxValue].AverageValue);
                SeriesLine.Points[RealIdx].BorderColor = Color.Black;
                SeriesLine.Points[RealIdx].MarkerStyle = MarkerStyle.Circle;
                SeriesLine.Points[RealIdx].MarkerSize = 4;
                RealIdx++;
            }

            SimpleForm NewWindow = new SimpleForm();
            int thisWidth = 200 * RealIdx;
            if (thisWidth > (int)GlobalInfo.OptionsWindow.numericUpDownMaximumWidth.Value)
                thisWidth = (int)GlobalInfo.OptionsWindow.numericUpDownMaximumWidth.Value;
            NewWindow.Width = thisWidth;
            NewWindow.Height = 400;
            NewWindow.Text = "Coeff. of Variation";

            ChartArea CurrentChartArea = new ChartArea();
            CurrentChartArea.BorderColor = Color.Black;
            CurrentChartArea.AxisX.Interval = 1;
            NewWindow.chartForSimpleForm.Series.Add(CurrentSeries);
            NewWindow.chartForSimpleForm.Series.Add(SeriesLine);

            CurrentChartArea.AxisX.IsLabelAutoFit = true;
            NewWindow.chartForSimpleForm.ChartAreas.Add(CurrentChartArea);

            // CurrentChartArea.Axes[1].Maximum = 2;
            CurrentChartArea.Axes[1].IsMarksNextToAxis = true;
            CurrentChartArea.Axes[0].MajorGrid.Enabled = false;
            CurrentChartArea.Axes[1].MajorGrid.Enabled = false;

            NewWindow.chartForSimpleForm.TextAntiAliasingQuality = TextAntiAliasingQuality.High;
            CurrentChartArea.BackGradientStyle = GradientStyle.TopBottom;
            CurrentChartArea.BackColor = CompleteScreening.GlobalInfo.OptionsWindow.panel1.BackColor;
            CurrentChartArea.BackSecondaryColor = Color.White;

            Title CurrentTitle = new Title(CompleteScreening.ListDescriptors[Desc].GetName() + " Coeff. of Variation");
            CurrentTitle.Font = new System.Drawing.Font("Arial", 11, FontStyle.Bold);
            NewWindow.chartForSimpleForm.Titles.Add(CurrentTitle);

            return NewWindow;
        }
예제 #6
0
        /// <summary>
        /// This function displays the evolution of the average value of a certain descriptor through the plates, for a specified class
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void descriptorEvolutionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CompleteScreening == null) return;

            FormClassification WindowClassification = new FormClassification(CompleteScreening);
            WindowClassification.label1.Text = "Class";
            WindowClassification.Text = CompleteScreening.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].GetName() + " evolution";
            WindowClassification.buttonClassification.Text = "Display";

            if (WindowClassification.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;
            int SelectedClass = WindowClassification.comboBoxForNeutralClass.SelectedIndex;
            cExtendedList ListValuePerWell = new cExtendedList();
            List<cDescriptor> List_Averages = new List<cDescriptor>();

            cWell TempWell;
            int Desc = this.comboBoxDescriptorToDisplay.SelectedIndex;

            int NumberOfPlates = CompleteScreening.ListPlatesActive.Count;
            Series CurrentSeries = new Series();
            CurrentSeries.Name = "Series1";

            CurrentSeries.ChartType = SeriesChartType.ErrorBar;
            CurrentSeries.ShadowOffset = 1;

            Series SeriesLine = new Series();
            SeriesLine.Name = "SeriesLine";
            SeriesLine.ShadowOffset = 1;
            SeriesLine.ChartType = SeriesChartType.Line;

            int RealPlateIdx = 0;

            // loop on all the plates
            for (int PlateIdx = 0; PlateIdx < NumberOfPlates; PlateIdx++)
            {
                cPlate CurrentPlateToProcess = CompleteScreening.ListPlatesActive.GetPlate(CompleteScreening.ListPlatesActive[PlateIdx].Name);
                ListValuePerWell.Clear();

                for (int row = 0; row < CompleteScreening.Rows; row++)
                    for (int col = 0; col < CompleteScreening.Columns; col++)
                    {
                        TempWell = CurrentPlateToProcess.GetWell(col, row, true);
                        if (TempWell == null) continue;
                        else
                        {
                            if (TempWell.GetClass() == SelectedClass)
                            {
                                double Val = TempWell.ListDescriptors[Desc].GetValue();
                                if (double.IsNaN(Val)) continue;

                                ListValuePerWell.Add(Val);
                            }
                        }
                    }

                if (ListValuePerWell.Count >= 1)
                {
                    DataPoint CurrentPt = new DataPoint();
                    CurrentPt.XValue = RealPlateIdx;

                    double[] Values = new double[3];
                    Values[0] = ListValuePerWell.Mean();
                    double Std = ListValuePerWell.Std();
                    if (double.IsInfinity(Std) || (double.IsNaN(Std))) Std = 0;
                    Values[1] = Values[0] - Std;
                    Values[2] = Values[0] + Std;
                    CurrentPt.YValues = Values;//ListValuePerWell.ToArray();
                    CurrentSeries.Points.Add(CurrentPt);

                    CurrentSeries.Points[RealPlateIdx].AxisLabel = CurrentPlateToProcess.Name;
                    CurrentSeries.Points[RealPlateIdx].Font = new Font("Arial", 8);
                    CurrentSeries.Points[RealPlateIdx].Color = CompleteScreening.GlobalInfo.GetColor(SelectedClass);

                    SeriesLine.Points.AddXY(RealPlateIdx, Values[0]);

                    SeriesLine.Points[RealPlateIdx].ToolTip = "Plate name: " + CurrentPlateToProcess.Name + "\nAverage: " + string.Format("{0:0.###}", Values[0]) + "\nStdev: " + string.Format("{0:0.###}", Std);
                    SeriesLine.Points[RealPlateIdx].Font = new Font("Arial", 8);
                    SeriesLine.Points[RealPlateIdx].BorderColor = Color.Black;
                    SeriesLine.Points[RealPlateIdx].MarkerStyle = MarkerStyle.Circle;
                    SeriesLine.Points[RealPlateIdx].MarkerSize = 8;

                    RealPlateIdx++;
                }
            }

            SimpleForm NewWindow = new SimpleForm(CompleteScreening);
            int thisWidth = 200 * SeriesLine.Points.Count;
            if (thisWidth > 1500) thisWidth = 1500;
            NewWindow.Width = thisWidth;
            NewWindow.Height = 400;

            ChartArea CurrentChartArea = new ChartArea();
            CurrentChartArea.BorderColor = Color.Black;
            NewWindow.chartForSimpleForm.ChartAreas.Add(CurrentChartArea);

            CurrentChartArea.AxisX.Interval = 1;
            CurrentChartArea.Axes[1].IsMarksNextToAxis = true;
            CurrentChartArea.Axes[1].Title = CompleteScreening.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].GetName();
            CurrentChartArea.Axes[0].MajorGrid.Enabled = false;
            CurrentChartArea.Axes[1].MajorGrid.Enabled = false;

            NewWindow.chartForSimpleForm.TextAntiAliasingQuality = TextAntiAliasingQuality.High;
            CurrentChartArea.BackGradientStyle = GradientStyle.TopBottom;
            CurrentChartArea.BackColor = CompleteScreening.GlobalInfo.OptionsWindow.panel1.BackColor;
            CurrentChartArea.BackSecondaryColor = Color.White;

            CurrentSeries["BoxPlotWhiskerPercentile"] = "false";
            CurrentSeries["BoxPlotShowMedian"] = "false";
            CurrentSeries["BoxPlotWhiskerPercentile"] = "false";
            CurrentSeries["BoxPlotShowAverage"] = "false";
            CurrentSeries["BoxPlotPercentile"] = "false";

            CurrentChartArea.AxisX.IsLabelAutoFit = true;
            NewWindow.chartForSimpleForm.Series.Add(CurrentSeries);
            NewWindow.chartForSimpleForm.Series.Add(SeriesLine);

            Title CurrentTitle = new Title("Class " + SelectedClass + " " + CurrentChartArea.Axes[1].Title + " evolution");

            NewWindow.chartForSimpleForm.Titles.Add(CurrentTitle);
            NewWindow.chartForSimpleForm.Titles[0].Font = new Font("Arial", 9);
            NewWindow.Show();
            NewWindow.chartForSimpleForm.Update();
            NewWindow.chartForSimpleForm.Show();
            NewWindow.Controls.AddRange(new System.Windows.Forms.Control[] { NewWindow.chartForSimpleForm });
            return;
        }
예제 #7
0
        public void DisplayHistogram(bool IsFullScreen)
        {
            if (CompleteScreening == null) return;
            if ((CompleteScreening.ListDescriptors == null) || (CompleteScreening.ListDescriptors.Count == 0)) return;

            cExtendedList Pos = new cExtendedList();
            cWell TempWell;

            if (IsFullScreen == false)
            {
                for (int row = 0; row < CompleteScreening.Rows; row++)
                    for (int col = 0; col < CompleteScreening.Columns; col++)
                    {
                        TempWell = CompleteScreening.GetCurrentDisplayPlate().GetWell(col, row, false);
                        if (TempWell == null) continue;
                        else
                        {
                            if (TempWell.GetClass() == CompleteScreening.SelectedClass)
                                Pos.Add(TempWell.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].GetValue());
                        }
                    }
            }
            else
            {
                int NumberOfPlates = CompleteScreening.ListPlatesActive.Count;

                // loop on all the plate
                for (int PlateIdx = 0; PlateIdx < NumberOfPlates; PlateIdx++)
                {
                    cPlate CurrentPlateToProcess = CompleteScreening.ListPlatesActive.GetPlate(CompleteScreening.ListPlatesActive[PlateIdx].Name);

                    for (int row = 0; row < CompleteScreening.Rows; row++)
                        for (int col = 0; col < CompleteScreening.Columns; col++)
                        {
                            TempWell = CurrentPlateToProcess.GetWell(col, row, false);
                            if (TempWell == null) continue;
                            else
                            {
                                if (TempWell.GetClass() == CompleteScreening.SelectedClass)
                                    Pos.Add(TempWell.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].GetValue());
                            }
                        }
                }
            }

            if (Pos.Count == 0)
            {
                MessageBox.Show("No well of class " + CompleteScreening.SelectedClass + " selected !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            List<double[]> HistoPos = CreateHistogram(Pos.ToArray(), (int)GlobalInfo.OptionsWindow.numericUpDownHistoBin.Value);
            SimpleForm NewWindow = new SimpleForm();

            Series SeriesPos = new Series();
            SeriesPos.ShadowOffset = 1;

            if (HistoPos.Count == 0) return;

            for (int IdxValue = 0; IdxValue < HistoPos[0].Length; IdxValue++)
            {
                SeriesPos.Points.AddXY(HistoPos[0][IdxValue], HistoPos[1][IdxValue]);
                SeriesPos.Points[IdxValue].ToolTip = HistoPos[1][IdxValue].ToString();
                if (CompleteScreening.SelectedClass == -1)
                    SeriesPos.Points[IdxValue].Color = Color.Black;
                else
                    SeriesPos.Points[IdxValue].Color = CompleteScreening.GlobalInfo.GetColor(CompleteScreening.SelectedClass);

            }

            ChartArea CurrentChartArea = new ChartArea();
            CurrentChartArea.BorderColor = Color.Black;

            NewWindow.chartForSimpleForm.ChartAreas.Add(CurrentChartArea);
            CurrentChartArea.Axes[0].MajorGrid.Enabled = false;
            CurrentChartArea.Axes[0].Title = CompleteScreening.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].GetName();
            CurrentChartArea.Axes[1].Title = "Sum";
            CurrentChartArea.AxisX.LabelStyle.Format = "N2";

            NewWindow.chartForSimpleForm.TextAntiAliasingQuality = TextAntiAliasingQuality.High;
            CurrentChartArea.BackGradientStyle = GradientStyle.TopBottom;
            CurrentChartArea.BackColor = CompleteScreening.GlobalInfo.OptionsWindow.panel1.BackColor;
            CurrentChartArea.BackSecondaryColor = Color.White;

            SeriesPos.ChartType = SeriesChartType.Column;
            SeriesPos.Color = CompleteScreening.GlobalInfo.GetColor(1);
            NewWindow.chartForSimpleForm.Series.Add(SeriesPos);

            //Series SeriesGaussNeg = new Series();
            //SeriesGaussNeg.ChartType = SeriesChartType.Spline;

            //Series SeriesGaussPos = new Series();
            //SeriesGaussPos.ChartType = SeriesChartType.Spline;

            //if (HistoPos.Count != 0)
            //{
            //    double[] HistoGaussPos = CreateGauss(Mean(Pos.ToArray()), std(Pos.ToArray()), HistoPos[0].Length);

            //    SeriesGaussPos.Color = Color.Black;
            //    SeriesGaussPos.BorderWidth = 2;
            //}
            //SeriesGaussNeg.Color = Color.Black;
            //SeriesGaussNeg.BorderWidth = 2;

            //NewWindow.chartForSimpleForm.Series.Add(SeriesGaussNeg);
            // NewWindow.chartForSimpleForm.Series.Add(SeriesGaussPos);
            NewWindow.chartForSimpleForm.ChartAreas[0].CursorX.IsUserEnabled = true;
            NewWindow.chartForSimpleForm.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
            NewWindow.chartForSimpleForm.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
            NewWindow.chartForSimpleForm.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;

            if (GlobalInfo.OptionsWindow.checkBoxDisplayHistoStats.Checked)
            {
                StripLine AverageLine = new StripLine();
                AverageLine.BackColor = Color.Black;
                AverageLine.IntervalOffset = Pos.Mean();
                AverageLine.StripWidth = double.Epsilon;
                CurrentChartArea.AxisX.StripLines.Add(AverageLine);
                AverageLine.Text = String.Format("{0:0.###}", AverageLine.IntervalOffset);

                StripLine StdLine = new StripLine();
                StdLine.BackColor = Color.FromArgb(64, Color.Black);
                double Std = Pos.Std();
                StdLine.IntervalOffset = AverageLine.IntervalOffset - 0.5 * Std;
                StdLine.StripWidth = Std;
                CurrentChartArea.AxisX.StripLines.Add(StdLine);
                AverageLine.StripWidth = 0.0001;
            }

            Title CurrentTitle = null;

            if (IsFullScreen)
                CurrentTitle = new Title("Class " + CompleteScreening.SelectedClass + " - " + CompleteScreening.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].GetName() + " histogram.");
            else
                CurrentTitle = new Title("Class " + CompleteScreening.SelectedClass + " - " + CompleteScreening.GetCurrentDisplayPlate().Name + " - " + CompleteScreening.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].GetName() + " histogram.");

            CurrentTitle.Font = new System.Drawing.Font("Arial", 11, FontStyle.Bold);
            NewWindow.chartForSimpleForm.Titles.Add(CurrentTitle);
            NewWindow.Text = CurrentTitle.Text;
            NewWindow.Show();
            NewWindow.chartForSimpleForm.Update();
            NewWindow.chartForSimpleForm.Show();
            NewWindow.Controls.AddRange(new System.Windows.Forms.Control[] { NewWindow.chartForSimpleForm });
            return;
        }
예제 #8
0
        private void StandardNormalization()
        {
            System.Windows.Forms.DialogResult Res = MessageBox.Show("By applying this process, data will be definitively modified ! Proceed ?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (Res == System.Windows.Forms.DialogResult.No) return;

            richTextBoxInfoForNormalization.Clear();

            int NumberOfPlates = cGlobalInfo.CurrentScreening.ListPlatesActive.Count;
            int NumberOfProcessedPlates = 0;
            // loop on all the plate
            for (int PlateIdx = 0; PlateIdx < NumberOfPlates; PlateIdx++)
            {
                cPlate CurrentPlateToProcess = cGlobalInfo.CurrentScreening.ListPlatesActive.GetPlate(PlateIdx);

                if (CurrentPlateToProcess.GetNumberOfWellOfClass(comboBoxNormalizationNegativeCtrl.SelectedIndex) < 2)
                {
                    richTextBoxInfoForNormalization.AppendText("\n" + CurrentPlateToProcess.GetName() + " does not contain enough well of the selected class. Plate skipped.");
                    continue;
                }

               // GlobalInfo.ConsoleWriteLine("Plate: " + CurrentPlateToProcess.Name);
                cExtendedList Neg = new cExtendedList();
                int NumDesc = cGlobalInfo.CurrentScreening.ListDescriptors.Count;

                cWell TempWell;
                // loop on all the desciptors
                for (int Desc = 0; Desc < NumDesc; Desc++)
                {
                    if (cGlobalInfo.CurrentScreening.ListDescriptors[Desc].IsConnectedToDatabase == true)
                    {
                        cGlobalInfo.ConsoleWriteLine("Cell by cell normalization not implemented yet. " + cGlobalInfo.CurrentScreening.ListDescriptors[Desc].GetName() + " skipped");
                        continue;
                    }

                    Neg.Clear();

                    if (cGlobalInfo.CurrentScreening.ListDescriptors[Desc].IsActive() == false) continue;

                    for (int row = 0; row < cGlobalInfo.CurrentScreening.Rows; row++)
                        for (int col = 0; col < cGlobalInfo.CurrentScreening.Columns; col++)
                        {
                            TempWell = CurrentPlateToProcess.GetWell(col, row, true);
                            if (TempWell == null) continue;
                            if (TempWell.GetCurrentClassIdx() == comboBoxNormalizationNegativeCtrl.SelectedIndex) Neg.Add(TempWell.ListSignatures[Desc].GetValue());
                        }

                    double CurrentMean = Neg.Mean();
                    double CurrentStd = Neg.Std();
                    if (CurrentStd == 0.0)
                    {
                        richTextBoxInfoForNormalization.AppendText("\n" + CurrentPlateToProcess.GetName() + " - " + cGlobalInfo.CurrentScreening.ListDescriptors[Desc].GetName() + ", Standard deviation = 0, process cancelled");
                        goto NEXTPLATE;

                    }
                    cGlobalInfo.ConsoleWriteLine(cGlobalInfo.CurrentScreening.ListDescriptors[Desc].GetName() + ", average = " + CurrentMean);

                    for (int row = 0; row < cGlobalInfo.CurrentScreening.Rows; row++)
                        for (int col = 0; col < cGlobalInfo.CurrentScreening.Columns; col++)
                        {
                            TempWell = CurrentPlateToProcess.GetWell(col, row, true);
                            if (TempWell == null) continue;
                           // for (int i = 0; i < TempWell.ListDescriptors[Desc].GetAssociatedType().GetBinNumber(); i++)
                            {
                                double Value = TempWell.ListSignatures[Desc].GetValue() - CurrentMean;

                                TempWell.ListSignatures[Desc].SetHistoValues(Value / CurrentStd);
                            }

                            TempWell.ListSignatures[Desc].UpDateDescriptorStatistics();
                        }

                    CurrentPlateToProcess.UpDataMinMax();

                }
                richTextBoxInfoForNormalization.AppendText("\n" + CurrentPlateToProcess.GetName() + " successfully normalized.");
                NumberOfProcessedPlates++;
            NEXTPLATE: ;
            }
            richTextBoxInfoForNormalization.AppendText("\n" + NumberOfProcessedPlates + " / " + NumberOfPlates + " successfully normalized.");
        }
예제 #9
0
        private void NegativePositiveBasedNormalization()
        {
            System.Windows.Forms.DialogResult Res = MessageBox.Show("By applying this process, data will be definitively modified ! Proceed ?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (Res == System.Windows.Forms.DialogResult.No) return;

            richTextBoxInfoForNormalization.Clear();

            int NumberOfPlates = cGlobalInfo.CurrentScreening.ListPlatesActive.Count;
            int NumberOfProcessedPlates = 0;
            // loop on all the plate
            for (int PlateIdx = 0; PlateIdx < NumberOfPlates; PlateIdx++)
            {
                cPlate CurrentPlateToProcess = cGlobalInfo.CurrentScreening.ListPlatesActive.GetPlate(cGlobalInfo.CurrentScreening.ListPlatesActive[PlateIdx].GetName());
               // GlobalInfo.ConsoleWriteLine("Plate: " + CurrentPlateToProcess.Name);

                if ((CurrentPlateToProcess.GetNumberOfWellOfClass(comboBoxNormalizationNegativeCtrl.SelectedIndex)==0)||((CurrentPlateToProcess.GetNumberOfWellOfClass(comboBoxNormalizationPositiveCtrl.SelectedIndex)==0)))
                {
                    richTextBoxInfoForNormalization.AppendText("\n" + CurrentPlateToProcess.GetName() + " does not contain well of the selected classes. Plate skipped.");
                    continue;
                }

                cExtendedList Neg = new cExtendedList();
                cExtendedList Pos = new cExtendedList();
                int NumDesc = cGlobalInfo.CurrentScreening.ListDescriptors.Count;

                cWell TempWell;
                // loop on all the desciptors
                for (int Desc = 0; Desc < NumDesc; Desc++)
                {
                    Neg.Clear();
                    if (cGlobalInfo.CurrentScreening.ListDescriptors[Desc].IsActive() == false) continue;
                    if (cGlobalInfo.CurrentScreening.ListDescriptors[Desc].IsConnectedToDatabase == true)
                    {
                        cGlobalInfo.ConsoleWriteLine("Cell by cell normalization not implemented yet. "+ cGlobalInfo.CurrentScreening.ListDescriptors[Desc].GetName() + " skipped");
                        continue;
                    }

                    for (int row = 0; row < cGlobalInfo.CurrentScreening.Rows; row++)
                        for (int col = 0; col < cGlobalInfo.CurrentScreening.Columns; col++)
                        {
                            TempWell = CurrentPlateToProcess.GetWell(col, row, true);
                            if (TempWell == null) continue;
                            if (TempWell.GetCurrentClassIdx() == comboBoxNormalizationPositiveCtrl.SelectedIndex) Pos.Add(TempWell.ListSignatures[Desc].GetValue());
                            if (TempWell.GetCurrentClassIdx() == comboBoxNormalizationNegativeCtrl.SelectedIndex) Neg.Add(TempWell.ListSignatures[Desc].GetValue());
                        }

                    double CurrentMeanNeg = Neg.Mean();
                    double CurrentMeanPos = Pos.Mean();

                    if (CurrentMeanNeg == CurrentMeanPos)
                    {
                        cGlobalInfo.ConsoleWriteLine("Negative and positive are similar, no normalization operated on " + cGlobalInfo.CurrentScreening.ListDescriptors[Desc].GetName());
                        continue;
                    }
                    double Denominator = (Math.Abs(CurrentMeanPos - CurrentMeanNeg));

                    for (int row = 0; row < cGlobalInfo.CurrentScreening.Rows; row++)
                        for (int col = 0; col < cGlobalInfo.CurrentScreening.Columns; col++)
                        {
                            TempWell = CurrentPlateToProcess.GetWell(col, row, true);
                            if (TempWell == null) continue;
                            //for (int i = 0; i < TempWell.ListDescriptors[Desc].GetAssociatedType().GetBinNumber(); i++)
                            {
                                double CurrValue = TempWell.ListSignatures[Desc].GetValue();
                                TempWell.ListSignatures[Desc].SetHistoValues((CurrValue - CurrentMeanNeg) / Denominator);
                                //TempWell.ListDescriptors[Desc].Histogram.SetYvalues((CurrValue - CurrentMeanNeg) / Denominator,0);
                            }
                            //TempWell.ListDescriptors[Desc].Histogram.
                            TempWell.ListSignatures[Desc].UpDateDescriptorStatistics();
                        }

                    CurrentPlateToProcess.UpDataMinMax();

                }
                richTextBoxInfoForNormalization.AppendText("\n" + CurrentPlateToProcess.GetName() + " successfully normalized.");
                NumberOfProcessedPlates++;
            }
            richTextBoxInfoForNormalization.AppendText("\n" + NumberOfProcessedPlates + " / " + NumberOfPlates + " successfully normalized.");
        }
예제 #10
0
        public int FindIterationForBestMatch(double[,] Plate)
        {
            int BestIter = -1;
            double Dist = double.MaxValue;

            cExtendedList LextPlate = new cExtendedList();
            double[,] TmpPlate = new double[cGlobalInfo.CurrentScreening.Columns, cGlobalInfo.CurrentScreening.Rows];

            // compute average
            for (int Y = 0; Y < cGlobalInfo.CurrentScreening.Rows; Y++)
                for (int X = 0; X < cGlobalInfo.CurrentScreening.Columns; X++)
                {
                    LextPlate.Add(Plate[X, Y]);
                }

            double Average = LextPlate.Mean();
            double Stdev = LextPlate.Std();

            for (int Y = 0; Y < cGlobalInfo.CurrentScreening.Rows; Y++)
                for (int X = 0; X < cGlobalInfo.CurrentScreening.Columns; X++)
                {
                    TmpPlate[X, Y] = (Plate[X, Y] - Average) / Stdev;
                }

            for (int Iter = 0; Iter < this.DiffusionMaps.Count; Iter++)
            {
                double CurrentDist = 0;

                for (int Y = 0; Y < cGlobalInfo.CurrentScreening.Rows; Y++)
                    for (int X = 0; X < cGlobalInfo.CurrentScreening.Columns; X++)
                    {
                        CurrentDist += Math.Sqrt( (this.DiffusionMaps[Iter][X, Y] - TmpPlate[X, Y]) * (this.DiffusionMaps[Iter][X, Y] - TmpPlate[X, Y]));
                    }

                if (CurrentDist < Dist)
                {
                    BestIter = Iter;
                    Dist = CurrentDist;
                }
            }
            return BestIter;
        }
예제 #11
0
        private void DiffusionLaplacianFunction(double[,] input, double[,] output, int Width, int Height)
        {
            for (int j = 0; j < Height; j++)
                for (int i = 0; i < Width; i++)
                {

                    if (Mask[i,j] == 0)
                    {
                        output[i,j] = input[i, j] + (input[i + 1,j] + input[i - 1,j] + input[i,j+1] + input[i,j-1] - 4 * input[i,j]) * CoeffDiff;
                    }
                    else
                        output[i,j] = Mask[i,j];
                }

            // normalize the plate
             cExtendedList LextPlate = new cExtendedList();

            // compute average
             for (int Y = 0; Y < cGlobalInfo.CurrentScreening.Rows; Y++)
                 for (int X = 0; X < cGlobalInfo.CurrentScreening.Columns; X++)
                {
                    LextPlate.Add(output[X+1, Y+1]);
                }

            double Average = LextPlate.Mean();
            double Stdev = LextPlate.Std();

            for (int Y = 0; Y < cGlobalInfo.CurrentScreening.Rows; Y++)
                for (int X = 0; X < cGlobalInfo.CurrentScreening.Columns; X++)
                {
                    output[X+1, Y+1] = (output[X+1, Y+1] - Average) / Stdev;
                }

            return;
        }
예제 #12
0
        /// <summary>
        /// compute the diffusion maps from Iteration = 0 to Iteration = NumIterations
        /// </summary>
        /// <param name="NumIterations">Maximum number of iterations</param>
        private void ComputeDiffusionMaps(int NumIterations)
        {
            DiffusionMaps = new List<double[,]>();
            DiffusionMapsMeans = new List<double>();
            DiffusionMapsStdev = new List<double>();

            double[,] CurrentMap = new double[cGlobalInfo.CurrentScreening.Columns + 2, cGlobalInfo.CurrentScreening.Rows + 2];
            double[,] NextMap = new double[cGlobalInfo.CurrentScreening.Columns + 2, cGlobalInfo.CurrentScreening.Rows + 2];

            Array.Copy(Mask, CurrentMap, Mask.Length);

            double[,] CurrentMapWithoutBorders0 = new double[cGlobalInfo.CurrentScreening.Columns, cGlobalInfo.CurrentScreening.Rows];

            for (int X = 0; X < cGlobalInfo.CurrentScreening.Columns; X++)
                for (int Y = 0; Y < cGlobalInfo.CurrentScreening.Rows; Y++)
                    CurrentMapWithoutBorders0[X, Y] = CurrentMap[X + 1, Y + 1];
            DiffusionMaps.Add(CurrentMapWithoutBorders0);

            cExtendedList ValueList = new cExtendedList();

            for (int it = 0; it < NumIterations; it++)
            {
                DiffusionLaplacianFunction(CurrentMap, NextMap, cGlobalInfo.CurrentScreening.Columns + 2, cGlobalInfo.CurrentScreening.Rows + 2);
                ValueList.Clear();

                double[,] CurrentMapWithoutBorders = new double[cGlobalInfo.CurrentScreening.Columns, cGlobalInfo.CurrentScreening.Rows];
                for (int X = 0; X < cGlobalInfo.CurrentScreening.Columns; X++)
                    for (int Y = 0; Y < cGlobalInfo.CurrentScreening.Rows; Y++)
                    {
                        CurrentMapWithoutBorders[X, Y] = NextMap[X + 1, Y + 1];
                        ValueList.Add(CurrentMapWithoutBorders[X, Y]);
                    }
                DiffusionMaps.Add(CurrentMapWithoutBorders);
                DiffusionMapsMeans.Add(ValueList.Mean());
                DiffusionMapsStdev.Add(ValueList.Std());

                Array.Copy(NextMap, CurrentMap, CurrentMap.Length);
            }
            return;
        }
        public cFeedBackMessage Run(cScreening CompleteScreening)
        {
            if (this.Input == null)
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "No input data defined.";
                return FeedBackMessage;
            }

            bool IsCurrentDescOnly = false;
            if (this.ListPlates == null)
                ListPlates = CompleteScreening.ListPlatesActive;

            cDisplayToWindow CDW1 = new cDisplayToWindow();

            cDesignerTab DT = new cDesignerTab();

            foreach (cDescriptorType CurrentDesc in CompleteScreening.ListDescriptors.GetActiveDescriptors())
            {
                cListExtendedTable CompleteListOfData = new cListExtendedTable();

                cExtendedTable FullTableAverage = new cExtendedTable();
                FullTableAverage.ListRowNames = new List<string>();

                string TableName = CurrentDesc.GetName() + " evolution\n" + Input[0].Sum() + " classes - ";

                for (int i = 0; i < Input[0].Count; i++)
                {
                    if ((Input[0][i] == 1) && (Input[0].ListTags != null) && (Input[0].ListTags[i].GetType() == typeof(cWellClassType)))
                    {
                        cWellClassType TmpWellClass = (cWellClassType)Input[0].ListTags[i];

                        CompleteListOfData.Add(new cExtendedTable());
                        CompleteListOfData[CompleteListOfData.Count - 1].Name = TmpWellClass.Name;
                        CompleteListOfData[CompleteListOfData.Count - 1].Tag = Input[0].ListTags[i];

                        FullTableAverage.Add(new cExtendedList(TmpWellClass.Name));
                        FullTableAverage[FullTableAverage.Count - 1].ListTags = new List<object>();
                        FullTableAverage[FullTableAverage.Count - 1].Name = TmpWellClass.Name;
                        FullTableAverage[FullTableAverage.Count - 1].Tag = TmpWellClass;

                        int IdxPlate = 0;
                        foreach (cPlate TmpPlate in CompleteScreening.ListPlatesActive)
                        {
                            FullTableAverage[FullTableAverage.Count - 1].Add(0);
                            FullTableAverage[FullTableAverage.Count - 1].ListTags.Add(TmpWellClass);

                            CompleteListOfData[CompleteListOfData.Count - 1].Add(new cExtendedList(TmpPlate.GetName()));
                            CompleteListOfData[CompleteListOfData.Count - 1][CompleteListOfData[CompleteListOfData.Count - 1].Count - 1].Tag = TmpPlate;
                            CompleteListOfData[CompleteListOfData.Count - 1][CompleteListOfData[CompleteListOfData.Count - 1].Count - 1].Add(IdxPlate);

                            IdxPlate++;
                        }
                    }
                }

                TableName += FullTableAverage[0].Count + " plates";
                FullTableAverage.Name = TableName;

                foreach (cPlate TmpPlate in CompleteScreening.ListPlatesActive)
                    FullTableAverage.ListRowNames.Add(TmpPlate.GetName());

              //  cDescriptorsType CurrentDesc = CompleteScreening.ListDescriptors.GetActiveDescriptor();
                int RealIdx = 0;
                for (int i = 0; i < Input[0].Count; i++)
                {
                    if (Input[0][i] == 1)
                    {
                        int IdxPlate = 0;
                        foreach (cPlate TmpPlate in ListPlates/*CompleteScreening.ListPlatesActive*/)
                        {
                            cExtendedList CurrentListValues = new cExtendedList();

                            foreach (cWell item in TmpPlate.ListActiveWells)
                                if ((item.GetCurrentClassIdx() != -1) && (item.GetCurrentClassIdx() == i))
                                {
                                    double Value = item.ListSignatures.GetSignature(CurrentDesc).GetValue();
                                    CurrentListValues.Add(Value);
                                    CompleteListOfData[RealIdx][IdxPlate].Add(Value);
                                }

                            FullTableAverage[RealIdx][IdxPlate] = CurrentListValues.Mean();
                            IdxPlate++;
                        }
                        RealIdx++;
                    }
                }

                cViewerGraph1D VG = new cViewerGraph1D();
                VG.Chart.IsLine = true;
                VG.Chart.IsShadow = true;
                VG.Chart.IsZoomableX = true;
                // VG.Chart.IsYGrid = true;
                //VG.Chart.IsDisplayValues = true;
                VG.Chart.IsLegend = true;
                //cViewerStackedHistogram CV1 = new cViewerStackedHistogram();
                //  CV1.SetInputData(NewTable);

                VG.SetInputData(FullTableAverage);
                VG.SetInputData(CompleteListOfData);

                VG.Chart.LabelAxisX = "Plate";
                VG.Chart.LabelAxisY = CurrentDesc.GetName();
                VG.Run();

                cExtendedControl TmpCtrl = VG.GetOutPut();
                TmpCtrl.Title = CurrentDesc.GetName();

                DT.SetInputData(TmpCtrl);

            }
            DT.Run();

            CDW1.Title = "Descriptor Evolution";
            CDW1.SetInputData(DT.GetOutPut());
            CDW1.Run();
            CDW1.Display();

            return FeedBackMessage;
        }
예제 #14
0
        public void Run()
        {
            this.SliderForMarkerSize.trackBar.Value = this.MarkerSize;
            this.SliderForMarkerSize.numericUpDown.Value = this.MarkerSize;

            this.SliderForLineWidth.trackBar.Value = this.LineWidth;
            this.SliderForLineWidth.numericUpDown.Value = this.LineWidth;

            this.SliderForOpacity.numericUpDown.Maximum = this.SliderForOpacity.trackBar.Maximum = 255;
            this.SliderForOpacity.trackBar.Value = this.Opacity;
            this.SliderForOpacity.numericUpDown.Value = this.Opacity;

            if ((InputSimpleData==null)||((X_AxisValues != null) && (X_AxisValues.Count != InputSimpleData[0].Count))) return;
            if ((X_AxisValues != null) && (X_AxisValues.Min() <= 0) && (IsLogAxis)) return;

            #region multiple readouts
            if (ListCurves.Count > 0)
            {
                //for (int IdxSimpleReadoutCurve = 0; IdxSimpleReadoutCurve < input.Count; IdxSimpleReadoutCurve++)

                foreach (cCurveForGraph item in ListCurves)
                {
                    if (item == null) continue;
                    Series NewSerie = new System.Windows.Forms.DataVisualization.Charting.Series(item.Title);

                    //NewSerie.ChartType = SeriesChartType.ErrorBar;
                    NewSerie.ChartType = SeriesChartType.Point;

                //    NewSerie.ChartType = SeriesChartType.Point;

                    //NewSerie.ChartType = SeriesChartType.SplineRange;
                    NewSerie.ShadowOffset = 0;
                    //NewSerie.ShadowColor = Color.Transparent;

                    #region loop over the multireadouts curves
                    for (int j = 0; j < item.ListPtValues.Count; j++)
                    {
                        //this.chartForPoints.Series[0].Points[j].MarkerColor = Color.FromArgb(128, GlobalInfo.ListCellularPhenotypes[(int)MachineLearning.Classes[j]].ColourForDisplay);

                        cExtendedList ListValues = new cExtendedList();
                        for (int IdxValue = 1; IdxValue < item.ListPtValues[j].Count; IdxValue++)
                        {
                            ListValues.Add(item.ListPtValues[j][IdxValue]);
                        }

                        double[] Values = new double[2];

                        double Mean = ListValues.Mean();
                        double Std = ListValues.Std();

                        if (NewSerie.ChartType == SeriesChartType.ErrorBar)
                        {
                            Values = new double[3];
                            Values[0] = Mean;
                            Values[1] = Mean - Std;
                            Values[2] = Mean + Std;
                            DataPoint DP = new DataPoint();
                            DP.XValue = item.ListPtValues[j][0];
                            DP.YValues = Values;
                            DP.Color = Color.AliceBlue;
                            NewSerie.Points.Add(DP);
                        }
                        else if (NewSerie.ChartType == SeriesChartType.SplineRange)
                        {
                            Values[0] = Mean - Std;
                            Values[1] = Mean + Std;
                            DataPoint DP = new DataPoint();
                            DP.XValue = item.ListPtValues[j][0];
                            DP.YValues = Values;
                            DP.Color = Color.FromArgb(200, Color.Tomato);
                           // DP.MarkerSize = 10;
                            NewSerie.Points.Add(DP);
                        }
                        else
                        {
                           // Values = ListValues.ToArray();
                            for (int i = 0; i < ListValues.Count; i++)
                            {
                                 DataPoint DP = new DataPoint();
                                 DP.SetValueXY(item.ListPtValues[j][0], ListValues[i]);
                                 DP.Color = Color.FromArgb(190, Color.Tomato);
                                 DP.BorderColor = Color.Black;

                                 DP.BorderWidth = 1;
                                 DP.MarkerSize = 8;
                                 DP.MarkerStyle = MarkerStyle.Circle;
                                 NewSerie.Points.Add(DP);
                            }

                        }

                       // DP.Tag = DataSerie.Tag;
                        ////   Value[0] = item.ListPtValues[j];
                        //for (int IdxValue = 1; IdxValue < item.ListPtValues[j].Count; IdxValue++)
                        //{
                        //    ListValues.Add(item.ListPtValues[j][IdxValue]);
                        //}

                        //double[] Values = new double[2];
                        ////Values[0] = ListValues.Mean();
                        //double Mean = ListValues.Mean();
                        //double Std = ListValues.Std();
                        //Values[0] = Mean - Std;
                        //Values[1] = Mean + Std;

                        //DP.YValues = Values;

                        //if (IsBorder)
                        //{
                        //    DP.MarkerBorderColor = Color.Black;
                        //    DP.MarkerBorderWidth = 1;
                        //}

                        //if ((ArraySeriesInfo != null) && (ArraySeriesInfo[IdxSimpleReadoutCurve] != null))
                        //{
                        //    DP.Color = Color.FromArgb(this.Opacity, ArraySeriesInfo[IdxSimpleReadoutCurve].color);
                        //    NewSerie.Tag = ArraySeriesInfo[IdxSimpleReadoutCurve];
                        //    DP.MarkerStyle = ArraySeriesInfo[IdxSimpleReadoutCurve].markerStyle;
                        //    DP.MarkerSize = this.MarkerSize;
                        //}
                        //else
                       // {
                            //DP.MarkerStyle = MarkerStyle.Diamond;
                            // DP.MarkerSize = 4;
                       // }

                        // DP.BorderWidth = 2;

                        //if (item.ListPtValues[0].ListTags != null)
                        //{
                        //    if (j >= item.ListPtValues[0].ListTags.Count) continue;
                        //    DP.Tag = item.ListPtValues[0].ListTags[j];

                        //    if (DP.Tag.GetType() == typeof(cWell))
                        //    {
                        //        DP.Color = ((cWell)(DP.Tag)).GetClassColor();
                        //        // DP.ToolTip = ((cWell)(DP.Tag)).GetShortInfo() + Value[0];
                        //    }
                        //    if (DP.Tag.GetType() == typeof(cDescriptorsType))
                        //    {
                        //        // DP.Color = ((cWell)(DP.Tag)).GetClassColor();
                        //        //  DP.ToolTip = ((cDescriptorsType)(DP.Tag)).GetShortInfo() + Value[0];
                        //        DP.AxisLabel = ((cDescriptorsType)(DP.Tag)).GetName();
                        //        base.CurrentChartArea.AxisX.Interval = 1;

                        //    }
                        //    if (DP.Tag.GetType() == typeof(cPlate))
                        //    {
                        //        // DP.Color = ((cWell)(DP.Tag)).GetClassColor();
                        //        //  DP.ToolTip = ((cPlate)(DP.Tag)).Name + " : " + Value[0];
                        //        DP.AxisLabel = ((cPlate)(DP.Tag)).Name;
                        //        base.CurrentChartArea.AxisX.Interval = 1;

                        //    }

                        //}
                        //NewSerie.Points.Add(DP);
                    }
                    #endregion

                    base.CurrentSeries.Add(NewSerie);
                }
            }

            if (base.ListInput != null)
            {
                foreach (cExtendedTable DataSerie in base.ListInput)
                {
                    Series NewSerie = new System.Windows.Forms.DataVisualization.Charting.Series("ComplexD_ataTable"+DataSerie.Name);
                    NewSerie.Tag = DataSerie.Tag;

                    //NewSerie.ChartType = SeriesChartType.SplineRange;
                    NewSerie.ChartType = SeriesChartType.ErrorBar;

                    for (int IdxPt = 0; IdxPt < DataSerie.Count; IdxPt++)
                    {
                        DataPoint DP = new DataPoint();
                        DP.XValue = DataSerie[IdxPt][0];

                        cExtendedList ListValues = new cExtendedList();
                        for (int i = 1; i < DataSerie[IdxPt].Count; i++)
                        {
                            ListValues.Add(DataSerie[IdxPt][i]);
                        }

                        if (ListValues.Count == 0) continue;
                        double[] Values = new double[2];

                        double Mean = ListValues.Mean();
                        double Std = ListValues.Std();
                        if (ListValues.Count == 1)
                            Std = 0;

                        if (NewSerie.ChartType == SeriesChartType.ErrorBar)
                        {
                            Values = new double[3];
                            Values[0] = Mean;
                            Values[1] = Mean - Std;
                            Values[2] = Mean + Std;
                        }
                        else
                        {
                            Values[0] = Mean - Std;
                            Values[1] = Mean + Std;
                        }
                        DP.YValues = Values;
                        DP.Tag = DataSerie.Tag;

                        DP.ToolTip = "Mean: " + Mean + "\nStdev: " + Std;

                        if (DP.Tag.GetType() == typeof(cWellClassType))
                        {
                            DP.Color = Color.FromArgb(200, ((cWellClassType)(DP.Tag)).ColourForDisplay);
                        }
                        //if (DP.Tag.GetType() == typeof(cWell))
                        //{
                        //    DP.Color = ((cWell)(DP.Tag)).GetClassColor();

                        //}
                       // DP.Color = Color.FromArgb(200, Color.Tomato);

                        NewSerie.Points.Add(DP);
                    }

                    base.CurrentSeries.Add(NewSerie);

                }

            }

            #endregion

            #region simple readout curves
            if (InputSimpleData != null)
            {
                cLUTProcess LUTProcess = new cLUTProcess(cGlobalInfo.GraphsLUT);

                for (int IdxSimpleReadoutCurve = 0; IdxSimpleReadoutCurve < InputSimpleData.Count; IdxSimpleReadoutCurve++)
                {
                    Series NewSerie = new System.Windows.Forms.DataVisualization.Charting.Series(base.InputSimpleData[IdxSimpleReadoutCurve].Name);
                    NewSerie.Tag = base.InputSimpleData[IdxSimpleReadoutCurve].Tag;

                    if (ISPoint)
                        NewSerie.ChartType = SeriesChartType.Point;
                    if (ISFastPoint)
                        NewSerie.ChartType = SeriesChartType.FastPoint;
                    if (IsLine)
                        NewSerie.ChartType = SeriesChartType.Line;
                    if (IsBar)
                        NewSerie.ChartType = SeriesChartType.Column;

                    if ((ArraySeriesInfo != null) && (ArraySeriesInfo[IdxSimpleReadoutCurve] != null))
                    {
                        NewSerie.ChartType = SeriesChartType.Spline;
                        //NewSerie.ChartType = SeriesChartType.Line;
                    }

                    #region loop over the simple readout curves
                    for (int j = 0; j < this.InputSimpleData[IdxSimpleReadoutCurve].Count; j++)
                    {
                        //this.chartForPoints.Series[0].Points[j].MarkerColor = Color.FromArgb(128, GlobalInfo.ListCellularPhenotypes[(int)MachineLearning.Classes[j]].ColourForDisplay);
                        DataPoint DP = new DataPoint();
                        double[] Value = new double[1];
                        Value[0] = this.InputSimpleData[IdxSimpleReadoutCurve][j];
                        if (double.IsNaN(Value[0])) continue;
                        DP.YValues = Value;

                        if (X_AxisValues != null)
                            DP.XValue = X_AxisValues[j];
                        else
                            DP.XValue = j;

                      //  DP.AxisLabel = this.InputSimpleData.ListRowNames[j].ToString();

                        if (IsBorder)
                        {
                            DP.MarkerBorderColor = Color.Black;
                            DP.MarkerBorderWidth = 0;// 1;
                        }

                        if ((ArraySeriesInfo != null) && (ArraySeriesInfo[IdxSimpleReadoutCurve] != null))
                        {
                            DP.Color = Color.FromArgb(this.Opacity, ArraySeriesInfo[IdxSimpleReadoutCurve].color);
                            NewSerie.Tag = ArraySeriesInfo[IdxSimpleReadoutCurve];
                            DP.MarkerStyle = ArraySeriesInfo[IdxSimpleReadoutCurve].markerStyle;
                            DP.MarkerSize = this.MarkerSize;
                        }
                        else
                        {
                            int IdxColor = IdxSimpleReadoutCurve % LUTProcess.GetNumberOfColors();
                            NewSerie.Color = LUTProcess.GetColor(IdxColor);
                            DP.Color = Color.FromArgb(this.Opacity, LUTProcess.GetColor(IdxColor));
                            DP.MarkerStyle = MarkerStyle.Circle;
                            DP.MarkerSize = this.MarkerSize;
                        }

                        DP.BorderWidth = this.LineWidth;

                        if (this.InputSimpleData[IdxSimpleReadoutCurve].ListTags != null)
                        {
                            if (j >= this.InputSimpleData[IdxSimpleReadoutCurve].ListTags.Count)
                            {
                                DP.Tag = this.InputSimpleData[IdxSimpleReadoutCurve];
                                NewSerie.Points.Add(DP);

                                continue;
                            }
                            DP.Tag = this.InputSimpleData[IdxSimpleReadoutCurve].ListTags[j];

                            if (DP.Tag.GetType() == typeof(string))
                            {
                                DP.ToolTip = (string)(DP.Tag);
                            }

                            if (DP.Tag.GetType() == typeof(cWellClassType))
                            {
                                DP.Color = ((cWellClassType)(DP.Tag)).ColourForDisplay;
                                DP.ToolTip = ((cWellClassType)(DP.Tag)).GetShortInfo() + Value[0];
                                //  DP.AxisLabel = ((cWellClass)(DP.Tag)).Name;
                                base.CurrentChartArea.AxisX.Interval = 1;

                                if (this.InputSimpleData.ListRowNames != null)
                                    DP.AxisLabel = this.InputSimpleData.ListRowNames[j];

                            }
                            if (DP.Tag.GetType() == typeof(cWell))
                            {
                                DP.Color = ((cWell)(DP.Tag)).GetClassColor();
                                DP.ToolTip = ((cWell)(DP.Tag)).GetShortInfo() + Value[0];

                                if ((this.InputSimpleData.ListRowNames != null) && (j < this.InputSimpleData.ListRowNames.Count))
                                    DP.AxisLabel = this.InputSimpleData.ListRowNames[j];
                            }
                            if (DP.Tag.GetType() == typeof(cDescriptorType))
                            {
                                // DP.Color = ((cWell)(DP.Tag)).GetClassColor();
                                DP.ToolTip = ((cDescriptorType)(DP.Tag)).GetShortInfo() + Value[0];
                                DP.AxisLabel = ((cDescriptorType)(DP.Tag)).GetName();
                                base.CurrentChartArea.AxisX.Interval = 1;

                            }
                            if (DP.Tag.GetType() == typeof(cPlate))
                            {
                                // DP.Color = ((cWell)(DP.Tag)).GetClassColor();
                                DP.ToolTip = ((cPlate)(DP.Tag)).GetName() + " : " + Value[0];
                                DP.AxisLabel = ((cPlate)(DP.Tag)).GetName();
                                base.CurrentChartArea.AxisX.Interval = 1;
                            }
                        }
                        NewSerie.Points.Add(DP);
                    }
                    #endregion

                    base.CurrentSeries.Add(NewSerie);
                }
            }
            #endregion

            base.Run();
            base.ChartAreas[0].AxisX.IsLogarithmic = IsLogAxis;
        }