private void AverageOperationsToDescriptorItem(object sender, EventArgs e) { FormForDescOperations MainWindow = new FormForDescOperations(cGlobalInfo.CurrentScreening.ListDescriptors.GetListNames()); MainWindow.Text = "Average Based Operations"; if (MainWindow.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; string NewDescName = MainWindow.textBoxNewDescName.Text; cDescriptorType DescType1 = cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorByName(MainWindow.comboBoxDescriptor1.Text); cDescriptorType DescType2 = cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorByName(MainWindow.comboBoxDescriptor2.Text); if ((DescType1 == null) || (DescType2 == null)) return; FormForProgress ProgressWindow = new FormForProgress(); ProgressWindow.Show(); int IdxProgress = 1; int MaxProgress = cGlobalInfo.CurrentScreening.ListPlatesAvailable.Count; ProgressWindow.progressBar.Maximum = MaxProgress; cDescriptorType NewDescType = new cDescriptorType(NewDescName, true, 1); cGlobalInfo.CurrentScreening.ListDescriptors.AddNew(NewDescType); eBinaryOperationType PostProcessBinaryOp = eBinaryOperationType.UNDEFINED; if (MainWindow.checkBoxActivePostProcess.Checked) { switch (MainWindow.domainUpDownPostProcessOperator.Text) { case "*": PostProcessBinaryOp = eBinaryOperationType.MULTIPLY; break; case "+": PostProcessBinaryOp = eBinaryOperationType.ADD; break; case "/": PostProcessBinaryOp = eBinaryOperationType.DIVIDE; break; case "-": PostProcessBinaryOp = eBinaryOperationType.SUBSTRACT; break; default: return; } } if (MainWindow.tabControlMain.SelectedTab.Name == "tabPageBinary") { // SingleCellOperation.ListDualOperations = new List<eBinaryOperationType>(); // eDualOperationType OperationType = eDualOperationType.ADD; eBinaryOperationType BinaryOp = eBinaryOperationType.ADD; switch (MainWindow.domainUpDown1.Text) { case "*": BinaryOp = eBinaryOperationType.MULTIPLY; break; case "+": BinaryOp = eBinaryOperationType.ADD; break; case "/": BinaryOp = eBinaryOperationType.DIVIDE; break; case "-": BinaryOp = eBinaryOperationType.SUBSTRACT; break; default: return; } foreach (cPlate CurrentPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable) { foreach (cWell Tmpwell in CurrentPlate.ListActiveWells) { cListSignature LDesc = new cListSignature(); cSignature NewDesc = null; double Val = 0; switch (BinaryOp) { case eBinaryOperationType.ADD: Val = Tmpwell.GetAverageValue(DescType1) + Tmpwell.GetAverageValue(DescType2); break; case eBinaryOperationType.MULTIPLY: Val = Tmpwell.GetAverageValue(DescType1) * Tmpwell.GetAverageValue(DescType2); break; case eBinaryOperationType.SUBSTRACT: Val = Tmpwell.GetAverageValue(DescType1) - Tmpwell.GetAverageValue(DescType2); break; case eBinaryOperationType.DIVIDE: double denominator = Tmpwell.GetAverageValue(DescType2); if (denominator == 0) Val = 0; else Val = Tmpwell.GetAverageValue(DescType1) / denominator; break; default: break; } if (PostProcessBinaryOp != eBinaryOperationType.UNDEFINED) { double ValuePostProcess = (double)MainWindow.numericUpDownPostProcessValue.Value; switch (PostProcessBinaryOp) { case eBinaryOperationType.ADD: Val += ValuePostProcess; break; case eBinaryOperationType.SUBSTRACT: Val -= ValuePostProcess; break; case eBinaryOperationType.MULTIPLY: Val *= ValuePostProcess; break; case eBinaryOperationType.DIVIDE: if (ValuePostProcess == 0) Val = 0; else Val /= ValuePostProcess; break; default: break; } } NewDesc = new cSignature(Val, NewDescType, cGlobalInfo.CurrentScreening); LDesc.Add(NewDesc); Tmpwell.AddSignatures(LDesc); } ProgressWindow.progressBar.Value = IdxProgress++; ProgressWindow.richTextBoxForComment.AppendText(CurrentPlate.GetShortInfo()); ProgressWindow.Refresh(); } } #region unary operator else { eUnaryOperationType OperationType = eUnaryOperationType.LOG; if (MainWindow.radioButtonSQRT.Checked) OperationType = eUnaryOperationType.SQRT; else if (MainWindow.radioButtonLog.Checked) OperationType = eUnaryOperationType.LOG; else if (MainWindow.radioButtonABS.Checked) OperationType = eUnaryOperationType.ABS; else if (MainWindow.radioButtonEXP.Checked) OperationType = eUnaryOperationType.EXP; foreach (cPlate CurrentPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable) { foreach (cWell Tmpwell in CurrentPlate.ListActiveWells) { cListSignature LDesc = new cListSignature(); cSignature NewDesc = null; double Val = 0; switch (OperationType) { case eUnaryOperationType.LOG: Val = Math.Log(Tmpwell.GetAverageValue(DescType1)); if (double.IsInfinity(Val) || double.IsNaN(Val)) Val = double.Epsilon; break; case eUnaryOperationType.SQRT: Val = Tmpwell.GetAverageValue(DescType1); if (Val < 0) Val = 0; Val = Math.Sqrt(Val); break; case eUnaryOperationType.ABS: Val = Math.Abs(Tmpwell.GetAverageValue(DescType1)); break; case eUnaryOperationType.EXP: Val = Math.Exp(Tmpwell.GetAverageValue(DescType1)); break; default: break; } if (PostProcessBinaryOp != eBinaryOperationType.UNDEFINED) { double ValuePostProcess = (double)MainWindow.numericUpDownPostProcessValue.Value; switch (PostProcessBinaryOp) { case eBinaryOperationType.ADD: Val += ValuePostProcess; break; case eBinaryOperationType.SUBSTRACT: Val -= ValuePostProcess; break; case eBinaryOperationType.MULTIPLY: Val *= ValuePostProcess; break; case eBinaryOperationType.DIVIDE: if (ValuePostProcess == 0) Val = 0; else Val /= ValuePostProcess; break; default: break; } } NewDesc = new cSignature(Val, NewDescType, cGlobalInfo.CurrentScreening); LDesc.Add(NewDesc); Tmpwell.AddSignatures(LDesc); } ProgressWindow.progressBar.Value = IdxProgress++; ProgressWindow.richTextBoxForComment.AppendText(CurrentPlate.GetShortInfo()); ProgressWindow.Refresh(); } } #endregion ProgressWindow.Close(); int IdxNull = 0; foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesActive) { foreach (cWell TmpWell in TmpPlate.ListActiveWells) if (TmpWell.ListSignatures.Count != cGlobalInfo.CurrentScreening.ListDescriptors.Count) IdxNull++; } if (IdxNull > 0) System.Windows.Forms.MessageBox.Show("List signature count is different from list descriptor count", "Critical Error !", MessageBoxButtons.OK, MessageBoxIcon.Error); cGlobalInfo.CurrentScreening.ListDescriptors.UpDateDisplay(); // CompleteScreening.UpDatePlateListWithFullAvailablePlate(); for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesAvailable.Count; idxP++) cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax(); StartingUpDateUI(); this.toolStripcomboBoxPlateList.Items.Clear(); for (int IdxPlate = 0; IdxPlate < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; IdxPlate++) { string Name = cGlobalInfo.CurrentScreening.ListPlatesActive.GetPlate(IdxPlate).GetName(); this.toolStripcomboBoxPlateList.Items.Add(Name); PlateListWindow.listBoxPlateNameToProcess.Items.Add(Name); PlateListWindow.listBoxAvaliableListPlates.Items.Add(Name); } cGlobalInfo.CurrentScreening.CurrentDisplayPlateIdx = 0; cGlobalInfo.CurrentScreening.SetSelectionType(comboBoxClass.SelectedIndex - 1); UpdateUIAfterLoading(); cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().DisplayDistribution(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor(), false); }
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(); }
private void SumCheckedDescToDescriptorItem(object sender, EventArgs e) { string NewName = ""; string Description = "Sum of:\n"; for (int Idx = 0; Idx < cGlobalInfo.WindowHCSAnalyzer.checkedListBoxActiveDescriptors.Items.Count; Idx++) { if (cGlobalInfo.CurrentScreening.ListDescriptors[Idx].IsActive()) if (cGlobalInfo.CurrentScreening.ListDescriptors[Idx].GetBinNumber() == 1) { NewName += cGlobalInfo.CurrentScreening.ListDescriptors[Idx].GetName() + "+"; Description += cGlobalInfo.CurrentScreening.ListDescriptors[Idx].GetName() + "+\n"; } else { MessageBox.Show("Descriptor length not consistent (" + cGlobalInfo.CurrentScreening.ListDescriptors[Idx].GetName() + " : " + cGlobalInfo.CurrentScreening.ListDescriptors[Idx].GetBinNumber() + " bins", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } cDescriptorType ColumnType = new cDescriptorType(NewName.Remove(NewName.Length - 1), true, 1); ColumnType.description = Description; cGlobalInfo.CurrentScreening.ListDescriptors.AddNew(ColumnType); foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable) { foreach (cWell Tmpwell in TmpPlate.ListActiveWells) { cListSignature LDesc = new cListSignature(); double NewValue = 0; for (int IdxActiveDesc = 0; IdxActiveDesc < cGlobalInfo.CurrentScreening.ListDescriptors.Count - 1; IdxActiveDesc++) { if (cGlobalInfo.CurrentScreening.ListDescriptors[IdxActiveDesc].IsActive()) NewValue += Tmpwell.ListSignatures[IdxActiveDesc].GetValue(); } cSignature NewDesc = new cSignature(NewValue, ColumnType, cGlobalInfo.CurrentScreening); LDesc.Add(NewDesc); Tmpwell.AddSignatures(LDesc); } } cGlobalInfo.CurrentScreening.ListDescriptors.UpDateDisplay(); cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate(); for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++) cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax(); }
private void AddCorrelatedSquareDescItem(object sender, EventArgs e) { cDescriptorType ColumnType = new cDescriptorType("Square(" + cGlobalInfo.CurrentScreening.ListDescriptors[IntToTransfer].GetName() + ")", true, 1); cGlobalInfo.CurrentScreening.ListDescriptors.AddNew(ColumnType); foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable) { foreach (cWell Tmpwell in TmpPlate.ListActiveWells) { cListSignature LDesc = new cListSignature(); cSignature NewDesc = new cSignature(Math.Pow(Tmpwell.ListSignatures[IntToTransfer].GetValue(), 2), ColumnType, cGlobalInfo.CurrentScreening); LDesc.Add(NewDesc); Tmpwell.AddSignatures(LDesc); } } cGlobalInfo.CurrentScreening.ListDescriptors.UpDateDisplay(); cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate(); for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++) cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax(); }
public void CreateNewColumn(cDescriptorType NewDescType, cDescriptorType Desc0, eUnaryOperationType OperationType, cGlobalInfo GlobalInfo, ref cListWells ListWell) { string ColumnName = NewDescType.GetName(); int NumTableProcessed = 0; foreach (var item in GetListTableNames()) // loop over the wells { // compute the new values List<cDescriptorType> LDes = new List<cDescriptorType>(); LDes.Add(Desc0); // LDes.Add(Desc1); cExtendedTable LValues = this.GetWellValues(item, LDes); cExtendedList ListResults = new cExtendedList();// LValues[0].Operation(LValues[1], OperationType); if (OperationType == eUnaryOperationType.LOG) { for (int i = 0; i < LValues[0].Count; i++) { double tmpVal = LValues[0][i]; if (tmpVal <= 0) tmpVal = double.Epsilon; ListResults.Add(Math.Log10(tmpVal)); } } else if (OperationType == eUnaryOperationType.SQRT) { for (int i = 0; i < LValues[0].Count; i++) { double tmpVal = LValues[0][i]; if (tmpVal < 0) tmpVal = 0; ListResults.Add(Math.Sqrt(tmpVal)); } } else if (OperationType == eUnaryOperationType.ABS) { for (int i = 0; i < LValues[0].Count; i++) { double tmpVal = LValues[0][i]; ListResults.Add(Math.Abs(tmpVal)); } } else if (OperationType == eUnaryOperationType.EXP) { for (int i = 0; i < LValues[0].Count; i++) { double tmpVal = LValues[0][i]; ListResults.Add(Math.Exp(tmpVal)); } } #region Update the database // create new column SQLiteCommand mycommand = new SQLiteCommand(_SQLiteConnection); String SQL = "ALTER TABLE \"" + item + "\" ADD COLUMN \"" + ColumnName + "\" REAL DEFAULT 0"; using (SQLiteCommand Command = new SQLiteCommand(SQL, _SQLiteConnection)) { Command.ExecuteNonQuery(); } // write data using (SQLiteTransaction transaction = _SQLiteConnection.BeginTransaction()) using (SQLiteDataAdapter sqliteAdapter = new SQLiteDataAdapter("SELECT * FROM \"" + item + "\"", _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][ColumnName] = ListResults[i]; sqliteAdapter.Update(DS); } transaction.Commit(); } #endregion #region Update the screening data cListSignature LDesc = new cListSignature(); cSignature NewSignature = new cSignature(ListResults, 256, NewDescType, cGlobalInfo.CurrentScreening); LDesc.Add(NewSignature); string[] Positions = item.Split('x'); ListWell.GetFirstWell(int.Parse(Positions[1]), int.Parse(Positions[2])).AddSignatures(LDesc); #endregion NumTableProcessed++; } }
private void SubPopulationStatDescItem(object sender, EventArgs e) { PanelForClassSelection ClassSelectionPanel = new PanelForClassSelection(true, eClassType.PHENOTYPE); //ClassSelectionPanel.Height = WindowToDisplay.Height; ClassSelectionPanel.UnSelectAll(); ClassSelectionPanel.Select(0); ClassSelectionPanel.Select(1); ClassSelectionPanel.Location = new System.Drawing.Point(10, 10); ClassSelectionPanel.Width = 150; ClassSelectionPanel.Height = ClassSelectionPanel.ListCheckBoxes.Count * 25; ClassSelectionPanel.BorderStyle = BorderStyle.Fixed3D; FormForStatDesc NewWindow = new FormForStatDesc(this.GlobalInfo); NewWindow.panelForSubPopulation.Controls.Add(ClassSelectionPanel); NewWindow.textBoxDescName.Text = cGlobalInfo.CurrentScreening.ListDescriptors[IntToTransfer].GetName() + "_Average"; if (NewWindow.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; if ((NewWindow.comboBoxStatistics.Text != "Average") && (NewWindow.comboBoxStatistics.Text != "Stdev") && (NewWindow.comboBoxStatistics.Text != "Sum") && (NewWindow.comboBoxStatistics.Text != "Median") && (NewWindow.comboBoxStatistics.Text != "MAD") && (NewWindow.comboBoxStatistics.Text != "CV%")) return; List<cCellularPhenotype> LCP = new List<cCellularPhenotype>(); for (int IdxPheno = 0; IdxPheno < ClassSelectionPanel.GetListSelectedClass().Count; IdxPheno++) { if (ClassSelectionPanel.GetListSelectedClass()[IdxPheno]) LCP.Add(cGlobalInfo.ListCellularPhenotypes[IdxPheno]); } if (LCP.Count == 0) return; double RatioPopulation = 1; string description = "This descriptor has been generated by computing the " + NewWindow.textBoxDescName.Text + " of " + RatioPopulation * 100 + "% the following phenotypic sub-populations:\n"; foreach (var item in LCP) { description += item.Name + "\n"; } cDescriptorType NewAverageType = new cDescriptorType(NewWindow.textBoxDescName.Text, true, 1, description); cGlobalInfo.CurrentScreening.ListDescriptors.AddNew(NewAverageType); FormForProgress ProgressWindow = new FormForProgress(); ProgressWindow.Show(); int IdxProgress = 0; int MaxProgress = 0; foreach (cPlate CurrentPlateToProcess in cGlobalInfo.CurrentScreening.ListPlatesAvailable) MaxProgress += (int)CurrentPlateToProcess.ListActiveWells.Count; ProgressWindow.progressBar.Maximum = MaxProgress; foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable) { foreach (cWell Tmpwell in TmpPlate.ListActiveWells) { TmpPlate.DBConnection = new cDBConnection(TmpPlate, Tmpwell.SQLTableName); List<cDescriptorType> LDT = new List<cDescriptorType>(); LDT.Add(cGlobalInfo.CurrentScreening.ListDescriptors[IntToTransfer]); cExtendedTable CT = TmpPlate.DBConnection.GetWellValues(Tmpwell, LDT, LCP, RatioPopulation); cListSignature LDesc = new cListSignature(); double Value = 0; if (CT.Count == 1) { if (CT[0].Count == 0) { Value = 0; richTextBoxConsole.AppendText(TmpPlate.GetName() + " : " + Tmpwell.GetShortInfo().Remove(Tmpwell.GetShortInfo().Length - 2) + ": no objects fullfill your request. Statistics set to null.\n"); } else { if (NewWindow.comboBoxStatistics.Text == "Average") Value = CT[0].Average(); else if (NewWindow.comboBoxStatistics.Text == "Stdev") Value = CT[0].Std(); else if (NewWindow.comboBoxStatistics.Text == "Sum") Value = CT[0].Sum(); else if (NewWindow.comboBoxStatistics.Text == "Median") Value = CT[0].Median(); else if (NewWindow.comboBoxStatistics.Text == "MAD") Value = CT[0].MAD(true); else if (NewWindow.comboBoxStatistics.Text == "CV%") Value = CT[0].CV(); } } ProgressWindow.richTextBoxForComment.AppendText(Tmpwell.GetShortInfo() + ": " + CT[0].Count.ToString() + " / " + Tmpwell.GetNumBiologicalObjects() + "\n"); cSignature NewDesc = new cSignature(Value, NewAverageType, cGlobalInfo.CurrentScreening); LDesc.Add(NewDesc); Tmpwell.AddSignatures(LDesc); TmpPlate.DBConnection.CloseConnection(); ProgressWindow.progressBar.Value = IdxProgress++; ProgressWindow.richTextBoxForComment.AppendText(TmpPlate.GetName() + " : " + Tmpwell.GetShortInfo().Remove(Tmpwell.GetShortInfo().Length - 2) + "\n"); ProgressWindow.Refresh(); } } ProgressWindow.Close(); cGlobalInfo.CurrentScreening.ListDescriptors.UpDateDisplay(); cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate(); for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++) cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax(); }
private void RatioPopDescItem(object sender, EventArgs e) { cGUI_2ClassesSelection GUI_ListClasses = new cGUI_2ClassesSelection(); GUI_ListClasses.ClassType = eClassType.PHENOTYPE; GUI_ListClasses.PanelRight_IsCheckBoxes = true; GUI_ListClasses.PanelLeft_IsCheckBoxes = true; if (GUI_ListClasses.Run(this.GlobalInfo).IsSucceed == false) return; List<cCellularPhenotype> LCP0 = new List<cCellularPhenotype>(); List<cCellularPhenotype> LCP1 = new List<cCellularPhenotype>(); for (int IdxPheno = 0; IdxPheno < GUI_ListClasses.GetOutPut()[0].Count; IdxPheno++) { if (GUI_ListClasses.GetOutPut()[0][IdxPheno] == 1) LCP0.Add(cGlobalInfo.ListCellularPhenotypes[IdxPheno]); if (GUI_ListClasses.GetOutPut()[1][IdxPheno] == 1) LCP1.Add(cGlobalInfo.ListCellularPhenotypes[IdxPheno]); } //if (LCP.Count == 0) return; string description = "Ratio of:\n"; foreach (var item in LCP0) description += item.Name + "\n"; description += "over\n"; foreach (var item in LCP1) description += item.Name + "\n"; cDescriptorType NewAverageType = new cDescriptorType("Ratio_Pop", true, 1, description); cGlobalInfo.CurrentScreening.ListDescriptors.AddNew(NewAverageType); FormForProgress ProgressWindow = new FormForProgress(); ProgressWindow.Show(); int IdxProgress = 0; int MaxProgress = 0; foreach (cPlate CurrentPlateToProcess in cGlobalInfo.CurrentScreening.ListPlatesAvailable) MaxProgress += (int)CurrentPlateToProcess.ListWells.Count; ProgressWindow.progressBar.Maximum = MaxProgress; foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable) { foreach (cWell Tmpwell in TmpPlate.ListWells) { TmpPlate.DBConnection = new cDBConnection(TmpPlate, Tmpwell.SQLTableName); List<cDescriptorType> LDT = new List<cDescriptorType>(); LDT.Add(cGlobalInfo.CurrentScreening.ListDescriptors[0]); cExtendedTable CT = TmpPlate.DBConnection.GetWellValues(Tmpwell, LDT, LCP0, 1); double NumObject0 = CT[0].Count; cExtendedTable CT1 = TmpPlate.DBConnection.GetWellValues(Tmpwell, LDT, LCP1, 1); double NumObject1 = CT1[0].Count; cListSignature LDesc = new cListSignature(); double Value = 0; if (NumObject1 == 0) Value = 0; else Value = NumObject0 / NumObject1; cSignature NewDesc = new cSignature(Value, NewAverageType, cGlobalInfo.CurrentScreening); LDesc.Add(NewDesc); Tmpwell.AddSignatures(LDesc); TmpPlate.DBConnection.CloseConnection(); ProgressWindow.richTextBoxForComment.AppendText(TmpPlate.GetName() + " : " + Tmpwell.GetShortInfo().Remove(Tmpwell.GetShortInfo().Length - 2) + "\n"); ProgressWindow.progressBar.Value = IdxProgress++; ProgressWindow.Refresh(); } } ProgressWindow.Close(); cGlobalInfo.CurrentScreening.ListDescriptors.UpDateDisplay(); cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate(); for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++) cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax(); }
private void 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); }
private void NormalizeCheckedDescToDescriptorItem(object sender, EventArgs e) { FormForDescriptorNormalization WindowForDescNorm = new FormForDescriptorNormalization(); WindowForDescNorm.textBoxForDescName.Text = cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor().GetName(); if (WindowForDescNorm.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; // first: identify the reference desc. cDescriptorType SelectedDesc = cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor(); eBinaryOperationType OT = eBinaryOperationType.DIVIDE; string OperationString = " / "; if (WindowForDescNorm.radioButtonOperationMultiply.Checked) { OperationString = " * "; OT = eBinaryOperationType.MULTIPLY; } if (WindowForDescNorm.radioButtonOperationAdd.Checked) { OperationString = " + "; OT = eBinaryOperationType.ADD; } if (WindowForDescNorm.radioButtonOperationSubstract.Checked) { OperationString = " - "; OT = eBinaryOperationType.SUBSTRACT; } List<cDescriptorType> ListNewDesc = new List<cDescriptorType>(); int CurrentNumberOfDesc = cGlobalInfo.WindowHCSAnalyzer.checkedListBoxActiveDescriptors.Items.Count; for (int Idx = 0; Idx < CurrentNumberOfDesc; Idx++) { if (cGlobalInfo.CurrentScreening.ListDescriptors[Idx].IsActive()) { if (cGlobalInfo.CurrentScreening.ListDescriptors[Idx].GetBinNumber() == 1) { string NewName = cGlobalInfo.CurrentScreening.ListDescriptors[Idx].GetName() + OperationString; if (WindowForDescNorm.radioButtonValueCurrentActiveValue.Checked) NewName += SelectedDesc.GetName(); else NewName += WindowForDescNorm.numericUpDownValueConst.Value.ToString(); ListNewDesc.Add(new cDescriptorType(NewName, true, 1)); cGlobalInfo.CurrentScreening.ListDescriptors.AddNew(ListNewDesc[ListNewDesc.Count - 1]); } else { MessageBox.Show("Descriptor length not consistent (" + cGlobalInfo.CurrentScreening.ListDescriptors[Idx].GetName() + " : " + cGlobalInfo.CurrentScreening.ListDescriptors[Idx].GetBinNumber() + " bins", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } double NewValue = 1; double ValueForNormalization; foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable) { foreach (cWell Tmpwell in TmpPlate.ListActiveWells) { if (WindowForDescNorm.radioButtonValueConstant.Checked) ValueForNormalization = (double)WindowForDescNorm.numericUpDownValueConst.Value; else ValueForNormalization = Tmpwell.ListSignatures.GetSignature(SelectedDesc).GetValue(); int RealIDx = 0; for (int IdxActiveDesc = 0; IdxActiveDesc < CurrentNumberOfDesc; IdxActiveDesc++) { if (cGlobalInfo.CurrentScreening.ListDescriptors[IdxActiveDesc].IsActive()) { cListSignature LDesc = new cListSignature(); switch (OT) { case eBinaryOperationType.DIVIDE: NewValue = Tmpwell.ListSignatures[IdxActiveDesc].GetValue() / ValueForNormalization; break; case eBinaryOperationType.MULTIPLY: NewValue = Tmpwell.ListSignatures[IdxActiveDesc].GetValue() * ValueForNormalization; break; case eBinaryOperationType.ADD: NewValue = Tmpwell.ListSignatures[IdxActiveDesc].GetValue() + ValueForNormalization; break; case eBinaryOperationType.SUBSTRACT: NewValue = Tmpwell.ListSignatures[IdxActiveDesc].GetValue() - ValueForNormalization; break; default: break; } cSignature NewDesc = new cSignature(NewValue, ListNewDesc[RealIDx++], cGlobalInfo.CurrentScreening); LDesc.Add(NewDesc); Tmpwell.AddSignatures(LDesc); } } } } cGlobalInfo.CurrentScreening.ListDescriptors.UpDateDisplay(); cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate(); for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++) cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax(); }
public string GeneratePCADescriptor(cListPlates PlatesToProcess, int NumberOfAxis, int NeutralClass) { int NumWell = 0; int NumWellForLearning = 0; foreach (cPlate CurrentPlate in PlatesToProcess) { NumWellForLearning += CurrentPlate.GetNumberOfWellOfClass(NeutralClass); NumWell += cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().GetNumberOfActiveWells(); } if (NumWellForLearning == 0) { MessageBox.Show("No well identified !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return null; } int NumDesc = cGlobalInfo.CurrentScreening.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, cGlobalInfo.CurrentScreening.GetNumberOfActiveDescriptor() + 1]; // return; Matrix EigenVectors = PCAComputation(DataForLDA, NumWellForLearning, 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 = cGlobalInfo.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); cDescriptorType ColumnType = new cDescriptorType("PCA_" + (AxesIdx + 1), true, 1); while (cGlobalInfo.CurrentScreening.ListDescriptors.AddNew(ColumnType) == false) { FormForNewDescName NewNameWindow = new FormForNewDescName(); NewNameWindow.textBoxName.Text = ColumnType.GetName(); if (NewNameWindow.ShowDialog() != System.Windows.Forms.DialogResult.OK) return ColumnType.GetName(); ColumnType.ChangeName(NewNameWindow.textBoxName.Text); } //CompleteScreening.ListDescriptors.AddNew(ColumnType); foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable) { foreach (cWell Tmpwell in TmpPlate.ListActiveWells) { cListSignature LDesc = new cListSignature(); double NewValue = 0; IDxDesc = 0; // AxeName += "\nPCA_" + (AxesIdx + 1); for (int Idx = 0; Idx < OriginalDescNumber - 1; Idx++) { if (cGlobalInfo.CurrentScreening.ListDescriptors[Idx].IsActive()) // AxeName += String.Format("{0:0.###}", EigenVectors.getElement(IDxDesc, AxesIdx)) + "x" + CompleteScreening.ListDescriptors[Idx].GetName() + " + "; NewValue += EigenVectors.getElement(IDxDesc++, AxesIdx) * Tmpwell.ListSignatures[Idx].GetValue(); } cSignature NewDesc = new cSignature(NewValue, ColumnType, cGlobalInfo.CurrentScreening); LDesc.Add(NewDesc); Tmpwell.AddSignatures(LDesc); } } } cGlobalInfo.CurrentScreening.ListDescriptors.UpDateDisplay(); cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate(); for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++) cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax(); StartingUpDateUI(); return AxeName; }
private void ConcentrationToDescriptorItem(object sender, EventArgs e) { cDescriptorType ConcentrationType = new cDescriptorType("Concentration", true, 1); cGlobalInfo.CurrentScreening.ListDescriptors.AddNew(ConcentrationType); foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable) { foreach (cWell Tmpwell in TmpPlate.ListActiveWells) { cListSignature LDesc = new cListSignature(); object ConcentrationValue = Tmpwell.ListProperties.FindValueByName("Concentration"); float Value = 0; if (ConcentrationValue == null) { Value = 0; richTextBoxConsole.AppendText(Tmpwell.GetShortInfo() + ": Concentration NULL. Value set to 0\n"); } else Value = (float)ConcentrationValue; cSignature NewDesc = new cSignature(Value, ConcentrationType, cGlobalInfo.CurrentScreening); LDesc.Add(NewDesc); Tmpwell.AddSignatures(LDesc); } } cGlobalInfo.CurrentScreening.ListDescriptors.UpDateDisplay(); cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate(); for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++) cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax(); }
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 (cGlobalInfo.CurrentScreening != null) cGlobalInfo.CurrentScreening.Close3DView(); // CompleteScreening.ListDescriptors.RemoveDesc(CompleteScreening.ListDescriptors[IntToTransfer], CompleteScreening); cScreening MergedScreening = new cScreening("Merged Screen"); MergedScreening.PanelForPlate = this.panelForPlate; MergedScreening.Rows = cGlobalInfo.CurrentScreening.Rows; MergedScreening.Columns = cGlobalInfo.CurrentScreening.Columns; MergedScreening.ListPlatesAvailable = new cListPlates(null); // create the descriptor MergedScreening.ListDescriptors.Clean(); int Idesc = 0; List<cDescriptorType> ListDescType = new List<cDescriptorType>(); for (int i = 0; i < cGlobalInfo.CurrentScreening.ListDescriptors.Count; i++) { if (!cGlobalInfo.CurrentScreening.ListDescriptors[i].IsActive()) continue; cDescriptorType DescEC50 = new cDescriptorType("EC50_" + cGlobalInfo.CurrentScreening.ListDescriptors[i].GetName(), true, 1); ListDescType.Add(DescEC50); MergedScreening.ListDescriptors.AddNew(DescEC50); cDescriptorType DescTop = new cDescriptorType("Top_" + cGlobalInfo.CurrentScreening.ListDescriptors[i].GetName(), true, 1); ListDescType.Add(DescTop); MergedScreening.ListDescriptors.AddNew(DescTop); cDescriptorType DescBottom = new cDescriptorType("Bottom_" + cGlobalInfo.CurrentScreening.ListDescriptors[i].GetName(), true, 1); ListDescType.Add(DescBottom); MergedScreening.ListDescriptors.AddNew(DescBottom); cDescriptorType DescSlope = new cDescriptorType("Slope_" + cGlobalInfo.CurrentScreening.ListDescriptors[i].GetName(), true, 1); ListDescType.Add(DescSlope); MergedScreening.ListDescriptors.AddNew(DescSlope); Idesc++; } MergedScreening.ListDescriptors.CurrentSelectedDescriptorIdx = 0; foreach (cPlate CurrentPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable) { cPlate NewPlate = new cPlate(CurrentPlate.GetName() + " Merged", MergedScreening); // check if the plate exist already MergedScreening.AddPlate(NewPlate); foreach (cDRC_Region CurrentRegion in CurrentPlate.ListDRCRegions) { cListSignature LDesc = new cListSignature(); Idesc = 0; int IDESCBase = 0; for (int i = 0; i < cGlobalInfo.CurrentScreening.ListDescriptors.Count; i++) { if (!cGlobalInfo.CurrentScreening.ListDescriptors[i].IsActive()) continue; cDRC CurrentDRC = CurrentRegion.GetDRC(cGlobalInfo.CurrentScreening.ListDescriptors[IDESCBase++]); cSignature Desc_EC50 = new cSignature(CurrentDRC.EC50, ListDescType[Idesc++], cGlobalInfo.CurrentScreening); LDesc.Add(Desc_EC50); cSignature Desc_Top = new cSignature(CurrentDRC.Top, ListDescType[Idesc++], cGlobalInfo.CurrentScreening); LDesc.Add(Desc_Top); cSignature Desc_Bottom = new cSignature(CurrentDRC.Bottom, ListDescType[Idesc++], cGlobalInfo.CurrentScreening); LDesc.Add(Desc_Bottom); cSignature Desc_Slope = new cSignature(CurrentDRC.Slope, ListDescType[Idesc++], cGlobalInfo.CurrentScreening); LDesc.Add(Desc_Slope); } cWell NewWell = new cWell(LDesc, CurrentRegion.PosXMin + 1, CurrentRegion.PosYMin + 1, MergedScreening, NewPlate); NewWell.ListProperties.UpdateValueByName("Compound Name","DRC [" + CurrentRegion.PosXMin + ":" + CurrentRegion.PosYMin + "]"); NewPlate.AddWell(NewWell); } } // PanelList[0].CurrentScreening.ListPlatesActive.Clear(); // PanelList[0].CurrentScreening.GlobalInfo.WindowHCSAnalyzer.RefreshInfoScreeningRichBox(); MergedScreening.ListPlatesActive = new cListPlates(); 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); 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.GetCurrentDisplayPlate().DisplayDistribution(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor(), true); }
public void CreateNewColumnFromExisting(cDescriptorType NewDescType, string DescToBeDuplicated, cGlobalInfo GlobalInfo, ref cListWells ListWell) { this.CreateNewColumn(NewDescType.GetName(), 0); // cExtendedList ListResults = null; foreach (var item in GetListTableNames()) { SQLiteCommand mycommand = new SQLiteCommand(_SQLiteConnection); //update tableName set onefield = secondfield; string SQL = "UPDATE \"" + item + "\" SET \"" + NewDescType.GetName() + "\" = \"" + DescToBeDuplicated + "\""; using (SQLiteCommand Command = new SQLiteCommand(SQL, _SQLiteConnection)) { Command.ExecuteNonQuery(); } #region Update the screening data List<cDescriptorType> LDes = new List<cDescriptorType>(); LDes.Add(NewDescType); cExtendedTable LValues = this.GetWellValues(item, LDes); cListSignature LDesc = new cListSignature(); cSignature NewSignature = new cSignature(LValues[0], NewDescType.GetBinNumber(), NewDescType, cGlobalInfo.CurrentScreening); LDesc.Add(NewSignature); string[] Positions = item.Split('x'); ListWell.GetFirstWell(int.Parse(Positions[1]), int.Parse(Positions[2])).AddSignatures(LDesc); #endregion } return; }
private void mahalanobisDistanceToolStripMenuItem_Click(object sender, EventArgs e) { FormForMahalanobisDistance MainWindow = new FormForMahalanobisDistance(); PanelForClassSelection ClassSelectionPanel = new PanelForClassSelection(true, eClassType.WELL); ClassSelectionPanel.Height = MainWindow.panelForSourceCloud.Height; MainWindow.panelForSourceCloud.Controls.Add(ClassSelectionPanel); PanelForClassSelection HitClassSelectionPanel = new PanelForClassSelection(false, eClassType.WELL); HitClassSelectionPanel.Height = MainWindow.panelHitClass.Height; HitClassSelectionPanel.ListRadioButtons[1].Checked = true; MainWindow.panelHitClass.Controls.Add(HitClassSelectionPanel); if (MainWindow.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; cExtendedList ListClassSelected = new cExtendedList(); for (int i = 0; i < ClassSelectionPanel.ListCheckBoxes.Count; i++) if (ClassSelectionPanel.ListCheckBoxes[i].Checked) ListClassSelected.Add(1); else ListClassSelected.Add(0); int IdxClassForOutliers = 0; for (int i = 0; i < HitClassSelectionPanel.ListRadioButtons.Count; i++) if (HitClassSelectionPanel.ListRadioButtons[i].Checked) { IdxClassForOutliers = i; break; } if (ListClassSelected.Sum() < 1) { MessageBox.Show("At least one classe has to be selected.", "Error !", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // start by computing the inversed covariance matrix //if (checkedListBoxActiveDescriptors.CheckedItems.Count <= 1) //{ // MessageBox.Show("At least two descriptors have to be selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // return; //} cCovarianceMatrix CM = new cCovarianceMatrix(); cExtendedTable NewTable = null; if (this.ProcessModeplateByPlateToolStripMenuItem.Checked) { //foreach (cPlate TmpPlate in CompleteScreening.ListPlatesActive) //{ // cListWells ListWellsToProcess = new cListWells(null); // foreach (cWell item in TmpPlate.ListActiveWells) // if ((item.GetClassIdx() != -1) && (ListClassSelected[item.GetClassIdx()] == 1)) ListWellsToProcess.Add(item); // cExtendedTable NewTable = new cExtendedTable(ListWellsToProcess, true); // CM.SetInputData(NewTable); //} } else if (this.ProcessModeEntireScreeningToolStripMenuItem.Checked) { cListWells ListWellsToProcess = new cListWells(null); foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesActive) foreach (cWell item in TmpPlate.ListActiveWells) if ((item.GetCurrentClassIdx() != -1) && (ListClassSelected[item.GetCurrentClassIdx()] == 1)) ListWellsToProcess.Add(item); NewTable = new cExtendedTable(ListWellsToProcess, true); // cTwoSampleFTest CM = new cTwoSampleFTest(); CM.SetInputData(NewTable); } else { cListWells ListWellsToProcess = new cListWells(null); foreach (cWell item in cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().ListActiveWells) if ((item.GetCurrentClassIdx() != -1) && (ListClassSelected[item.GetCurrentClassIdx()] == 1)) ListWellsToProcess.Add(item); NewTable = new cExtendedTable(ListWellsToProcess, true); // cTwoSampleFTest CM = new cTwoSampleFTest(); CM.SetInputData(NewTable); } CM.Run(); cInverse cI = new cInverse(); cI.SetInputData(CM.GetOutPut()); cI.Run(); // get the cloud center cStatistics cstat = new cStatistics(); cstat.UnselectAll(); cstat.IsMean = true; cstat.SetInputData(NewTable); cstat.Run(); if (cstat.GetOutPut() == null) return; cExtendedList ListMeans = cstat.GetOutPut().GetRow(0); cDescriptorType MahalanobisType = new cDescriptorType("Mahalanobis Distance", true, 1); #region Compute the Threshold int DegreeOfFreedom = cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptors().Count; cExtendedTable T = new cExtendedTable(); T.Add(new cExtendedList()); T[0].Add((double)MainWindow.numericUpDownPValue.Value); cFunctions F = new cFunctions(); F.SetInputData(T); F.IsInverse = true; F.DegreeOfFreedom = DegreeOfFreedom; F.Run(); double ThresholdForMahalanobis = Math.Sqrt(F.GetOutPut()[1][0]); #endregion int IdxClassForNonOutliers = 1; foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable) { for (int Col = 0; Col < cGlobalInfo.CurrentScreening.Columns; Col++) for (int Row = 0; Row < cGlobalInfo.CurrentScreening.Rows; Row++) { cWell TmpWell = TmpPlate.GetWell(Col, Row, false); if (TmpWell == null) continue; double ValueDistance = TmpWell.GetAverageValuesList(true)[0].Dist_Mahalanobis(ListMeans, cI.GetOutPut()); if (ValueDistance > ThresholdForMahalanobis || double.IsNaN(ValueDistance) ) // that's an outlier { TmpWell.SetClass(IdxClassForOutliers); } else { TmpWell.SetClass(IdxClassForNonOutliers); } if (MainWindow.checkBoxDistAsDesc.Checked) { cListSignature LDesc = new cListSignature(); cSignature NewDesc = new cSignature(ValueDistance, MahalanobisType, cGlobalInfo.CurrentScreening); LDesc.Add(NewDesc); TmpWell.AddSignatures(LDesc); } } } if (MainWindow.checkBoxDistAsDesc.Checked) { cGlobalInfo.CurrentScreening.ListDescriptors.AddNew(MahalanobisType); } cGlobalInfo.CurrentScreening.ListDescriptors.UpDateDisplay(); cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate(); for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++) cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax(); }
private void RowToDescriptorItem(object sender, EventArgs e) { cDescriptorType RowType = new cDescriptorType("Row", true, 1); cGlobalInfo.CurrentScreening.ListDescriptors.AddNew(RowType); foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable) { foreach (cWell Tmpwell in TmpPlate.ListActiveWells) { cListSignature LDesc = new cListSignature(); cSignature NewDesc = new cSignature(Tmpwell.GetPosY(), RowType, cGlobalInfo.CurrentScreening); LDesc.Add(NewDesc); Tmpwell.AddSignatures(LDesc); } } cGlobalInfo.CurrentScreening.ListDescriptors.UpDateDisplay(); cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate(); for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++) cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax(); }
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(); }
private void SplitDescItem(object sender, EventArgs e) { int NumBin = cGlobalInfo.CurrentScreening.ListDescriptors[IntToTransfer].GetBinNumber(); // first we update the descriptor for (int i = 0; i < NumBin; i++) cGlobalInfo.CurrentScreening.ListDescriptors.AddNew(new cDescriptorType(cGlobalInfo.CurrentScreening.ListDescriptors[IntToTransfer].GetName() + "_" + i, true, 1)); foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable) { foreach (cWell Tmpwell in TmpPlate.ListActiveWells) { cListSignature LDesc = new cListSignature(); for (int i = 0; i < NumBin; i++) { cSignature NewDesc = new cSignature(Tmpwell.ListSignatures[IntToTransfer].GetHistovalue(i), cGlobalInfo.CurrentScreening.ListDescriptors[i + IntToTransfer + 1], cGlobalInfo.CurrentScreening); LDesc.Add(NewDesc); } Tmpwell.AddSignatures(LDesc); } } cGlobalInfo.CurrentScreening.ListDescriptors.UpDateDisplay(); cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate(); for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++) cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax(); }
void ConvertItem_Click(object sender, EventArgs e) { if (sender.GetType() != typeof(ToolStripMenuItem)) return; ToolStripMenuItem TMI = (ToolStripMenuItem)(sender); cPropertyType CP = null; if ((TMI.Tag != null) && (TMI.Tag.GetType() == typeof(cPropertyType))) CP = (cPropertyType)(TMI.Tag); else return; cDescriptorType ClassType = new cDescriptorType(CP.Name, true, 1); cGlobalInfo.CurrentScreening.ListDescriptors.AddNew(ClassType); foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable) { foreach (cWell Tmpwell in TmpPlate.ListWells) { cListSignature LDesc = new cListSignature(); double TmpValue = 0; object TmpObj = Tmpwell.ListProperties.FindByName(CP.Name).GetValue(); if ((TmpObj==null)||(!double.TryParse(TmpObj.ToString(), out TmpValue))) TmpValue = 0; cSignature NewDesc = new cSignature(TmpValue, ClassType, cGlobalInfo.CurrentScreening); LDesc.Add(NewDesc); Tmpwell.AddSignatures(LDesc); } } cGlobalInfo.CurrentScreening.ListDescriptors.UpDateDisplay(); cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate(); for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++) cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax(); }
/// <summary> /// Create a new column in the database of the current plate /// </summary> /// <param name="ColumnName">Column name</param> /// <param name="DefaultValue">Array of values</param> /// <returns>Return the number of table (i.e. wells) processed</returns> public void CreateNewColumn(cDescriptorType NewDescType, cDescriptorType Desc0, cDescriptorType Desc1, cSingleCellOperations SingleCellOperations, cGlobalInfo GlobalInfo, ref cListWells ListWell) { string ColumnName = NewDescType.GetName(); int NumTableProcessed = 0; foreach (var item in GetListTableNames()) // loop over the wells { // compute the new values List<cDescriptorType> LDes = new List<cDescriptorType>(); LDes.Add(Desc0); LDes.Add(Desc1); cExtendedTable LValues = this.GetWellValues(item, LDes); cExtendedList ListResults = LValues[0].Operation(LValues[1], SingleCellOperations.ListDualOperations[0]); if ((SingleCellOperations.PostProcessingOperation != null) && (SingleCellOperations.PostProcessingOperation.Count > 0)) { switch (SingleCellOperations.PostProcessingOperation[0]) { case eBinaryOperationType.ADD: ListResults += SingleCellOperations.PostProcessingValue; break; case eBinaryOperationType.SUBSTRACT: ListResults -= SingleCellOperations.PostProcessingValue; break; case eBinaryOperationType.MULTIPLY: ListResults *= SingleCellOperations.PostProcessingValue; break; case eBinaryOperationType.DIVIDE: ListResults /= SingleCellOperations.PostProcessingValue; break; default: break; } } #region Update the database // create new column SQLiteCommand mycommand = new SQLiteCommand(_SQLiteConnection); String SQL = "ALTER TABLE \"" + item + "\" ADD COLUMN \"" + ColumnName + "\" REAL DEFAULT 0"; using (SQLiteCommand Command = new SQLiteCommand(SQL, _SQLiteConnection)) { Command.ExecuteNonQuery(); } // write data using (SQLiteTransaction transaction = _SQLiteConnection.BeginTransaction()) using (SQLiteDataAdapter sqliteAdapter = new SQLiteDataAdapter("SELECT * FROM \"" + item + "\"", _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][ColumnName] = ListResults[i]; sqliteAdapter.Update(DS); } transaction.Commit(); } #endregion #region Update the screening data cListSignature LDesc = new cListSignature(); cSignature NewSignature = new cSignature(ListResults, 256, NewDescType, cGlobalInfo.CurrentScreening); LDesc.Add(NewSignature); string[] Positions = item.Split('x'); cWell TmpWell = ListWell.GetFirstWell(int.Parse(Positions[1]), int.Parse(Positions[2])); if(TmpWell!=null) TmpWell.AddSignatures(LDesc); #endregion NumTableProcessed++; } }