Exemplo n.º 1
0
        private void statisticsToolStripMenuItem1_Click_1(object sender, EventArgs e)
        {
            string NameFunction = "";

            if (_StatCVItem.Checked)
                NameFunction = "Coeff. of Variation";
            else if (_StatMeanItem.Checked)
                NameFunction = "Mean";
            else if (_StatSumItem.Checked)
                NameFunction = "Sum";
            else if (_StatJarqueBeraItem.Checked)
                NameFunction = "Jarque-Bera";

            cGUI_ListClasses GUI_ListClasses = new cGUI_ListClasses();

            GUI_ListClasses.IsCheckBoxes = true;
            GUI_ListClasses.IsSelectAll = true;

            if (GUI_ListClasses.Run().IsSucceed == false) return;
            cExtendedTable ListClassSelected = new cExtendedTable(GUI_ListClasses.GetOutPut());// GetOutPut();


            int IdxClass = -1;
            for (int IdxC = 0; IdxC < ListClassSelected[0].Count; IdxC++)
            {
                if (ListClassSelected[0][IdxC] == 1) IdxClass = IdxC;
            }

            #region single plate and plate by plate

            cDesignerTab DT = new cDesignerTab();
            if ((ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked) || (ProcessModeplateByPlateToolStripMenuItem.Checked)/*||(ProcessModeEntireScreeningToolStripMenuItem.Checked)*/)
            {
                List<cPlate> ListPlatesToProcess = new List<cPlate>();
                if ((ProcessModeplateByPlateToolStripMenuItem.Checked)/*||(ProcessModeEntireScreeningToolStripMenuItem.Checked)*/)
                {
                    foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesActive)
                        ListPlatesToProcess.Add(TmpPlate);
                }
                else
                    ListPlatesToProcess.Add(cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate());

                foreach (cPlate TmpPlate in ListPlatesToProcess)
                {
                    cListWells ListWellsToProcess1 = new cListWells(null);

                    foreach (cWell item in TmpPlate.ListActiveWells)
                    {
                        if (item.GetCurrentClassIdx() != -1)
                        {
                            if (ListClassSelected[0][item.GetCurrentClassIdx()] == 1)
                                ListWellsToProcess1.Add(item);
                        }
                    }

                    cExtendedTable NewTable1 = new cExtendedTable(ListWellsToProcess1, true);

                    if ((NewTable1.Count == 0) || (NewTable1[0].Count < 3))
                    {
                        if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)
                        {
                            MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        else
                            continue;
                    }

                    cExtendedList ListValues = new cExtendedList();
                    List<cDescriptorType> ListDescs = new List<cDescriptorType>();
                    List<string> ListNames = new List<string>();
                    int RealIdx = 0;
                    for (int IDxDesc = 0; IDxDesc < cGlobalInfo.CurrentScreening.ListDescriptors.Count; IDxDesc++)
                    {
                        if (!cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc].IsActive()) continue;

                        cExtendedTable TableForValues = new cExtendedTable();

                        TableForValues.Add(NewTable1[RealIdx]);

                        RealIdx++;

                        if (_StatJarqueBeraItem.Checked)
                        {
                            cNormalityJarqueBera JB = new cNormalityJarqueBera();
                            JB.SetInputData(TableForValues);
                            JB.Run();
                            ListValues.Add(JB.GetOutPut()[0][0]);
                        }
                        else
                        {
                            cStatistics CS = new cStatistics();
                            CS.UnselectAll();

                            if (_StatCVItem.Checked)
                                CS.IsCV = true;
                            else if (_StatMeanItem.Checked)
                                CS.IsMean = true;
                            else if (_StatSumItem.Checked)
                                CS.IsSum = true;

                            CS.SetInputData(TableForValues);
                            CS.Run();
                            ListValues.Add(CS.GetOutPut()[0][0]);
                        }

                        ListDescs.Add(cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc]);

                    }

                    cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListValues));
                    ET[0].ListTags = new List<object>();
                    ET[0].ListTags.AddRange(ListDescs);
                    ET.Name = TmpPlate.GetName() + "\n" + NameFunction + " - " + cGlobalInfo.ListWellClasses[IdxClass].Name + " (" + NewTable1[0].Count + " wells)";
                    ET[0].Name = ET.Name;

                    cSort S = new cSort();
                    S.SetInputData(ET);
                    S.ColumnIndexForSorting = 0;
                    S.Run();

                    //ZFactorList.Sort(delegate(cSimpleSignature p1, cSimpleSignature p2) { return p1.AverageValue.CompareTo(p2.AverageValue); });
                    cViewerGraph1D VG1 = new cViewerGraph1D();
                    VG1.SetInputData(S.GetOutPut());

                    VG1.Chart.LabelAxisY = NameFunction;
                    VG1.Chart.LabelAxisX = "Descriptor";
                    VG1.Chart.IsZoomableX = true;
                    VG1.Chart.IsBar = true;
                    VG1.Chart.IsBorder = true;
                    VG1.Chart.IsDisplayValues = true;
                    VG1.Chart.IsShadow = true;
                    VG1.Chart.MarkerSize = 4;
                    VG1.Title = TmpPlate.GetName();
                    VG1.Run();

                    DT.SetInputData(VG1.GetOutPut());
                }
                DT.Run();

                cDisplayToWindow CDW = new cDisplayToWindow();
                CDW.SetInputData(DT.GetOutPut());//VG1.GetOutPut());


                if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)
                    CDW.Title = NameFunction + " - " + ListPlatesToProcess[0].GetName();
                else
                    CDW.Title = NameFunction + " - " + ListPlatesToProcess.Count + " plates";

                CDW.Run();
                CDW.Display();
            }
            #endregion
            #region entire screening
            else if (ProcessModeEntireScreeningToolStripMenuItem.Checked)
            {
                List<cPlate> ListPlatesToProcess = new List<cPlate>();
                foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesActive)
                    ListPlatesToProcess.Add(TmpPlate);

                cExtendedList ListZ = new cExtendedList();
                List<cPlate> ListPlatesForZFactor = new List<cPlate>();
                foreach (cPlate TmpPlate in ListPlatesToProcess)
                {
                    cListWells ListWellsToProcess1 = new cListWells(null);

                    foreach (cWell item in TmpPlate.ListActiveWells)
                    {
                        if (item.GetCurrentClassIdx() != -1)
                        {
                            if (ListClassSelected[0][item.GetCurrentClassIdx()] == 1)
                                ListWellsToProcess1.Add(item);
                        }
                    }


                    cExtendedTable NewTable1 = new cExtendedTable(ListWellsToProcess1, cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorIndex(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor()));


                    if ((NewTable1.Count == 0) || (NewTable1[0].Count < 3))
                    {
                        if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)
                        {
                            MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        else
                            continue;
                    }


                    if (_StatJarqueBeraItem.Checked)
                    {
                        cNormalityJarqueBera JB = new cNormalityJarqueBera();
                        JB.SetInputData(NewTable1);
                        JB.Run();
                        ListZ.Add(JB.GetOutPut()[0][0]);
                    }
                    else
                    {
                        cStatistics CS = new cStatistics();
                        CS.UnselectAll();

                        if (_StatCVItem.Checked)
                            CS.IsCV = true;
                        else if (_StatMeanItem.Checked)
                            CS.IsMean = true;
                        else if (_StatSumItem.Checked)
                            CS.IsSum = true;

                        CS.SetInputData(NewTable1);
                        CS.Run();
                        ListZ.Add(CS.GetOutPut()[0][0]);
                    }
                    ListPlatesForZFactor.Add(TmpPlate);
                }
            #endregion

                cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListZ));
                ET[0].ListTags = new List<object>();
                ET[0].ListTags.AddRange(ListPlatesForZFactor);
                ET.Name = NameFunction + " - " + cGlobalInfo.CurrentScreening.ListDescriptors[cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx].GetName();// +" - " +cGlobalInfo.ListWellClasses[IdxClassNeg].Name + " (" + NewTable1[0].Count + " wells) vs. " +cGlobalInfo.ListWellClasses[IdxClassPos].Name + " (" + NewTable2[0].Count + " wells)";
                ET[0].Name = ET.Name;

                cViewerGraph1D VG1 = new cViewerGraph1D();
                VG1.SetInputData(ET);

                VG1.Chart.LabelAxisY = NameFunction;
                VG1.Chart.LabelAxisX = "Plate";
                VG1.Chart.IsZoomableX = true;
                VG1.Chart.IsBar = true;
                VG1.Chart.IsBorder = true;
                VG1.Chart.IsDisplayValues = true;
                VG1.Chart.IsShadow = true;
                VG1.Chart.MarkerSize = 4;
                VG1.Title = cGlobalInfo.CurrentScreening.ListDescriptors[cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx].GetName();
                VG1.Run();

                cDisplayToWindow CDW = new cDisplayToWindow();
                CDW.SetInputData(VG1.GetOutPut());
                CDW.Title = NameFunction + " - " + ListPlatesToProcess.Count + " plates";
                CDW.Run();
                CDW.Display();
            }
        }
        void Process()
        {
            cExtendedTable NewTable1 = null;
            string DescName = "";

            if (this.InputWells != null)
            {
                NewTable1 = new cExtendedTable(this.InputWells, cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx);
                DescName = cGlobalInfo.CurrentScreening.ListDescriptors[cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx].GetName();
            }
            else if (this.InputTable != null)
            {
                NewTable1 = this.InputTable;
            }

            cDesignerTab NormalityTestTabs = new cDesignerTab();

            cNormalityAndersonDarling NAD = new cNormalityAndersonDarling();
            NAD.SetInputData(NewTable1);
            NAD.Run();

            cExtendedTable TNAD = NAD.GetOutPut();

            TNAD[0].Name = "Anderson-Darling Test";
            cViewerTable VTNAD = new cViewerTable();
            VTNAD.SetInputData(TNAD);
            VTNAD.Sender = NAD;
            VTNAD.IsDisplayInfo = true;
            VTNAD.DigitNumber = -1;
            VTNAD.Run();

            cExtendedControl AndersonCtrl = VTNAD.GetOutPut();
            AndersonCtrl.Title = TNAD[0].Name;

            cNormalityJarqueBera NJB = new cNormalityJarqueBera();
            NJB.SetInputData(NewTable1);
            NJB.Run();

            cExtendedTable TmpTest = NJB.GetOutPut();
            TmpTest[0].Name = "Jarque-Bera Test";
            cViewerTable VT = new cViewerTable();
            VT.SetInputData(TmpTest);
            VT.Sender = NJB;
            VT.IsDisplayInfo = true;
            VT.DigitNumber = -1;
            VT.Run();

            cExtendedControl JarqueCtrl = VT.GetOutPut();
            JarqueCtrl.Title = TmpTest[0].Name;

            NormalityTestTabs.SetInputData(JarqueCtrl);
            NormalityTestTabs.SetInputData(AndersonCtrl);

            NormalityTestTabs.Run();

            //cExtendedControl ControlForTab = CADP.GetOutPut();
            //NormalityTestTabs.Title = TmpPlate.Name;

            cDesignerSplitter MainDS = new cDesignerSplitter();
            MainDS.Orientation = Orientation.Vertical;

            cDesignerSplitter DS = new cDesignerSplitter();
            DS.Orientation = Orientation.Horizontal;

            cNormalProbabilityPlot NPP = new cNormalProbabilityPlot();
            NPP.SetInputData(NewTable1);
            NPP.IdxColumnToProcess = 0;
            NPP.Run();

            cViewer2DScatterPoint V2DS = new cViewer2DScatterPoint();
            cExtendedTable TableToDisp = NPP.GetOutPut();
            TableToDisp.Name = "";
            V2DS.Chart.IsSelectable = true;
            V2DS.Chart.IsBorder = false;
            V2DS.Chart.IsShadow = false;
            V2DS.Chart.IsXGrid = true;
            V2DS.Chart.IsYGrid = true;
            V2DS.Chart.IsDisplayTrendLine = true;
            V2DS.SetInputData(TableToDisp);
            V2DS.Run();
            V2DS.Chart.CurrentTitle.Text = "Normal Probability Plot\n" + DescName + " - " + NewTable1[0].Count + " points";

            DS.SetInputData(V2DS.GetOutPut());

            cViewerStackedHistogram VSH = new cViewerStackedHistogram();

            cExtendedTable NewTable = null;

            if (this.InputWells != null)
            {
                NewTable = this.InputWells.GetAverageDescriptorValues(cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx);
            }
            else
            {
                NewTable = this.InputTable;
            }
            NewTable.Name = DescName + " - Stacked Histogram - " + NewTable1[0].Count + " values";

            VSH.SetInputData(NewTable);
            VSH.Chart.LabelAxisX = DescName;
            VSH.Run();

            DS.SetInputData(VSH.GetOutPut());
            DS.Run();

            cExtendedControl TextEC = NormalityTestTabs.GetOutPut();
            TextEC.Width = 0;
            TextEC.Height = 0;

            TextEC.Anchor = (System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom
                    | System.Windows.Forms.AnchorStyles.Left
                    | System.Windows.Forms.AnchorStyles.Right);

            MainDS.SetInputData(TextEC);
            MainDS.SetInputData(DS.GetOutPut());

            MainDS.Run();
            this.Output = MainDS.GetOutPut();
        }