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 cExtendedControl BuildChartForImage() { // Panel TmpPanel = new Panel(); int Field = 0; cViewerImage MyImageViewer = new cViewerImage(); cGetImageFromWells GIFW = new cGetImageFromWells(); GIFW.SetInputData(new cListWells(this)); if(!GIFW.Run().IsSucceed) return null; MyImageViewer.SetInputData(GIFW.GetOutPut()); MyImageViewer.Run(); int GutterSize = (int)cGlobalInfo.OptionsWindow.FFAllOptions.numericUpDownGutter.Value; MyImageViewer.GetOutPut().Location = new System.Drawing.Point( (int)((PosX - 1) * (cGlobalInfo.SizeHistoWidth + GutterSize) + cGlobalInfo.SizeHistoWidth), (int)((PosY - 1) * (cGlobalInfo.SizeHistoHeight + GutterSize) + cGlobalInfo.SizeHistoHeight)); MyImageViewer.GetOutPut().BackColor = this.GetClassColor();//cGlobalInfo.ListClasses[this.ClassForClassif].ColourForDisplay;// CurrentColor; MyImageViewer.GetOutPut().Width = (int)cGlobalInfo.SizeHistoWidth; MyImageViewer.GetOutPut().Height = (int)cGlobalInfo.SizeHistoHeight; //PictureBox PB = new PictureBox(); //PB.Width = (int)cGlobalInfo.SizeHistoWidth-4; //PB.Height = (int)cGlobalInfo.SizeHistoHeight-4; //PB.Location = new Point(2, 2); //PB.BackColor = this.GetClassColor(); //PB.BorderStyle = BorderStyle.None; //PB.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; //PB.MouseClick += new System.Windows.Forms.MouseEventHandler(this.AssociatedChart_MouseClick); //PB.MouseDown += new MouseEventHandler(AssociatedChart_MouseDown); //PB.AllowDrop = true; //PB.DragDrop += new DragEventHandler(AssociatedChart_DragDrop); //PB.DragEnter += new DragEventHandler(AssociatedChart_DragEnter); if (this.Thumbnail == null) { cGetImageFromWells GIFWT = new cGetImageFromWells(); GIFWT.SetInputData(new cListWells(this)); if (!GIFWT.Run().IsSucceed) return null; this.Thumbnail = GIFWT.GetOutPut().GetBitmap(1, null, null); } // PB.Image = this.Thumbnail; // TmpPanel.Controls.Add(PB); //TmpPanel. //.GetToolTipText += new System.EventHandler<ToolTipEventArgs>(this.AssociatedChart_GetToolTipText); return MyImageViewer.GetOutPut(); }
cFeedBackMessage Process() { if (base.Start() == false) { base.FeedBackMessage.IsSucceed = false; return base.FeedBackMessage; } object _firstValue = base.ListProperties.FindByName("Include Images?"); bool IsIncludeImages = false; if (_firstValue == null) { base.GenerateError("-Include Images?- not found !"); return base.FeedBackMessage; } try { cProperty TmpProp = (cProperty)_firstValue; IsIncludeImages = (bool)TmpProp.GetValue(); } catch (Exception) { base.GenerateError("-Include Images?- cast didn't work"); return base.FeedBackMessage; } this.Output = this.Input.GetAverageDescriptorValuesFull(); if (IsIncludeImages) { this.Output.ListTags = new List<object>(); foreach (cWell item in Input) { cGetImageFromWells GIFW = new cGetImageFromWells(); GIFW.SetInputData(new cListWells(this)); if (!GIFW.Run().IsSucceed) continue; cImage AccessedImage = GIFW.GetOutPut(); List<byte[][]> ListLUTs = new List<byte[][]>(); cLUT LUT = new cLUT(); ListLUTs.Add(LUT.LUT_LINEAR_RED); ListLUTs.Add(LUT.LUT_LINEAR_GREEN); ListLUTs.Add(LUT.LUT_LINEAR_BLUE); List<double> ListMin = new List<double>(); ListMin.Add(200); ListMin.Add(200); List<double> ListMax = new List<double>(); ListMax.Add(65530); ListMax.Add(5000); cImageDisplayProperties IP = new cImageDisplayProperties(); IP.ListMax = ListMax; IP.ListMin = ListMin; this.Output.ListTags.Add(AccessedImage.GetBitmap(0.2f, IP, ListLUTs)); } } base.End(); return FeedBackMessage; //// here is the core of the meta component ... //// just a list of Component steps //foreach (cWell item in Input) //{ // item.AssociatedPlate.DBConnection = new cDBConnection(item.AssociatedPlate, item.SQLTableName); // cListSingleBiologicalObjects ListPhenotypes = item.AssociatedPlate.DBConnection.GetBiologicalPhenotypes(item); // cExtendedTable ET = item.AssociatedPlate.DBConnection.GetWellValues(item, cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptors()); // item.AssociatedPlate.DBConnection.CloseConnection(); // ET.ListTags = new List<object>(); // for (int i = 0; i < ET.Count; i++) // { // ET[i].ListTags = new List<object>(); // for (int j = 0; j < ListPhenotypes.Count; j++) // ET[i].ListTags.Add(ListPhenotypes[j]); // } // for (int j = 0; j < ListPhenotypes.Count; j++) // ET.ListTags.Add(ListPhenotypes[j]); // if (Output == null) // Output = new cExtendedTable(ET); // else // { // cMerge M = new cMerge(); // M.IsHorizontal = false; // M.SetInputData(Output, ET); // M.Run(); // Output = M.GetOutPut(); // } //} }
/// <summary> /// Display the information window related to the selected well /// </summary> private void ToolStripMenuItem_Image(object sender, EventArgs e) { int Field = (int)cGlobalInfo.OptionsWindow.numericUpDownDefaultField.Value; cDisplaySingleImage IV = new cDisplaySingleImage(); cGetImageFromWells IFW = new cGetImageFromWells(); IFW.SetInputData(new cListWells(this)); IFW.ListProperties.FindByName("Field").SetNewValue((int)0); if(cGlobalInfo.OptionsWindow.numericUpDownImageAccessNumberOfFields.Value>1) IFW.ListProperties.FindByName("Field").IsGUIforValue = true; if (IFW.Run().IsSucceed == false) { return; } IV.SetInputData(IFW.GetOutPut()); IV.Title = this.GetShortInfo() + " - Field: " + ((int)(IFW.ListProperties.FindByName("Field").GetValue())); IV.IsDisplayScale = true; IV.IsUseSavedDefaultDisplayProperties = true; IV.Run(); }