public cFeedBackMessage Run() { if (this.Input == null) { FeedBackMessage.IsSucceed = false; FeedBackMessage.Message = "No input data defined."; return FeedBackMessage; } OutPutList = new cExtendedList(); OutPutList.ListTags = new List<object>(); for (int i = 0; i < this.Input.Count; i++) { for (int j = 0; j < this.Input[0].Count; j++) { OutPutList.Add(this.Input[i][j]); } if (this.Input[i].ListTags != null) { for (int j = 0; j < this.Input[i].Count; j++) OutPutList.ListTags.Add(this.Input[i].ListTags[j]); } } this.OutPut = new cExtendedTable(OutPutList); this.OutPut.Name = "Linearize(" + this.Input.Name + ")"; return FeedBackMessage; }
private void Process() { this.OutPut = new cExtendedTable(); double Value = double.NaN; this.OutPut.ListRowNames = new List<string>(); this.OutPut.Name = "Z-Factor(s)"; for (int IdxCol = 0; IdxCol < this.Input.Count; IdxCol++) { this.OutPut.ListRowNames.Add(this.Input[IdxCol].Name); cExtendedList NewResult = new cExtendedList(); NewResult.Name = this.Input[IdxCol].Name; for (int IdxColBis = 0; IdxColBis < this.Input.Count; IdxColBis++) { if (IdxCol != IdxColBis) Value = this.Input[IdxCol].ZFactor(this.Input[IdxColBis], this.IsRobust); else Value = double.NaN; //if (double.IsInfinity(Value)) Value = 1; NewResult.Add(Value); } this.OutPut.Add(NewResult); } base.Info = "Z-Factor ("; if (IsRobust) base.Info += "Robust) - "; else base.Info += "Regular) - "; base.Info += this.Input[0].Count + " vs. " + this.Input[1].Count + " values."; }
public cExtendedTable GetPropertyTable() { cExtendedTable ToReturn = new cExtendedTable(); ToReturn.Name = this.Name + " - Properties"; cExtendedList Properties = new cExtendedList("Properties"); ToReturn.Add(Properties); ToReturn.ListRowNames = new List<string>(); ToReturn.ListRowNames.Add("Dimension X"); Properties.Add(this.Width); ToReturn.ListRowNames.Add("Dimension Y"); Properties.Add(this.Height); ToReturn.ListRowNames.Add("Dimension Z"); Properties.Add(this.Depth); ToReturn.ListRowNames.Add("Voxel Size X"); Properties.Add(this.Resolution.X); ToReturn.ListRowNames.Add("Voxel Size Y"); Properties.Add(this.Resolution.Y); ToReturn.ListRowNames.Add("Voxel Size Z"); Properties.Add(this.Resolution.Z); ToReturn.ListRowNames.Add("Position X"); Properties.Add(this.Position.X); ToReturn.ListRowNames.Add("Position Y"); Properties.Add(this.Position.Y); ToReturn.ListRowNames.Add("Position Z"); Properties.Add(this.Position.Z); ToReturn.ListRowNames.Add("Channel Numbers"); Properties.Add(this.GetNumChannels()); for (int i = 0; i < this.GetNumChannels(); i++) { ToReturn.ListRowNames.Add(this.SingleChannelImage[i].Name + " - Wavelenght"); Properties.Add(i); } return ToReturn; }
public cExtendedList GetListValues() { if (ValuesMatrix == null) return null; cExtendedList ToReturn = new cExtendedList(); for (int j = 0; j < ValuesMatrix.Length; j++) for (int i = 0; i < ValuesMatrix[0].Length; i++) { if (ValuesMatrix[j][i] != null) ToReturn.Add(ValuesMatrix[j][i]); } return ToReturn; }
void DisplayGraphItem(object sender, EventArgs e) { FormForDisplay TMPWin = new FormForDisplay(); Panel Pan = new Panel(); Pan.Show(); cExtendedList ListValue = new cExtendedList(); for (int Idx = 0; Idx < this.listViewForClassifHistory.Items.Count; Idx++) { // this.listViewForCellPopulations.Items[Idx]; ListValue.Add(double.Parse(this.listViewForClassifHistory.Items[Idx].SubItems[2].Text)); } // ListValue.Name = this.dt.Columns[e.ColumnIndex].ColumnName; cPanelHisto PanelHisto = new cPanelHisto(ListValue, eGraphType.LINE, eOrientation.HORIZONTAL); TMPWin.Controls.Add(PanelHisto.WindowForPanelHisto.panelForGraphContainer); TMPWin.Show(); }
private void Process() { this.OutPut = new cExtendedTable(); double Value = double.NaN; this.OutPut.ListRowNames = new List<string>(); this.OutPut.Name = "Mahalanobis"; for (int IdxCol = 0; IdxCol < this.Input.Count; IdxCol++) { this.OutPut.ListRowNames.Add(this.Input[IdxCol].Name); cExtendedList NewResult = new cExtendedList(); NewResult.Name = this.Input[IdxCol].Name; for (int IdxColBis = 0; IdxColBis < this.Input.Count; IdxColBis++) { Value = this.Input[IdxCol].Dist_Euclidean(this.Input[IdxColBis]); NewResult.Add(Value); } this.OutPut.Add(NewResult); } }
private void Process() { this.OutPut = new cExtendedTable(); double Value = double.NaN; this.OutPut.ListRowNames = new List<string>(); this.OutPut.Name = "Covariance Matrix"; for (int IdxCol = 0; IdxCol < this.Input.Count; IdxCol++) { this.OutPut.ListRowNames.Add(this.Input[IdxCol].Name); cExtendedList NewResult = new cExtendedList(); NewResult.Name = this.Input[IdxCol].Name; for (int IdxColBis = 0; IdxColBis < this.Input.Count; IdxColBis++) { Value = alglib.cov2(this.Input[IdxCol].ToArray(), this.Input[IdxColBis].ToArray()); NewResult.Add(Value); } this.OutPut.Add(NewResult); } }
private void Process() { this.OutPut = new cExtendedTable(); double Value = double.NaN; this.OutPut.ListRowNames = new List<string>(); this.OutPut.Name = "dot product(s)"; for (int IdxCol = 0; IdxCol < this.Input.Count; IdxCol++) { this.OutPut.ListRowNames.Add(this.Input[IdxCol].Name); cExtendedList NewResult = new cExtendedList(); NewResult.Name = this.Input[IdxCol].Name; for (int IdxColBis = 0; IdxColBis < this.Input.Count; IdxColBis++) { //if (IdxCol != IdxColBis) Value = this.Input[IdxCol].DotProduct(this.Input[IdxColBis], IsNormalized); NewResult.Add(Value); } this.OutPut.Add(NewResult); } }
private void Process() { base.Output = new cExtendedTable(); double Value = double.NaN; base.Output.ListRowNames = new List<string>(); base.Output.ListRowNames.Add(base.Input1.Name); if (this.CorrelationType == eCorrelationType.PEARSON) { base.Output.Name = "Pearson Correlation Coefficient"; Value = alglib.pearsoncorr2(base.Input1.ToArray(), base.Input2.ToArray()); } else if (this.CorrelationType == eCorrelationType.SPEARMAN) { base.Output.Name = "Spearman Correlation Coefficient"; Value = alglib.spearmancorr2(base.Input1.ToArray(), base.Input2.ToArray()); } cExtendedList Result = new cExtendedList(); Result.Add(Value); base.Output.Add(Result); base.Output[0].Name = base.Input2.Name; }
private void aNOVAToolStripMenuItem1_Click(object sender, EventArgs e) { cGUI_ListClasses GUI_ListClasses = new cGUI_ListClasses(); GUI_ListClasses.IsCheckBoxes = true; GUI_ListClasses.IsSelectAll = true; if (GUI_ListClasses.Run().IsSucceed == false) return; cExtendedTable ListClassSelected = GUI_ListClasses.GetOutPut(); string SubTitle = "ANOVA (One-Way)"; #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) { cExtendedTable NewTable1 = new cExtendedTable(); List<cListWells> ListListWells = new List<cListWells>(); int NumWells = 0; for (int IdxClassWell = 0; IdxClassWell < ListClassSelected[0].Count; IdxClassWell++) { if (ListClassSelected[0][IdxClassWell] >= 1) { List<cWellClassType> LCT = new List<cWellClassType>(); LCT.Add(cGlobalInfo.ListWellClasses[IdxClassWell]); cListWells TmpList = TmpPlate.ListWells.Filter(LCT); if (TmpList.Count >= 3) { ListListWells.Add(TmpList); NumWells += TmpList.Count; } } } if (ListListWells.Count <= 1) { if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked) { MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else continue; } cExtendedTable CompleteReport = null; cExtendedList ListZ = new cExtendedList(); List<cDescriptorType> ListDescForZFactor = 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 TableForZ = new cExtendedTable(); foreach (var item in ListListWells) { List<cDescriptorType> LType = new List<cDescriptorType>(); LType.Add(cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc]); cExtendedTable TTable = item.GetAverageDescriptorValues(LType, false, false); TableForZ.Add(TTable[0]); } RealIdx++; cANOVA ZF = new cANOVA(); ZF.SetInputData(TableForZ); ZF.Run(); ListZ.Add(ZF.GetOutPut()[0][0]); ZF.GetOutPut()[0].Name = cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc].GetName(); if (CompleteReport == null) CompleteReport = new cExtendedTable(ZF.GetOutPut()); else { cMerge M = new cMerge(); M.IsHorizontal = true; M.SetInputData(CompleteReport, ZF.GetOutPut()); M.Run(); CompleteReport = M.GetOutPut(); } ListDescForZFactor.Add(cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc]); } cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListZ)); ET[0].ListTags = new List<object>(); ET[0].ListTags.AddRange(ListDescForZFactor); ET.Name = TmpPlate.GetName() + "\n" + SubTitle + " - " + NumWells + " wells";// +" - " +cGlobalInfo.ListWellClasses[IdxClassNeg].Name + " (" + NewTable1[0].Count + " wells) vs. " +cGlobalInfo.ListWellClasses[IdxClassPos].Name + " (" + NewTable2[0].Count + " wells)"; ET[0].Name = ET.Name; cSort S = new cSort(); S.SetInputData(ET); S.IsAscending = false; 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 = SubTitle; 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.Chart.Max VG1.Title = TmpPlate.GetName(); // Classes.Base_Classes.General.cLineHorizontalForGraph VLZ05 = new Classes.Base_Classes.General.cLineHorizontalForGraph(.05); // VLZ05.IsAllowMoving = true; // VG1.Chart.ListHorizontalLines.Add(VLZ05); VG1.Run(); cDesignerSplitter DS = new cDesignerSplitter(); DS.Orientation = Orientation.Vertical; DS.SetInputData(VG1.GetOutPut()); cTranspose T = new cTranspose(); T.SetInputData(CompleteReport); T.Run(); CompleteReport = T.GetOutPut(); CompleteReport[0].Name = "P-Value"; CompleteReport[1].Name = "Is significant ?"; cSort S1 = new cSort(); S1.SetInputData(CompleteReport); S1.ColumnIndexForSorting = 0; S1.IsAscending = true; S1.Run(); cViewerTable VT = new cViewerTable(); VT.SetInputData(S1.GetOutPut()); VT.DigitNumber = -1; VT.Run(); DS.SetInputData(VT.GetOutPut()); DS.Title = TmpPlate.GetName(); DS.Run(); DT.SetInputData(DS.GetOutPut()); } DT.Run(); cDisplayToWindow CDW = new cDisplayToWindow(); CDW.SetInputData(DT.GetOutPut());//VG1.GetOutPut()); if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked) CDW.Title = SubTitle + " - " + ListPlatesToProcess[0].GetName(); else CDW.Title = SubTitle + " - " + 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); cListWells ListWellsToProcess2 = new cListWells(null); foreach (cWell item in TmpPlate.ListActiveWells) { if (item.GetCurrentClassIdx() != -1) { if (ListClassSelected[0][item.GetCurrentClassIdx()] == 1) ListWellsToProcess1.Add(item); if (ListClassSelected[1][item.GetCurrentClassIdx()] == 1) ListWellsToProcess2.Add(item); } } cExtendedTable NewTable1 = new cExtendedTable(ListWellsToProcess1, cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorIndex(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor())); cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorIndex(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor())); //cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, false); if ((NewTable1.Count == 0) || (NewTable1[0].Count < 2) || (NewTable2.Count == 0) || (NewTable2[0].Count < 2)) { if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked) { MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else continue; } cExtendedTable TableForZ = new cExtendedTable(); TableForZ.Add(NewTable1[0]); TableForZ.Add(NewTable2[0]); cStudent_tTest ZF = new cStudent_tTest(); ZF.SetInputData(TableForZ); ZF.Run(); double Zfactor = ZF.GetOutPut()[0][1]; ListZ.Add(Zfactor); // update plate quality //TmpPlate.ListProperties.UpdateValueByName("Quality", Math.Exp(Zfactor - 1)); //cProperty Prop = TmpPlate.ListProperties.FindByName("Quality"); //Prop.Info = ZF.GetInfo(); ListPlatesForZFactor.Add(TmpPlate); } cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListZ)); ET[0].ListTags = new List<object>(); ET[0].ListTags.AddRange(ListPlatesForZFactor); ET.Name = SubTitle + " - " + 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 = SubTitle; 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 = SubTitle + " - " + ListPlatesToProcess.Count + " plates"; CDW.Run(); CDW.Display(); #endregion } }
private void mannWithneyTestToolStripMenuItem_Click(object sender, EventArgs e) { cGUI_2ClassesSelection GUI_ListClasses = new cGUI_2ClassesSelection(); if (GUI_ListClasses.Run(this.GlobalInfo).IsSucceed == false) return; cExtendedTable ListClassSelected = GUI_ListClasses.GetOutPut(); int IdxClassNeg = -1; int IdxClassPos = -1; for (int IdxC = 0; IdxC < ListClassSelected[0].Count; IdxC++) { if (ListClassSelected[0][IdxC] == 1) IdxClassNeg = IdxC; if (ListClassSelected[1][IdxC] == 1) IdxClassPos = IdxC; } string SubTitle = "Mann-Withney (both tails)"; #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); cListWells ListWellsToProcess2 = new cListWells(null); foreach (cWell item in TmpPlate.ListActiveWells) { if (item.GetCurrentClassIdx() != -1) { if (ListClassSelected[0][item.GetCurrentClassIdx()] == 1) ListWellsToProcess1.Add(item); if (ListClassSelected[1][item.GetCurrentClassIdx()] == 1) ListWellsToProcess2.Add(item); } } cExtendedTable NewTable1 = new cExtendedTable(ListWellsToProcess1, true); cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, true); if ((NewTable1.Count == 0) || (NewTable1[0].Count < 5) || (NewTable2.Count == 0) || (NewTable2[0].Count < 5)) { if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked) { MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else continue; } cExtendedList ListZ = new cExtendedList(); List<cDescriptorType> ListDescForZFactor = 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 TableForZ = new cExtendedTable(); TableForZ.Add(NewTable1[RealIdx]); TableForZ.Add(NewTable2[RealIdx]); RealIdx++; cMannWithneyTest ZF = new cMannWithneyTest(); ZF.SetInputData(TableForZ); ZF.Run(); ListZ.Add(ZF.GetOutPut()[0][1]); ListDescForZFactor.Add(cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc]); } cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListZ)); ET[0].ListTags = new List<object>(); ET[0].ListTags.AddRange(ListDescForZFactor); ET.Name = TmpPlate.GetName() + "\n" + SubTitle + " - " + cGlobalInfo.ListWellClasses[IdxClassNeg].Name + " (" + NewTable1[0].Count + " wells) vs. " + cGlobalInfo.ListWellClasses[IdxClassPos].Name + " (" + NewTable2[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 = SubTitle; 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.Chart.Max VG1.Title = TmpPlate.GetName(); Classes.Base_Classes.General.cLineHorizontalForGraph VLZ05 = new Classes.Base_Classes.General.cLineHorizontalForGraph(.05); VLZ05.IsAllowMoving = true; VG1.Chart.ListHorizontalLines.Add(VLZ05); VG1.Run(); cDesignerSplitter DS = new cDesignerSplitter(); DS.Orientation = Orientation.Vertical; DS.SetInputData(VG1.GetOutPut()); cSort S1 = new cSort(); S1.SetInputData(ET); S1.ColumnIndexForSorting = 0; S1.IsAscending = false; S1.Run(); cViewerTable VT = new cViewerTable(); VT.SetInputData(S1.GetOutPut()); VT.DigitNumber = -1; VT.Run(); DS.SetInputData(VT.GetOutPut()); DS.Title = TmpPlate.GetName(); DS.Run(); DT.SetInputData(DS.GetOutPut()); } DT.Run(); cDisplayToWindow CDW = new cDisplayToWindow(); CDW.SetInputData(DT.GetOutPut());//VG1.GetOutPut()); if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked) CDW.Title = SubTitle + " - " + ListPlatesToProcess[0].GetName(); else CDW.Title = SubTitle + " - " + 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); cListWells ListWellsToProcess2 = new cListWells(null); foreach (cWell item in TmpPlate.ListActiveWells) { if (item.GetCurrentClassIdx() != -1) { if (ListClassSelected[0][item.GetCurrentClassIdx()] == 1) ListWellsToProcess1.Add(item); if (ListClassSelected[1][item.GetCurrentClassIdx()] == 1) ListWellsToProcess2.Add(item); } } cExtendedTable NewTable1 = new cExtendedTable(ListWellsToProcess1, cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorIndex(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor())); cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorIndex(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor())); //cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, false); if ((NewTable1.Count == 0) || (NewTable1[0].Count < 5) || (NewTable2.Count == 0) || (NewTable2[0].Count < 5)) { if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked) { MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else continue; } cExtendedTable TableForZ = new cExtendedTable(); TableForZ.Add(NewTable1[0]); TableForZ.Add(NewTable2[0]); cMannWithneyTest ZF = new cMannWithneyTest(); ZF.SetInputData(TableForZ); ZF.Run(); double Zfactor = ZF.GetOutPut()[0][1]; ListZ.Add(Zfactor); // update plate quality //TmpPlate.ListProperties.UpdateValueByName("Quality", Math.Exp(Zfactor - 1)); //cProperty Prop = TmpPlate.ListProperties.FindByName("Quality"); //Prop.Info = ZF.GetInfo(); ListPlatesForZFactor.Add(TmpPlate); } cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListZ)); ET[0].ListTags = new List<object>(); ET[0].ListTags.AddRange(ListPlatesForZFactor); ET.Name = SubTitle + " - " + 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 = SubTitle; 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; Classes.Base_Classes.General.cLineHorizontalForGraph VLZ05 = new Classes.Base_Classes.General.cLineHorizontalForGraph(.05); VLZ05.IsAllowMoving = true; VG1.Chart.ListHorizontalLines.Add(VLZ05); VG1.Title = cGlobalInfo.CurrentScreening.ListDescriptors[cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx].GetName(); VG1.Run(); cDisplayToWindow CDW = new cDisplayToWindow(); CDW.SetInputData(VG1.GetOutPut()); CDW.Title = SubTitle + " - " + ListPlatesToProcess.Count + " plates"; CDW.Run(); CDW.Display(); #endregion } }
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(); } }
private void lDAToolStripMenuItem_Click(object sender, EventArgs e) { cGUI_ListClasses GUI_ListClasses = new cGUI_ListClasses(); if (GUI_ListClasses.Run().IsSucceed == false) return; cExtendedList ListClassSelected = GUI_ListClasses.GetOutPut()[0]; if (ListClassSelected.Sum() < 2) { MessageBox.Show("At least two classes have to be selected to perfom a LDA.", "Error !", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } cDisplayToWindow vD = new cDisplayToWindow(); if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked) { cPlate TmpPlate = cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate(); cListWells ListWellsToProcess = new cListWells(null); cExtendedList ListClasses = new cExtendedList(); ListClasses.Name = "Classes"; foreach (cWell item in TmpPlate.ListActiveWells) if ((item.GetCurrentClassIdx() != -1) && (ListClassSelected[item.GetCurrentClassIdx()] == 1)) { ListWellsToProcess.Add(item); ListClasses.Add(item.GetCurrentClassIdx()); } cExtendedTable NewTable = new cExtendedTable(ListWellsToProcess, true); NewTable.Add(ListClasses); cProjectorLDA LDA = new cProjectorLDA(); LDA.SetInputData(NewTable); cFeedBackMessage FM = LDA.Run(); if (!FM.IsSucceed) { MessageBox.Show(FM.Message, "Error !", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } cViewerTable VHM = new cViewerTable(); cExtendedTable CT = LDA.GetOutPut(); foreach (var item in CT) { cDescriptorsLinearCombination DLC = new cDescriptorsLinearCombination(item); foreach (cDescriptorType Desc in item.ListTags) DLC.Add(Desc); item.Tag = DLC; } VHM.SetInputData(CT); VHM.Run(); vD.SetInputData(VHM.GetOutPut()); vD.Title = "LDA - " + TmpPlate.GetName() + " : " + ListWellsToProcess.Count + " wells"; } else if (ProcessModeEntireScreeningToolStripMenuItem.Checked) { cListWells ListWellsToProcess = new cListWells(null); cExtendedList ListClasses = new cExtendedList(); ListClasses.Name = "Classes"; foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesActive) { foreach (cWell item in TmpPlate.ListActiveWells) { if (item.GetCurrentClassIdx() != -1) { if (ListClassSelected[item.GetCurrentClassIdx()] == 1) { ListWellsToProcess.Add(item); ListClasses.Add(item.GetCurrentClassIdx()); } } } } cExtendedTable NewTable = new cExtendedTable(ListWellsToProcess, true); NewTable.Add(ListClasses); cProjectorLDA LDA = new cProjectorLDA(); LDA.SetInputData(NewTable); cFeedBackMessage FM = LDA.Run(); if (!FM.IsSucceed) { MessageBox.Show(FM.Message, "Error !", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } cExtendedTable CT = LDA.GetOutPut(); foreach (var item in CT) { cDescriptorsLinearCombination DLC = new cDescriptorsLinearCombination(item); foreach (cDescriptorType Desc in item.ListTags) DLC.Add(Desc); item.Tag = DLC; } cViewerTable VHM = new cViewerTable(); VHM.SetInputData(CT); VHM.Run(); vD.SetInputData(VHM.GetOutPut()); vD.Title = "LDA - " + ListWellsToProcess.Count + " wells."; } else if (ProcessModeplateByPlateToolStripMenuItem.Checked) { cDesignerTab CDT = new cDesignerTab(); foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesActive) { cListWells ListWellsToProcess = new cListWells(null); cExtendedList ListClasses = new cExtendedList(); ListClasses.Name = "Classes"; foreach (cWell item in TmpPlate.ListActiveWells) { if (item.GetCurrentClassIdx() != -1) { if (ListClassSelected[item.GetCurrentClassIdx()] == 1) { ListWellsToProcess.Add(item); ListClasses.Add(item.GetCurrentClassIdx()); } } } cExtendedTable NewTable = new cExtendedTable(ListWellsToProcess, true); NewTable.Add(ListClasses); NewTable.Name = TmpPlate.GetName(); cProjectorLDA LDA = new cProjectorLDA(); LDA.SetInputData(NewTable); cFeedBackMessage FM = LDA.Run(); if (!FM.IsSucceed) { MessageBox.Show(FM.Message, "Error !", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } cExtendedTable CT = LDA.GetOutPut(); foreach (var item in CT) { cDescriptorsLinearCombination DLC = new cDescriptorsLinearCombination(item); foreach (cDescriptorType Desc in item.ListTags) DLC.Add(Desc); item.Tag = DLC; } cViewerTable VHM = new cViewerTable(); VHM.SetInputData(CT); VHM.Run(); CDT.SetInputData(VHM.GetOutPut()); } CDT.Run(); vD.SetInputData(CDT.GetOutPut()); } else return; vD.Run(); vD.Display(); }
private void zScoreToolStripMenuItem_Click(object sender, EventArgs e) { #region obsolete //List<double> Pos = new List<double>(); //List<double> Neg = new List<double>(); //List<cSimpleSignature> ZFactorList = new List<cSimpleSignature>(); //int NumDesc = CompleteScreening.ListDescriptors.Count; //cWell TempWell; //// loop on all the desciptors //for (int Desc = 0; Desc < NumDesc; Desc++) //{ // Pos.Clear(); // 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 = CompleteScreening.GetCurrentDisplayPlate().GetWell(col, row, true); // if (TempWell == null) continue; // else // { // if (TempWell.GetClassIdx() == 0) // Pos.Add(TempWell.ListDescriptors[Desc].GetValue()); // if (TempWell.GetClassIdx() == 1) // Neg.Add(TempWell.ListDescriptors[Desc].GetValue()); // } // } // if (Pos.Count < 3) // { // MessageBox.Show("No or not enough positive controls !", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // return; // } // if (Neg.Count < 3) // { // MessageBox.Show("No or not enough negative controls !", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // return; // } // double ZScore = 1 - 3 * (std(Pos.ToArray()) + std(Neg.ToArray())) / (Math.Abs(Mean(Pos.ToArray()) - Mean(Neg.ToArray()))); // GlobalInfo.ConsoleWriteLine(CompleteScreening.ListDescriptors[Desc].GetName() + ", Z-Score = " + ZScore); // cSimpleSignature TmpDesc = new cSimpleSignature(CompleteScreening.ListDescriptors[Desc].GetName(), ZScore); // ZFactorList.Add(TmpDesc); //} //ZFactorList.Sort(delegate(cSimpleSignature p1, cSimpleSignature p2) { return p1.AverageValue.CompareTo(p2.AverageValue); }); //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 < ZFactorList.Count; IdxValue++) //{ // if (double.IsNaN(ZFactorList[IdxValue].AverageValue)) continue; // if (double.IsInfinity(ZFactorList[IdxValue].AverageValue)) continue; // CurrentSeries.Points.Add(ZFactorList[IdxValue].AverageValue); // CurrentSeries.Points[RealIdx].Label = ZFactorList[IdxValue].AverageValue.ToString("N2"); // CurrentSeries.Points[RealIdx].Font = new Font("Arial", 10); // CurrentSeries.Points[RealIdx].ToolTip = ZFactorList[IdxValue].Name; // CurrentSeries.Points[RealIdx].AxisLabel = ZFactorList[IdxValue].Name; // SeriesLine.Points.Add(ZFactorList[IdxValue].AverageValue); // SeriesLine.Points[RealIdx].BorderColor = Color.Black; // SeriesLine.Points[RealIdx].MarkerStyle = MarkerStyle.Circle; // SeriesLine.Points[RealIdx].MarkerSize = 4; // RealIdx++; //} //SimpleForm NewWindow = new SimpleForm(CompleteScreening); //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 = "Z-factors"; //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; //CurrentChartArea.AxisX.ScaleView.Zoomable = true; //CurrentChartArea.AxisY.ScaleView.Zoomable = true; //Title CurrentTitle = new Title(CompleteScreening.GetCurrentDisplayPlate().Name + " Z-factors"); //CurrentTitle.Font = new System.Drawing.Font("Arial", 11, FontStyle.Bold); //NewWindow.chartForSimpleForm.Titles.Add(CurrentTitle); //NewWindow.Show(); //NewWindow.chartForSimpleForm.Update(); //NewWindow.chartForSimpleForm.Show(); //NewWindow.AutoScroll = true; //NewWindow.Controls.AddRange(new System.Windows.Forms.Control[] { NewWindow.chartForSimpleForm }); #endregion cGUI_2ClassesSelection GUI_ListClasses = new cGUI_2ClassesSelection(); if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked) { GUI_ListClasses.PanelRight_IsCheckBoxes = true; } if (GUI_ListClasses.Run(this.GlobalInfo).IsSucceed == false) return; cExtendedTable ListClassSelected = GUI_ListClasses.GetOutPut(); int IdxClassNeg = -1; int IdxClassPos = -1; for (int IdxC = 0; IdxC < ListClassSelected[0].Count; IdxC++) { if (ListClassSelected[0][IdxC] == 1) IdxClassNeg = IdxC; if (ListClassSelected[1][IdxC] == 1) IdxClassPos = IdxC; } string SubTitle = "Z-Factor"; if (_QCZRobustItem.Checked) SubTitle += " (Robust)"; #region Single plate cDesignerTab DT = new cDesignerTab(); // cDesignerMultiChoices DT = new cDesignerMultiChoices(); if ((ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)/*||(ProcessModeEntireScreeningToolStripMenuItem.Checked)*/) { List<cPlate> ListPlatesToProcess = new List<cPlate>(); cPlate TmpPlate = cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate(); // foreach (cPlate TmpPlate in ListPlatesToProcess) // GUI_ListClasses.Get // ListClassSelected List<int> ListCheckBoxes = new List<int>(); for (int i = 0; i < ListClassSelected[1].Count; i++) { if (ListClassSelected[1][i] > 0) ListCheckBoxes.Add(i); } for (int IdxClassSelected = 0; IdxClassSelected < ListCheckBoxes.Count; IdxClassSelected++) { cListWells ListWellsToProcess1 = new cListWells(null); cListWells ListWellsToProcess2 = new cListWells(null); int CurrentClassTobeProcessed = ListCheckBoxes[IdxClassSelected]; foreach (cWell item in TmpPlate.ListActiveWells) { if (item.GetCurrentClassIdx() != -1) { if (ListClassSelected[0][item.GetCurrentClassIdx()] == 1) ListWellsToProcess1.Add(item); if (item.GetCurrentClassIdx() == CurrentClassTobeProcessed) // if (ListClassSelected[1][ListCheckBoxes[IdxClassSelected]] == 1) ListWellsToProcess2.Add(item); } } cExtendedTable NewTable1 = new cExtendedTable(ListWellsToProcess1, true); cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, true); if ((NewTable1.Count == 0) || (NewTable1[0].Count < 2) || (NewTable2.Count == 0) || (NewTable2[0].Count < 2)) { if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked) { MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //else // continue; } cExtendedList ListZ = new cExtendedList(); List<cDescriptorType> ListDescForZFactor = 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 TableForZ = new cExtendedTable(); TableForZ.Add(NewTable1[RealIdx]); TableForZ.Add(NewTable2[RealIdx]); RealIdx++; cZFactor ZF = new cZFactor(); ZF.SetInputData(TableForZ); ZF.IsRobust = _QCZRobustItem.Checked; ZF.Run(); ListZ.Add(ZF.GetOutPut()[0][1]); ListDescForZFactor.Add(cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc]); } cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListZ)); ET[0].ListTags = new List<object>(); ET[0].ListTags.AddRange(ListDescForZFactor); ET.Name = TmpPlate.GetName() + "\n" + SubTitle + " - " + cGlobalInfo.ListWellClasses[IdxClassNeg].Name + " (" + NewTable1[0].Count + " wells) vs. " + cGlobalInfo.ListWellClasses[CurrentClassTobeProcessed].Name + " (" + NewTable2[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 = SubTitle; 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.Chart.DefaultAxisYMax = new cExtendedList(); VG1.Chart.DefaultAxisYMax.Add(1); if (!cGlobalInfo.OptionsWindow.FFAllOptions.checkBoxZscoreMinValueAutomated.Checked) { VG1.Chart.DefaultAxisYMin = new cExtendedList(); VG1.Chart.DefaultAxisYMin.Add((double)cGlobalInfo.OptionsWindow.FFAllOptions.numericUpDownZscoreMinValue.Value); } VG1.Title = TmpPlate.GetName(); Classes.Base_Classes.General.cLineHorizontalForGraph VLZ05 = new Classes.Base_Classes.General.cLineHorizontalForGraph(.5); VLZ05.IsAllowMoving = true; VG1.Chart.ListHorizontalLines.Add(VLZ05); VG1.Run(); cDesignerSplitter DS = new cDesignerSplitter(); DS.Orientation = Orientation.Vertical; DS.SetInputData(VG1.GetOutPut()); cSort S1 = new cSort(); S1.SetInputData(ET); S1.ColumnIndexForSorting = 0; S1.IsAscending = false; S1.Run(); cViewerTable VT = new cViewerTable(); VT.SetInputData(S1.GetOutPut()); VT.Run(); DS.SetInputData(VT.GetOutPut()); DS.Title = cGlobalInfo.ListWellClasses[IdxClassNeg].Name + " vs. " + cGlobalInfo.ListWellClasses[CurrentClassTobeProcessed].Name; DS.Run(); DT.SetInputData(DS.GetOutPut()); } DT.Run(); cDisplayToWindow CDW = new cDisplayToWindow(); CDW.SetInputData(DT.GetOutPut());//VG1.GetOutPut()); CDW.Title = SubTitle + " - " + TmpPlate.GetName(); CDW.Run(); CDW.Display(); } #endregion #region plate by plate DT = new cDesignerTab(); // cDesignerMultiChoices DT = new cDesignerMultiChoices(); if ((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); } foreach (cPlate TmpPlate in ListPlatesToProcess) { cListWells ListWellsToProcess1 = new cListWells(null); cListWells ListWellsToProcess2 = new cListWells(null); foreach (cWell item in TmpPlate.ListActiveWells) { if (item.GetCurrentClassIdx() != -1) { if (ListClassSelected[0][item.GetCurrentClassIdx()] == 1) ListWellsToProcess1.Add(item); if (ListClassSelected[1][item.GetCurrentClassIdx()] == 1) ListWellsToProcess2.Add(item); } } cExtendedTable NewTable1 = new cExtendedTable(ListWellsToProcess1, true); cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, true); if ((NewTable1.Count == 0) || (NewTable1[0].Count < 2) || (NewTable2.Count == 0) || (NewTable2[0].Count < 2)) { if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked) { MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else continue; } cExtendedList ListZ = new cExtendedList(); List<cDescriptorType> ListDescForZFactor = 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 TableForZ = new cExtendedTable(); TableForZ.Add(NewTable1[RealIdx]); TableForZ.Add(NewTable2[RealIdx]); RealIdx++; cZFactor ZF = new cZFactor(); ZF.SetInputData(TableForZ); ZF.IsRobust = _QCZRobustItem.Checked; ZF.Run(); ListZ.Add(ZF.GetOutPut()[0][1]); ListDescForZFactor.Add(cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc]); } cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListZ)); ET[0].ListTags = new List<object>(); ET[0].ListTags.AddRange(ListDescForZFactor); ET.Name = TmpPlate.GetName() + "\n" + SubTitle + " - " + cGlobalInfo.ListWellClasses[IdxClassNeg].Name + " (" + NewTable1[0].Count + " wells) vs. " + cGlobalInfo.ListWellClasses[IdxClassPos].Name + " (" + NewTable2[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 = SubTitle; 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.Chart.DefaultAxisYMax = new cExtendedList(); VG1.Chart.DefaultAxisYMax.Add(1); if (!cGlobalInfo.OptionsWindow.FFAllOptions.checkBoxZscoreMinValueAutomated.Checked) { VG1.Chart.DefaultAxisYMin = new cExtendedList(); VG1.Chart.DefaultAxisYMin.Add((double)cGlobalInfo.OptionsWindow.FFAllOptions.numericUpDownZscoreMinValue.Value); } VG1.Title = TmpPlate.GetName(); Classes.Base_Classes.General.cLineHorizontalForGraph VLZ05 = new Classes.Base_Classes.General.cLineHorizontalForGraph(.5); VLZ05.IsAllowMoving = true; VG1.Chart.ListHorizontalLines.Add(VLZ05); VG1.Run(); cDesignerSplitter DS = new cDesignerSplitter(); DS.Orientation = Orientation.Vertical; DS.SetInputData(VG1.GetOutPut()); cSort S1 = new cSort(); S1.SetInputData(ET); S1.ColumnIndexForSorting = 0; S1.IsAscending = false; S1.Run(); cViewerTable VT = new cViewerTable(); VT.SetInputData(S1.GetOutPut()); VT.Run(); DS.SetInputData(VT.GetOutPut()); DS.Title = TmpPlate.GetName(); DS.Run(); DT.SetInputData(DS.GetOutPut()); } DT.Run(); cDisplayToWindow CDW = new cDisplayToWindow(); CDW.SetInputData(DT.GetOutPut());//VG1.GetOutPut()); CDW.Title = SubTitle + " - " + 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); cListWells ListWellsToProcess2 = new cListWells(null); foreach (cWell item in TmpPlate.ListActiveWells) { if (item.GetCurrentClassIdx() != -1) { if (ListClassSelected[0][item.GetCurrentClassIdx()] == 1) ListWellsToProcess1.Add(item); if (ListClassSelected[1][item.GetCurrentClassIdx()] == 1) ListWellsToProcess2.Add(item); } } cExtendedTable NewTable1 = new cExtendedTable(ListWellsToProcess1, cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorIndex(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor())); cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorIndex(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor())); //cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, false); if ((NewTable1.Count == 0) || (NewTable1[0].Count < 2) || (NewTable2.Count == 0) || (NewTable2[0].Count < 2)) { if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked) { MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else continue; } cExtendedTable TableForZ = new cExtendedTable(); TableForZ.Add(NewTable1[0]); TableForZ.Add(NewTable2[0]); cZFactor ZF = new cZFactor(); ZF.IsRobust = _QCZRobustItem.Checked; ZF.SetInputData(TableForZ); ZF.Run(); double Zfactor = ZF.GetOutPut()[0][1]; ListZ.Add(Zfactor); // update plate quality TmpPlate.ListProperties.UpdateValueByName("Quality", Math.Exp(Zfactor - 1)); cProperty Prop = TmpPlate.ListProperties.FindByName("Quality"); Prop.Info = ZF.GetInfo(); ListPlatesForZFactor.Add(TmpPlate); } cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListZ)); ET[0].ListTags = new List<object>(); ET[0].ListTags.AddRange(ListPlatesForZFactor); ET.Name = SubTitle + " - " + 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 = SubTitle; 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.Chart.DefaultAxisYMax = new cExtendedList(); VG1.Chart.DefaultAxisYMax.Add(1); if (!cGlobalInfo.OptionsWindow.FFAllOptions.checkBoxZscoreMinValueAutomated.Checked) { VG1.Chart.DefaultAxisYMin = new cExtendedList(); VG1.Chart.DefaultAxisYMin.Add((double)cGlobalInfo.OptionsWindow.FFAllOptions.numericUpDownZscoreMinValue.Value); } Classes.Base_Classes.General.cLineHorizontalForGraph VLZ05 = new Classes.Base_Classes.General.cLineHorizontalForGraph(.5); VLZ05.IsAllowMoving = true; VG1.Chart.ListHorizontalLines.Add(VLZ05); VG1.Title = cGlobalInfo.CurrentScreening.ListDescriptors[cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx].GetName(); VG1.Run(); cDisplayToWindow CDW = new cDisplayToWindow(); CDW.SetInputData(VG1.GetOutPut()); CDW.Title = SubTitle + " - " + ListPlatesToProcess.Count + " plates"; CDW.Run(); CDW.Display(); #endregion } }
public cFeedBackMessage Run(c3DNewWorld _3DWorld) { if (base.Start() == false) { base.FeedBackMessage.IsSucceed = false; return base.FeedBackMessage; } //if (this.Input == null) //{ // FeedBackMessage.IsSucceed = false; // FeedBackMessage.Message = "No input data table defined."; // return FeedBackMessage; //} #region Properties Management object _firstValue = base.ListProperties.FindByName("Normalized ?"); bool IsNormalized = false; if (_firstValue == null) { base.GenerateError("-Normalized ?- not found !"); return base.FeedBackMessage; } try { cProperty TmpProp = (cProperty)_firstValue; IsNormalized = (bool)TmpProp.GetValue(); } catch (Exception) { base.GenerateError("-Normalized ?- cast didn't work"); return base.FeedBackMessage; } _firstValue = base.ListProperties.FindByName("Draw Axis ?"); bool IsdrawAxis = true; if (_firstValue == null) { base.GenerateError("-Draw Axis ?- not found !"); return base.FeedBackMessage; } try { cProperty TmpProp = (cProperty)_firstValue; IsdrawAxis = (bool)TmpProp.GetValue(); } catch (Exception) { base.GenerateError("-Draw Axis ?- cast didn't work"); return base.FeedBackMessage; } _firstValue = base.ListProperties.FindByName("Link Points ?"); bool IsLinked = false; if (_firstValue == null) { base.GenerateError("-Link Points ?- not found !"); return base.FeedBackMessage; } try { cProperty TmpProp = (cProperty)_firstValue; IsLinked = (bool)TmpProp.GetValue(); } catch (Exception) { base.GenerateError("-Link Points ?- cast didn't work"); return base.FeedBackMessage; } #endregion cExtendedList ListLenghtsMax = new cExtendedList(); ListObjects = new cListGeometric3DObject("Scatter Plot MetaObject"); double MinX = this.Input.Min(0); double MaxX = this.Input.Max(0); double DeltaX = MaxX - MinX; ListLenghtsMax.Add(DeltaX); if (DeltaX == 0) DeltaX = 1; double MinY = this.Input.Min(1); double MaxY = this.Input.Max(1); double DeltaY = MaxY - MinY; ListLenghtsMax.Add(DeltaY); if (DeltaY == 0) DeltaY = 1; double MinZ = this.Input.Min(2); double MaxZ = this.Input.Max(2); double DeltaZ = MaxZ - MinZ; ListLenghtsMax.Add(DeltaZ); if (DeltaZ == 0) DeltaZ = 1; double MinRad = 0; double MaxRad = 0; double DeltaRad = 1; double MaxLenght = ListLenghtsMax.Min(); if (MaxLenght <= 0) MaxLenght = 1; for (int CurrentSerie = 0; CurrentSerie < this.Input.Count; CurrentSerie++) { cExtendedTable CurrentTable = this.Input[CurrentSerie]; if ((IndexColumnForSphereRadius > 0) && (IndexColumnForSphereRadius < CurrentTable.Count)) { MinRad = CurrentTable[IndexColumnForSphereRadius].Min(); MaxRad = CurrentTable[IndexColumnForSphereRadius].Max(); if (MaxRad != MinRad) DeltaRad = MaxRad - MinRad; } if (CurrentTable.Count == 0) continue; cListGeometric3DObject TmpListObjects = new cListGeometric3DObject("Scatter MetaObject"); TmpListObjects.Tag = CurrentTable.Tag; cPoint3D Pt = null; for (int IdxPt = 0; IdxPt < CurrentTable[0].Count; IdxPt++) { if(IsNormalized) Pt = new cPoint3D((CurrentTable[0][IdxPt] - MinX) / DeltaX, (CurrentTable[1][IdxPt] - MinY) / DeltaY, (CurrentTable[2][IdxPt] - MinZ) / DeltaZ); else Pt = new cPoint3D(CurrentTable[0][IdxPt], CurrentTable[1][IdxPt], CurrentTable[2][IdxPt]); double Rad = this.Radius; if ((IndexColumnForSphereRadius > 0) && (IndexColumnForSphereRadius < CurrentTable.Count)) { Rad = this.Radius * ((CurrentTable[IndexColumnForSphereRadius][IdxPt] - MinRad)) / DeltaRad; Rad /= 200; } if(IndexColumnForSphereRadius>-1) Rad = CurrentTable[IndexColumnForSphereRadius][IdxPt]; if (IsNormalized) Rad /= 300.0; else { Rad = MaxLenght / 100.0; } c3DSphere Sphere = new c3DSphere(Pt, Rad); //c3DPoint Sphere = new c3DPoint(Pt); if ((CurrentTable.ListRowNames != null) && (CurrentTable.ListRowNames.Count > IdxPt)) { if (CurrentTable.ListRowNames[IdxPt] != null) Sphere.SetName(CurrentTable.ListRowNames[IdxPt]); else Sphere.SetName("Sphere " + IdxPt); } else { Sphere.SetName("Sphere " + IdxPt); } if ((CurrentTable.ListTags != null) && (CurrentTable.ListTags[IdxPt] != null) && (CurrentTable.ListTags[IdxPt].GetType() == typeof(cWell))) { if (CurrentTable.ListTags[IdxPt].GetType() == typeof(cWell)) { Sphere.Colour = ((cWell)(CurrentTable.ListTags[IdxPt])).GetClassType().ColourForDisplay; Sphere.Tag = CurrentTable.ListTags[IdxPt]; } } else //if (this.GlobalInfo != null) { Sphere.Colour = cGlobalInfo.ListCellularPhenotypes[CurrentSerie % cGlobalInfo.ListCellularPhenotypes.Count].ColourForDisplay; } TmpListObjects.AddObject(Sphere); if ((ValueToBeDisplayed > 0) && (ValueToBeDisplayed < CurrentTable.Count)) { if (_3DWorld != null) TmpListObjects.Add(new c3DText(_3DWorld, CurrentTable[ValueToBeDisplayed][IdxPt].ToString("N3"), new cPoint3D(Pt.X + 0.02, Pt.Y + 0.02, Pt.Z + 0.02), Color.White, 0.01)); } } ListObjects.AddRange(TmpListObjects); #region Draw Links if (IsLinked) { cListGeometric3DObject ListLinks = new cListGeometric3DObject( "Links MetaObject"); for (int IdxPt = 1; IdxPt < CurrentTable[0].Count; IdxPt++) { cPoint3D Pt1 = null; cPoint3D Pt0 = null; if (IsNormalized) { Pt1 = new cPoint3D((CurrentTable[0][IdxPt] - MinX) / DeltaX, (CurrentTable[1][IdxPt] - MinY) / DeltaY, (CurrentTable[2][IdxPt] - MinZ) / DeltaZ); Pt0 = new cPoint3D((CurrentTable[0][IdxPt - 1] - MinX) / DeltaX, (CurrentTable[1][IdxPt - 1] - MinY) / DeltaY, (CurrentTable[2][IdxPt - 1] - MinZ) / DeltaZ); } else { Pt1 = new cPoint3D(CurrentTable[0][IdxPt], CurrentTable[1][IdxPt] , CurrentTable[2][IdxPt] ); Pt0 = new cPoint3D(CurrentTable[0][IdxPt - 1] , CurrentTable[1][IdxPt - 1] , CurrentTable[2][IdxPt - 1] ); } // new cPoint3D((CurrentTable[0][IdxPt] - MinX) / DeltaX, (CurrentTable[1][IdxPt] - MinY) / DeltaY, (CurrentTable[2][IdxPt] - MinZ) / DeltaZ); //cPoint3D Pt0 = new cPoint3D((CurrentTable[0][IdxPt - 1] - MinX) / DeltaX, (CurrentTable[1][IdxPt - 1] - MinY) / DeltaY, (CurrentTable[2][IdxPt - 1] - MinZ) / DeltaZ); c3DLine Line = new c3DLine(Pt0, Pt1); Line.SetName("Link ["+(IdxPt-1)+";"+IdxPt+"]"); ListLinks.AddObject(Line); } ListObjects.AddRange(ListLinks); } #endregion } #region Draw Axis if (IsdrawAxis && (this.Input[0].Count > 2)) { c3DObject_Axis Axis = new c3DObject_Axis(); cExtendedTable T = new cExtendedTable(); T.Add(new cExtendedList(Input[0][0].Name)); if (IsNormalized) { T[0].Tag = Input[0][0].Tag; T[0].Add(0); T[0].Add(1); T.Add(new cExtendedList(Input[0][1].Name)); T[1].Tag = Input[0][1].Tag; T[1].Add(0); T[1].Add(1); T.Add(new cExtendedList(Input[0][2].Name)); T[2].Tag = Input[0][2].Tag; T[2].Add(0); T[2].Add(1); } else { T[0].Tag = Input[0][0].Tag; T[0].Add(MinX); T[0].Add(MaxX); T.Add(new cExtendedList(Input[0][1].Name)); T[1].Tag = Input[0][1].Tag; T[1].Add(MinY); T[1].Add(MaxY); T.Add(new cExtendedList(Input[0][2].Name)); T[2].Tag = Input[0][2].Tag; T[2].Add(MinZ); T[2].Add(MaxZ); } Axis.SetInputData(T); Axis.Run(_3DWorld); ListObjects.AddRange(Axis.GetOutPut()); } #endregion // _3DWorld.AddGeometric3DObjects(this.ListObjects); return base.FeedBackMessage; }
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; }
//public FormToDisplayTable() //{ // InitializeComponent(); //} private void ReDraw() { cExtendedList ListX = new cExtendedList(); cExtendedList ListY = new cExtendedList(); if (this.comboBoxAxeY.SelectedIndex == -1) return; if (this.comboBoxVolume.SelectedIndex == -1) return; cExtendedList ListVolumes = new cExtendedList(); for (int j = 0; j < dt.Rows.Count; j++) { ListX.Add(double.Parse(dt.Rows[j][this.comboBoxAxeX.SelectedIndex].ToString())); ListY.Add(double.Parse(dt.Rows[j][this.comboBoxAxeY.SelectedIndex].ToString())); ListVolumes.Add(double.Parse(dt.Rows[j][this.comboBoxVolume.SelectedIndex].ToString())); } this.chartForPoints.ChartAreas[0].AxisX.Title = this.comboBoxAxeX.SelectedItem.ToString(); this.chartForPoints.ChartAreas[0].AxisY.Title = this.comboBoxAxeY.SelectedItem.ToString(); this.chartForPoints.Series[0].Points.DataBindXY(ListX, ListY); if (!checkBoxIsVolumeConstant.Checked) { double MaxVolume = ListVolumes.Max(); double MinVolume = ListVolumes.Min(); for (int j = 0; j < dt.Rows.Count; j++) { int MarkerArea = (int)((50 * (ListVolumes[j] - MinVolume)) / (MaxVolume - MinVolume)); this.chartForPoints.Series[0].Points[j].MarkerSize = MarkerArea; } } }
public cFeedBackMessage Run() { if (this.Input == null) { FeedBackMessage.IsSucceed = false; FeedBackMessage.Message = "No input data defined."; return FeedBackMessage; } // ------------- now proceed ------------- this.OutPut = new cExtendedTable(); this.OutPut.ListRowNames = new List<string>(); this.OutPut.Name = "Mann-Withney Test"; if (FTestTails == eFTestTails.BOTH) this.OutPut.Name += " (both tails)"; else if (FTestTails == eFTestTails.LEFT) this.OutPut.Name += " (left tail)"; else if (FTestTails == eFTestTails.RIGHT) this.OutPut.Name += " (right tail)"; for (int IdxCol = 0; IdxCol < this.Input.Count; IdxCol++) { this.OutPut.ListRowNames.Add(this.Input[IdxCol].Name); cExtendedList NewResult = new cExtendedList(); NewResult.Name = this.Input[IdxCol].Name; for (int IdxColBis = 0; IdxColBis < this.Input.Count; IdxColBis++) { double bothtails; double lefttail; double righttail; alglib.mannwhitneyutest(this.Input[IdxCol].ToArray(), this.Input[IdxCol].Count, this.Input[IdxColBis].ToArray(), this.Input[IdxColBis].Count, out bothtails, out lefttail, out righttail); if (FTestTails == eFTestTails.BOTH) NewResult.Add(bothtails); else if (FTestTails == eFTestTails.LEFT) NewResult.Add(lefttail); else if (FTestTails == eFTestTails.RIGHT) NewResult.Add(righttail); } this.OutPut.Add(NewResult); } return FeedBackMessage; }
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."); }
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; }
/// <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; }
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; }
private void sigmoidFittToolStripMenuItem_Click(object sender, EventArgs e) { int NumberOfReplicate = 4; int NumberOfCurves = 30; int DRCNumberofPoints = 12; cExtendedTable FullResults = new cExtendedTable(); FullResults.ListRowNames = new List<string>(); double RealEC50 = 0.0001; int NumberOfDiffEC50 = 20; int NumberOfSlopes = 100; // for (int EC50 = 0; EC50 < NumberOfDiffEC50; EC50++) { //double TmpSlopeValue = 0.0; for (int EC50 = 0; EC50 < NumberOfDiffEC50; EC50++) //for (int SlopeTmp = 0; SlopeTmp < NumberOfSlopes; SlopeTmp++) { RealEC50 *= 2; //TmpSlopeValue += 0.1; cExtendedList ListPValues = new cExtendedList("EC50 - " + RealEC50/*TmpSlopeValue*/); cDesignerTab DT = new cDesignerTab(); DT.IsMultiline = false; cDataGeneratorTitration GT = new cDataGeneratorTitration(); GT.NumberOfPoint = DRCNumberofPoints; GT.Start = 5; GT.DilutionFactor = 2; GT.Run(); Random RND = new Random(); //cExtendedTable EXT = new cExtendedTable(); //EXT.ListRowNames = new List<string>(); //EXT.Name = "Quality fitting Report"; //EXT.Add(new cExtendedList("Noise Level")); //EXT.Add(new cExtendedList("Original EC50")); //EXT.Add(new cExtendedList("Estimated EC50")); //EXT.Add(new cExtendedList("p-Value")); for (int i = 0; i < NumberOfCurves; i++) { cExtendedTable FinalTable = new cExtendedTable(); cDataGeneratorSigmoid DGS = null; DGS = new cDataGeneratorSigmoid(); DGS.SetInputData(GT.GetOutPut()[0]); DGS.EC50 = RealEC50;// 0.01;// 1;// 0.1;// Math.Pow((double)10, -2); DGS.Bottom = 0; DGS.Top = 100; DGS.Slope = 2;// TmpSlopeValue;//1; DGS.Run(); cAddNoise AN = new cAddNoise(); AN.DistributionType = eRandDistributionType.GAUSSIAN; double NoiseLevel = (i + 1) * 5; // EXT[0].Add(NoiseLevel); // EXT[1].Add(DGS.EC50); #region loop over the replicates for (int NumReplic = 0; NumReplic < NumberOfReplicate; NumReplic++) { //AN.Mean = 0; //AN.Stdv = 10; //AN.SetInputData(DGS.GetOutPut()); //AN.Run(); cExtendedList NewL = DGS.GetOutPut()[1]; for (int k = 0; k < NewL.Count; k++) { NewL[k] += RND.NextDouble() * NoiseLevel; } cExtendedTable TmpTable = new cExtendedTable(); TmpTable.Add(GT.GetOutPut()[0]); TmpTable.Add(/*AN.GetOutPut()[1]*/NewL); if (NumReplic >= 1) { cMerge M = new cMerge(); M.IsHorizontal = false; M.SetInputData(TmpTable, FinalTable); M.Run(); FinalTable = M.GetOutPut(); } else FinalTable = new cExtendedTable(TmpTable); } #endregion //cListWell LW = new cListWell(null); //foreach (cWell item in CompleteScreening.GetCurrentDisplayPlate().ListActiveWells) //{ // if (item.GetClassIdx() == 0) // LW.Add(item); //} //cExtendedTable ET = LW.GetDescriptorValues(CompleteScreening.ListDescriptors.GetActiveDescriptors(), true); cCurveForGraph CFG = new cCurveForGraph(); CFG.SetInputData(FinalTable); CFG.Run(); // compute ANOVA cANOVA S = new cANOVA(); cExtendedTable NewTable = CFG.ListPtValues.Crop(0, CFG.ListPtValues.Count - 1, 1, CFG.ListPtValues[0].Count - 1); S.SignificanceThreshold = 1E-11; S.SetInputData(NewTable); S.Run(); //cLinearRegression LR = new cLinearRegression(); //LR.SetInputData(FinalTable); //LR.Run(); cSigmoidFitting SF = new cSigmoidFitting(); SF.SetInputData(FinalTable); if (SF.Run().IsSucceed == false) continue; // double Ratio = LR.GetOutPut()[0][LR.GetOutPut().Count - 1] / SF.GetOutPut()[0][SF.GetOutPut().Count - 1]; cExtendedTable Sigmoid = SF.GetFittedRawValues(GT.GetOutPut()[0]); FinalTable[0] = Sigmoid[1]; cDesignerSplitter DS = new cDesignerSplitter(); ////cViewerTableAsRichText VT = new cViewerTableAsRichText(); cViewerTable VT = new cViewerTable(); cExtendedTable TableResults = SF.GetOutPut(); TableResults[0].Add(S.GetOutPut()[0][0]); ListPValues.Add(S.GetOutPut()[0][0]); TableResults[0].Add(S.GetOutPut()[0][1]); TableResults.ListRowNames.Add("p-Value"); TableResults.ListRowNames.Add("Null hyp. rejected?"); VT.SetInputData(TableResults); VT.DigitNumber = -1; VT.Run(); cViewerGraph1D VS1 = new cViewerGraph1D(); VS1.SetInputData(new cExtendedTable(Sigmoid[1])); VS1.AddCurve(CFG); VS1.Chart.X_AxisValues = Sigmoid[0];//DGS.GetOutPut()[0]; VS1.Chart.IsLogAxis = true; VS1.Chart.IsLine = true; VS1.Chart.IsShadow = true; VS1.Chart.Opacity = 210; VS1.Chart.LineWidth = 3; VS1.Chart.LabelAxisX = "Concentration"; VS1.Chart.LabelAxisY = "Readout"; VS1.Chart.XAxisFormatDigitNumber = -1; VS1.Chart.IsZoomableX = true; //Classes.Base_Classes.General.cLineVerticalForGraph VLForEC50 = new Classes.Base_Classes.General.cLineVerticalForGraph(SF.GetOutPut()[0][2]); //VLForEC50.AddText("EC50: " + SF.GetOutPut()[0][2].ToString("e3")/* + "\nError Ratio:" + Ratio.ToString("N4")*/); //VS1.Chart.ListVerticalLines.Add(VLForEC50); //VS1.Chart.ArraySeriesInfo = new cSerieInfoDesign[FinalTable.Count]; //EXT[2].Add(SF.GetOutPut()[0][2]); //EXT[3].Add(S.GetOutPut()[0][0]); //for (int IdxCurve = 0; IdxCurve < FinalTable.Count; IdxCurve++) //{ // cSerieInfoDesign TmpSerieInfo = new cSerieInfoDesign(); // TmpSerieInfo.color = Color.FromArgb(100, GlobalInfo.ListCellularPhenotypes[IdxCurve % GlobalInfo.ListCellularPhenotypes.Count].ColourForDisplay); // TmpSerieInfo.markerStyle = MarkerStyle.Circle; // VS1.Chart.ArraySeriesInfo[IdxCurve] = TmpSerieInfo; //} VS1.Run(); DS.SetInputData(VS1.GetOutPut()); DS.SetInputData(VT.GetOutPut()); DS.Orientation = Orientation.Horizontal; DS.Title = "Noise Stdev " + NoiseLevel; DS.Run(); DT.SetInputData(DS.GetOutPut()); // EXT.ListRowNames.Add(DS.Title); } DT.Run(); //cDisplayToWindow DTW = new cDisplayToWindow(); //DTW.SetInputData(DT.GetOutPut()); //DTW.Run(); //DTW.Display(); //cDisplayExtendedTable DET = new cDisplayExtendedTable(); //DET.SetInputData(EXT); //DET.DigitNumber = -1; //DET.Run(); FullResults.Add(ListPValues); } } cDisplayExtendedTable DET = new cDisplayExtendedTable(); DET.SetInputData(FullResults); DET.DigitNumber = -1; DET.Run(); }
private void backgroundWorkerForCSVtoDB_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; CSVsr = new CsvFileReader(PathName); CSVsr.Separator = this.Delimiter.ToCharArray()[0]; CsvRow OriginalNames = new CsvRow(); if (!CSVsr.ReadRow(OriginalNames)) { CSVsr.Close(); return; } int ColPlateName = GetColIdxFor("Plate name", CSVWindow); int ColCol = GetColIdxFor("Column", CSVWindow); int ColRow = GetColIdxFor("Row", CSVWindow); int ColWellPos = GetColIdxFor("Well position", CSVWindow); int ColPhenotypeClass = GetColIdxFor("Phenotype Class", CSVWindow); int[] ColsForDescriptors = GetColsIdxFor("Descriptor", CSVWindow); FormForProgress ProgressWindow = new FormForProgress(); ProgressWindow.Text = "CSV -> DB : processing"; ProgressWindow.Show(); CsvRow CurrentDesc = new CsvRow(); int TotalPlateNumber = 0; int TotalObjectNumber = 0; int TotalWellNumber = 0; string OriginalPlatePlateName; string CurrentPlateName; string ConvertedName; this.CompleteReportString += "Source file: " + PathName + "\n"; this.CompleteReportString += OriginalNames.Count + " features selected.\n"; this.CompleteReportString += "Time stamp: " + DateTime.Now.ToString() + " \n"; if (CSVsr.ReadRow(CurrentDesc) == false) return; do { if (ColPlateName == -1) { ConvertedName = OriginalPlatePlateName = CurrentPlateName = "Generated Plate Name"; } else { OriginalPlatePlateName = CurrentDesc[ColPlateName]; CurrentPlateName = CurrentDesc[ColPlateName]; ConvertedName = ""; foreach (var c in System.IO.Path.GetInvalidFileNameChars()) ConvertedName = OriginalPlatePlateName.Replace(c, '-'); } List<string> ListNameSignature = new List<string>(); for (int idxDesc = 0/*Mode + 1*/; idxDesc < ColsForDescriptors.Length/* + Mode + 1*/; idxDesc++) { string TmpSignature = OriginalNames[ColsForDescriptors[idxDesc]]; TmpSignature = TmpSignature.Replace('[', '_'); TmpSignature = TmpSignature.Replace(']', '_'); ListNameSignature.Add(TmpSignature); } ListNameSignature.Add("Phenotype_Class"); ListNameSignature.Add("Phenotype_Confidence"); cSQLiteDatabase SQDB = new cSQLiteDatabase(SelectedPath + "\\" + ConvertedName, ListNameSignature, true); this.CompleteReportString += "\n" + CurrentPlateName + ":\n"; TotalPlateNumber++; do { string OriginalWellPos; int[] Pos = new int[2]; if (Mode == 1) { Pos = ConvertPosition(CurrentDesc[ColWellPos]); if (Pos == null) { if (MessageBox.Show("Error in converting the current well position.\nGo to Edit->Options->Import-Export->Well Position Mode to fix this.\nDo you want continue ?", "Loading error !", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == System.Windows.Forms.DialogResult.No) { CSVsr.Close(); return; } //else // goto NEXTLOOP; } OriginalWellPos = CurrentDesc[ColWellPos]; } else { if (int.TryParse(CurrentDesc[ColCol], out Pos[0]) == false) goto NEXTLOOP; if (int.TryParse(CurrentDesc[ColRow], out Pos[1]) == false) goto NEXTLOOP; OriginalWellPos = ConvertPosition(int.Parse(CurrentDesc[ColCol]), int.Parse(CurrentDesc[ColRow]));// "("+CurrentDesc[ColCol]+","+CurrentDesc[ColRow]+")"; } string CurrentWellPos = OriginalWellPos; cWellForDatabase WellForDB = new cWellForDatabase(OriginalPlatePlateName, Pos[0], Pos[1]); cExtendedTable ListData = new cExtendedTable(); // for (int idxDesc = 0; idxDesc < ColsForDescriptors.Length; idxDesc++) // ListData[idxDesc] = new List<double>(); ProgressWindow.richTextBoxForComment.AppendText(CurrentPlateName + " : " + CurrentWellPos + "\n"); //ProgressWindow.label.Refresh(); ProgressWindow.Refresh(); do { // CurrentWellPos = CurrentDesc[ColWellPos]; cExtendedList Signature = new cExtendedList(); for (int idxDesc = 0; idxDesc < ColsForDescriptors.Length; idxDesc++) { double Value; if (double.TryParse(CurrentDesc[ColsForDescriptors[idxDesc]], NumberStyles.Any, CultureInfo.InvariantCulture/*.CreateSpecificCulture("en-US")*/, out Value)) { if (double.IsNaN(Value)) Signature.Add(0); else Signature.Add(Value); } else { Signature.Add(0); } } // if the class of the phenotype is defined in the file then use it // if not, put it at 0 double ValueClass; if ((ColPhenotypeClass != -1) && (double.TryParse(CurrentDesc[ColPhenotypeClass], out ValueClass) == true)) { double IntValue = (int)(ValueClass) % cGlobalInfo.ListCellularPhenotypes.Count; Signature.Add(IntValue); } else { Signature.Add(0); } // finally add the classification confidence column (1 by default) Signature.Add(1); ListData.Add(Signature); // WellForDB.AddSignature(Signature); // manage the end of the file if (CSVsr.ReadRow(CurrentDesc) == false) { WellForDB.AddListSignatures(ListData); cFeedBackMessage FeedBackMessage = SQDB.AddNewWell(WellForDB); SQDB.CloseConnection(); // this.CompleteReportString += FeedBackMessage.Message + "\n"; goto NEXTLOOP; } if (ColPlateName == -1) CurrentPlateName = "Generated Plate Name"; else CurrentPlateName = CurrentDesc[ColPlateName]; if (Mode == 1) CurrentWellPos = CurrentDesc[ColWellPos]; else { int ResCol; int ResRow; if ((!int.TryParse(CurrentDesc[ColCol], out ResCol)) || (!int.TryParse(CurrentDesc[ColRow], out ResRow))) goto NEXTLOOP; CurrentWellPos = ConvertPosition(ResCol, ResRow); } TotalObjectNumber++; // NEXTSIGNATURE: ; } while (CurrentWellPos == OriginalWellPos); TotalWellNumber++; WellForDB.AddListSignatures(ListData); SQDB.AddNewWell(WellForDB); ReportTable.ListRowNames.Add(CurrentPlateName + " : " + CurrentWellPos); ReportTable[0].Add(ListData.Count); ReportTable[0].ListTags.Add(CurrentPlateName + " : " + CurrentWellPos + "\n" + ListData.Count + " objects"); this.CompleteReportString += "\t" + CurrentWellPos + " : " + ListData.Count + " objects\n"; NEXTSIGNATURE: ; } while (OriginalPlatePlateName == CurrentPlateName); SQDB.CloseConnection(); } while (true); NEXTLOOP: ; ProgressWindow.Close(); this.CompleteReportString += "\n-----------------------------\n"; this.CompleteReportString += TotalPlateNumber + " plates\n"; this.CompleteReportString += TotalWellNumber + " wells\n"; this.CompleteReportString += TotalObjectNumber + " objects\n"; this.CompleteReportString += "\nDataBase location:\n" + SelectedPath; // worker.ReportProgress(10); }
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(); }
private void ToolStripMenuItem_ZFactor(object sender, EventArgs e) { cGUI_2ClassesSelection GUI_ListClasses = new cGUI_2ClassesSelection(); if (GUI_ListClasses.Run(this.GlobalInfo).IsSucceed == false) return; cExtendedTable ListClassSelected = GUI_ListClasses.GetOutPut(); int IdxClassNeg = -1; int IdxClassPos = -1; for (int IdxC = 0; IdxC < ListClassSelected[0].Count; IdxC++) { if (ListClassSelected[0][IdxC] == 1) IdxClassNeg = IdxC; if (ListClassSelected[1][IdxC] == 1) IdxClassPos = IdxC; } string SubTitle = "Z-Factor"; cListWells ListWellsToProcess1 = new cListWells(null); cListWells ListWellsToProcess2 = new cListWells(null); foreach (cWell item in cGlobalInfo.ListSelectedWell) { if (item.GetCurrentClassIdx() != -1) { if (ListClassSelected[0][item.GetCurrentClassIdx()] == 1) ListWellsToProcess1.Add(item); if (ListClassSelected[1][item.GetCurrentClassIdx()] == 1) ListWellsToProcess2.Add(item); } } cExtendedTable NewTable1 = new cExtendedTable(ListWellsToProcess1, true); cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, true); if ((NewTable1.Count == 0) || (NewTable1[0].Count < 2) || (NewTable2.Count == 0) || (NewTable2[0].Count < 2)) { if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked) { MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } cExtendedList ListZ = new cExtendedList(); List<cDescriptorType> ListDescForZFactor = 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 TableForZ = new cExtendedTable(); TableForZ.Add(NewTable1[RealIdx]); TableForZ.Add(NewTable2[RealIdx]); RealIdx++; cZFactor ZF = new cZFactor(); ZF.SetInputData(TableForZ); ZF.IsRobust = _QCZRobustItem.Checked; ZF.Run(); ListZ.Add(ZF.GetOutPut()[0][1]); ListDescForZFactor.Add(cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc]); } cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListZ)); ET[0].ListTags = new List<object>(); ET[0].ListTags.AddRange(ListDescForZFactor); ET.Name = SubTitle + " - " + cGlobalInfo.ListWellClasses[IdxClassNeg].Name + " (" + NewTable1[0].Count + " wells) vs. " + cGlobalInfo.ListWellClasses[IdxClassPos].Name + " (" + NewTable2[0].Count + " wells)"; ET[0].Name = ET.Name; cSort S = new cSort(); S.SetInputData(ET); S.ColumnIndexForSorting = 0; S.Run(); cViewerGraph1D VG1 = new cViewerGraph1D(); VG1.SetInputData(S.GetOutPut()); VG1.Chart.LabelAxisY = SubTitle; 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.Chart.DefaultAxisYMax = new cExtendedList(); VG1.Chart.DefaultAxisYMax.Add(1); //VG1.Title = TmpPlate.Name; Classes.Base_Classes.General.cLineHorizontalForGraph VLZ05 = new Classes.Base_Classes.General.cLineHorizontalForGraph(.5); VLZ05.IsAllowMoving = true; VG1.Chart.ListHorizontalLines.Add(VLZ05); VG1.Run(); cDesignerSplitter DS = new cDesignerSplitter(); DS.Orientation = Orientation.Vertical; DS.SetInputData(VG1.GetOutPut()); cSort S1 = new cSort(); S1.SetInputData(ET); S1.ColumnIndexForSorting = 0; S1.IsAscending = false; S1.Run(); cViewerTable VT = new cViewerTable(); VT.SetInputData(S1.GetOutPut()); VT.Run(); DS.SetInputData(VT.GetOutPut()); DS.Run(); cDisplayToWindow CDW = new cDisplayToWindow(); CDW.SetInputData(DS.GetOutPut());//VG1.GetOutPut()); CDW.Title = "List Wells - Z Factor"; CDW.Run(); CDW.Display(); }
private void Process() { double[,] DataForLDA = Input.CopyToArray(); //double[,] Basis; //double[] s2; int Info; /************************************************************************* Linear least squares fitting. QR decomposition is used to reduce task to MxM, then triangular solver or SVD-based solver is used depending on condition number of the system. It allows to maximize speed and retain decent accuracy. INPUT PARAMETERS: Y - array[0..N-1] Function values in N points. FMatrix - a table of basis functions values, array[0..N-1, 0..M-1]. FMatrix[I, J] - value of J-th basis function in I-th point. N - number of points used. N>=1. M - number of basis functions, M>=1. OUTPUT PARAMETERS: Info - error code: * -4 internal SVD decomposition subroutine failed (very rare and for degenerate systems only) * 1 task is solved C - decomposition coefficients, array[0..M-1] Rep - fitting report. Following fields are set: * Rep.TaskRCond reciprocal of condition number * R2 non-adjusted coefficient of determination (non-weighted) * RMSError rms error on the (X,Y). * AvgError average error on the (X,Y). * AvgRelError average relative error on the non-zero Y * MaxError maximum error NON-WEIGHTED ERRORS ARE CALCULATED ERRORS IN PARAMETERS This solver also calculates different kinds of errors in parameters and fills corresponding fields of report: * Rep.CovPar covariance matrix for parameters, array[K,K]. * Rep.ErrPar errors in parameters, array[K], errpar = sqrt(diag(CovPar)) * Rep.ErrCurve vector of fit errors - standard deviations of empirical best-fit curve from "ideal" best-fit curve built with infinite number of samples, array[N]. errcurve = sqrt(diag(F*CovPar*F')), where F is functions matrix. * Rep.Noise vector of per-point estimates of noise, array[N] NOTE: noise in the data is estimated as follows: * for fitting without user-supplied weights all points are assumed to have same level of noise, which is estimated from the data * for fitting with user-supplied weights we assume that noise level in I-th point is inversely proportional to Ith weight. Coefficient of proportionality is estimated from the data. NOTE: we apply small amount of regularization when we invert squared Jacobian and calculate covariance matrix. It guarantees that algorithm won't divide by zero during inversion, but skews error estimates a bit (fractional error is about 10^-9). However, we believe that this difference is insignificant for all practical purposes except for the situation when you want to compare ALGLIB results with "reference" implementation up to the last significant digit. -- ALGLIB -- Copyright 17.08.2009 by Bochkanov Sergey *************************************************************************/ double[] weights = null; int fitResult = 0; double[] resultData = new double[this.Input[0].Count]; //alglib.lsfit.lsfitreport rep = new alglib.lsfit.lsfitreport(); //alglib.lsfit.lsfitlinear(resultData, DataForLDA, this.Input[0].Count, this.Input.Count, ref fitResult, ref weights, rep); //alglib.lsfitstate state; int info; //double[] c = new double[] { 0, 0, 0, 0 }; //alglib.lsfitreport Nrep; //alglib.lsfitresults(state, out info, out c, out Nrep); // alglib.fisherldan(DataForLDA, this.Input[0].Count, this.Input.Count - 1, (int)this.Input[this.Input.Count - 1].Max() + 1, out Info, out Basis); //Output = new cExtendedTable(Basis); alglib.linearmodel LM = null; alglib.lrreport Lreport = null; alglib.lrbuild(DataForLDA, this.Input[0].Count, this.Input.Count-1, out info, out LM, out Lreport); //RelativeError = rep.avgrelerror; //LM.innerobj.w[0] = 1; double[] Coeff = null; int NVars; alglib.lrunpack(LM, out Coeff, out NVars); cExtendedList CL = new cExtendedList(); CL.AddRange(Coeff); CL.Name = "Coefficients"; this.Output = new cExtendedTable(CL); this.Output.ListRowNames = new List<string>(); for (int i = 0; i < this.Output[0].Count; i++) this.Output.ListRowNames.Add("Coeff_" + i); double RelativeError = Lreport.avgrelerror; this.Output.ListRowNames.Add("Relative Error"); CL.Add(RelativeError); Output.Name = "Linear regression coeff. of (" + this.Input.Name + ")"; //foreach (var item in Output) //{ // item.ListTags = new List<object>(); // for (int i = 0; i < Output[0].Count; i++) // item.ListTags.Add(this.Input[i].Tag); //} //for (int IdxLDA = 0; IdxLDA < Output.Count; IdxLDA++) //{ // Output[IdxLDA].Name = "LDA_" + (IdxLDA + 1); // Output.ListRowNames.Add(this.Input[IdxLDA].Name); //} }
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."); }
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."); }
public void DisplayXYZ() { if (CompleteScreening == null) return; int DescX = this.comboBoxDescriptorX.SelectedIndex; int DescY = this.comboBoxDescriptorY.SelectedIndex; int DescZ = this.comboBoxDescriptorZ.SelectedIndex; if (DescX < 0) DescX = 0; if (DescY < 0) DescY = 0; if (DescZ < 0) DescZ = 0; int[] Pos = new int[2]; Pos[0] = 0; Pos[1] = 0; if (CurrentWorld == null) { CurrentWorld = new c3DWorld(new cPoint3D(1000, 1000, 1000), new cPoint3D(ListScales[DescX], ListScales[DescY], ListScales[DescZ]), this.renderWindowControl1, Pos, CompleteScreening); } CurrentWorld.SetBackgroundColor(Color.Black); CurrentWorld.ren1.RemoveAllViewProps(); // if (widget != null) widget.SetEnabled(0); Series CurrentSeries = new Series("ScatterPoints"); double MinX = double.MaxValue; double MinY = double.MaxValue; double MinZ = double.MaxValue; double MaxZ = double.MinValue; double MaxX = double.MinValue; double MaxY = double.MinValue; double TempX, TempY, TempZ; int Idx = 0; cExtendPlateList ListPlate = new cExtendPlateList(); cMetaBiologicalObjectList ListMeta = new cMetaBiologicalObjectList("Test"); cBiologicalSpot CurrentSpot1 = new cBiologicalSpot(Color.White, new cPoint3D(0, 0, 0), 1, 4); cMetaBiologicalObject Plate3D = new cMetaBiologicalObject("Data", ListMeta, CurrentSpot1); if (!IsFullScreen) ListPlate.Add(CompleteScreening.GetCurrentDisplayPlate()); else ListPlate = CompleteScreening.ListPlatesActive; vtkUnsignedCharArray colors = vtkUnsignedCharArray.New(); colors.SetName("colors"); colors.SetNumberOfComponents(3); vtkPoints Allpoints = vtkPoints.New(); cExtendedList ListPtX = new cExtendedList(); cExtendedList ListPtY = new cExtendedList(); cExtendedList ListPtZ = new cExtendedList(); for (int i = 0; i < ListPlate.Count; i++) { cPlate CurrentPlate = ListPlate[i]; for (int IdxValue = 0; IdxValue < CompleteScreening.Columns; IdxValue++) for (int IdxValue0 = 0; IdxValue0 < CompleteScreening.Rows; IdxValue0++) { cWell TmpWell = CurrentPlate.GetWell(IdxValue, IdxValue0, true); if (TmpWell != null) { TempX = TmpWell.ListDescriptors[DescX].GetValue(); if (TempX < MinX) MinX = TempX; if (TempX > MaxX) MaxX = TempX; TempY = TmpWell.ListDescriptors[DescY].GetValue(); if (TempY < MinY) MinY = TempY; if (TempY > MaxY) MaxY = TempY; TempZ = TmpWell.ListDescriptors[DescZ].GetValue(); if (TempZ < MinZ) MinZ = TempZ; if (TempZ > MaxZ) MaxZ = TempZ; // cBiologicalSpot CurrentSpot = new cBiologicalSpot(TmpWell.GetColor(), new cPoint3D(TempX, TempY, TempZ), 1, 4); List<char> Col = new List<char>(); Col.Add((char)(TmpWell.GetColor().R)); Col.Add((char)(TmpWell.GetColor().G)); Col.Add((char)(TmpWell.GetColor().B)); // IntPtr unmanagedPointer = Marshal.UnsafeAddrOfPinnedArrayElement(Col.ToArray(), 0); //colors.InsertNextTupleValue(unmanagedPointer); colors.InsertNextTuple3(Col[0], Col[1], Col[2]); ListPtX.Add(TempX); ListPtY.Add(TempY); ListPtZ.Add(TempZ); // CurrentSpot.Name = TmpWell.AssociatedPlate.Name + " - " + TmpWell.GetPosX() + "x" + TmpWell.GetPosY() + " :" + TmpWell.Name; // CurrentSpot.ObjectType = TmpWell.AssociatedPlate.Name + " - " + TmpWell.GetPosX() + "x" + TmpWell.GetPosY() + " :" + TmpWell.Name; // Plate3D.AddObject(CurrentSpot); // CurrentWorld.AddBiological3DObject(CurrentSpot); //CurrentSeries.Points.Add(TempX, TempY); // if (IsFullScreen) // CurrentSeries.Points[Idx].ToolTip = TmpWell.AssociatedPlate.Name + "\n" + TmpWell.GetPosX() + "x" + TmpWell.GetPosY() + " :" + TmpWell.Name; // else // CurrentSeries.Points[Idx].ToolTip = TmpWell.GetPosX() + "x" + TmpWell.GetPosY() + " :" + TmpWell.Name; Idx++; } } } double MinValueX = ListPtX.Min(); double MaxValueX = ListPtX.Max(); cExtendedList NormX = ListPtX.Normalize(MinValueX, MaxValueX); double MinValueY = ListPtY.Min(); double MaxValueY = ListPtY.Max(); cExtendedList NormY = ListPtY.Normalize(MinValueY, MaxValueY); double MinValueZ = ListPtZ.Min(); double MaxValueZ = ListPtZ.Max(); cExtendedList NormZ = ListPtZ.Normalize(MinValueZ, MaxValueZ); for (int IdxPt = 0; IdxPt < ListPtX.Count; IdxPt++) Allpoints.InsertNextPoint(NormX[IdxPt], NormY[IdxPt], NormZ[IdxPt]); vtkPolyData polydata = vtkPolyData.New(); polydata.SetPoints(Allpoints); polydata.GetPointData().SetScalars(colors); vtkSphereSource SphereSource = vtkSphereSource.New(); SphereSource.SetRadius(RadiusSphere); vtkGlyph3D glyph3D = vtkGlyph3D.New(); glyph3D.SetColorModeToColorByScalar(); glyph3D.SetSourceConnection(SphereSource.GetOutputPort()); glyph3D.SetInput(polydata); glyph3D.ScalingOff(); glyph3D.Update(); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(glyph3D.GetOutputPort()); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); CurrentWorld.ren1.AddActor(actor); if ((CompleteScreening.GetCurrentDisplayPlate().ListDRCRegions != null) && (CompleteScreening.GlobalInfo.OptionsWindow.checkBoxConnectDRCPts.Checked)) { foreach (cDRC_Region TmpRegion in CompleteScreening.GetCurrentDisplayPlate().ListDRCRegions) { int cpt = 0; cWell[][] ListWells = TmpRegion.GetListWells(); foreach (cWell[] item in ListWells) { for (int IdxWell = 0; IdxWell < item.Length - 1; IdxWell++) { //cWell TmpWell0 = CompleteScreening.GetCurrentDisplayPlate().GetWell(item[IdxWell], IdxValue0, true); if ((item[IdxWell] != null) && (item[IdxWell + 1] != null) && (item[IdxWell].GetClass() >= -1)) { double StartX = (item[IdxWell].ListDescriptors[DescX].GetValue() - MinValueX) / (MaxValueX - MinValueX); double StartY = (item[IdxWell].ListDescriptors[DescY].GetValue() - MinValueY) / (MaxValueY - MinValueY); double StartZ = (item[IdxWell].ListDescriptors[DescZ].GetValue() - MinValueZ) / (MaxValueZ - MinValueZ); double EndX = (item[IdxWell + 1].ListDescriptors[DescX].GetValue() - MinValueX) / (MaxValueX - MinValueX); double EndY = (item[IdxWell + 1].ListDescriptors[DescY].GetValue() - MinValueY) / (MaxValueY - MinValueY); double EndZ = (item[IdxWell + 1].ListDescriptors[DescZ].GetValue() - MinValueZ) / (MaxValueZ - MinValueZ); cPoint3D StartPt = new cPoint3D(StartX, StartY, StartZ); cPoint3D EndPt = new cPoint3D(EndX, EndY, EndZ); c3DLine NewLine = new c3DLine(StartPt, EndPt); CurrentWorld.AddGeometric3DObject(NewLine); } } } /*List<cDRC> ListDRC = new List<cDRC>(); for (int i = 0; i < CompleteScreening.ListDescriptors.Count; i++) { if (CompleteScreening.ListDescriptors[i].IsActive()) { cDRC CurrentDRC = new cDRC(TmpRegion, CompleteScreening.ListDescriptors[i]); ListDRC.Add(CurrentDRC); cpt++; } } */ //cDRCDisplay DRCDisplay = new cDRCDisplay(ListDRC, GlobalInfo); //if (DRCDisplay.CurrentChart.Series.Count == 0) continue; //DRCDisplay.CurrentChart.Location = new Point((DRCDisplay.CurrentChart.Width + 50) * 0, (DRCDisplay.CurrentChart.Height + 10 + DRCDisplay.CurrentRichTextBox.Height) * h++); //DRCDisplay.CurrentRichTextBox.Location = new Point(DRCDisplay.CurrentChart.Location.X, DRCDisplay.CurrentChart.Location.Y + DRCDisplay.CurrentChart.Height + 5); //WindowforDRCsDisplay.LChart.Add(DRCDisplay.CurrentChart); //WindowforDRCsDisplay.LRichTextBox.Add(DRCDisplay.CurrentRichTextBox); } } // vtkAxesActor axis = vtkAxesActor.New(); vtkAxisActor axisX = vtkAxisActor.New(); axisX.SetPoint1(0, 0, 0); axisX.SetPoint2(1, 0, 0); axisX.SetTickLocationToBoth(); axisX.SetDeltaMajor(0.1); axisX.SetMajorTickSize(0); axisX.MinorTicksVisibleOff(); //axisX.Maj CurrentWorld.ren1.AddActor(axisX); vtkAxisActor axisY = vtkAxisActor.New(); axisY.SetPoint1(0, 0, 0); axisY.SetPoint2(0, 1, 0); axisY.SetTickLocationToBoth(); axisY.SetDeltaMajor(0.1); axisY.SetMajorTickSize(0.05); axisY.MinorTicksVisibleOff(); CurrentWorld.ren1.AddActor(axisY); vtkAxisActor axisZ = vtkAxisActor.New(); axisZ.SetPoint1(0, 0, 0); axisZ.SetPoint2(0, 0, 1); axisZ.SetTickLocationToBoth(); axisZ.SetDeltaMajor(0.1); axisZ.SetMajorTickSize(0.05); axisZ.MinorTicksVisibleOff(); CurrentWorld.ren1.AddActor(axisZ); if (widget == null) { widget = vtkOrientationMarkerWidget.New(); axes = vtkAxesActor.New(); widget.SetOutlineColor(0.9300, 0.5700, 0.1300); widget.SetInteractor(CurrentWorld.iren); widget.SetViewport(0.0, 0.0, 0.4, 0.4); widget.SetEnabled(0); // widget.InteractiveOn(); if (this.comboBoxDescriptorX.SelectedItem == null) axes.SetXAxisLabelText(this.comboBoxDescriptorX.Items[0].ToString()); else axes.SetXAxisLabelText(this.comboBoxDescriptorX.SelectedItem.ToString()); if (this.comboBoxDescriptorY.SelectedItem == null) axes.SetYAxisLabelText(this.comboBoxDescriptorY.Items[0].ToString()); else axes.SetYAxisLabelText(this.comboBoxDescriptorY.SelectedItem.ToString()); if (this.comboBoxDescriptorZ.SelectedItem == null) axes.SetZAxisLabelText(this.comboBoxDescriptorZ.Items[0].ToString()); else axes.SetZAxisLabelText(this.comboBoxDescriptorZ.SelectedItem.ToString()); widget.SetOrientationMarker(axes); } else { if(this.comboBoxDescriptorX.SelectedItem!=null) axes.SetXAxisLabelText(this.comboBoxDescriptorX.SelectedItem.ToString()); if (this.comboBoxDescriptorY.SelectedItem != null) axes.SetYAxisLabelText(this.comboBoxDescriptorY.SelectedItem.ToString()); if (this.comboBoxDescriptorZ.SelectedItem != null) axes.SetZAxisLabelText(this.comboBoxDescriptorZ.SelectedItem.ToString()); widget.SetOrientationMarker(axes); } // //vtkCameraWidget Wid = vtkCameraWidget.New(); //Wid.SetInteractor(CurrentWorld.iren); //Wid.SetEnabled(1); // Wid.InteractiveOn(); //vtkDistanceWidget distanceWidget = vtkDistanceWidget.New(); //distanceWidget.SetInteractor(CurrentWorld.iren); //distanceWidget.SetEnabled(1); //distanceWidget.CreateDefaultRepresentation(); //((vtkDistanceRepresentation)distanceWidget.GetRepresentation()).SetLabelFormat("%-#6.3g mm"); /*static_cast<vtkDistanceRepresentation*>(distanceWidget->GetRepresentation()) ->SetLabelFormat("%-#6.3g mm"); */ // Plate3D.GenerateAndDisplayBoundingBox(1, Color.White, false, CurrentWorld); //c3DText CaptionX = new c3DText(CurrentWorld, CompleteScreening.ListDescriptors[DescX].GetName(), new cPoint3D(MaxX, MinY, MinZ), Color.DarkRed, this.FontSize); //c3DLine LineX = new c3DLine(new cPoint3D(MinX, MinY, MinZ), new cPoint3D(MaxX, MinY, MinZ), Color.DarkRed); //CurrentWorld.AddGeometric3DObject(LineX); //c3DText CaptionY = new c3DText(CurrentWorld, CompleteScreening.ListDescriptors[DescY].GetName(), new cPoint3D(MinX, MaxY, MinZ), Color.DarkGreen, this.FontSize); //c3DLine LineY = new c3DLine(new cPoint3D(MinX, MinY, MinZ), new cPoint3D(MinX, MaxY, MinZ), Color.DarkGreen); //CurrentWorld.AddGeometric3DObject(LineY); //c3DText CaptionZ = new c3DText(CurrentWorld, CompleteScreening.ListDescriptors[DescZ].GetName(), new cPoint3D(MinX, MinY, MaxZ), Color.DarkBlue, this.FontSize); //c3DLine LineZ = new c3DLine(new cPoint3D(MinX, MinY, MinZ), new cPoint3D(MinX, MinY, MaxZ), Color.DarkBlue); //CurrentWorld.AddGeometric3DObject(LineZ); CurrentWorld.SimpleRender();// Render(); }