예제 #1
0
        public FormForManualClustering(cGlobalInfo GlobalInfo)
        {
            InitializeComponent();

            this.GlobalInfo = GlobalInfo;
            WellClassSelectionPanel = new PanelForClassSelection(true, eClassType.WELL);
            WellClassSelectionPanel.SelectAll();
            WellClassSelectionPanel.Height = tabPageWellClasses.Height;
            tabPageWellClasses.Controls.Add(WellClassSelectionPanel);

            HitClassPanel = new PanelForClassSelection(false, eClassType.WELL);
            HitClassPanel.Height = panelForHitClass.Height;
            HitClassPanel.UnSelectAll();
            HitClassPanel.Select(1);
            panelForHitClass.Controls.Add(HitClassPanel);

            NonHitClassPanel = new PanelForClassSelection( false, eClassType.WELL);
            NonHitClassPanel.Height = panelForNonHitClass.Height;
            NonHitClassPanel.UnSelectAll();
            NonHitClassPanel.Select(0);
            panelForNonHitClass.Controls.Add(NonHitClassPanel);

            PlatesSelectionPanel = new PanelForPlatesSelection(true, null, true);
            PlatesSelectionPanel.Height = tabPageWellClasses.Height;
            PlatesSelectionPanel.Width = tabPageWellClasses.Width;
            TabPagePlates.Controls.Add(PlatesSelectionPanel);
        }
예제 #2
0
        public cFeedBackMessage Run()
        {
            FormForDisplay WindowToDisplay = new FormForDisplay();
            WindowToDisplay.Text = "Plates Selection";
            WindowToDisplay.FormBorderStyle = FormBorderStyle.Sizable;

            PanelForPlatesSelection PlateSelectionPanel = new PanelForPlatesSelection(this.IsCheckBoxes, ListInitialPlates, IsCheckOnlyActive);
            PlateSelectionPanel.Height = WindowToDisplay.Height - 70;
            PlateSelectionPanel.Width = WindowToDisplay.Width - 30;
               // PlateSelectionPanel.SelectAll();
            //ClassSelectionPanel.Select(0);
            //ClassSelectionPanel.Select(1);
            PlateSelectionPanel.Location = new System.Drawing.Point(5, 5);
            //PlateSelectionPanel.Width = 300;
            //PlateSelectionPanel.Height = PlateSelectionPanel.ListCheckBoxes.Count * 25;
            PlateSelectionPanel.BorderStyle = BorderStyle.Fixed3D;
            PlateSelectionPanel.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);
            // MyPanel.Controls.Add(ClassSelectionPanel);

            Button ReturnButton = new Button();
            ReturnButton.Text = "Ok";
            ReturnButton.Anchor = (System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);

            ReturnButton.DialogResult = DialogResult.OK;
            ReturnButton.Location = new System.Drawing.Point(PlateSelectionPanel.Location.X, PlateSelectionPanel.Location.Y + PlateSelectionPanel.Height );
            WindowToDisplay.Controls.Add(ReturnButton);

            WindowToDisplay.Controls.Add(PlateSelectionPanel);
            WindowToDisplay.Width = PlateSelectionPanel.Width + 28;
            WindowToDisplay.Height = PlateSelectionPanel.Height + ReturnButton.Height + 48;

            if (WindowToDisplay.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "Selection aborded !";
                return FeedBackMessage;
            }

            this.ListSelectedPlates = PlateSelectionPanel.GetListSelectedPlates();

            if (this.ListSelectedPlates.Count == 0)
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "No class selected !";
                return FeedBackMessage;
            }
            return FeedBackMessage;
        }
