// static cImageAccessor ImageAccessor; public cSingleBiologicalObject(cCellularPhenotype CellularPhenotypeType, cWell AssociatedWell, int Idx) { // this.GlobalInfo = GlobalInfo; // this.Class = Class; this.CellularPhenotypeType = CellularPhenotypeType; this.AssociatedWell = AssociatedWell; }
// protected Size SizeHisto = new System.Drawing.Size(10, 5); public cWell(cWell NewWell) { this.PosX = NewWell.PosX; this.PosY = NewWell.PosY; this.ListDescriptors = NewWell.ListDescriptors; this.Parent = NewWell.Parent; this.AssociatedChart = NewWell.AssociatedChart; this.AssociatedPlate = NewWell.AssociatedPlate; this.CurrentColor = this.Parent.GlobalInfo.GetColor(ClassForClassif); }
public int AddWellToDataTable(cWell Well, DataTable DataTableToAddedTo, cGlobalInfo GlobalInfo) { SQLiteCommand mycommand = new SQLiteCommand(_SQLiteConnection); mycommand.CommandText = "SELECT * FROM \"" + Well.SQLTableName + "\""; SQLiteDataReader value = mycommand.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(value); List<string> Names = this.GetDescriptorNames(Well); int CurrentClass = Well.GetCurrentClassIdx(); if (DataTableToAddedTo.Columns.Count == 0) { foreach (string TmpName in Names) { int DescIdx = cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorIndex(TmpName); if ((DescIdx != -1) && (cGlobalInfo.CurrentScreening.ListDescriptors[DescIdx].IsActive())) DataTableToAddedTo.Columns.Add(new DataColumn(TmpName, typeof(double))); } //if (IsAddWellClass) // DataTableToAddedTo.Columns.Add(new DataColumn("Well_Class", typeof(int))); } for (int i = 0; i < dt.Rows.Count; i++) { DataTableToAddedTo.Rows.Add(); int RealIdxCol = 0; for (int IdxCol = 0; IdxCol < Names.Count; IdxCol++) { int DescIdx = cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorIndex(Names[IdxCol]); if ((DescIdx != -1) && (cGlobalInfo.CurrentScreening.ListDescriptors[DescIdx].IsActive())) { DataTableToAddedTo.Rows[DataTableToAddedTo.Rows.Count - 1][RealIdxCol++] = dt.Rows[i][IdxCol]; } } //if (IsAddWellClass) // DataTableToAddedTo.Rows[DataTableToAddedTo.Rows.Count - 1][DataTableToAddedTo.Columns.Count - 1] = CurrentClass; } mycommand.Dispose(); mycommand = null; value.Close(); value.Dispose(); value = null; return dt.Rows.Count; }
/// <summary> /// Draw the dendogram signature for a specific well /// </summary> /// <param name="Well"></param> /// <param name="Size"></param> /// <param name="PosX"></param> /// <param name="PosY"></param> /// <returns>Lenght of the signature</returns> private int DrawSignature(cWell Well, int Size, int PosX, int PosY) { int RealIdx = 0; int SizeFont = Size / 4; int ScrollShiftY = this.VerticalScroll.Value; double Min, Max; int ConvertedValue; g.DrawString("[" + Well.GetPosX() + "x" + Well.GetPosY() + "]", new Font("Arial", 8), Brushes.Black, 15, PosY - ScrollShiftY); Rectangle CurrentRect = new Rectangle(5, PosY, 8, Size); SolidBrush CurrBrush = new SolidBrush(Well.GetClassColor()); // draw the rectangle g.FillRectangle(CurrBrush, CurrentRect); for (int iDesc = 0; iDesc < cGlobalInfo.CurrentScreening.ListDescriptors.Count; iDesc++) { if (!cGlobalInfo.CurrentScreening.ListDescriptors[iDesc].IsActive()) continue; // specify the rect shape CurrentRect = new Rectangle(PosX + RealIdx * Size, PosY, Size, Size); // specify the color cSignature CurrentDesc = Well.ListSignatures[iDesc]; byte[][] LUT = cGlobalInfo.CurrentPlateLUT; Min = CurrentDendo.InfoForHierarchical.ListMin[RealIdx]; Max = CurrentDendo.InfoForHierarchical.ListMax[RealIdx]; if (Min == Max) ConvertedValue = 0; else ConvertedValue = (int)(((CurrentDesc.GetValue() - Min) * (LUT[0].Length - 1)) / (Max - Min)); if (ConvertedValue >= LUT[0].Length) ConvertedValue = LUT[0].Length - 1; CurrBrush = new SolidBrush(Color.FromArgb(LUT[0][ConvertedValue], LUT[1][ConvertedValue], LUT[2][ConvertedValue])); // draw the rectangle g.FillRectangle(CurrBrush, CurrentRect); RealIdx++; } return PosX + RealIdx * Size; }
public void ChangePhenotypeClass(cWell Well, cExtendedList ListNewClasses) { using (SQLiteTransaction transaction = _SQLiteConnection.BeginTransaction()) using (SQLiteDataAdapter sqliteAdapter = new SQLiteDataAdapter("SELECT * FROM \"" + Well.SQLTableName + "\"", _SQLiteConnection)) { DataSet DS = new DataSet(); sqliteAdapter.Fill(DS); using (sqliteAdapter.InsertCommand = new SQLiteCommandBuilder(sqliteAdapter).GetUpdateCommand()) { for (int i = 0; i < DS.Tables[0].Rows.Count; i++) DS.Tables[0].Rows[i]["Phenotype_Class"] = ListNewClasses[i]; sqliteAdapter.Update(DS); } transaction.Commit(); } return; }
public c3DWell(cPoint3D MinPt, cPoint3D MaxPt, Color Colour, cWell CurrentWell) { this.SetPosition(new cPoint3D(0, 0, 0)); this.Colour = Colour; VTK_Cube = vtkCubeSource.New(); //VTK_Cube.SetBounds(MinPt.X, MaxPt.X, MinPt.Y, MaxPt.Y, MinPt.Z, MaxPt.Z); VTK_Cube.SetXLength(MaxPt.X - MinPt.X); VTK_Cube.SetYLength(MaxPt.Y - MinPt.Y); VTK_Cube.SetZLength(MaxPt.Z - MinPt.Z); vtk_PolyDataMapper = vtkPolyDataMapper.New(); vtk_PolyDataMapper.SetInputConnection(VTK_Cube.GetOutputPort()); this.SetPosition(MinPt); this.Colour = Colour; this.AssociatedWell = CurrentWell; CreateVTK3DObject(1); Information = new cInformation(this); }
public FormForWellInformation(cWell CurrentWell) { InitializeComponent(); this.CurrentWell = CurrentWell; }
//public cExtendedList GetWellPhenotypeClasses(string TableName) //{ // cExtendedList ToReturn = new cExtendedList(); // SQLiteCommand mycommand = new SQLiteCommand(_SQLiteConnection); // mycommand.CommandText = "SELECT *, \"" + "Phenotype_Class" + "\" FROM \"" + TableName + "\""; // SQLiteDataReader value = mycommand.ExecuteReader(); // int Pos = value.GetOrdinal("Phenotype_Class"); // while (value.Read()) // ToReturn.Add(value.GetFloat(Pos)); // return ToReturn; //} public cListSingleBiologicalObjects GetBiologicalPhenotypes(cWell TmpWell) { cListSingleBiologicalObjects ToReturn = new cListSingleBiologicalObjects(); SQLiteCommand mycommand = new SQLiteCommand(_SQLiteConnection); mycommand.CommandText = "SELECT *, \"" + "Phenotype_Class" + "\" FROM \"" + TmpWell.SQLTableName + "\""; SQLiteDataReader value = mycommand.ExecuteReader(); int PosPhenotypeID = value.GetOrdinal("Phenotype_Class"); int PosPhenotypeConfidence = value.GetOrdinal("Phenotype_Confidence"); int PosPosX = value.GetOrdinal(cGlobalInfo.OptionsWindow.comboBoxDescriptorForPosX.Text); int PosPosY = value.GetOrdinal(cGlobalInfo.OptionsWindow.comboBoxDescriptorForPosY.Text); int BB_MinX = value.GetOrdinal(cGlobalInfo.OptionsWindow.comboBoxDescForBoundingMinX.Text); int BB_MaxX = value.GetOrdinal(cGlobalInfo.OptionsWindow.comboBoxDescForBoundingMaxX.Text); int BB_MinY = value.GetOrdinal(cGlobalInfo.OptionsWindow.comboBoxDescForBoundingMinY.Text); int BB_MaxY = value.GetOrdinal(cGlobalInfo.OptionsWindow.comboBoxDescForBoundingMaxY.Text); int PosField = value.GetOrdinal(cGlobalInfo.OptionsWindow.comboBoxDescriptorForField.Text); int PosIdx = value.GetOrdinal("rowid"); if (PosPhenotypeID != -1) { while (value.Read()) { string Res = value.GetValue(PosPhenotypeID).ToString(); if (Res == "") continue; cSingleBiologicalObject NewPhenotype = new cSingleBiologicalObject(cGlobalInfo.ListCellularPhenotypes[(int)value.GetFloat(PosPhenotypeID)], TmpWell, (int)value.GetFloat(PosIdx)); ToReturn.Add(NewPhenotype); if (PosPhenotypeConfidence != -1) NewPhenotype.ClassificationConfidence = (double)value.GetFloat(PosPhenotypeConfidence); else { cGlobalInfo.WindowHCSAnalyzer.richTextBoxConsole.AppendText(TmpWell.AssociatedPlate.GetName() + " / " + TmpWell.GetPos() + ": Phenotype_Confidence column not found. Value set to null."); NewPhenotype.ClassificationConfidence = 0; } if ((PosPosX != -1) && (PosPosY != -1)) ToReturn[ToReturn.Count - 1].Position = new _3D.cPoint3D(value.GetFloat(PosPosX), value.GetFloat(PosPosY), -1); if ((BB_MinX != -1) && (BB_MinY != -1) && (BB_MaxX != -1) && (BB_MaxY != -1)) { ToReturn[ToReturn.Count - 1].BD_BoxMin = new _3D.cPoint3D(value.GetFloat(BB_MinX), value.GetFloat(BB_MinY), -1); ToReturn[ToReturn.Count - 1].BD_BoxMax = new _3D.cPoint3D(value.GetFloat(BB_MaxX), value.GetFloat(BB_MaxY), -1); } if (PosField != -1) ToReturn[ToReturn.Count - 1].ImageField = (int)value.GetFloat(PosField); } } else { while (value.Read()) { cSingleBiologicalObject NewPhenotype = new cSingleBiologicalObject(cGlobalInfo.ListCellularPhenotypes[0], TmpWell, (int)value.GetFloat(PosIdx)); NewPhenotype.ClassificationConfidence = (double)value.GetFloat(PosPhenotypeConfidence); ToReturn.Add(NewPhenotype); if ((PosPosX != -1) && (PosPosY != -1)) ToReturn[ToReturn.Count - 1].Position = new _3D.cPoint3D(value.GetFloat(PosPosX), value.GetFloat(PosPosY), -1); if (PosField != -1) ToReturn[ToReturn.Count - 1].ImageField = (int)value.GetFloat(PosField); } } mycommand.Dispose(); mycommand = null; value.Close(); value.Dispose(); value = null; return ToReturn; }
public void LoadFromDisk(string Path) { if (ListWell == null) { cGlobalInfo.ConsoleWriteLine("ListWell NULL"); return; } IEnumerable<string> ListFile = Directory.EnumerateFiles(Path, "*.txt", SearchOption.TopDirectoryOnly); int ProcessedWell = 0; foreach (string FileName in ListFile) { cWell NewWell = new cWell(FileName, this.ParentScreening, this); if (NewWell.GetPosX() != -1) ProcessedWell++; this.AddWell(NewWell); //ListWell[NewWell.GetPosX() - 1, NewWell.GetPosY() - 1] = NewWell; } ListMinMax = new List<double[]>(); for (int i = 0; i < ParentScreening.ListDescriptors.Count; i++) { double[] TmpMinMax = GetMinMax(i); ListMinMax.Add(TmpMinMax); } this.NumberOfActiveWells = ProcessedWell; cGlobalInfo.ConsoleWriteLine(ProcessedWell + " well(s) succesfully processed"); }
private void hitsDistributionMapToolStripMenuItem_Click(object sender, EventArgs e) { if (cGlobalInfo.CurrentScreening == null) return; List<cPanelForDisplayArray> ListPlates = new List<cPanelForDisplayArray>(); foreach (cPlate CurrentPlate in cGlobalInfo.CurrentScreening.ListPlatesActive) { ListPlates.Add(new FormToDisplayPlate(CurrentPlate)); } cWindowToDisplayEntireScreening WindowToDisplayArray = new cWindowToDisplayEntireScreening(ListPlates, cGlobalInfo.CurrentScreening.ListDescriptors[cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx].GetName(), 6); WindowToDisplayArray.checkBoxDisplayClasses.Checked = true; WindowToDisplayArray.Text = "Generate Hits Distribution Maps"; WindowToDisplayArray.Show(); System.Windows.Forms.DialogResult ResWin = MessageBox.Show("By applying this process, the current screening will be entirely updated ! Proceed ?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (ResWin == System.Windows.Forms.DialogResult.No) { WindowToDisplayArray.Close(); return; } WindowToDisplayArray.Close(); if (cGlobalInfo.CurrentScreening != null) cGlobalInfo.CurrentScreening.Close3DView(); // CompleteScreening.ListDescriptors.RemoveDesc(CompleteScreening.ListDescriptors[IntToTransfer], CompleteScreening); cScreening MergedScreening = new cScreening("Class Screen"); MergedScreening.PanelForPlate = this.panelForPlate; MergedScreening.Rows = cGlobalInfo.CurrentScreening.Rows; MergedScreening.Columns = cGlobalInfo.CurrentScreening.Columns; MergedScreening.ListPlatesAvailable = new cListPlates(); // create the descriptor MergedScreening.ListDescriptors.Clean(); List<cDescriptorType> ListDescType = new List<cDescriptorType>(); List<int[][]> Values = new List<int[][]>(); for (int i = 0; i < cGlobalInfo.ListWellClasses.Count; i++) { cDescriptorType DescClass = new cDescriptorType("Class_" + i, true, 1); ListDescType.Add(DescClass); MergedScreening.ListDescriptors.AddNew(DescClass); int[][] TMpVal = new int[MergedScreening.Columns][]; for (int ii = 0; ii < MergedScreening.Columns; ii++) TMpVal[ii] = new int[MergedScreening.Rows]; Values.Add(TMpVal); } MergedScreening.ListDescriptors.CurrentSelectedDescriptorIdx = 0; foreach (cPlate CurrentPlate in cGlobalInfo.CurrentScreening.ListPlatesActive) { foreach (cWell TmpWell in CurrentPlate.ListActiveWells) { int Class = TmpWell.GetCurrentClassIdx(); if (Class >= 0) Values[Class][TmpWell.GetPosX() - 1][TmpWell.GetPosY() - 1]++; } } cPlate NewPlate = new cPlate(cGlobalInfo.CurrentScreening.GetName(), MergedScreening); for (int X = 0; X < cGlobalInfo.CurrentScreening.Columns; X++) for (int Y = 0; Y < cGlobalInfo.CurrentScreening.Rows; Y++) { cListSignature LDesc = new cListSignature(); for (int i = 0; i < cGlobalInfo.ListWellClasses.Count; i++) { cSignature Desc = new cSignature(Values[i][X][Y], ListDescType[i], cGlobalInfo.CurrentScreening); LDesc.Add(Desc); } cWell NewWell = new cWell(LDesc, X + 1, Y + 1, MergedScreening, NewPlate); // NewWell.SetCpdName("Well [" + (X + 1) + ":" + (Y + 1) + "]"); NewPlate.AddWell(NewWell); } // check if the plate exist already MergedScreening.AddPlate(NewPlate); MergedScreening.ListPlatesActive = new cListPlates(); cGlobalInfo.WindowHCSAnalyzer.toolStripcomboBoxPlateList.Items.Clear(); for (int i = 0; i < MergedScreening.ListPlatesAvailable.Count; i++) { MergedScreening.ListPlatesActive.Add(MergedScreening.ListPlatesAvailable[i]); cGlobalInfo.WindowHCSAnalyzer.toolStripcomboBoxPlateList.Items.Add(NewPlate.GetName()); } cGlobalInfo.CurrentScreening.ListDescriptors = MergedScreening.ListDescriptors; cGlobalInfo.CurrentScreening.ListPlatesAvailable = MergedScreening.ListPlatesAvailable; cGlobalInfo.CurrentScreening.ListPlatesActive = MergedScreening.ListPlatesActive; cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate(); for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++) cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax(); cGlobalInfo.CurrentScreening.CurrentDisplayPlateIdx = 0; cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().DisplayDistribution(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor(), true); ListPlates = new List<cPanelForDisplayArray>(); for (int DescIdx = 0; DescIdx < cGlobalInfo.CurrentScreening.ListDescriptors.Count; DescIdx++) { if (cGlobalInfo.CurrentScreening.ListDescriptors[DescIdx].IsActive()) ListPlates.Add(new FormToDisplayDescriptorPlate(cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate(), cGlobalInfo.CurrentScreening, DescIdx)); } cWindowToDisplayEntireDescriptors WindowToDisplayDesc = new cWindowToDisplayEntireDescriptors(ListPlates, cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().GetName(), cGlobalInfo.ListWellClasses.Count); WindowToDisplayDesc.checkBoxGlobalNormalization.Checked = true; WindowToDisplayDesc.Show(); }
void RenderWindow_RightButtonPressEvt(vtkObject sender, vtkObjectEventArgs e) { this.contextMenuStripActorPicker = new ContextMenuStrip(); int[] Pos; Pos = this.iren.GetLastEventPosition(); ToolStripMenuItem ToolStripMenuItem_World = new ToolStripMenuItem("World"); ToolStripMenuItem ScaleItem = new ToolStripMenuItem("Scale"); ToolStripMenuItem_World.DropDownItems.Add(ScaleItem); ScaleItem.Click += new System.EventHandler(this.ScaleClicking); ToolStripMenuItem ColorItem = new ToolStripMenuItem("Background Color"); ToolStripMenuItem_World.DropDownItems.Add(ColorItem); ColorItem.Click += new System.EventHandler(this.ColorClicking); ToolStripMenuItem ExportViewItem = new ToolStripMenuItem("Export View"); ToolStripMenuItem_World.DropDownItems.Add(ExportViewItem); ExportViewItem.Click += new System.EventHandler(this.ExportViewClicking); if (this.ListNameObjectType.Count >= 1) { ToolStripMenuItem SelectionItem = new ToolStripMenuItem("Selection Type"); ToolStripMenuItem_World.DropDownItems.Add(SelectionItem); SelectableObjectName = new List<bool>(); for (int idxName = 0; idxName < this.ListNameObjectType.Count; idxName++) { ToolStripMenuItem TypeName = new ToolStripMenuItem(ListNameObjectType[idxName]); TypeName.CheckOnClick = true; TypeName.Checked = true; TypeName.Click += new System.EventHandler(this.TypeNameClicking); if (TypeName.Checked) SelectableObjectName.Add(true); else SelectableObjectName.Add(false); } } string MetaObjectName = ""; vtkPicker Picker = vtkPicker.New(); int numActors = Picker.Pick(Pos[0], Pos[1], 0, this.ren1); if (numActors == 1) { vtkActor PickedActor = Picker.GetActor(); bool selectable = false; for (int i = 0; i < ListObject.Count; i++) if (ListObject[i].GetActor() == PickedActor) { cInteractive3DObject Obj = (cInteractive3DObject)ListObject[i]; if (Obj.GetMetaObjectContainer() != null) MetaObjectName = Obj.GetMetaObjectContainer().Information.GetName() + " -> "; for (int idx = 0; idx < this.SelectableObjectName.Count; idx++) { // the selected actor has been identified, let's get its type cInteractive3DObject TmpBioObj = (cInteractive3DObject)ListObject[i]; int IdxType = -1; for (int TmpIdx = 0; TmpIdx < this.ListNameObjectType.Count; TmpIdx++) if (TmpBioObj.GetType() == this.ListNameObjectType[TmpIdx]) IdxType = TmpIdx; // Is the type selectable (i.e. checked by the user in the contextual menu ? if (this.SelectableObjectName[IdxType]) { selectable = true; break; } } } if (selectable == true) { ToolStripMenuItem TypeItem = null; ToolStripMenuItem ToolStripMenuItem_ObjectDisplay = new ToolStripMenuItem("Object display"); // ToolStripMenuItem CentroidItem = new ToolStripMenuItem("Centroid"); ToolStripMenuItem ToolStripMenuItem_MetaDescriptorDisplay = null; ToolStripMenuItem_DescriptorDisplay = new ToolStripMenuItem("Object profil"); { for (int i = 0; i < ListObject.Count; i++) if (ListObject[i].GetActor() == PickedActor) { Type T = ListObject[i].GetType(); List<double> ListDesc = null; List<string> ListProfilName = null; if (T.Name == "cBiological3DVolume") { cBiological3DVolume TmpVol = (cBiological3DVolume)ListObject[i]; ListProfilName = TmpVol.Information.GetDescriptorNames(); ListDesc = TmpVol.Information.GetInformation(); TypeItem = new ToolStripMenuItem(MetaObjectName + TmpVol.GetType()); } else if (T.Name == "cBiologicalSpot") { cBiologicalSpot TmpSpot = (cBiologicalSpot)ListObject[i]; ListProfilName = TmpSpot.Information.GetDescriptorNames(); ListDesc = TmpSpot.Information.GetInformation(); TypeItem = new ToolStripMenuItem(MetaObjectName + TmpSpot.GetType()); } else if (T.Name == "c3DWell") { c3DWell TmpWell = (c3DWell)ListObject[i]; ListProfilName = TmpWell.Information.GetDescriptorNames(); ListDesc = TmpWell.Information.GetInformation(); TypeItem = new ToolStripMenuItem(MetaObjectName + TmpWell.GetType()); Chart ThumbnailChart = TmpWell.AssociatedWell.GetChart(); if (ThumbnailChart != null) { MemoryStream ms = new MemoryStream(); TmpWell.AssociatedWell.GetChart().SaveImage(ms, ChartImageFormat.Bmp); TypeItem.Image = new Bitmap(ms); TypeItem.ImageScaling = ToolStripItemImageScaling.None; TypeItem.Size = new System.Drawing.Size(48, 48); // New3DWell.ThumbnailnewImage = new Bitmap(ms); } CurrentlySelectedWell = TmpWell.AssociatedWell; TypeItem.Click += new System.EventHandler(this.WellInfoClick); } else if (T.Name == "c3DIsoContours") { c3DIsoContours TmpContours = (c3DIsoContours)ListObject[i]; // ListProfilName = TmpWell.Information.GetDescriptorNames(); // ListDesc = TmpWell.Information.GetInformation(); TypeItem = new ToolStripMenuItem(); Chart TmpChart = new Chart(); Series SeriesPos = new Series(); //SeriesPos.ShadowOffset = 1; ChartArea CurrentChartArea = new ChartArea(); List<double> DoubleList = new List<double>(); int Idx = 0; double[] Colour =TmpContours.GetActor().GetProperty().GetColor(); foreach (cPoint3D CurrentPt in TmpContours.ListPtContour) { SeriesPos.Points.AddY(CurrentPt.Z); SeriesPos.Points[Idx].MarkerSize = 2; SeriesPos.Points[Idx].MarkerStyle = MarkerStyle.Circle; SeriesPos.Points[Idx++].Color = Color.FromArgb((int)Colour[0], (int)Colour[1], (int)Colour[2]); //DoubleList.Add(CurrentPt.Z); } //CDisplayGraph DispGraph = new CDisplayGraph(DoubleList.ToArray()); SeriesPos.ChartType = SeriesChartType.Point; TmpChart.ChartAreas.Add(CurrentChartArea); CurrentChartArea.Axes[1].LabelStyle.Enabled = false; CurrentChartArea.Axes[1].MajorGrid.Enabled = false; CurrentChartArea.Axes[0].Enabled = AxisEnabled.False; CurrentChartArea.Axes[1].Enabled = AxisEnabled.False; CurrentChartArea.Axes[0].MajorGrid.Enabled = false; TmpChart.Width = 120; TmpChart.Height = 60; TmpChart.TextAntiAliasingQuality = TextAntiAliasingQuality.High; TmpChart.Series.Add(SeriesPos); //Chart ThumbnailChart = TmpChart.NewWindow.chartForSimpleForm; // if (ThumbnailChart != null) { MemoryStream ms = new MemoryStream(); TmpChart.SaveImage(ms, ChartImageFormat.Bmp); TypeItem.Image = new Bitmap(ms); TypeItem.ImageScaling = ToolStripItemImageScaling.None; TypeItem.Size = new System.Drawing.Size(48, 48); // New3DWell.ThumbnailnewImage = new Bitmap(ms); } // CurrentlySelectedWell = TmpWell.AssociatedWell; // TypeItem.Click += new System.EventHandler(this.WellInfoClick); } if (((cInteractive3DObject)ListObject[i]).ThumbnailnewImage != null) { // TypeItem.Image = ((cBiological3DObject)ListObject[i]).ThumbnailnewImage; // TypeItem.ImageScaling = ToolStripItemImageScaling.None; // TypeItem.Size = new System.Drawing.Size(48, 48); // TypeItem.Click += new System.EventHandler(this.WellInfoClick); } if (ListProfilName != null) for (int idxName = 0; idxName < ListProfilName.Count; idxName++) { ToolStripMenuItem descName = new ToolStripMenuItem(ListProfilName[idxName] + " : " + ListDesc[idxName]); ToolStripMenuItem_DescriptorDisplay.DropDownItems.Add(descName); } else { ToolStripMenuItem descName = new ToolStripMenuItem("Null"); ToolStripMenuItem_DescriptorDisplay.DropDownItems.Add(descName); } } } ToolStripSeparator SepratorStrip = new ToolStripSeparator(); if (ToolStripMenuItem_MetaDescriptorDisplay != null) contextMenuStripActorPicker.Items.AddRange(new ToolStripItem[] { TypeItem, SepratorStrip, ToolStripMenuItem_World, ToolStripMenuItem_ObjectDisplay, ToolStripMenuItem_DescriptorDisplay, ToolStripMenuItem_MetaDescriptorDisplay }); else contextMenuStripActorPicker.Items.AddRange(new ToolStripItem[] { TypeItem, SepratorStrip, ToolStripMenuItem_World, ToolStripMenuItem_ObjectDisplay, ToolStripMenuItem_DescriptorDisplay }); } else contextMenuStripActorPicker.Items.AddRange(new ToolStripItem[] { ToolStripMenuItem_World }); } else contextMenuStripActorPicker.Items.AddRange(new ToolStripItem[] { ToolStripMenuItem_World }); int[] PosWindow = this.renWin.GetSize(); contextMenuStripActorPicker.Show(Control.MousePosition); return; }
public List<string> GetDescriptorNames(cWell Well) { List<string> ToReturn = new List<string>(); // string NameWell = GetListTableNames()[IdxWell]; SQLiteCommand mycommand = new SQLiteCommand(_SQLiteConnection); mycommand.CommandText = "SELECT * FROM \"" + Well.SQLTableName + "\""; SQLiteDataReader value = mycommand.ExecuteReader(); for (int i = 0; i < value.FieldCount; i++) ToReturn.Add(value.GetName(i)); return ToReturn; }
private void generateDRCsToolStripMenuItem_Click(object sender, EventArgs e) { int nbrofdrugs = 6; int nbrofconcentrations = 10; int nbrofdesc = 3; double[, ,] DRC = new double[nbrofconcentrations, nbrofdrugs, nbrofdesc]; float[] X1 = new float[nbrofconcentrations]; X1[0] = 1000; for (int i = 1; i < X1.Length; i++) { X1[i] = X1[i - 1] / 3; } Random Bot = new Random(); Random To = new Random(); Random Ec5 = new Random(); Random Slop = new Random(); CompleteScreening = new cScreening("Current Screen", this.GlobalInfo); CompleteScreening.Columns = nbrofconcentrations; CompleteScreening.Rows = nbrofdrugs; for (int j = 0; j < nbrofdrugs; j++) { for (int k = 0; k < nbrofdesc; k++) { float Bottom = Bot.Next(10); float Top = To.Next(80, 100); float Ec50 = Ec5.Next(40, 60); float Slope = Slop.Next(1, 5); for (int i = 0; i < X1.Length; i++) { //DRC[i, j, k] = Bottom + (Top - Bottom) / (1 + Math.Pow(((Math.Pow(10, Ec50) / Math.Pow(10, X1[0]))), Slope)); DRC[i, j, k] = Bottom + (Top - Bottom) / (1 + Math.Pow((X1[i] / Ec50), -Slope)); } } } cPlate NewPlate = new cPlate("Cpds", "Plate0", CompleteScreening); CompleteScreening.AddPlate(NewPlate); CompleteScreening.ListDescriptors.Clean(); for (int k = 0; k < nbrofdesc; k++) { cDescriptorsType DescType = new cDescriptorsType("Desc" + k, true, 1, GlobalInfo); CompleteScreening.ListDescriptors.AddNew(DescType); } for (int j = 0; j < nbrofdrugs; j++) { for (int i = 0; i < nbrofconcentrations; i++) { List<cDescriptor> LDesc = new List<cDescriptor>(); for (int k = 0; k < nbrofdesc; k++) { //DRC[i, j, k] = Bottom + (Top - Bottom) / (1 + Math.Pow(((Math.Pow(10, Ec50) / Math.Pow(10, X1[0]))), Slope)); cDescriptor CurrentDesc = new cDescriptor(DRC[i, j, k], CompleteScreening.ListDescriptors[k], CompleteScreening); LDesc.Add(CurrentDesc); } cWell NewWell = new cWell(LDesc, i+1, j+1, CompleteScreening, NewPlate); NewWell.Concentration = X1[i]; NewPlate.AddWell(NewWell); } } CompleteScreening.ListDescriptors.UpDateDisplay(); CompleteScreening.UpDatePlateListWithFullAvailablePlate(); for (int idxP = 0; idxP < CompleteScreening.ListPlatesActive.Count; idxP++) CompleteScreening.ListPlatesActive[idxP].UpDataMinMax(); StartingUpDateUI(); this.toolStripcomboBoxPlateList.Items.Clear(); for (int IdxPlate = 0; IdxPlate < CompleteScreening.ListPlatesActive.Count; IdxPlate++) { string Name = CompleteScreening.ListPlatesActive.GetPlate(IdxPlate).Name; this.toolStripcomboBoxPlateList.Items.Add(Name); PlateListWindow.listBoxPlateNameToProcess.Items.Add(Name); PlateListWindow.listBoxAvaliableListPlates.Items.Add(Name); } CompleteScreening.CurrentDisplayPlateIdx = 0; CompleteScreening.SetSelectionType(comboBoxClass.SelectedIndex - 1); UpdateUIAfterLoading(); }
public cExtendedTable GetWellValues(cWell TmpWell, List<cDescriptorType> ListDescType, List<cCellularPhenotype> PhenotypesToBeSelected, double PopulationRatio) { cExtendedTable ToReturn = new cExtendedTable(); foreach (var item in ListDescType) { cExtendedList TmpList = new cExtendedList(); TmpList.Name = item.GetName(); TmpList.Tag = item; TmpList.ListTags = new List<object>(); SQLiteCommand mycommand = new SQLiteCommand(_SQLiteConnection); mycommand.CommandText = "SELECT \"" + item.GetName() + "\" FROM \"" + TmpWell.SQLTableName + "\" WHERE Phenotype_Class IN ("; foreach (var PhenotypeClass in PhenotypesToBeSelected) { mycommand.CommandText += PhenotypeClass.Idx + ","; } mycommand.CommandText = mycommand.CommandText.Remove(mycommand.CommandText.Length - 1); mycommand.CommandText += ")"; //mycommand.CommandText = "SELECT *, FROM \"" + TableName + "\""; SQLiteDataReader value = mycommand.ExecuteReader(); // value.Read(); int Pos = value.GetOrdinal(item.GetName()); if (Pos == -1) continue; while (value.Read()) { TmpList.Add(value.GetFloat(Pos)); } cExtendedList SubListToBeTransfered = new cExtendedList(TmpList, PopulationRatio); ToReturn.Add(SubListToBeTransfered); mycommand.Dispose(); mycommand = null; value.Close(); value.Dispose(); value = null; } return ToReturn; }
public cExtendedTable GetWellValues(cWell TmpWell, List<cDescriptorType> ListDescType) { cExtendedTable ToReturn = new cExtendedTable(); ToReturn.ListTags = new List<object>(); foreach (var item in ListDescType) { cExtendedList TmpList = new cExtendedList(); TmpList.Name = item.GetName(); TmpList.Tag = item; TmpList.ListTags = new List<object>(); SQLiteCommand mycommand = new SQLiteCommand(_SQLiteConnection); mycommand.CommandText = "SELECT \"" + item.GetName() + "\" FROM \"" + TmpWell.SQLTableName + "\" "; //mycommand.CommandText = "SELECT *, FROM \"" + TableName + "\""; SQLiteDataReader value = mycommand.ExecuteReader(); // value.Read(); int Pos = value.GetOrdinal(item.GetName()); if (Pos == -1) continue; if (value.GetValue(Pos).ToString() == "") continue; while (value.Read()) { TmpList.Add(value.GetFloat(Pos)); } ToReturn.Add(TmpList); mycommand.Dispose(); mycommand = null; value.Close(); value.Dispose(); value = null; } return ToReturn; }
public cExtendedTable GetWellValues(cWell TmpWell, cDescriptorType DescType) { List<cDescriptorType> LCDT = new List<cDescriptorType>(); LCDT.Add(DescType); cExtendedTable ToReturn = new cExtendedTable(this.GetWellValues(TmpWell, LCDT)); cListSingleBiologicalObjects ListClassesPhenotypes = this.GetBiologicalPhenotypes(/*this.GetWellValues(TmpWell.SQLTableName, DescType),*/ TmpWell); for (int i = 0; i < ToReturn.Count; i++) { ToReturn[i].ListTags = new List<object>(); for (int j = 0; j < ListClassesPhenotypes.Count; j++) ToReturn[i].ListTags.Add(ListClassesPhenotypes[j]); } return ToReturn; }
public cExtendedTable GetWellPhenotypeId(cWell TmpWell, List<cCellularPhenotype> PhenotypesToBeSelected) { cExtendedTable ToReturn = new cExtendedTable(); // foreach (var item in ListDescType) // { cExtendedList TmpList = new cExtendedList(); TmpList.Name = "Phenotype_Class"; //TmpList.Tag = item; TmpList.ListTags = new List<object>(); SQLiteCommand mycommand = new SQLiteCommand(_SQLiteConnection); if (PhenotypesToBeSelected != null) { mycommand.CommandText = "SELECT \"" + "Phenotype_Class" + "\" FROM \"" + TmpWell.SQLTableName + "\" WHERE Phenotype_Class IN ("; foreach (var PhenotypeClass in PhenotypesToBeSelected) { mycommand.CommandText += PhenotypeClass.Idx + ","; } mycommand.CommandText = mycommand.CommandText.Remove(mycommand.CommandText.Length - 1); mycommand.CommandText += ")"; } else { mycommand.CommandText = "SELECT \"" + "Phenotype_Class" + "\" FROM \"" + TmpWell.SQLTableName + "\""; } //mycommand.CommandText = "SELECT *, FROM \"" + TableName + "\""; SQLiteDataReader value = mycommand.ExecuteReader(); // value.Read(); int Pos = value.GetOrdinal("Phenotype_Class"); if (Pos != -1) { while (value.Read()) TmpList.Add(value.GetFloat(Pos)); } ToReturn.Add(TmpList); mycommand.Dispose(); mycommand = null; value.Close(); value.Dispose(); value = null; // } return ToReturn; //cExtendedTable ToReturn = new cExtendedTable(); //cExtendedList TmpList = new cExtendedList(); //SQLiteCommand mycommand = new SQLiteCommand(_SQLiteConnection); //mycommand.CommandText = "SELECT *, \"" + "Phenotype_Class" + "\" FROM \"" + TmpWell.SQLTableName + "\""; //SQLiteDataReader value = mycommand.ExecuteReader(); //int PosPhenotypeID = value.GetOrdinal("Phenotype_Class"); //cExtendedList ListErrorsIdx = new cExtendedList("List Error Indexes - " + TmpWell.Name); //int IdxRow = 0; ////if (Pos == -1) continue; //while (value.Read()) //{ // if (value.GetValue(PosPhenotypeID).ToString() != "") // { // TmpList.Add(value.GetDouble(PosPhenotypeID)); // } // else // { // TmpList.Add(0); // ListErrorsIdx.Add(IdxRow); // } // IdxRow++; //} //ToReturn.Add(TmpList); //return ToReturn; }
public int GetNumberOfRows(cWell Well) { SQLiteCommand mycommand = new SQLiteCommand(_SQLiteConnection); mycommand.CommandText = "SELECT COUNT(*) FROM " + Well.SQLTableName; try { SQLiteDataReader value = mycommand.ExecuteReader(); int ToReturn = 0; while (value.Read()) { ToReturn = value.GetInt32(0); } mycommand.Dispose(); mycommand = null; value.Close(); value.Dispose(); value = null; return ToReturn; } catch { mycommand.Dispose(); mycommand = null; return -1; } }
private void convertDRCToWellToolStripMenuItem1_Click(object sender, EventArgs e) { System.Windows.Forms.DialogResult ResWin = MessageBox.Show("By applying this process, the current screening will be entirely updated ! Proceed ?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (ResWin == System.Windows.Forms.DialogResult.No) return; //foreach (cDescriptorsType DescType in CompleteScreening.ListDescriptors) //{ // CompleteScreening.ListDescriptors.RemoveDescUnSafe(DescType, CompleteScreening); //} if (CompleteScreening != null) CompleteScreening.Close3DView(); // CompleteScreening.ListDescriptors.RemoveDesc(CompleteScreening.ListDescriptors[IntToTransfer], CompleteScreening); cScreening MergedScreening = new cScreening("Merged Screen", GlobalInfo); MergedScreening.PanelForPlate = this.panelForPlate; MergedScreening.Rows = CompleteScreening.Rows; MergedScreening.Columns = CompleteScreening.Columns; MergedScreening.ListPlatesAvailable = new cExtendPlateList(); // create the descriptor MergedScreening.ListDescriptors.Clean(); int Idesc = 0; List<cDescriptorsType> ListDescType = new List<cDescriptorsType>(); for (int i = 0; i < CompleteScreening.ListDescriptors.Count; i++) { if (!CompleteScreening.ListDescriptors[i].IsActive()) continue; cDescriptorsType DescEC50 = new cDescriptorsType("EC50_" + CompleteScreening.ListDescriptors[i].GetName(), true, 1, GlobalInfo); ListDescType.Add(DescEC50); MergedScreening.ListDescriptors.AddNew(DescEC50); cDescriptorsType DescTop = new cDescriptorsType("Top_" + CompleteScreening.ListDescriptors[i].GetName(), true, 1, GlobalInfo); ListDescType.Add(DescTop); MergedScreening.ListDescriptors.AddNew(DescTop); cDescriptorsType DescBottom = new cDescriptorsType("Bottom_" + CompleteScreening.ListDescriptors[i].GetName(), true, 1, GlobalInfo); ListDescType.Add(DescBottom); MergedScreening.ListDescriptors.AddNew(DescBottom); cDescriptorsType DescSlope = new cDescriptorsType("Slope_" + CompleteScreening.ListDescriptors[i].GetName(), true, 1, GlobalInfo); ListDescType.Add(DescSlope); MergedScreening.ListDescriptors.AddNew(DescSlope); Idesc++; } MergedScreening.ListDescriptors.CurrentSelectedDescriptor = 0; foreach (cPlate CurrentPlate in CompleteScreening.ListPlatesAvailable) { cPlate NewPlate = new cPlate("Cpds", CurrentPlate.Name + " Merged", MergedScreening); // check if the plate exist already MergedScreening.AddPlate(NewPlate); foreach (cDRC_Region CurrentRegion in CurrentPlate.ListDRCRegions) { List<cDescriptor> LDesc = new List<cDescriptor>(); Idesc = 0; int IDESCBase = 0; for (int i = 0; i < CompleteScreening.ListDescriptors.Count; i++) { if (!CompleteScreening.ListDescriptors[i].IsActive()) continue; cDRC CurrentDRC = CurrentRegion.GetDRC(CompleteScreening.ListDescriptors[IDESCBase++]); cDescriptor Desc_EC50 = new cDescriptor(CurrentDRC.EC50, ListDescType[Idesc++], CompleteScreening); LDesc.Add(Desc_EC50); cDescriptor Desc_Top = new cDescriptor(CurrentDRC.Top, ListDescType[Idesc++], CompleteScreening); LDesc.Add(Desc_Top); cDescriptor Desc_Bottom = new cDescriptor(CurrentDRC.Bottom, ListDescType[Idesc++], CompleteScreening); LDesc.Add(Desc_Bottom); cDescriptor Desc_Slope = new cDescriptor(CurrentDRC.Slope, ListDescType[Idesc++], CompleteScreening); LDesc.Add(Desc_Slope); } cWell NewWell = new cWell(LDesc, CurrentRegion.PosXMin + 1, CurrentRegion.PosYMin + 1, MergedScreening, NewPlate); NewWell.Name = "DRC [" + CurrentRegion.PosXMin + ":" + CurrentRegion.PosYMin + "]"; NewPlate.AddWell(NewWell); } } // PanelList[0].CurrentScreening.ListPlatesActive.Clear(); // PanelList[0].CurrentScreening.GlobalInfo.WindowHCSAnalyzer.RefreshInfoScreeningRichBox(); MergedScreening.ListPlatesActive = new cExtendPlateList(); for (int i = 0; i < MergedScreening.ListPlatesAvailable.Count; i++) { MergedScreening.ListPlatesActive.Add(MergedScreening.ListPlatesAvailable[i]); // MergedScreening.GlobalInfo.WindowHCSAnalyzer.toolStripcomboBoxPlateList.Items.Add(PanelList[0].CurrentScreening.ListPlatesActive[i].Name); } //PanelList[0].CurrentScreening.CurrentDisplayPlateIdx = 0; //PanelList[0].CurrentScreening.GlobalInfo.WindowHCSAnalyzer.toolStripcomboBoxPlateList.SelectedIndex = 0; //PanelList[0].CurrentScreening.GetCurrentDisplayPlate().DisplayDistribution(PanelList[0].CurrentScreening.ListDescriptors.CurrentSelectedDescriptor, false); CompleteScreening.ListDescriptors = MergedScreening.ListDescriptors; CompleteScreening.ListPlatesAvailable = MergedScreening.ListPlatesAvailable; CompleteScreening.ListPlatesActive = MergedScreening.ListPlatesActive; CompleteScreening.UpDatePlateListWithFullAvailablePlate(); for (int idxP = 0; idxP < CompleteScreening.ListPlatesActive.Count; idxP++) CompleteScreening.ListPlatesActive[idxP].UpDataMinMax(); CompleteScreening.GetCurrentDisplayPlate().DisplayDistribution(CompleteScreening.ListDescriptors.CurrentSelectedDescriptor, true); }
public double DistanceTo(cWell DestinationWell, int Idxdescriptor, eDistances DistanceType) { double Distance = 0; switch (DistanceType) { case eDistances.EUCLIDEAN: Distance = this.ListSignatures[Idxdescriptor].GetHistovalues().Dist_Euclidean(DestinationWell.ListSignatures[Idxdescriptor].GetHistovalues()); break; case eDistances.MANHATTAN: Distance = this.ListSignatures[Idxdescriptor].GetHistovalues().Dist_Manhattan(DestinationWell.ListSignatures[Idxdescriptor].GetHistovalues()); break; case eDistances.VECTOR_COS: Distance = this.ListSignatures[Idxdescriptor].GetHistovalues().Dist_VectorCosine(DestinationWell.ListSignatures[Idxdescriptor].GetHistovalues()); break; case eDistances.BHATTACHARYYA: Distance = this.ListSignatures[Idxdescriptor].GetHistovalues().Dist_BhattacharyyaCoefficient(DestinationWell.ListSignatures[Idxdescriptor].GetHistovalues()); break; case eDistances.EMD: Distance = this.ListSignatures[Idxdescriptor].GetHistovalues().Dist_EarthMover(DestinationWell.ListSignatures[Idxdescriptor].GetHistovalues()); break; default: break; } return Distance; }
private void buttonGenerate_Click(object sender, EventArgs e) { if (MessageBox.Show("This process will generate a new screening and delete the current one. Are you sure?", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != System.Windows.Forms.DialogResult.OK) return; // Now Let's write the CSV file //string FilePath = "c:\\test.csv"; //System.IO.StreamWriter file = new System.IO.StreamWriter(FilePath); //file.WriteLine("PlateName,WellPosition,ImageNumbers"); //foreach (var itemPlate in MainScreenDico) //{ // foreach (var itemWell in itemPlate.Value) // { // string Line = itemPlate.Key.ToString()+","+itemWell.Key.ToString()+","+itemWell.Value; // file.WriteLine(Line); // } //} //file.Close(); // return; // if (this.CurrentScreening == null) string[] ForNames = this.textBoxImageRoot.Text.Split('\\'); cGlobalInfo.CurrentScreening = new cScreening(ForNames[ForNames.Length - 1]); cGlobalInfo.CurrentScreening.Columns = 24; cGlobalInfo.CurrentScreening.Rows = 16; cGlobalInfo.CurrentScreening.ListDescriptors.Clean(); cGlobalInfo.CurrentScreening.ListDescriptors.AddNew(new cDescriptorType("ImageNumbers", true, 1)); foreach (var itemPlate in MainScreenDico) { cPlate CurrentPlate = cGlobalInfo.CurrentScreening.GetPlateIfNameIsContainIn(itemPlate.Key); if (CurrentPlate == null) { CurrentPlate = new cPlate(itemPlate.Key, cGlobalInfo.CurrentScreening); cGlobalInfo.CurrentScreening.AddPlate(CurrentPlate); } else { this.richTextBoxReport.AppendText("----------- Error ----------\nPlate " + itemPlate.Key + " has already been processed. Plate skipped !\n"); continue; } foreach (var itemWell in itemPlate.Value) { cListSignature LDesc = new cListSignature(); cSignature CurrentDescriptor = new cSignature((double)(int)itemWell.Value, cGlobalInfo.CurrentScreening.ListDescriptors[0/* + ShiftIdx*/], cGlobalInfo.CurrentScreening); LDesc.Add(CurrentDescriptor); int[] Pos = new int[2]; Pos = cGlobalInfo.WindowHCSAnalyzer.ConvertPosition(itemWell.Key.ToString()); cWell CurrentWell = new cWell(LDesc, Pos[0], Pos[1], cGlobalInfo.CurrentScreening, CurrentPlate); CurrentPlate.AddWell(CurrentWell); } } cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate(); foreach (var item in cGlobalInfo.CurrentScreening.ListPlatesActive) item.UpDataMinMax(); cGlobalInfo.WindowHCSAnalyzer.StartingUpDateUI(); cGlobalInfo.WindowHCSAnalyzer.toolStripcomboBoxPlateList.Items.Clear(); for (int IdxPlate = 0; IdxPlate < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; IdxPlate++) { string Name = cGlobalInfo.CurrentScreening.ListPlatesActive.GetPlate(IdxPlate).GetName(); cGlobalInfo.WindowHCSAnalyzer.toolStripcomboBoxPlateList.Items.Add(Name); cGlobalInfo.WindowHCSAnalyzer.PlateListWindow.listBoxPlateNameToProcess.Items.Add(Name); cGlobalInfo.WindowHCSAnalyzer.PlateListWindow.listBoxAvaliableListPlates.Items.Add(Name); cGlobalInfo.CurrentScreening.ListPlatesActive.GetPlate(IdxPlate).UpDataMinMax(); } cGlobalInfo.CurrentScreening.CurrentDisplayPlateIdx = 0; cGlobalInfo.CurrentScreening.SetSelectionType(cGlobalInfo.WindowHCSAnalyzer.comboBoxClass.SelectedIndex - 1); cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx = 0; cGlobalInfo.WindowHCSAnalyzer.UpdateUIAfterLoading(); // now Image Analysis // first create a descriptor for each readout cDescriptorType TmpDescType = new cDescriptorType("Total_Intensity_0", true, 1); cGlobalInfo.CurrentScreening.ListDescriptors.AddNew(TmpDescType); //FormForPlateDimensions PlateDim = new FormForPlateDimensions(); //PlateDim.checkBoxAddCellNumber.Visible = true; //PlateDim.checkBoxIsOmitFirstColumn.Visible = true; //PlateDim.labelHisto.Visible = true; //PlateDim.numericUpDownHistoSize.Visible = true; FormForDoubleProgress WindowProgress = new FormForDoubleProgress(); WindowProgress.Show(); WindowProgress.progressBarPlate.Maximum = cGlobalInfo.CurrentScreening.ListPlatesAvailable.Count; WindowProgress.progressBarPlate.Value = 0; WindowProgress.progressBarPlate.Refresh(); int IdxPlateProg = 0; foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable) { WindowProgress.progressBarPlate.Value++; WindowProgress.progressBarPlate.Refresh(); WindowProgress.labelPlateIdx.Text = (IdxPlateProg + 1) + " / " + cGlobalInfo.CurrentScreening.ListPlatesAvailable.Count; WindowProgress.progressBarWell.Value = 0; WindowProgress.progressBarWell.Maximum = TmpPlate.ListWells.Count; #region modif //List<cImageMetaInfo> ListImageMetaInfo = new List<cImageMetaInfo>(); //string Pathds = this.textBoxImageRoot.Text; //string XMLFile = Pathds+"\\"+ TmpPlate.GetName()+"\\MeasurementDetail.mrf"; //int NumberOfChannels = (int)this.numericUpDownChannelNumber.Value; //List<string> ListFiles = Directory.GetFiles(Pathds + "\\" + TmpPlate.GetName(), "*C0*.tif", SearchOption.AllDirectories).ToList(); //ListFiles.Sort(); //OrderBy(q=>q).ToList(); //if (File.Exists(XMLFile)) //{ // XmlDocument xmlDoc = new XmlDocument(); // xmlDoc.Load(XMLFile); // for (int Channel = 0; Channel < NumberOfChannels; Channel++) // { // //string FinalName = ListChannels[Channel]; // cImageMetaInfo TmpMetaInfo = new cImageMetaInfo(); // //TmpMetaInfo.FileName = FinalName; // TmpMetaInfo.Name = xmlDoc.ChildNodes[1].ChildNodes[1].Attributes["bts:Ch"].Value;//ListChannelNames[Channel]; // TmpMetaInfo.ResolutionX = double.Parse(xmlDoc.ChildNodes[1].ChildNodes[1].Attributes["bts:HorizontalPixelDimension"].Value);//1; // TmpMetaInfo.ResolutionY = double.Parse(xmlDoc.ChildNodes[1].ChildNodes[1].Attributes["bts:VerticalPixelDimension"].Value);//1; // TmpMetaInfo.ResolutionZ = 1; // ListImageMetaInfo.Add(TmpMetaInfo); // } //} //else //{ // for (int Channel = 0; Channel < NumberOfChannels; Channel++) // { // //string FinalName = ListChannels[Channel]; // cImageMetaInfo TmpMetaInfo = new cImageMetaInfo(); // //TmpMetaInfo.FileName = FinalName; // // TmpMetaInfo.Name = ListChannelNames[Channel]; // TmpMetaInfo.ResolutionX = 1; // TmpMetaInfo.ResolutionY = 1; // TmpMetaInfo.ResolutionZ = 1; // ListImageMetaInfo.Add(TmpMetaInfo); // } //} #endregion int IdxWell = 0; foreach (cWell TmpWell in TmpPlate.ListWells) { WindowProgress.labelWellIdx.Text = (IdxWell + 1) + " / " + TmpPlate.ListWells.Count; WindowProgress.progressBarWell.Value = IdxWell + 1; WindowProgress.progressBarWell.Refresh(); WindowProgress.Refresh(); int NumberOfFieldProcessed = 0; double AverageValue = 0; for (int IdxField = 0; IdxField < this.numericUpDownFieldNumber.Value; IdxField++) { //var watch = Stopwatch.StartNew(); cGetImageFromWells IFW = new cGetImageFromWells(); IFW.SetInputData(new cListWells(TmpWell)); IFW.ListProperties.FindByName("Field").SetNewValue(IdxField); IFW.Run(); cImage TmpImage = IFW.GetOutPut(); //watch.Stop(); //cGlobalInfo.WindowHCSAnalyzer.richTextBoxConsole.AppendText("IFW = "+watch.ElapsedMilliseconds + "\n"); if ((TmpImage == null) || (TmpImage.GetNumChannels() == 0)) { cGlobalInfo.WindowHCSAnalyzer.richTextBoxConsole.AppendText("Error while loading [Plate] " + TmpPlate.GetName() + " [Well] " + TmpWell.GetPos() + " [Field] " + IdxField + "\n"); continue; } else { AverageValue = 25; //TmpImage.SingleChannelImage[0].Data.Sum(); } IFW.GetOutPut().Dispose(); //GC.Collect(); NumberOfFieldProcessed++; } if (NumberOfFieldProcessed != 0) AverageValue /= (double)NumberOfFieldProcessed; else AverageValue = 0; cListSignature LDesc = new cListSignature(); cSignature NewDesc = new cSignature(AverageValue, TmpDescType, cGlobalInfo.CurrentScreening); LDesc.Add(NewDesc); TmpWell.AddSignatures(LDesc); IdxWell++; } IdxPlateProg++; } WindowProgress.Dispose(); cGlobalInfo.CurrentScreening.ListDescriptors.UpDateDisplay(); cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate(); for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++) cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax(); }
public double DistanceTo(cWell DestinationWell, eDistances DistanceType) { double Distance = 0; switch (DistanceType) { case eDistances.EUCLIDEAN: Distance += this.GetAverageValuesList(true)[0].Dist_Euclidean(DestinationWell.GetAverageValuesList(true)[0]); break; case eDistances.MANHATTAN: Distance += this.GetAverageValuesList(true)[0].Dist_Manhattan(DestinationWell.GetAverageValuesList(true)[0]); break; case eDistances.VECTOR_COS: Distance += this.GetAverageValuesList(true)[0].Dist_VectorCosine(DestinationWell.GetAverageValuesList(true)[0]); break; case eDistances.BHATTACHARYYA: Distance += this.GetAverageValuesList(true)[0].Dist_BhattacharyyaCoefficient(DestinationWell.GetAverageValuesList(true)[0]); break; case eDistances.EMD: Distance += this.GetAverageValuesList(true)[0].Dist_EarthMover(DestinationWell.GetAverageValuesList(true)[0]); break; default: break; } return Distance; }
private void createAveragePlateToolStripMenuItem_Click(object sender, EventArgs e) { FormForPlateAveraging FFPA = new FormForPlateAveraging(); PanelForPlatesSelection PlatesSelectionPanel = new PanelForPlatesSelection(true, null, true); PlatesSelectionPanel.Height = FFPA.panelForPlateList.Height; FFPA.panelForPlateList.Controls.Add(PlatesSelectionPanel); if (FFPA.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; cListPlates LP = PlatesSelectionPanel.GetListSelectedPlates(); cPlate NewPlate = new cPlate("Average Plate", cGlobalInfo.CurrentScreening); cWell TmpWell; #region QC report cExtendedList TmpReportForQuality = new cExtendedList("Weight"); TmpReportForQuality.ListTags = new List<object>(); cExtendedTable TableForQCReport = new cExtendedTable(TmpReportForQuality); TableForQCReport.ListRowNames = new List<string>(); TableForQCReport.ListTags = new List<object>(); foreach (cPlate TmpPlate in LP) { object QualityValue = TmpPlate.ListProperties.FindValueByName("Quality"); if ((QualityValue != null) && (FFPA.checkBoxWeightedSum.Checked)) TableForQCReport[0].Add((double)QualityValue); else { this.richTextBoxConsole.AppendText(TmpPlate.GetName() + " - Quality is NULL. Weight set to 1.\n"); TableForQCReport[0].Add(1); } TableForQCReport.ListRowNames.Add(TmpPlate.GetName()); TableForQCReport.ListTags.Add(TmpPlate); TableForQCReport[0].ListTags.Add(TmpPlate); } cDisplayExtendedTable DET = new cDisplayExtendedTable(); DET.SetInputData(TableForQCReport); DET.Title = "QC report"; TableForQCReport.Name = "QC report"; DET.Run(); #endregion for (int X = 0; X < cGlobalInfo.CurrentScreening.Columns; X++) for (int Y = 0; Y < cGlobalInfo.CurrentScreening.Rows; Y++) { cListSignature LDesc = new cListSignature(); for (int i = 0; i < cGlobalInfo.CurrentScreening.ListDescriptors.Count; i++) { double Value = 0; double NormFactor = 0; foreach (cPlate TmpPlate in LP) { double Weight = 1; object QualityValue = TmpPlate.ListProperties.FindValueByName("Quality"); if ((QualityValue != null) && (FFPA.checkBoxWeightedSum.Checked)) Weight = (double)QualityValue; NormFactor += Weight; TmpWell = TmpPlate.GetWell(X, Y, false); if (TmpWell != null) { Value += Weight * TmpWell.ListSignatures[i].GetValue(); } } if (NormFactor > 0) { cSignature Desc = new cSignature(Value / NormFactor, cGlobalInfo.CurrentScreening.ListDescriptors[i], cGlobalInfo.CurrentScreening); LDesc.Add(Desc); } } cWell NewWell = new cWell(LDesc, X + 1, Y + 1, cGlobalInfo.CurrentScreening, NewPlate); NewWell.SetCpdName("Average Well [" + (X + 1) + ":" + (Y + 1) + "]"); NewPlate.AddWell(NewWell); } cGlobalInfo.CurrentScreening.AddPlate(NewPlate); cGlobalInfo.CurrentScreening.ListPlatesActive.Add(NewPlate); toolStripcomboBoxPlateList.Items.Add(NewPlate.GetName()); cGlobalInfo.CurrentScreening.ListPlatesActive[cGlobalInfo.CurrentScreening.ListPlatesActive.Count - 1].UpDataMinMax(); cGlobalInfo.CurrentScreening.CurrentDisplayPlateIdx = 0; cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().DisplayDistribution(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor(), true); }
public double DistanceTo(cWell DestinationWell, eDistances IntraHistoDistanceType, eDistances InterHistoDistanceType) { double Distance = 0; cExtendedList ListDistSource = new cExtendedList(); cExtendedList ListDistDest = new cExtendedList(); for (int Idxdescriptor = 0; Idxdescriptor < cGlobalInfo.CurrentScreening.ListDescriptors.Count; Idxdescriptor++) { if (cGlobalInfo.CurrentScreening.ListDescriptors[Idxdescriptor].IsActive() == false) continue; switch (IntraHistoDistanceType) { case eDistances.EUCLIDEAN: ListDistSource.Add(this.ListSignatures[Idxdescriptor].GetHistovalues().Dist_Euclidean(DestinationWell.ListSignatures[Idxdescriptor].GetHistovalues())); ListDistDest.Add(DestinationWell.ListSignatures[Idxdescriptor].GetValue()); Distance = ListDistSource.Dist_Euclidean(ListDistDest); break; case eDistances.MANHATTAN: Distance = ListDistSource.Dist_Manhattan(ListDistDest); break; case eDistances.VECTOR_COS: Distance = ListDistSource.Dist_VectorCosine(ListDistDest); break; case eDistances.BHATTACHARYYA: Distance = ListDistSource.Dist_BhattacharyyaCoefficient(ListDistDest); break; case eDistances.EMD: Distance = ListDistSource.Dist_EarthMover(ListDistDest); break; default: break; } } switch (InterHistoDistanceType) { case eDistances.EUCLIDEAN: Distance = ListDistSource.Dist_Euclidean(ListDistDest); break; case eDistances.MANHATTAN: Distance = ListDistSource.Dist_Manhattan(ListDistDest); break; case eDistances.VECTOR_COS: Distance = ListDistSource.Dist_VectorCosine(ListDistDest); break; case eDistances.BHATTACHARYYA: Distance = ListDistSource.Dist_BhattacharyyaCoefficient(ListDistDest); break; case eDistances.EMD: Distance = ListDistSource.Dist_EarthMover(ListDistDest); break; default: break; } return Distance; }
public bool AddWell(cWell NewWell) { int PosX = NewWell.GetPosX() - 1; int PosY = NewWell.GetPosY() - 1; try { ListWell[PosX, PosY] = NewWell; ListActiveWells.Add(NewWell); ListWells.Add(NewWell); } catch (Exception) { return false; } return true; }
public void DisplayTable(cWell Well) { SQLiteCommand mycommand = new SQLiteCommand(_SQLiteConnection); mycommand.CommandText = "SELECT * FROM \"" + Well.SQLTableName + "\""; SQLiteDataReader value = mycommand.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(value); cDisplayScatter2D WindowForTable = new cDisplayScatter2D(dt); WindowForTable.comboBoxAxeX.DataSource = this.GetDescriptorNames(Well); WindowForTable.comboBoxAxeY.DataSource = this.GetDescriptorNames(Well); WindowForTable.comboBoxVolume.DataSource = this.GetDescriptorNames(Well); WindowForTable.chartForPoints.Series[0].MarkerColor = Well.GetClassColor(); // WindowForTable.ch WindowForTable.Text = Well.AssociatedPlate.GetName() + " [" + Well.GetPosX() + "x" + Well.GetPosY() + "]"; WindowForTable.Show(); }