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); }
public FormFor3DDataDisplay(bool IsFullScreen, cScreening CompleteScreening) { this.CompleteScreening = CompleteScreening; InitializeComponent(); // toolTip1.SetToolTip(comboBoxDescriptorX,comboBoxDescriptorX.Text+"aaaaaa"); //comboBoxDescriptorX.MouseHover += new System.EventHandler(this.comboBoxDescriptorX_MouseHover); //this.comboBoxDescriptorX.tool // Set up the ToolTip text for the Button and Checkbox. // toolTip1.SetToolTip(, "Unsupervised feature selection.\nThese approaches use all the active wells as data for the dimensionality reduction."); this.IsFullScreen = IsFullScreen; // WindowFormFor3DVizuOptions.Parent = this; for (int i = 0; i < (int)CompleteScreening.ListDescriptors.Count; i++) { ListScales.Add(1); } ClassSelectionPanel = new PanelForClassSelection(true, Classes.Base_Classes.GUI.eClassType.WELL); ClassSelectionPanel.Height = panelForClasses.Height; ClassSelectionPanel.SelectAll(); panelForClasses.Controls.Add(ClassSelectionPanel); foreach (var CurrentCheckBox in ClassSelectionPanel.ListCheckBoxes) { CurrentCheckBox.CheckedChanged += new EventHandler(CurrentCheckBox_CheckedChanged); } ToolTipForX.AutoPopDelay = ToolTipForY.AutoPopDelay = ToolTipForZ.AutoPopDelay = 5000; ToolTipForX.InitialDelay = ToolTipForY.InitialDelay = ToolTipForZ.InitialDelay = 500; ToolTipForX.ReshowDelay = ToolTipForY.ReshowDelay = ToolTipForZ.ReshowDelay = 500; ToolTipForX.ShowAlways = ToolTipForY.ShowAlways = ToolTipForZ.ShowAlways = true; ToolTipForX.SetToolTip(comboBoxDescriptorX, comboBoxDescriptorX.Text); this.WindowFormFor3DVizuOptions = new FormFor3DVizuOptions(this); this.LightIntensity = (double)this.WindowFormFor3DVizuOptions.numericUpDownLightIntensity.Value; this.LightAmbient = (double)this.WindowFormFor3DVizuOptions.numericUpDownLightAmbient.Value; this.LightDiffuse = (double)this.WindowFormFor3DVizuOptions.numericUpDownLightIntensity.Value; this.LightSpecular = (double)this.WindowFormFor3DVizuOptions.numericUpDownLightIntensity.Value; SphereSource = vtkSphereSource.New(); }
private void mahalanobisDistanceToolStripMenuItem_Click(object sender, EventArgs e) { FormForMahalanobisDistance MainWindow = new FormForMahalanobisDistance(); PanelForClassSelection ClassSelectionPanel = new PanelForClassSelection(true, eClassType.WELL); ClassSelectionPanel.Height = MainWindow.panelForSourceCloud.Height; MainWindow.panelForSourceCloud.Controls.Add(ClassSelectionPanel); PanelForClassSelection HitClassSelectionPanel = new PanelForClassSelection(false, eClassType.WELL); HitClassSelectionPanel.Height = MainWindow.panelHitClass.Height; HitClassSelectionPanel.ListRadioButtons[1].Checked = true; MainWindow.panelHitClass.Controls.Add(HitClassSelectionPanel); if (MainWindow.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; cExtendedList ListClassSelected = new cExtendedList(); for (int i = 0; i < ClassSelectionPanel.ListCheckBoxes.Count; i++) if (ClassSelectionPanel.ListCheckBoxes[i].Checked) ListClassSelected.Add(1); else ListClassSelected.Add(0); int IdxClassForOutliers = 0; for (int i = 0; i < HitClassSelectionPanel.ListRadioButtons.Count; i++) if (HitClassSelectionPanel.ListRadioButtons[i].Checked) { IdxClassForOutliers = i; break; } if (ListClassSelected.Sum() < 1) { MessageBox.Show("At least one classe has to be selected.", "Error !", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // start by computing the inversed covariance matrix //if (checkedListBoxActiveDescriptors.CheckedItems.Count <= 1) //{ // MessageBox.Show("At least two descriptors have to be selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // return; //} cCovarianceMatrix CM = new cCovarianceMatrix(); cExtendedTable NewTable = null; if (this.ProcessModeplateByPlateToolStripMenuItem.Checked) { //foreach (cPlate TmpPlate in CompleteScreening.ListPlatesActive) //{ // cListWells ListWellsToProcess = new cListWells(null); // foreach (cWell item in TmpPlate.ListActiveWells) // if ((item.GetClassIdx() != -1) && (ListClassSelected[item.GetClassIdx()] == 1)) ListWellsToProcess.Add(item); // cExtendedTable NewTable = new cExtendedTable(ListWellsToProcess, true); // CM.SetInputData(NewTable); //} } else if (this.ProcessModeEntireScreeningToolStripMenuItem.Checked) { cListWells ListWellsToProcess = new cListWells(null); foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesActive) foreach (cWell item in TmpPlate.ListActiveWells) if ((item.GetCurrentClassIdx() != -1) && (ListClassSelected[item.GetCurrentClassIdx()] == 1)) ListWellsToProcess.Add(item); NewTable = new cExtendedTable(ListWellsToProcess, true); // cTwoSampleFTest CM = new cTwoSampleFTest(); CM.SetInputData(NewTable); } else { cListWells ListWellsToProcess = new cListWells(null); foreach (cWell item in cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().ListActiveWells) if ((item.GetCurrentClassIdx() != -1) && (ListClassSelected[item.GetCurrentClassIdx()] == 1)) ListWellsToProcess.Add(item); NewTable = new cExtendedTable(ListWellsToProcess, true); // cTwoSampleFTest CM = new cTwoSampleFTest(); CM.SetInputData(NewTable); } CM.Run(); cInverse cI = new cInverse(); cI.SetInputData(CM.GetOutPut()); cI.Run(); // get the cloud center cStatistics cstat = new cStatistics(); cstat.UnselectAll(); cstat.IsMean = true; cstat.SetInputData(NewTable); cstat.Run(); if (cstat.GetOutPut() == null) return; cExtendedList ListMeans = cstat.GetOutPut().GetRow(0); cDescriptorType MahalanobisType = new cDescriptorType("Mahalanobis Distance", true, 1); #region Compute the Threshold int DegreeOfFreedom = cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptors().Count; cExtendedTable T = new cExtendedTable(); T.Add(new cExtendedList()); T[0].Add((double)MainWindow.numericUpDownPValue.Value); cFunctions F = new cFunctions(); F.SetInputData(T); F.IsInverse = true; F.DegreeOfFreedom = DegreeOfFreedom; F.Run(); double ThresholdForMahalanobis = Math.Sqrt(F.GetOutPut()[1][0]); #endregion int IdxClassForNonOutliers = 1; foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable) { for (int Col = 0; Col < cGlobalInfo.CurrentScreening.Columns; Col++) for (int Row = 0; Row < cGlobalInfo.CurrentScreening.Rows; Row++) { cWell TmpWell = TmpPlate.GetWell(Col, Row, false); if (TmpWell == null) continue; double ValueDistance = TmpWell.GetAverageValuesList(true)[0].Dist_Mahalanobis(ListMeans, cI.GetOutPut()); if (ValueDistance > ThresholdForMahalanobis || double.IsNaN(ValueDistance) ) // that's an outlier { TmpWell.SetClass(IdxClassForOutliers); } else { TmpWell.SetClass(IdxClassForNonOutliers); } if (MainWindow.checkBoxDistAsDesc.Checked) { cListSignature LDesc = new cListSignature(); cSignature NewDesc = new cSignature(ValueDistance, MahalanobisType, cGlobalInfo.CurrentScreening); LDesc.Add(NewDesc); TmpWell.AddSignatures(LDesc); } } } if (MainWindow.checkBoxDistAsDesc.Checked) { cGlobalInfo.CurrentScreening.ListDescriptors.AddNew(MahalanobisType); } cGlobalInfo.CurrentScreening.ListDescriptors.UpDateDisplay(); cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate(); for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++) cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax(); }
public cFeedBackMessage Run() { //if (GlobalInfo == null) //{ // base.FeedBackMessage.IsSucceed = false; // return base.FeedBackMessage; //} FormForDisplay WindowToDisplay = new FormForDisplay(); WindowToDisplay.Text = "Class Selection"; WindowToDisplay.FormBorderStyle = FormBorderStyle.FixedSingle; PanelForClassSelection ClassSelectionPanel = new PanelForClassSelection(this.IsCheckBoxes, this.ClassType); //ClassSelectionPanel.Height = WindowToDisplay.Height; if ((IsSelectAll) && (this.IsCheckBoxes)) { ClassSelectionPanel.SelectAll(); } else { ClassSelectionPanel.UnSelectAll(); ClassSelectionPanel.Select(0); ClassSelectionPanel.Select(1); } ClassSelectionPanel.Location = new System.Drawing.Point(10, 10); ClassSelectionPanel.Width = 150; ClassSelectionPanel.Height = ClassSelectionPanel.ListCheckBoxes.Count * 25; ClassSelectionPanel.BorderStyle = BorderStyle.Fixed3D; // MyPanel.Controls.Add(ClassSelectionPanel); Button ReturnButton = new Button(); ReturnButton.Text = "Ok"; ReturnButton.DialogResult = DialogResult.OK; ReturnButton.Location = new System.Drawing.Point(ClassSelectionPanel.Location.X, ClassSelectionPanel.Location.Y + ClassSelectionPanel.Height + 5); WindowToDisplay.Controls.Add(ReturnButton); WindowToDisplay.Controls.Add(ClassSelectionPanel); WindowToDisplay.Width = ClassSelectionPanel.Width + 28; WindowToDisplay.Height = ClassSelectionPanel.Height + ReturnButton.Height + 48; if (WindowToDisplay.ShowDialog() != System.Windows.Forms.DialogResult.OK) { FeedBackMessage.IsSucceed = false; FeedBackMessage.Message = "Selection aborded !"; return FeedBackMessage; } List<bool> ListBool = ClassSelectionPanel.GetListSelectedClass(); int NumSelected = 0; this.ListSelectedClass = new cExtendedList(); foreach (var item in ListBool) { if (item) { this.ListSelectedClass.Add(1); NumSelected++; } else this.ListSelectedClass.Add(0); } if (NumSelected == 0) { FeedBackMessage.IsSucceed = false; FeedBackMessage.Message = "No class selected !"; return FeedBackMessage; } return FeedBackMessage; }
public cFeedBackMessage Run() { FormForDisplay WindowToDisplay = new FormForDisplay(); WindowToDisplay.Text = "Class Selection"; WindowToDisplay.FormBorderStyle = FormBorderStyle.FixedSingle; PanelForClassSelection ClassSelectionPanel = new PanelForClassSelection( this.IsCheckBoxes, this.ClassType); //ClassSelectionPanel.Height = WindowToDisplay.Height; if (this.IsSelectAll && this.IsCheckBoxes) { ClassSelectionPanel.SelectAll(); } else { ClassSelectionPanel.UnSelectAll(); ClassSelectionPanel.Select(0); ClassSelectionPanel.Select(1); } ClassSelectionPanel.Location = new System.Drawing.Point(10, 10); ClassSelectionPanel.Width = 150; if(IsCheckBoxes) ClassSelectionPanel.Height = ClassSelectionPanel.ListCheckBoxes.Count*25; else ClassSelectionPanel.Height = ClassSelectionPanel.ListRadioButtons.Count * 25; ClassSelectionPanel.BorderStyle = BorderStyle.Fixed3D; // MyPanel.Controls.Add(ClassSelectionPanel); Button ReturnButton = new Button(); ReturnButton.Text = "Ok"; ReturnButton.DialogResult = DialogResult.OK; ReturnButton.Location = new System.Drawing.Point(ClassSelectionPanel.Location.X, ClassSelectionPanel.Location.Y + ClassSelectionPanel.Height + 5); WindowToDisplay.Controls.Add(ReturnButton); WindowToDisplay.Controls.Add(ClassSelectionPanel); WindowToDisplay.Width = ClassSelectionPanel.Width + 28; WindowToDisplay.Height = ClassSelectionPanel.Height + ReturnButton.Height+ 48; if (WindowToDisplay.ShowDialog() != System.Windows.Forms.DialogResult.OK) { FeedBackMessage.IsSucceed = false; FeedBackMessage.Message = "Selection aborded !"; return FeedBackMessage; } List<bool> ListBool = ClassSelectionPanel.GetListSelectedClass(); int NumSelected = 0; this.ListSelectedClass = new cExtendedTable(); this.ListSelectedClass.Name = "List Class Selected"; this.ListSelectedClass.Add(new cExtendedList()); this.ListSelectedClass[0].ListTags = new List<object>(); int Idx = 0; foreach (var item in ListBool) { if (item) { this.ListSelectedClass[0].Add(1); if(this.ClassType== eClassType.WELL) this.ListSelectedClass[0].ListTags.Add(cGlobalInfo.ListWellClasses[Idx]); else if(this.ClassType == eClassType.PHENOTYPE) this.ListSelectedClass[0].ListTags.Add(cGlobalInfo.ListCellularPhenotypes[Idx]); NumSelected++; } else { this.ListSelectedClass[0].Add(0); this.ListSelectedClass[0].ListTags.Add(null); } Idx++; } if (NumSelected==0) { FeedBackMessage.IsSucceed = false; FeedBackMessage.Message = "No class selected !"; return FeedBackMessage; } //if (NumSelected < MinNumberOfClass) //{ // FeedBackMessage.IsSucceed = false; // FeedBackMessage.Message = "At least "+MinNumberOfClass+" class have to be selected !"; // return FeedBackMessage; //} return FeedBackMessage; }
private void swapClassesToolStripMenuItem_Click(object sender, EventArgs e) { if (cGlobalInfo.CurrentScreening == null) return; FormForSwapClasses WindowSwapClasses = new FormForSwapClasses(GlobalInfo); PanelForClassSelection ClassSelectionPanel = new PanelForClassSelection(true, eClassType.WELL); ClassSelectionPanel.Height = WindowSwapClasses.panelToBeSwapped.Height; //ClassSelectionPanel.Location.Y = ClassSelectionPanel.Location.Y+ 20; ClassSelectionPanel.UnSelectAll(); WindowSwapClasses.panelToBeSwapped.Controls.Add(ClassSelectionPanel); if (WindowSwapClasses.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; int Idx = 0; int NumberOfPlates = cGlobalInfo.CurrentScreening.ListPlatesActive.Count; // int OriginalIdx = WindowSwapClasses.comboBoxOriginalClass.SelectedIndex - 1; int DestinatonIdx = WindowSwapClasses.comboBoxDestinationClass.SelectedIndex - 1; // loop on all the plate for (int PlateIdx = 0; PlateIdx < NumberOfPlates; PlateIdx++) { cPlate CurrentPlateToProcess = cGlobalInfo.CurrentScreening.ListPlatesActive.GetPlate(PlateIdx); for (int IdxValue = 0; IdxValue < cGlobalInfo.CurrentScreening.Columns; IdxValue++) for (int IdxValue0 = 0; IdxValue0 < cGlobalInfo.CurrentScreening.Rows; IdxValue0++) { cWell TmpWell = CurrentPlateToProcess.GetWell(IdxValue, IdxValue0, false); if (TmpWell == null) continue; if ((TmpWell.GetCurrentClassIdx() > -1) && (ClassSelectionPanel.GetListSelectedClass()[TmpWell.GetCurrentClassIdx()])) { if (DestinatonIdx == -1) TmpWell.SetAsNoneSelected(); else TmpWell.SetClass(DestinatonIdx); Idx++; } } } cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().DisplayDistribution(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor(), false); MessageBox.Show(Idx + " wells have been swapped !", "Process over !", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }
private void SubPopulationStatDescItem(object sender, EventArgs e) { PanelForClassSelection ClassSelectionPanel = new PanelForClassSelection(true, eClassType.PHENOTYPE); //ClassSelectionPanel.Height = WindowToDisplay.Height; ClassSelectionPanel.UnSelectAll(); ClassSelectionPanel.Select(0); ClassSelectionPanel.Select(1); ClassSelectionPanel.Location = new System.Drawing.Point(10, 10); ClassSelectionPanel.Width = 150; ClassSelectionPanel.Height = ClassSelectionPanel.ListCheckBoxes.Count * 25; ClassSelectionPanel.BorderStyle = BorderStyle.Fixed3D; FormForStatDesc NewWindow = new FormForStatDesc(this.GlobalInfo); NewWindow.panelForSubPopulation.Controls.Add(ClassSelectionPanel); NewWindow.textBoxDescName.Text = cGlobalInfo.CurrentScreening.ListDescriptors[IntToTransfer].GetName() + "_Average"; if (NewWindow.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; if ((NewWindow.comboBoxStatistics.Text != "Average") && (NewWindow.comboBoxStatistics.Text != "Stdev") && (NewWindow.comboBoxStatistics.Text != "Sum") && (NewWindow.comboBoxStatistics.Text != "Median") && (NewWindow.comboBoxStatistics.Text != "MAD") && (NewWindow.comboBoxStatistics.Text != "CV%")) return; List<cCellularPhenotype> LCP = new List<cCellularPhenotype>(); for (int IdxPheno = 0; IdxPheno < ClassSelectionPanel.GetListSelectedClass().Count; IdxPheno++) { if (ClassSelectionPanel.GetListSelectedClass()[IdxPheno]) LCP.Add(cGlobalInfo.ListCellularPhenotypes[IdxPheno]); } if (LCP.Count == 0) return; double RatioPopulation = 1; string description = "This descriptor has been generated by computing the " + NewWindow.textBoxDescName.Text + " of " + RatioPopulation * 100 + "% the following phenotypic sub-populations:\n"; foreach (var item in LCP) { description += item.Name + "\n"; } cDescriptorType NewAverageType = new cDescriptorType(NewWindow.textBoxDescName.Text, true, 1, description); cGlobalInfo.CurrentScreening.ListDescriptors.AddNew(NewAverageType); FormForProgress ProgressWindow = new FormForProgress(); ProgressWindow.Show(); int IdxProgress = 0; int MaxProgress = 0; foreach (cPlate CurrentPlateToProcess in cGlobalInfo.CurrentScreening.ListPlatesAvailable) MaxProgress += (int)CurrentPlateToProcess.ListActiveWells.Count; ProgressWindow.progressBar.Maximum = MaxProgress; foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable) { foreach (cWell Tmpwell in TmpPlate.ListActiveWells) { TmpPlate.DBConnection = new cDBConnection(TmpPlate, Tmpwell.SQLTableName); List<cDescriptorType> LDT = new List<cDescriptorType>(); LDT.Add(cGlobalInfo.CurrentScreening.ListDescriptors[IntToTransfer]); cExtendedTable CT = TmpPlate.DBConnection.GetWellValues(Tmpwell, LDT, LCP, RatioPopulation); cListSignature LDesc = new cListSignature(); double Value = 0; if (CT.Count == 1) { if (CT[0].Count == 0) { Value = 0; richTextBoxConsole.AppendText(TmpPlate.GetName() + " : " + Tmpwell.GetShortInfo().Remove(Tmpwell.GetShortInfo().Length - 2) + ": no objects fullfill your request. Statistics set to null.\n"); } else { if (NewWindow.comboBoxStatistics.Text == "Average") Value = CT[0].Average(); else if (NewWindow.comboBoxStatistics.Text == "Stdev") Value = CT[0].Std(); else if (NewWindow.comboBoxStatistics.Text == "Sum") Value = CT[0].Sum(); else if (NewWindow.comboBoxStatistics.Text == "Median") Value = CT[0].Median(); else if (NewWindow.comboBoxStatistics.Text == "MAD") Value = CT[0].MAD(true); else if (NewWindow.comboBoxStatistics.Text == "CV%") Value = CT[0].CV(); } } ProgressWindow.richTextBoxForComment.AppendText(Tmpwell.GetShortInfo() + ": " + CT[0].Count.ToString() + " / " + Tmpwell.GetNumBiologicalObjects() + "\n"); cSignature NewDesc = new cSignature(Value, NewAverageType, cGlobalInfo.CurrentScreening); LDesc.Add(NewDesc); Tmpwell.AddSignatures(LDesc); TmpPlate.DBConnection.CloseConnection(); ProgressWindow.progressBar.Value = IdxProgress++; ProgressWindow.richTextBoxForComment.AppendText(TmpPlate.GetName() + " : " + Tmpwell.GetShortInfo().Remove(Tmpwell.GetShortInfo().Length - 2) + "\n"); ProgressWindow.Refresh(); } } ProgressWindow.Close(); cGlobalInfo.CurrentScreening.ListDescriptors.UpDateDisplay(); cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate(); for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++) cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax(); }
private void GeneratePCADescriptorItem(object sender, EventArgs e) { FormForProjections WindowClassification = new FormForProjections(); //WindowClassification.buttonClassification.Text = "Process"; WindowClassification.label1.Text = "Class of Interest"; WindowClassification.Text = "PCA"; WindowClassification.IsPCA = true; WindowClassification.numericUpDownNumberOfAxis.Maximum = cGlobalInfo.CurrentScreening.GetNumberOfActiveDescriptor(); PanelForClassSelection ClassSelectionPanel = new PanelForClassSelection(true, eClassType.WELL); ClassSelectionPanel.Height = WindowClassification.panelForClasses.Height; ClassSelectionPanel.UnSelectAll(); ClassSelectionPanel.Select(2); WindowClassification.panelForClasses.Controls.Add(ClassSelectionPanel); cListPlates PlatesToProcess = new cListPlates(null); if (WindowClassification.radioButtonFromCurrentPlate.Checked) PlatesToProcess.Add(cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate()); else PlatesToProcess = cGlobalInfo.CurrentScreening.ListPlatesActive; WindowClassification.PlatesToProcess = PlatesToProcess; if (WindowClassification.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; }
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(); }
public FormForSingleCellsDisplay(cExtendedTable InputTable, cExtendedList ListClasses) { InitializeComponent(); SliderForOpacity.numericUpDown.Maximum = 255; SliderForOpacity.numericUpDown.Value = this.Opacity; this.InputTable = InputTable; // build the panel for the phenotypic selection PanelPhenotypeSelection = new PanelForClassSelection(true, eClassType.PHENOTYPE); PanelPhenotypeSelection.SelectionChanged += new PanelForClassSelection.ChangedEventHandler(PanelPhenotypeSelection_SelectionChanged); PanelPhenotypeSelection.Height = this.panelForClasses.Height; this.panelForClasses.Controls.Add(PanelPhenotypeSelection); #region initialize histograms display splitContainerHorizontal.Panel1Collapsed = true; splitContainerVertical.Panel2Collapsed = true; System.Drawing.Image ImageOriginal = (System.Drawing.Image)(Properties.Resources.Arrow); if (splitContainerVertical.Panel2Collapsed) ImageOriginal.RotateFlip(RotateFlipType.Rotate270FlipNone); else ImageOriginal.RotateFlip(RotateFlipType.Rotate90FlipNone); buttonCollapseVertical.BackgroundImage = ImageOriginal; #endregion MachineLearning = new cMachineLearning(GlobalInfo); MachineLearning.Classes.AddRange(ListClasses); WindowForModelHistory.Show(); WindowForModelHistory.Visible = false; ToolTipForX.AutoPopDelay = ToolTipForY.AutoPopDelay = 5000; ToolTipForX.InitialDelay = ToolTipForY.InitialDelay = 500; ToolTipForX.ReshowDelay = ToolTipForY.ReshowDelay = 500; ToolTipForX.ShowAlways = ToolTipForY.ShowAlways = true; ToolTipForX.SetToolTip(comboBoxAxeX, comboBoxAxeX.Text); ToolTipForY.SetToolTip(comboBoxAxeY, comboBoxAxeY.Text); ToolTipForVolume.SetToolTip(comboBoxVolume, comboBoxVolume.Text); this.chartForPoints.ChartAreas[0].CursorX.Interval = double.Epsilon; this.chartForPoints.ChartAreas[0].CursorY.Interval = double.Epsilon; this.chartForPoints.MouseClick += new System.Windows.Forms.MouseEventHandler(this.AssociatedChart_MouseClick); for (int i = 0; i < cGlobalInfo.ListCellularPhenotypes.Count; i++) { this.ListPhenotypeVisible.Add(true); } }
public cFeedBackMessage Run(cGlobalInfo GlobalInfo) { FormForDisplay WindowToDisplay = new FormForDisplay(); WindowToDisplay.Text = "2 Classes Selection"; WindowToDisplay.FormBorderStyle = FormBorderStyle.FixedSingle; PanelForClassSelection ClassSelectionPanel1 = new PanelForClassSelection(PanelLeft_IsCheckBoxes, this.ClassType); ClassSelectionPanel1.UnSelectAll(); ClassSelectionPanel1.Select(0); ClassSelectionPanel1.Location = new System.Drawing.Point(10, 10); ClassSelectionPanel1.Width = 140; if(ClassSelectionPanel1.ListCheckBoxes!=null) ClassSelectionPanel1.Height = ClassSelectionPanel1.ListCheckBoxes.Count*25; else ClassSelectionPanel1.Height = ClassSelectionPanel1.ListRadioButtons.Count * 25; ClassSelectionPanel1.BorderStyle = BorderStyle.Fixed3D; PanelForClassSelection ClassSelectionPanel2 = new PanelForClassSelection( PanelRight_IsCheckBoxes, this.ClassType); ClassSelectionPanel2.UnSelectAll(); ClassSelectionPanel2.Select(1); ClassSelectionPanel2.Location = new System.Drawing.Point(10 + ClassSelectionPanel1.Width, 10); ClassSelectionPanel2.Width = 140; if (ClassSelectionPanel2.ListCheckBoxes != null) ClassSelectionPanel2.Height = ClassSelectionPanel2.ListCheckBoxes.Count * 25; else ClassSelectionPanel2.Height = ClassSelectionPanel2.ListRadioButtons.Count * 25; ClassSelectionPanel2.BorderStyle = BorderStyle.Fixed3D; Button ReturnButton = new Button(); ReturnButton.Text = "Ok"; ReturnButton.DialogResult = DialogResult.OK; ReturnButton.Location = new System.Drawing.Point(ClassSelectionPanel1.Location.X, ClassSelectionPanel1.Location.Y + ClassSelectionPanel1.Height + 5); WindowToDisplay.Controls.Add(ReturnButton); WindowToDisplay.Controls.Add(ClassSelectionPanel1); WindowToDisplay.Controls.Add(ClassSelectionPanel2); WindowToDisplay.Width = ClassSelectionPanel1.Width + ClassSelectionPanel2.Width + 28; WindowToDisplay.Height = ClassSelectionPanel1.Height + ReturnButton.Height+ 48; if (WindowToDisplay.ShowDialog() != System.Windows.Forms.DialogResult.OK) { FeedBackMessage.IsSucceed = false; FeedBackMessage.Message = "Selection aborded !"; return FeedBackMessage; } List<bool> ListBool1 = ClassSelectionPanel1.GetListSelectedClass(); List<bool> ListBool2 = ClassSelectionPanel2.GetListSelectedClass(); int NumSelected = 0; this.ListSelectedClass = new cExtendedTable(); foreach (var item in ListBool1) { this.ListSelectedClass.Add(new cExtendedList()); if (item) { this.ListSelectedClass[0].Add(1); NumSelected++; } else this.ListSelectedClass[0].Add(0); } foreach (var item in ListBool2) { this.ListSelectedClass.Add(new cExtendedList()); if (item) { this.ListSelectedClass[1].Add(1); NumSelected++; } else this.ListSelectedClass[1].Add(0); } return FeedBackMessage; }