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(); }
public void DisplayXY() { if (CompleteScreening == null) return; int DescX = this.comboBoxDescriptorX.SelectedIndex; int DescY = this.comboBoxDescriptorY.SelectedIndex; if (DescX < 0) DescX = 0; if (DescY < 0) DescY = 0; CurrentSeries = new Series("ScatterPoints"); CurrentSeries.ShadowOffset = 1; double MinX = double.MaxValue; double MinY = double.MaxValue; double MaxX = double.MinValue; double MaxY = double.MinValue; double TempX, TempY; int Idx = 0; cExtendPlateList ListPlate = new cExtendPlateList(); if (!IsFullScreen) ListPlate.Add(CompleteScreening.GetCurrentDisplayPlate()); else ListPlate = CompleteScreening.ListPlatesActive; 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; CurrentSeries.Points.AddXY(TempX, TempY); CurrentSeries.Points[Idx].Color = TmpWell.GetColor(); 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; CurrentSeries.Points[Idx].MarkerStyle = MarkerStyle.Circle; CurrentSeries.Points[Idx].MarkerSize = 8; Idx++; } } } CurrentChartArea.CursorX.IsUserSelectionEnabled = true; CurrentChartArea.BorderColor = Color.Black; this.chartForSimpleFormXY.ChartAreas.Clear(); this.chartForSimpleFormXY.ChartAreas.Add(CurrentChartArea); this.chartForSimpleFormXY.TextAntiAliasingQuality = TextAntiAliasingQuality.High; CurrentChartArea.BackColor = Color.FromArgb(164, 164, 164); CurrentChartArea.Axes[0].Title = CompleteScreening.ListDescriptors[DescX].GetName(); CurrentChartArea.Axes[0].Minimum = MinX; CurrentChartArea.Axes[0].Maximum = MaxX; CurrentChartArea.Axes[1].Title = CompleteScreening.ListDescriptors[DescY].GetName(); CurrentChartArea.Axes[1].Minimum = MinY; CurrentChartArea.Axes[1].Maximum = MaxY; CurrentChartArea.AxisX.LabelStyle.Format = "N2"; CurrentChartArea.AxisY.LabelStyle.Format = "N2"; CurrentSeries.ChartType = SeriesChartType.Point; this.chartForSimpleFormXY.Series.Clear(); this.chartForSimpleFormXY.Series.Add(CurrentSeries); this.Text = "Scatter Point / " + Idx+ " points"; this.chartForSimpleFormXY.Update(); }
public string GeneratePCADescriptor(cExtendPlateList PlatesToProcess, int NumberOfAxis, int NeutralClass) { int NumWell = 0; int NumWellForLearning = 0; foreach (cPlate CurrentPlate in PlatesToProcess) { NumWellForLearning += CurrentPlate.GetNumberOfWellOfClass(NeutralClass); NumWell += CompleteScreening.GetCurrentDisplayPlate().GetNumberOfActiveWells(); } if (NumWellForLearning == 0) { MessageBox.Show("No well identified !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return null; } int NumDesc = CompleteScreening.GetNumberOfActiveDescriptor(); if (NumDesc <= 1) { MessageBox.Show("More than one descriptor are required for this operation", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return null; } double[,] DataForLDA = new double[NumWellForLearning, CompleteScreening.GetNumberOfActiveDescriptor() + 1]; // return; Matrix EigenVectors = PCAComputation(DataForLDA, NumWellForLearning, NumWell, NumDesc, NeutralClass, PlatesToProcess); string AxeName = ""; int IDxDesc = 0; //for (int Desc = 0; Desc < CompleteScreening.ListDescriptors.Count; Desc++) //{ // if (CompleteScreening.ListDescriptors[Desc].IsActive() == false) continue; // // AxeName += String.Format("{0:0.##}", EigenVectors.getElement(CompleteScreening.ListDescriptors.Count - 1, 0)) + "x" + CompleteScreening.ListDescriptorName[CompleteScreening.ListDescriptors.Count - 1]; //} int OriginalDescNumber = CompleteScreening.GlobalInfo.WindowHCSAnalyzer.checkedListBoxActiveDescriptors.Items.Count; for (int AxesIdx = 0; AxesIdx < NumberOfAxis; AxesIdx++) { //for (int Idx = 0; Idx < CompleteScreening.GlobalInfo.WindowHCSAnalyzer.checkedListBoxActiveDescriptors.Items.Count; Idx++) //{ // if (CompleteScreening.ListDescriptors[Idx].IsActive()) // if (CompleteScreening.ListDescriptors[Idx].GetBinNumber() == 1) // { // AxeName += String.Format("{0:0.###}", EigenVectors.getElement(IDxDesc++, AxesIdx)) + "x" + CompleteScreening.ListDescriptors[Idx].GetName() + " + "; // } // else // { // MessageBox.Show("Descriptor length not consistent (" + CompleteScreening.ListDescriptors[Idx].GetName() + " : " + CompleteScreening.ListDescriptors[Idx].GetBinNumber() + " bins", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // return; // } // } //cDescriptorsType ColumnType = new cDescriptorsType(AxeName.Remove(AxeName.Length - 3), true, 1); cDescriptorsType ColumnType = new cDescriptorsType("PCA_" + (AxesIdx + 1), true, 1, GlobalInfo); CompleteScreening.ListDescriptors.AddNew(ColumnType); foreach (cPlate TmpPlate in CompleteScreening.ListPlatesAvailable) { foreach (cWell Tmpwell in TmpPlate.ListActiveWells) { List<cDescriptor> LDesc = new List<cDescriptor>(); double NewValue = 0; IDxDesc = 0; // AxeName += "\nPCA_" + (AxesIdx + 1); for (int Idx = 0; Idx < OriginalDescNumber - 1; Idx++) { if (CompleteScreening.ListDescriptors[Idx].IsActive()) // AxeName += String.Format("{0:0.###}", EigenVectors.getElement(IDxDesc, AxesIdx)) + "x" + CompleteScreening.ListDescriptors[Idx].GetName() + " + "; NewValue += EigenVectors.getElement(IDxDesc++, AxesIdx) * Tmpwell.ListDescriptors[Idx].GetValue(); } cDescriptor NewDesc = new cDescriptor(NewValue, ColumnType, CompleteScreening); LDesc.Add(NewDesc); Tmpwell.AddDescriptors(LDesc); } } } CompleteScreening.ListDescriptors.UpDateDisplay(); CompleteScreening.UpDatePlateListWithFullAvailablePlate(); for (int idxP = 0; idxP < CompleteScreening.ListPlatesActive.Count; idxP++) CompleteScreening.ListPlatesActive[idxP].UpDataMinMax(); StartingUpDateUI(); return AxeName; }
private void aToolStripMenuItem_Click(object sender, EventArgs e) { cExtendPlateList ListToProcess = new cExtendPlateList(); ListToProcess.Add(CompleteScreening.GetCurrentDisplayPlate()); ComputeAndDisplayPCA(ListToProcess); }
private Matrix PCAComputation(double[,] DataForPCA, int NumWellForLearning, int NumWell, int NumDesc, int NeutralClass, cExtendPlateList PlatesToProcess) { for (int desc = 0; desc < NumDesc; desc++) { if (CompleteScreening.ListDescriptors[desc].IsActive() == false) continue; List<double> CurrentDesc = new List<double>(); foreach (cPlate CurrentPlate in PlatesToProcess) { 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) || (TmpWell.GetClass() != NeutralClass)) continue; CurrentDesc.Add(TmpWell.ListDescriptors[desc].GetValue()); } } for (int i = 0; i < NumWellForLearning; i++) { DataForPCA[i, desc] = CurrentDesc[i]; } } int IDx = 0; foreach (cPlate CurrentPlate in PlatesToProcess) { foreach (cWell CurrentWell in CurrentPlate.ListActiveWells) { if (CurrentWell.GetClass() == NeutralClass) DataForPCA[IDx++, NumDesc] = CurrentWell.GetClass(); } NumWell += CompleteScreening.GetCurrentDisplayPlate().GetNumberOfActiveWells(); } double[,] Basis; double[] s2; int Info; alglib.pcabuildbasis(DataForPCA, NumWellForLearning, NumDesc, out Info, out s2, out Basis); Matrix EigenVectors = null; if (Info > 0) { EigenVectors = new Matrix(NumDesc, NumDesc); for (int row = 0; row < NumDesc; row++) for (int col = 0; col < NumDesc; col++) EigenVectors.addElement(row, col, Basis[row, col]); } return EigenVectors; }
private void GeneratePCADescriptorItem(object sender, EventArgs e) { FormForPCAAxisGeneration WindowClassification = new FormForPCAAxisGeneration(CompleteScreening); //WindowClassification.buttonClassification.Text = "Process"; WindowClassification.label1.Text = "Class of Interest"; WindowClassification.Text = "PCA"; WindowClassification.IsPCA = true; WindowClassification.numericUpDownNumberOfAxis.Maximum = CompleteScreening.GetNumberOfActiveDescriptor(); // if (WindowClassification.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; cExtendPlateList PlatesToProcess = new cExtendPlateList(); if (WindowClassification.radioButtonFromCurrentPlate.Checked) PlatesToProcess.Add(CompleteScreening.GetCurrentDisplayPlate()); else PlatesToProcess = CompleteScreening.ListPlatesActive; WindowClassification.PlatesToProcess = PlatesToProcess; if (WindowClassification.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; }
private void GenerateLADDescriptorItem(object sender, EventArgs e) { FormForPCAAxisGeneration WindowClassification = new FormForPCAAxisGeneration(CompleteScreening); //WindowClassification.buttonClassification.Text = "Process"; WindowClassification.label1.Text = "Neutral Class"; WindowClassification.Text = "LDA"; WindowClassification.IsPCA = false; WindowClassification.numericUpDownNumberOfAxis.Visible = false; WindowClassification.labelAxeNumber.Visible = false; // // int NeutralClass = WindowClassification.comboBoxForNeutralClass.SelectedIndex; cExtendPlateList PlatesToProcess = new cExtendPlateList(); if (WindowClassification.radioButtonFromCurrentPlate.Checked) PlatesToProcess.Add(CompleteScreening.GetCurrentDisplayPlate()); else PlatesToProcess = CompleteScreening.ListPlatesActive; WindowClassification.PlatesToProcess = PlatesToProcess; if (WindowClassification.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; }
private void ComputeAndDisplayPCA(cExtendPlateList PlatesToProcess) { if (CompleteScreening == null) return; FormClassification WindowClassification = new FormClassification(CompleteScreening); WindowClassification.label1.Text = "Class of interest"; WindowClassification.Text = "PCA"; WindowClassification.buttonClassification.Text = "Process"; if (WindowClassification.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; int NeutralClass = WindowClassification.comboBoxForNeutralClass.SelectedIndex; int NumWell = 0; int NumWellForLearning = 0; foreach (cPlate CurrentPlate in PlatesToProcess) { foreach (cWell CurrentWell in CurrentPlate.ListActiveWells) { if (CurrentWell.GetClass() == NeutralClass) NumWellForLearning++; } NumWell += CurrentPlate.GetNumberOfActiveWells(); } if (NumWellForLearning == 0) { MessageBox.Show("No well of the selected class identified", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int NumDesc = CompleteScreening.GetNumberOfActiveDescriptor(); if (NumDesc <= 1) { MessageBox.Show("More than one descriptor are required for this operation", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } double[,] DataForPCA = new double[NumWellForLearning, CompleteScreening.GetNumberOfActiveDescriptor() + 1]; // return; Matrix EigenVectors = PCAComputation(DataForPCA, NumWellForLearning, NumWell, NumDesc, NeutralClass, PlatesToProcess); if (EigenVectors == null) return; SimpleForm NewWindow = new SimpleForm(CompleteScreening); Series CurrentSeries = new Series(); CurrentSeries.ShadowOffset = 1; Matrix CurrentPt = new Matrix(NumWell, NumDesc); DataForPCA = new double[NumWell, NumDesc + 1]; for (int desc = 0; desc < NumDesc; desc++) { if (CompleteScreening.ListDescriptors[desc].IsActive() == false) continue; List<double> CurrentDesc = new List<double>(); foreach (cPlate CurrentPlate in PlatesToProcess) { 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) continue; CurrentDesc.Add(TmpWell.ListDescriptors[desc].GetValue()); } } for (int i = 0; i < NumWell; i++) DataForPCA[i, desc] = CurrentDesc[i]; } int IDx = 0; foreach (cPlate CurrentPlate in PlatesToProcess) { 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) continue; DataForPCA[IDx++, NumDesc] = TmpWell.GetClass(); } } for (int i = 0; i < NumWell; i++) for (int j = 0; j < NumDesc; j++) CurrentPt.addElement(i, j, DataForPCA[i, j]); Matrix NewPt = new Matrix(NumWell, NumDesc); NewPt = CurrentPt.multiply(EigenVectors); double MinY = double.MaxValue, MaxY = double.MinValue; for (int IdxValue0 = 0; IdxValue0 < NumWell; IdxValue0++) { double CurrentY = NewPt.getElement(IdxValue0, 1); if (CurrentY < MinY) MinY = CurrentY; if (CurrentY > MaxY) MaxY = CurrentY; CurrentSeries.Points.AddXY(NewPt.getElement(IdxValue0, 0), CurrentY); CurrentSeries.Points[IdxValue0].Color = CompleteScreening.GlobalInfo.GetColor((int)DataForPCA[IdxValue0, NumDesc]); CurrentSeries.Points[IdxValue0].MarkerStyle = MarkerStyle.Circle; CurrentSeries.Points[IdxValue0].MarkerSize = 8; } ChartArea CurrentChartArea = new ChartArea(); CurrentChartArea.BorderColor = Color.Black; NewWindow.chartForSimpleForm.ChartAreas.Add(CurrentChartArea); NewWindow.chartForSimpleForm.TextAntiAliasingQuality = TextAntiAliasingQuality.High; CurrentChartArea.BackColor = Color.FromArgb(164, 164, 164); string AxeName = ""; int IDxDesc = 0; for (int Desc = 0; Desc < CompleteScreening.ListDescriptors.Count; Desc++) { if (CompleteScreening.ListDescriptors[Desc].IsActive() == false) continue; AxeName += String.Format("{0:0.###}", EigenVectors.getElement(IDxDesc++, 0)) + "x" + CompleteScreening.ListDescriptors[Desc].GetName() + " + "; // AxeName += String.Format("{0:0.##}", EigenVectors.getElement(CompleteScreening.ListDescriptors.Count - 1, 0)) + "x" + CompleteScreening.ListDescriptorName[CompleteScreening.ListDescriptors.Count - 1]; } CurrentChartArea.Axes[0].Title = AxeName.Remove(AxeName.Length - 3); CurrentChartArea.Axes[0].MajorGrid.Enabled = true; AxeName = ""; IDxDesc = 0; for (int Desc = 0; Desc < CompleteScreening.ListDescriptors.Count; Desc++) { if (CompleteScreening.ListDescriptors[Desc].IsActive() == false) continue; AxeName += String.Format("{0:0.###}", EigenVectors.getElement(IDxDesc++, 1)) + "x" + CompleteScreening.ListDescriptors[Desc].GetName() + " + "; } //AxeName += String.Format("{0:0.##}", EigenVectors.getElement(CompleteScreening.ListDescriptors.Count - 1, 0)) + "x" + CompleteScreening.ListDescriptorName[CompleteScreening.ListDescriptors.Count - 1]; CurrentChartArea.Axes[1].Title = AxeName.Remove(AxeName.Length - 3); CurrentChartArea.Axes[1].MajorGrid.Enabled = true; CurrentChartArea.Axes[1].Minimum = MinY; CurrentChartArea.Axes[1].Maximum = MaxY; CurrentChartArea.AxisX.LabelStyle.Format = "N2"; CurrentChartArea.AxisY.LabelStyle.Format = "N2"; CurrentSeries.ChartType = SeriesChartType.Point; if (GlobalInfo.OptionsWindow.checkBoxDisplayFastPerformance.Checked) CurrentSeries.ChartType = SeriesChartType.FastPoint; NewWindow.chartForSimpleForm.Series.Add(CurrentSeries); NewWindow.Text = "PCA"; NewWindow.Show(); NewWindow.chartForSimpleForm.Update(); NewWindow.chartForSimpleForm.Show(); NewWindow.Controls.AddRange(new System.Windows.Forms.Control[] { NewWindow.chartForSimpleForm }); }
public bool DisplayXY() { if (CompleteScreening == null) return false; int DescX = this.comboBoxDescriptorX.SelectedIndex; int DescY = this.comboBoxDescriptorY.SelectedIndex; if (DescX < 0) DescX = 0; if (DescY < 0) DescY = 0; CurrentSeries = new Series("ScatterPoints"); CurrentSeries.ShadowOffset = 1; double MinX = double.MaxValue; double MinY = double.MaxValue; double MaxX = double.MinValue; double MaxY = double.MinValue; double TempX, TempY; int Idx = 0; cExtendPlateList ListPlate = new cExtendPlateList(); if (!IsFullScreen) ListPlate.Add(CompleteScreening.GetCurrentDisplayPlate()); else ListPlate = CompleteScreening.ListPlatesActive; 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; CurrentSeries.Points.AddXY(TempX, TempY); CurrentSeries.Points[Idx].Color = TmpWell.GetColor(); 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; CurrentSeries.Points[Idx].Tag = TmpWell; CurrentSeries.Points[Idx].MarkerStyle = MarkerStyle.Circle; CurrentSeries.Points[Idx].MarkerSize = 8; Idx++; } } } if (CurrentSeries.Points.Count < 2) { MessageBox.Show("Statistical Analyses - More than one data point needed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } CurrentChartArea.CursorX.IsUserSelectionEnabled = true; CurrentChartArea.CursorY.IsUserSelectionEnabled = true; CurrentChartArea.BorderColor = Color.Black; this.chartForSimpleFormXY.ChartAreas.Clear(); this.chartForSimpleFormXY.ChartAreas.Add(CurrentChartArea); this.chartForSimpleFormXY.TextAntiAliasingQuality = TextAntiAliasingQuality.High; CurrentChartArea.BackColor = Color.FromArgb(164, 164, 164); CurrentChartArea.Axes[0].Title = CompleteScreening.ListDescriptors[DescX].GetName(); CurrentChartArea.Axes[0].Minimum = MinX; CurrentChartArea.Axes[0].Maximum = MaxX; CurrentChartArea.Axes[1].Title = CompleteScreening.ListDescriptors[DescY].GetName(); CurrentChartArea.Axes[1].Minimum = MinY; CurrentChartArea.Axes[1].Maximum = MaxY; CurrentChartArea.AxisX.LabelStyle.Format = "N2"; CurrentChartArea.AxisY.LabelStyle.Format = "N2"; CurrentSeries.ChartType = SeriesChartType.Point; this.chartForSimpleFormXY.Series.Clear(); this.chartForSimpleFormXY.Series.Add(CurrentSeries); this.Text = "Scatter Point / " + Idx + " points"; // this.chartForSimpleFormXY.GetToolTipText += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.ToolTipEventArgs>(this.chartForSimpleFormXY_GetToolTipText); this.chartForSimpleFormXY.Update(); return true; }