예제 #3
0
        private void createAveragePlateToolStripMenuItem_Click(object sender, EventArgs e)
        {

            FormForPlateAveraging FFPA = new FormForPlateAveraging();

            PanelForPlatesSelection PlatesSelectionPanel = new PanelForPlatesSelection(true, null, true);
            PlatesSelectionPanel.Height = FFPA.panelForPlateList.Height;

            FFPA.panelForPlateList.Controls.Add(PlatesSelectionPanel);
            if (FFPA.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;

            cListPlates LP = PlatesSelectionPanel.GetListSelectedPlates();


            cPlate NewPlate = new cPlate("Average Plate", cGlobalInfo.CurrentScreening);
            cWell TmpWell;

            #region QC report
            cExtendedList TmpReportForQuality = new cExtendedList("Weight");
            TmpReportForQuality.ListTags = new List<object>();
            cExtendedTable TableForQCReport = new cExtendedTable(TmpReportForQuality);
            TableForQCReport.ListRowNames = new List<string>();
            TableForQCReport.ListTags = new List<object>();
            foreach (cPlate TmpPlate in LP)
            {
                object QualityValue = TmpPlate.ListProperties.FindValueByName("Quality");
                if ((QualityValue != null) && (FFPA.checkBoxWeightedSum.Checked))
                    TableForQCReport[0].Add((double)QualityValue);
                else
                {
                    this.richTextBoxConsole.AppendText(TmpPlate.GetName() + " - Quality is NULL. Weight set to 1.\n");
                    TableForQCReport[0].Add(1);
                }

                TableForQCReport.ListRowNames.Add(TmpPlate.GetName());
                TableForQCReport.ListTags.Add(TmpPlate);
                TableForQCReport[0].ListTags.Add(TmpPlate);

            }

            cDisplayExtendedTable DET = new cDisplayExtendedTable();
            DET.SetInputData(TableForQCReport);
            DET.Title = "QC report";
            TableForQCReport.Name = "QC report";
            DET.Run();
            #endregion


            for (int X = 0; X < cGlobalInfo.CurrentScreening.Columns; X++)
                for (int Y = 0; Y < cGlobalInfo.CurrentScreening.Rows; Y++)
                {
                    cListSignature LDesc = new cListSignature();

                    for (int i = 0; i < cGlobalInfo.CurrentScreening.ListDescriptors.Count; i++)
                    {
                        double Value = 0;
                        double NormFactor = 0;

                        foreach (cPlate TmpPlate in LP)
                        {
                            double Weight = 1;
                            object QualityValue = TmpPlate.ListProperties.FindValueByName("Quality");
                            if ((QualityValue != null) && (FFPA.checkBoxWeightedSum.Checked))
                                Weight = (double)QualityValue;

                            NormFactor += Weight;
                            TmpWell = TmpPlate.GetWell(X, Y, false);
                            if (TmpWell != null)
                            {
                                Value += Weight * TmpWell.ListSignatures[i].GetValue();
                            }
                        }

                        if (NormFactor > 0)
                        {
                            cSignature Desc = new cSignature(Value / NormFactor, cGlobalInfo.CurrentScreening.ListDescriptors[i], cGlobalInfo.CurrentScreening);
                            LDesc.Add(Desc);
                        }
                    }
                    cWell NewWell = new cWell(LDesc, X + 1, Y + 1, cGlobalInfo.CurrentScreening, NewPlate);
                    NewWell.SetCpdName("Average Well [" + (X + 1) + ":" + (Y + 1) + "]");
                    NewPlate.AddWell(NewWell);

                }

            cGlobalInfo.CurrentScreening.AddPlate(NewPlate);
            cGlobalInfo.CurrentScreening.ListPlatesActive.Add(NewPlate);
            toolStripcomboBoxPlateList.Items.Add(NewPlate.GetName());
            cGlobalInfo.CurrentScreening.ListPlatesActive[cGlobalInfo.CurrentScreening.ListPlatesActive.Count - 1].UpDataMinMax();
            cGlobalInfo.CurrentScreening.CurrentDisplayPlateIdx = 0;
            cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().DisplayDistribution(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor(), true);
        }
예제 #4
0
        private void buttonApply_Click(object sender, EventArgs e)
        {
            FormForDRCDesignValidation FFDRCVal = new FormForDRCDesignValidation();

            PanelForPlatesSelection PanelForPlates = new PanelForPlatesSelection(true, null, false);
            PanelForPlates.Width = FFDRCVal.panelForPlatesName.Width;
            PanelForPlates.Height = FFDRCVal.panelForPlatesName.Height;
            FFDRCVal.panelForPlatesName.Controls.Add(PanelForPlates);

            if (!this.radioButtonConcentrationsManual.Checked) FFDRCVal.label.Text = "";

            if (FFDRCVal.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;

            this.Visible = false;

            //cScreening CurrentScreen = cGlobalInfo.CurrentScreening;
            int IdxGroup = 0;

            foreach (cPlate TmpPlate in PanelForPlates.GetListSelectedPlates())
            {
                TmpPlate.ListDRCRegions = new cListDRCRegion();

                int SizeX, SizeY;
                if (TemplateRegion.IsConcentrationHorizontal)
                {
                    SizeX = TemplateRegion.NumConcentrations;
                    SizeY = TemplateRegion.NumReplicate;
                }
                else
                {
                    SizeX = TemplateRegion.NumReplicate;
                    SizeY = TemplateRegion.NumConcentrations;
                }

                int NumRepeatX = (AssociatedPlate.ParentScreening.Columns - (TemplateRegion.PosXMin - 1)) / SizeX;
                int NumRepeatY = (AssociatedPlate.ParentScreening.Rows - (TemplateRegion.PosYMin - 1)) / SizeY;

                if (!this.radioButtonOrientationColumn.Checked)
                {
                    for (int j = 0; j < NumRepeatY; j++)
                        for (int i = 0; i < NumRepeatX; i++)
                        {
                            cDRC_Region TempRegion = new cDRC_Region(TmpPlate, (int)this.numericUpDownConcentrationNumber.Value, (int)this.numericUpDownReplication.Value, i * SizeX + (TemplateRegion.PosXMin - 1), j * SizeY + (TemplateRegion.PosYMin - 1), true);
                            TmpPlate.ListDRCRegions.AddNewRegion(TempRegion);

                            // Update the concentration from the manual entry

                            for (int Replicate = 0; Replicate < TempRegion.NumReplicate; Replicate++)
                            {
                                cWell[] TmpList = TempRegion.GetlistReplicate(Replicate);
                                for (int IdxConc = 0; IdxConc < TmpList.Length; IdxConc++)
                                {

                                    if ((this.radioButtonConcentrationsManual.Checked) && (TmpList[IdxConc] != null))
                                        TmpList[IdxConc].ListProperties.UpdateValueByName("Concentration", (double)Convert.ToDouble(dataGridViewForConcentration.Rows[IdxConc].Cells[1].Value.ToString(), CultureInfo.CreateSpecificCulture("en-US")));

                                    if ((FFDRCVal.checkBoxUpdateGroupID.Checked) && (TmpList[IdxConc] != null))
                                        TmpList[IdxConc].ListProperties.UpdateValueByName("Group", (int)IdxGroup);

                                }
                            }

                            IdxGroup++;

                        }
                }
                else
                {
                    for (int j = 0; j < NumRepeatY; j++)
                        for (int i = 0; i < NumRepeatX; i++)
                        {
                            cDRC_Region TempRegion = new cDRC_Region(TmpPlate, (int)this.numericUpDownConcentrationNumber.Value, (int)this.numericUpDownReplication.Value, i * SizeX + (TemplateRegion.PosXMin - 1), j * SizeY + (TemplateRegion.PosYMin - 1), false);
                            TmpPlate.ListDRCRegions.AddNewRegion(TempRegion);

                            // Update the concentration from the manual entry
                            //   if (this.radioButtonConcentrationsManual.Checked)
                            {
                                for (int Replicate = 0; Replicate < TempRegion.NumReplicate; Replicate++)
                                {
                                    cWell[] TmpList = TempRegion.GetlistReplicate(Replicate);
                                    for (int IdxConc = 0; IdxConc < TmpList.Length; IdxConc++)
                                    {
                                        if ((this.radioButtonConcentrationsManual.Checked) && (TmpList[IdxConc] != null))
                                            TmpList[IdxConc].ListProperties.UpdateValueByName("Concentration", Convert.ToDouble(dataGridViewForConcentration.Rows[IdxConc].Cells[1].Value.ToString()));

                                        if ((FFDRCVal.checkBoxUpdateGroupID.Checked) && (TmpList[IdxConc] != null))
                                            TmpList[IdxConc].ListProperties.UpdateValueByName("Group", (int)IdxGroup);
                                    }
                                }
                            }
                            IdxGroup++;
                        }
                }
            }

            //cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().Refresh3D(cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx);
            cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().DisplayDistribution(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor(), false);
        }
예제 #5
0
        public void PerformClassification()
        {
            FormForSingleCellClassifOptions FFSC = new FormForSingleCellClassifOptions();
            //cGUI_ListClasses GLC = new cGUI_ListClasses();
            //GLC.ClassType = eClassType.PHENOTYPE;
            //GLC.IsCheckBoxes = true;
            //GLC.IsSelectAll = true;
            //GLC.Run(GlobalInfo);

            PanelForClassSelection PhenotypeSelectionPanel = new PanelForClassSelection( true, eClassType.PHENOTYPE);
            PhenotypeSelectionPanel.Height = FFSC.panelPhenoToBeClassified.Height;
            FFSC.panelPhenoToBeClassified.Controls.Add(PhenotypeSelectionPanel);

            PanelForClassSelection WellClassSelectionPanel = new PanelForClassSelection( true, eClassType.WELL);
            WellClassSelectionPanel.Height = FFSC.panelWellToBeClassified.Height;
            FFSC.panelWellToBeClassified.Controls.Add(WellClassSelectionPanel);

            PanelForPlatesSelection PlatesSelectionPanel = new PanelForPlatesSelection( true, null, true);
            PlatesSelectionPanel.Height = FFSC.panelWellToBeClassified.Height;
            FFSC.tabPagePlates.Controls.Add(PlatesSelectionPanel);

            if (FFSC.ShowDialog() != DialogResult.OK) return;

            // ----------------------- Classification ------------------------------
            int DescrCount = cGlobalInfo.CurrentScreening.ListDescriptors.Count;

            this.UpDateNumberOfCluster();
            if (NumberOfClusters == 0)
            {
                System.Windows.Forms.MessageBox.Show("Number of cluster is null", "Error !", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }

            //if (FFSC.checkBoxGenerationRatio.Checked)
            //{
            //    // first we update the descriptor
            //    for (int i = 0; i < this.NumberOfClusters; i++)
            //        GlobalInfo.CurrentScreening.ListDescriptors.AddNew(new cDescriptorType("Ratio_" + GlobalInfo.ListCellularPhenotypes[i].Name, true, 1, GlobalInfo));
            //}

            FormForProgress ProgressWindow = new FormForProgress();
            ProgressWindow.Show();

            int IdxProgress = 0;
            int MaxProgress = 0;

            #region Confusion Matrix init
            cListExtendedTable LT = new cListExtendedTable();
            cExtendedTable ConfusionMatrix = new cExtendedTable(cGlobalInfo.ListCellularPhenotypes.Count, cGlobalInfo.ListCellularPhenotypes.Count, 0);
            ConfusionMatrix.Name = "Confusion Matrix (global)";
            ConfusionMatrix.ListRowNames = new List<string>();
            for (int i = 0; i < cGlobalInfo.ListCellularPhenotypes.Count; i++)
            {
                ConfusionMatrix.ListRowNames.Add(cGlobalInfo.ListCellularPhenotypes[i].Name + "*");
                ConfusionMatrix[i].Name = cGlobalInfo.ListCellularPhenotypes[i].Name;
            }
            LT.Add(ConfusionMatrix);
            for (int i = 0; i < cGlobalInfo.ListWellClasses.Count; i++)
            {
                cExtendedTable ConfusionMatrixTmp = new cExtendedTable(cGlobalInfo.ListCellularPhenotypes.Count, cGlobalInfo.ListCellularPhenotypes.Count, 0);
                ConfusionMatrixTmp.Name = "Confusion Matrix - " + cGlobalInfo.ListWellClasses[i].Name;
                ConfusionMatrixTmp.ListRowNames = new List<string>();
                for (int j = 0; j < cGlobalInfo.ListCellularPhenotypes.Count; j++)
                {
                    ConfusionMatrixTmp.ListRowNames.Add(cGlobalInfo.ListCellularPhenotypes[j].Name + "*");
                    ConfusionMatrixTmp[j].Name =cGlobalInfo.ListCellularPhenotypes[j].Name;
                }
                LT.Add(ConfusionMatrixTmp);
            }
            #endregion

            cListPlates LP = PlatesSelectionPanel.GetListSelectedPlates();

            foreach (cPlate CurrentPlateToProcess in LP /*GlobalInfo.CurrentScreening.ListPlatesAvailable*/)
                MaxProgress += (int)CurrentPlateToProcess.ListActiveWells.Count;
            ProgressWindow.progressBar.Maximum = MaxProgress;

            FastVector attVals = new FastVector();
            for (int i = 0; i < this.NumberOfClusters; i++)
                attVals.addElement(i.ToString());

            cPlate CurrentDispPlate = cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate();

            foreach (cPlate CurrentPlateToProcess in LP/* GlobalInfo.CurrentScreening.ListPlatesAvailable*/)
            {
                foreach (cWell TmpWell in CurrentPlateToProcess.ListActiveWells)
                {
                    ProgressWindow.progressBar.Value = IdxProgress++;

                    if (TmpWell.GetCurrentClassIdx() == -1) continue;
                    if (WellClassSelectionPanel.ListCheckBoxes[TmpWell.GetCurrentClassIdx()].Checked == false) continue;

                    DataTable FinalDataTable = new DataTable();
                    TmpWell.AssociatedPlate.DBConnection = new cDBConnection(TmpWell.AssociatedPlate, TmpWell.SQLTableName);
                    TmpWell.AssociatedPlate.DBConnection.AddWellToDataTable(TmpWell, FinalDataTable, this.GlobalInfo);
                    cListSingleBiologicalObjects LSBO = TmpWell.AssociatedPlate.DBConnection.GetBiologicalPhenotypes(TmpWell);
                    //TmpWell.AssociatedPlate.DBConnection.AddWellToDataTable(TmpWell, FinalDataTable, checkBoxIncludeWellClassAsDesc.Checked, GlobalInfo);
                    Instances ListInstancesTOClassify = this.CreateInstancesWithoutClass(FinalDataTable);

                    ListInstancesTOClassify.insertAttributeAt(new weka.core.Attribute("Class", attVals), ListInstancesTOClassify.numAttributes());
                    ListInstancesTOClassify.setClassIndex(ListInstancesTOClassify.numAttributes() - 1);

                    cExtendedList ListNewClasses = new cExtendedList();

                    int NumInstances = ListInstancesTOClassify.numInstances();
                    for (int i = 0; i < NumInstances; i++)
                    {
                        // ClassId contains the new class
                        Instance CurrentInst = ListInstancesTOClassify.instance(i);

                        double classId = this.CurrentClassifier.classifyInstance(CurrentInst);
                        double[] ClassConfidence = this.CurrentClassifier.distributionForInstance(CurrentInst);
                        LSBO[i].ClassificationConfidence = ClassConfidence[(int)classId];
                        ListNewClasses.Add(classId);

                        if (CurrentPlateToProcess == CurrentDispPlate)
                        {
                            LT[0][LSBO[i].GetAssociatedPhenotype().Idx][(int)classId]++;

                            if (TmpWell.GetCurrentClassIdx() >= 0)
                                LT[TmpWell.GetCurrentClassIdx() + 1][LSBO[i].GetAssociatedPhenotype().Idx][(int)classId]++;
                        }
                    }

                    ProgressWindow.richTextBoxForComment.AppendText(TmpWell.GetShortInfo().Remove(TmpWell.GetShortInfo().Length - 2) + " : " + NumInstances + " objects\n");
                    ProgressWindow.Refresh();
                    // ------------- update class within the database -----------------------------
                    TmpWell.AssociatedPlate.DBConnection.ChangePhenotypeClass(TmpWell, ListNewClasses);

                    //if (FFSC.checkBoxGenerationRatio.Checked)
                    //{
                    //    List<double[]> Histo = ListNewClasses.CreateHistogram(0, ListInstancesTOClassify.numClasses(), ListInstancesTOClassify.numClasses());
                    //    cListSignature LDesc = new cListSignature();

                    //    for (int IdxHisto = 0; IdxHisto < Histo[1].Length - 1; IdxHisto++)
                    //    {
                    //        Histo[1][IdxHisto] = (100.0 * Histo[1][IdxHisto]) / (double)ListInstancesTOClassify.numInstances();

                    //        cSignature NewDesc = new cSignature(Histo[1][IdxHisto], GlobalInfo.CurrentScreening.ListDescriptors[IdxHisto + DescrCount], GlobalInfo.CurrentScreening);
                    //        LDesc.Add(NewDesc);
                    //    }
                    //    TmpWell.AddSignatures(LDesc);
                    //}

                    TmpWell.AssociatedPlate.DBConnection.CloseConnection();
                }
            }

            #region Display Report
            cDesignerSplitter DS = new cDesignerSplitter();
            DS.Orientation = Orientation.Vertical;

            cViewertext VTEXT = new cViewertext();
            VTEXT.SetInputData(ProgressWindow.richTextBoxForComment.Text);
            VTEXT.Run();

            cDesignerTab DT = new cDesignerTab();
            DT.IsMultiline = false;

            foreach (var item in LT)
            {
                cViewerTable VT = new cViewerTable();
                VT.SetInputData(item);
                VT.DigitNumber = 0;
                VT.Run();
                DT.SetInputData(VT.GetOutPut());
            }

            DT.Run();

            cExtendedControl TextEC = DT.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);

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

            DS.Run();

            ProgressWindow.Close();

            cDisplayToWindow CDT = new cDisplayToWindow();
            CDT.SetInputData(DS.GetOutPut());
            CDT.IsModal = true;
            CDT.Title = "Phenotypic Classificaton Report";
            CDT.Run();
            CDT.Display();

            #endregion

            //if (IsKeepOriginalDesc == System.Windows.Forms.DialogResult.No)
            //{
            //    // int DescNumToRemove = GlobalInfo.CurrentScreen.ListDescriptors.Count -
            //    for (int IdxDesc = 0; IdxDesc < DescrCount; IdxDesc++)
            //        GlobalInfo.CurrentScreening.ListDescriptors.RemoveDesc(GlobalInfo.CurrentScreening.ListDescriptors[0], GlobalInfo.CurrentScreening);
            //}

            cGlobalInfo.CurrentScreening.ListDescriptors.UpDateDisplay();
            cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate();

            for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++)
                cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax();

            //WindowFormForCellbyCellClassif.Close();
            //WindowClusteringInfo.Close();
        }