Esempio n. 1
0
            private void backgroundWorkerForCSVtoDB_DoWork(object sender, DoWorkEventArgs e)
            {
                BackgroundWorker worker = sender as BackgroundWorker;

                CSVsr = new CsvFileReader(PathName);
                CSVsr.Separator = this.Delimiter.ToCharArray()[0];
                CsvRow OriginalNames = new CsvRow();
                
                if (!CSVsr.ReadRow(OriginalNames))
                {
                    CSVsr.Close();
                    return;
                }

                int ColPlateName = GetColIdxFor("Plate name", CSVWindow);
                int ColCol = GetColIdxFor("Column", CSVWindow);
                int ColRow = GetColIdxFor("Row", CSVWindow);
                int ColWellPos = GetColIdxFor("Well position", CSVWindow);
                int ColPhenotypeClass = GetColIdxFor("Phenotype Class", CSVWindow);
                int[] ColsForDescriptors = GetColsIdxFor("Descriptor", CSVWindow);

                FormForProgress ProgressWindow = new FormForProgress();
                ProgressWindow.Text = "CSV -> DB : processing";
                ProgressWindow.Show();
                CsvRow CurrentDesc = new CsvRow();
                int TotalPlateNumber = 0;
                int TotalObjectNumber = 0;
                int TotalWellNumber = 0;
                string OriginalPlatePlateName;
                string CurrentPlateName;
                string ConvertedName;


                this.CompleteReportString += "Source file: " + PathName + "\n";
                this.CompleteReportString += OriginalNames.Count + " features selected.\n";
                this.CompleteReportString += "Time stamp: " + DateTime.Now.ToString() + " \n";

                if (CSVsr.ReadRow(CurrentDesc) == false) return;
                do
                {
                    if (ColPlateName == -1)
                    {
                        ConvertedName = OriginalPlatePlateName = CurrentPlateName = "Generated Plate Name";
                    }
                    else
                    {
                        OriginalPlatePlateName = CurrentDesc[ColPlateName];
                        CurrentPlateName = CurrentDesc[ColPlateName];
                        ConvertedName = "";

                        foreach (var c in System.IO.Path.GetInvalidFileNameChars())
                            ConvertedName = OriginalPlatePlateName.Replace(c, '-');
                    }

                    List<string> ListNameSignature = new List<string>();

                    for (int idxDesc = 0/*Mode + 1*/; idxDesc < ColsForDescriptors.Length/* + Mode + 1*/; idxDesc++)
                    {
                        string TmpSignature = OriginalNames[ColsForDescriptors[idxDesc]];
                        TmpSignature = TmpSignature.Replace('[', '_');
                        TmpSignature = TmpSignature.Replace(']', '_');

                        ListNameSignature.Add(TmpSignature);
                    }
                    ListNameSignature.Add("Phenotype_Class");
                    ListNameSignature.Add("Phenotype_Confidence");
                    cSQLiteDatabase SQDB = new cSQLiteDatabase(SelectedPath + "\\" + ConvertedName, ListNameSignature, true);

                    this.CompleteReportString += "\n" + CurrentPlateName + ":\n";
                    TotalPlateNumber++;

                    do
                    {
                        string OriginalWellPos;
                        int[] Pos = new int[2];

                        if (Mode == 1)
                        {
                            Pos = ConvertPosition(CurrentDesc[ColWellPos]);
                            if (Pos == null)
                            {
                                if (MessageBox.Show("Error in converting the current well position.\nGo to Edit->Options->Import-Export->Well Position Mode to fix this.\nDo you want continue ?", "Loading error !", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == System.Windows.Forms.DialogResult.No)
                                {
                                    CSVsr.Close();
                                    return;
                                }
                                //else
                                //    goto NEXTLOOP;
                            }
                            OriginalWellPos = CurrentDesc[ColWellPos];
                        }
                        else
                        {
                            if (int.TryParse(CurrentDesc[ColCol], out Pos[0]) == false)
                                goto NEXTLOOP;
                            if (int.TryParse(CurrentDesc[ColRow], out Pos[1]) == false)
                                goto NEXTLOOP;

                            OriginalWellPos = ConvertPosition(int.Parse(CurrentDesc[ColCol]), int.Parse(CurrentDesc[ColRow]));// "("+CurrentDesc[ColCol]+","+CurrentDesc[ColRow]+")";
                        }

                        string CurrentWellPos = OriginalWellPos;

                        cWellForDatabase WellForDB = new cWellForDatabase(OriginalPlatePlateName, Pos[0], Pos[1]);
                        cExtendedTable ListData = new cExtendedTable();
                        //   for (int idxDesc = 0; idxDesc < ColsForDescriptors.Length; idxDesc++)
                        //   ListData[idxDesc] = new List<double>();

                        ProgressWindow.richTextBoxForComment.AppendText(CurrentPlateName + " : " + CurrentWellPos + "\n");
                        //ProgressWindow.label.Refresh();
                        ProgressWindow.Refresh();

                        do
                        {
                            //  CurrentWellPos = CurrentDesc[ColWellPos];
                            cExtendedList Signature = new cExtendedList();

                            for (int idxDesc = 0; idxDesc < ColsForDescriptors.Length; idxDesc++)
                            {
                                double Value;

                                if (double.TryParse(CurrentDesc[ColsForDescriptors[idxDesc]], NumberStyles.Any, CultureInfo.InvariantCulture/*.CreateSpecificCulture("en-US")*/, out Value))
                                {
                                    if (double.IsNaN(Value))
                                        Signature.Add(0);
                                    else
                                        Signature.Add(Value);
                                }
                                else
                                {
                                    Signature.Add(0);
                                }

                            }
                            // if the class of the phenotype is defined in the file then use it
                            // if not, put it at 0
                            double ValueClass;
                            if ((ColPhenotypeClass != -1) && (double.TryParse(CurrentDesc[ColPhenotypeClass], out ValueClass) == true))
                            {
                                double IntValue = (int)(ValueClass) % cGlobalInfo.ListCellularPhenotypes.Count;
                                Signature.Add(IntValue);
                            }
                            else
                            {
                                Signature.Add(0);
                            }

                            // finally add the classification confidence column (1 by default)
                            Signature.Add(1);

                            ListData.Add(Signature);
                            // WellForDB.AddSignature(Signature);
                            // manage the end of the file
                            if (CSVsr.ReadRow(CurrentDesc) == false)
                            {
                                WellForDB.AddListSignatures(ListData);
                                cFeedBackMessage FeedBackMessage = SQDB.AddNewWell(WellForDB);
                                SQDB.CloseConnection();
                                // this.CompleteReportString += FeedBackMessage.Message + "\n";
                                goto NEXTLOOP;
                            }
                            if (ColPlateName == -1)
                                CurrentPlateName = "Generated Plate Name";
                            else
                                CurrentPlateName = CurrentDesc[ColPlateName];

                            if (Mode == 1)
                                CurrentWellPos = CurrentDesc[ColWellPos];
                            else
                            {
                                int ResCol;
                                int ResRow;
                                if ((!int.TryParse(CurrentDesc[ColCol], out ResCol)) || (!int.TryParse(CurrentDesc[ColRow], out ResRow))) goto NEXTLOOP;

                                CurrentWellPos = ConvertPosition(ResCol, ResRow);
                            }

                            TotalObjectNumber++;

                            // NEXTSIGNATURE: ;

                        } while (CurrentWellPos == OriginalWellPos);

                        TotalWellNumber++;

                        WellForDB.AddListSignatures(ListData);
                        SQDB.AddNewWell(WellForDB);

                        ReportTable.ListRowNames.Add(CurrentPlateName + " : " + CurrentWellPos);
                        ReportTable[0].Add(ListData.Count);
                        ReportTable[0].ListTags.Add(CurrentPlateName + " : " + CurrentWellPos + "\n" + ListData.Count + " objects");
                        this.CompleteReportString += "\t" + CurrentWellPos + " : " + ListData.Count + " objects\n";

                    NEXTSIGNATURE: ;

                    } while (OriginalPlatePlateName == CurrentPlateName);

                    SQDB.CloseConnection();
                } while (true);

            NEXTLOOP: ;
                ProgressWindow.Close();

                this.CompleteReportString += "\n-----------------------------\n";
                this.CompleteReportString += TotalPlateNumber + " plates\n";
                this.CompleteReportString += TotalWellNumber + " wells\n";
                this.CompleteReportString += TotalObjectNumber + " objects\n";
                this.CompleteReportString += "\nDataBase location:\n" + SelectedPath;
                //    worker.ReportProgress(10);
            }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        private void TSItemSubPopSelectionDataTableImages(object sender, EventArgs e)
        {
            ToolStripMenuItem ParentTag = (ToolStripMenuItem)(sender);
            List<int> MyList = ((List<int>)(ParentTag.Tag));

            cExtendedTable ET = new cExtendedTable(this.InputSimpleData.Count, MyList.Count, 0);

            for (int i = 0; i < this.InputSimpleData.Count; i++)
            {
                ET[i].Name = this.InputSimpleData[i].Name;
            }

            ET.ListRowNames = new List<string>();
            for (int i = 0; i < MyList.Count; i++)
            {
                ET.ListRowNames.Add(i.ToString());
            }

            if (this.InputSimpleData.ListTags != null) ET.ListTags = new List<object>();

            int IdxPt = 0;

            FormForProgress FP = new FormForProgress();
            FP.Show();

            int MaxProgress = MyList.Count;
            FP.progressBar.Maximum = MaxProgress;

            foreach (var item in MyList)
            {
                for (int i = 0; i < this.InputSimpleData.Count; i++)
                {
                    ET[i][IdxPt] = this.InputSimpleData[i][MyList[IdxPt]];
                }

                if ((this.InputSimpleData.ListTags != null) && (this.InputSimpleData.ListTags[IdxPt] != null))
                {
                    if (this.InputSimpleData.ListTags[MyList[IdxPt]].GetType() == typeof(cSingleBiologicalObject))
                    {
                        cSingleBiologicalObject TmpBioObj = ((cSingleBiologicalObject)this.InputSimpleData.ListTags[MyList[IdxPt]]);
                        List<cImageMetaInfo> ListMeta = cGlobalInfo.ImageAccessor.GetImageInfo(TmpBioObj);
                        if (ListMeta==null) continue;
                        cImage Image = new cImage(ListMeta);
                        TmpBioObj.BD_BoxMax.Z = TmpBioObj.BD_BoxMin.Z = 0;
                        cImage CroppedImaged = Image.Crop(TmpBioObj.BD_BoxMin, TmpBioObj.BD_BoxMax);

                        if((cGlobalInfo.TmpImageDisplayProperties==null)||(cGlobalInfo.TmpImageDisplayProperties.ListMin.Count != CroppedImaged.GetNumChannels()))
                        {
                            ET.ListTags.Add(CroppedImaged.GetBitmap(1f, null, null));
                        }
                        else
                        {
                            cImageDisplayProperties IP = cGlobalInfo.TmpImageDisplayProperties;
                            ET.ListTags.Add(CroppedImaged.GetBitmap(1f, IP, null));
                        }

                        FP.richTextBoxForComment.AppendText("Object "+ IdxPt +" / "+MyList.Count +"\n");
                    }

                }
                FP.progressBar.Value = IdxPt;

                FP.Refresh();
                IdxPt++;
            }

            FP.Close();

            ET.Name = "Data Table - " + MyList.Count + " Objects";
            cDisplayExtendedTable DET = new cDisplayExtendedTable();
            DET.SetInputData(ET);
            DET.Run();

            //DataPoint DP = new DataPoint();

            //if (this.InputSimpleData[0].ListTags != null)
            //{
            //    if (j >= this.InputSimpleData[0].ListTags.Count) continue;
            //    DP.Tag = this.InputSimpleData[0].ListTags[j];

            //    //    if (DP.Tag.GetType() == typeof(cWell))
            //    //    {
            //    //        DP.Color = ((cWell)(DP.Tag)).GetClassColor();
            //    //        DP.ToolTip = ((cWell)(DP.Tag)).GetShortInfo() + Value[0];
            //    //    }
            //    if (DP.Tag.GetType() == typeof(cSingleBiologicalObject))
            //    {
            //        //        DP.Color = ((cSingleBiologicalObject)(DP.Tag)).GetColor();
            //        //        DP.ToolTip = ((cSingleBiologicalObject)(DP.Tag)).GetAssociatedPhenotype().Name + "\nValue: (" + DP.XValue.ToString("N2") + ":" + DP.YValues[0].ToString("N2") + ")";

            //    }
            //}
        }
Esempio n. 4
0
        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();
        }
Esempio n. 5
0
        private void SingleCellOperationsToDescriptorItem(object sender, EventArgs e)
        {
            List<string> ListNamesDesc = new List<string>();
            foreach (var item in cGlobalInfo.CurrentScreening.ListDescriptors)
            {
                if (item.GetDataType() != "Single")
                {
                    ListNamesDesc.Add(item.GetName());
                }
            }

            FormForDescOperations MainWindow = new FormForDescOperations(ListNamesDesc);
            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, 256, true);
            cGlobalInfo.CurrentScreening.ListDescriptors.AddNew(NewDescType);

            //HCSAnalyzer.Classes.General_Types.cDBConnection.cSingleCellOperations SCO = new HCSAnalyzer.Classes.General_Types.cDBConnection.cSingleCellOperations()

            cSingleCellOperations SingleCellOperation = new cSingleCellOperations();

            if (MainWindow.tabControlMain.SelectedTab.Name == "tabPageBinary")
            {
                SingleCellOperation.ListDualOperations = new List<eBinaryOperationType>();
                //  eDualOperationType OperationType = eDualOperationType.ADD;
                switch (MainWindow.domainUpDown1.Text)
                {
                    case "*":
                        SingleCellOperation.ListDualOperations.Add(eBinaryOperationType.MULTIPLY);
                        break;
                    case "+":
                        SingleCellOperation.ListDualOperations.Add(eBinaryOperationType.ADD);
                        break;
                    case "/":
                        SingleCellOperation.ListDualOperations.Add(eBinaryOperationType.DIVIDE);
                        break;
                    case "-":
                        SingleCellOperation.ListDualOperations.Add(eBinaryOperationType.SUBSTRACT);
                        break;
                    default:
                        return;
                }

                if (MainWindow.checkBoxActivePostProcess.Checked)
                {
                    SingleCellOperation.PostProcessingOperation = new List<eBinaryOperationType>();

                    switch (MainWindow.domainUpDownPostProcessOperator.Text)
                    {
                        case "*":
                            SingleCellOperation.PostProcessingOperation.Add(eBinaryOperationType.MULTIPLY);
                            break;
                        case "+":
                            SingleCellOperation.PostProcessingOperation.Add(eBinaryOperationType.ADD);
                            break;
                        case "/":
                            SingleCellOperation.PostProcessingOperation.Add(eBinaryOperationType.DIVIDE);
                            break;
                        case "-":
                            SingleCellOperation.PostProcessingOperation.Add(eBinaryOperationType.SUBSTRACT);
                            break;
                        default:
                            return;
                    }

                    SingleCellOperation.PostProcessingValue = (double)MainWindow.numericUpDownPostProcessValue.Value;
                }

                foreach (cPlate CurrentPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable)
                {
                    CurrentPlate.DBConnection.OpenConnection();
                    CurrentPlate.DBConnection.CreateNewColumn(NewDescType,
                                                                DescType1,
                                                                DescType2,
                                                                SingleCellOperation,
                                                                GlobalInfo, ref CurrentPlate.ListActiveWells);
                    CurrentPlate.DBConnection.CloseConnection();
                    ProgressWindow.progressBar.Value = IdxProgress++;
                    ProgressWindow.richTextBoxForComment.AppendText(CurrentPlate.GetShortInfo());
                    ProgressWindow.Refresh();
                }
            }
            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)
                {
                    CurrentPlate.DBConnection.OpenConnection();
                    CurrentPlate.DBConnection.CreateNewColumn(NewDescType,
                                                                DescType1,
                                                                OperationType,
                                                                GlobalInfo, ref CurrentPlate.ListActiveWells);
                    CurrentPlate.DBConnection.CloseConnection();
                    ProgressWindow.progressBar.Value = IdxProgress++;
                    ProgressWindow.richTextBoxForComment.AppendText(CurrentPlate.GetShortInfo());
                    ProgressWindow.Refresh();
                }

            }

            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);
        }
Esempio n. 6
0
        private void SingleCellOperationPhenotypeConfidenceToDesc(object sender, EventArgs e)
        {
            //string description = "This descriptor has been generated by converting single cell phenotypic class into feature\n";
            FormForNameRequest FFNR = new FormForNameRequest();
            FFNR.Text = "Descriptor Name";
            FFNR.textBoxForName.Text = "Classification Confidence";
            if (FFNR.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;
            if (FFNR.textBoxForName.Text == "") return;

            cDescriptorType NewDescType = new cDescriptorType(FFNR.textBoxForName.Text, true, cGlobalInfo.ListCellularPhenotypes.Count, true);
            cGlobalInfo.CurrentScreening.ListDescriptors.AddNew(NewDescType);

            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 CurrentPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable)
            {
                CurrentPlate.DBConnection.OpenConnection();
                CurrentPlate.DBConnection.CreateNewColumnFromExisting(NewDescType, "Phenotype_Confidence", GlobalInfo, ref CurrentPlate.ListActiveWells);
                CurrentPlate.DBConnection.CloseConnection();
                ProgressWindow.progressBar.Value = IdxProgress++;
                ProgressWindow.richTextBoxForComment.AppendText(CurrentPlate.GetShortInfo());
                ProgressWindow.Refresh();
            }

            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);
        }
Esempio n. 7
0
        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();
        }
Esempio n. 8
0
        public void PerformClassification()
        {
            FormForSingleCellClassifOptions FFSC = new FormForSingleCellClassifOptions();
            //cGUI_ListClasses GLC = new cGUI_ListClasses();
            //GLC.ClassType = eClassType.PHENOTYPE;
            //GLC.IsCheckBoxes = true;
            //GLC.IsSelectAll = true;
            //GLC.Run(GlobalInfo);

            PanelForClassSelection PhenotypeSelectionPanel = new PanelForClassSelection( true, eClassType.PHENOTYPE);
            PhenotypeSelectionPanel.Height = FFSC.panelPhenoToBeClassified.Height;
            FFSC.panelPhenoToBeClassified.Controls.Add(PhenotypeSelectionPanel);

            PanelForClassSelection WellClassSelectionPanel = new PanelForClassSelection( true, eClassType.WELL);
            WellClassSelectionPanel.Height = FFSC.panelWellToBeClassified.Height;
            FFSC.panelWellToBeClassified.Controls.Add(WellClassSelectionPanel);

            PanelForPlatesSelection PlatesSelectionPanel = new PanelForPlatesSelection( true, null, true);
            PlatesSelectionPanel.Height = FFSC.panelWellToBeClassified.Height;
            FFSC.tabPagePlates.Controls.Add(PlatesSelectionPanel);

            if (FFSC.ShowDialog() != DialogResult.OK) return;

            // ----------------------- Classification ------------------------------
            int DescrCount = cGlobalInfo.CurrentScreening.ListDescriptors.Count;

            this.UpDateNumberOfCluster();
            if (NumberOfClusters == 0)
            {
                System.Windows.Forms.MessageBox.Show("Number of cluster is null", "Error !", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }

            //if (FFSC.checkBoxGenerationRatio.Checked)
            //{
            //    // first we update the descriptor
            //    for (int i = 0; i < this.NumberOfClusters; i++)
            //        GlobalInfo.CurrentScreening.ListDescriptors.AddNew(new cDescriptorType("Ratio_" + GlobalInfo.ListCellularPhenotypes[i].Name, true, 1, GlobalInfo));
            //}

            FormForProgress ProgressWindow = new FormForProgress();
            ProgressWindow.Show();

            int IdxProgress = 0;
            int MaxProgress = 0;

            #region Confusion Matrix init
            cListExtendedTable LT = new cListExtendedTable();
            cExtendedTable ConfusionMatrix = new cExtendedTable(cGlobalInfo.ListCellularPhenotypes.Count, cGlobalInfo.ListCellularPhenotypes.Count, 0);
            ConfusionMatrix.Name = "Confusion Matrix (global)";
            ConfusionMatrix.ListRowNames = new List<string>();
            for (int i = 0; i < cGlobalInfo.ListCellularPhenotypes.Count; i++)
            {
                ConfusionMatrix.ListRowNames.Add(cGlobalInfo.ListCellularPhenotypes[i].Name + "*");
                ConfusionMatrix[i].Name = cGlobalInfo.ListCellularPhenotypes[i].Name;
            }
            LT.Add(ConfusionMatrix);
            for (int i = 0; i < cGlobalInfo.ListWellClasses.Count; i++)
            {
                cExtendedTable ConfusionMatrixTmp = new cExtendedTable(cGlobalInfo.ListCellularPhenotypes.Count, cGlobalInfo.ListCellularPhenotypes.Count, 0);
                ConfusionMatrixTmp.Name = "Confusion Matrix - " + cGlobalInfo.ListWellClasses[i].Name;
                ConfusionMatrixTmp.ListRowNames = new List<string>();
                for (int j = 0; j < cGlobalInfo.ListCellularPhenotypes.Count; j++)
                {
                    ConfusionMatrixTmp.ListRowNames.Add(cGlobalInfo.ListCellularPhenotypes[j].Name + "*");
                    ConfusionMatrixTmp[j].Name =cGlobalInfo.ListCellularPhenotypes[j].Name;
                }
                LT.Add(ConfusionMatrixTmp);
            }
            #endregion

            cListPlates LP = PlatesSelectionPanel.GetListSelectedPlates();

            foreach (cPlate CurrentPlateToProcess in LP /*GlobalInfo.CurrentScreening.ListPlatesAvailable*/)
                MaxProgress += (int)CurrentPlateToProcess.ListActiveWells.Count;
            ProgressWindow.progressBar.Maximum = MaxProgress;

            FastVector attVals = new FastVector();
            for (int i = 0; i < this.NumberOfClusters; i++)
                attVals.addElement(i.ToString());

            cPlate CurrentDispPlate = cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate();

            foreach (cPlate CurrentPlateToProcess in LP/* GlobalInfo.CurrentScreening.ListPlatesAvailable*/)
            {
                foreach (cWell TmpWell in CurrentPlateToProcess.ListActiveWells)
                {
                    ProgressWindow.progressBar.Value = IdxProgress++;

                    if (TmpWell.GetCurrentClassIdx() == -1) continue;
                    if (WellClassSelectionPanel.ListCheckBoxes[TmpWell.GetCurrentClassIdx()].Checked == false) continue;

                    DataTable FinalDataTable = new DataTable();
                    TmpWell.AssociatedPlate.DBConnection = new cDBConnection(TmpWell.AssociatedPlate, TmpWell.SQLTableName);
                    TmpWell.AssociatedPlate.DBConnection.AddWellToDataTable(TmpWell, FinalDataTable, this.GlobalInfo);
                    cListSingleBiologicalObjects LSBO = TmpWell.AssociatedPlate.DBConnection.GetBiologicalPhenotypes(TmpWell);
                    //TmpWell.AssociatedPlate.DBConnection.AddWellToDataTable(TmpWell, FinalDataTable, checkBoxIncludeWellClassAsDesc.Checked, GlobalInfo);
                    Instances ListInstancesTOClassify = this.CreateInstancesWithoutClass(FinalDataTable);

                    ListInstancesTOClassify.insertAttributeAt(new weka.core.Attribute("Class", attVals), ListInstancesTOClassify.numAttributes());
                    ListInstancesTOClassify.setClassIndex(ListInstancesTOClassify.numAttributes() - 1);

                    cExtendedList ListNewClasses = new cExtendedList();

                    int NumInstances = ListInstancesTOClassify.numInstances();
                    for (int i = 0; i < NumInstances; i++)
                    {
                        // ClassId contains the new class
                        Instance CurrentInst = ListInstancesTOClassify.instance(i);

                        double classId = this.CurrentClassifier.classifyInstance(CurrentInst);
                        double[] ClassConfidence = this.CurrentClassifier.distributionForInstance(CurrentInst);
                        LSBO[i].ClassificationConfidence = ClassConfidence[(int)classId];
                        ListNewClasses.Add(classId);

                        if (CurrentPlateToProcess == CurrentDispPlate)
                        {
                            LT[0][LSBO[i].GetAssociatedPhenotype().Idx][(int)classId]++;

                            if (TmpWell.GetCurrentClassIdx() >= 0)
                                LT[TmpWell.GetCurrentClassIdx() + 1][LSBO[i].GetAssociatedPhenotype().Idx][(int)classId]++;
                        }
                    }

                    ProgressWindow.richTextBoxForComment.AppendText(TmpWell.GetShortInfo().Remove(TmpWell.GetShortInfo().Length - 2) + " : " + NumInstances + " objects\n");
                    ProgressWindow.Refresh();
                    // ------------- update class within the database -----------------------------
                    TmpWell.AssociatedPlate.DBConnection.ChangePhenotypeClass(TmpWell, ListNewClasses);

                    //if (FFSC.checkBoxGenerationRatio.Checked)
                    //{
                    //    List<double[]> Histo = ListNewClasses.CreateHistogram(0, ListInstancesTOClassify.numClasses(), ListInstancesTOClassify.numClasses());
                    //    cListSignature LDesc = new cListSignature();

                    //    for (int IdxHisto = 0; IdxHisto < Histo[1].Length - 1; IdxHisto++)
                    //    {
                    //        Histo[1][IdxHisto] = (100.0 * Histo[1][IdxHisto]) / (double)ListInstancesTOClassify.numInstances();

                    //        cSignature NewDesc = new cSignature(Histo[1][IdxHisto], GlobalInfo.CurrentScreening.ListDescriptors[IdxHisto + DescrCount], GlobalInfo.CurrentScreening);
                    //        LDesc.Add(NewDesc);
                    //    }
                    //    TmpWell.AddSignatures(LDesc);
                    //}

                    TmpWell.AssociatedPlate.DBConnection.CloseConnection();
                }
            }

            #region Display Report
            cDesignerSplitter DS = new cDesignerSplitter();
            DS.Orientation = Orientation.Vertical;

            cViewertext VTEXT = new cViewertext();
            VTEXT.SetInputData(ProgressWindow.richTextBoxForComment.Text);
            VTEXT.Run();

            cDesignerTab DT = new cDesignerTab();
            DT.IsMultiline = false;

            foreach (var item in LT)
            {
                cViewerTable VT = new cViewerTable();
                VT.SetInputData(item);
                VT.DigitNumber = 0;
                VT.Run();
                DT.SetInputData(VT.GetOutPut());
            }

            DT.Run();

            cExtendedControl TextEC = DT.GetOutPut();
            TextEC.Width = 0;
            TextEC.Height = 0;
            TextEC.Anchor = (System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom
                                                                | System.Windows.Forms.AnchorStyles.Left
                                                                | System.Windows.Forms.AnchorStyles.Right);

            DS.SetInputData(VTEXT.GetOutPut());
            DS.SetInputData(TextEC);

            DS.Run();

            ProgressWindow.Close();

            cDisplayToWindow CDT = new cDisplayToWindow();
            CDT.SetInputData(DS.GetOutPut());
            CDT.IsModal = true;
            CDT.Title = "Phenotypic Classificaton Report";
            CDT.Run();
            CDT.Display();

            #endregion

            //if (IsKeepOriginalDesc == System.Windows.Forms.DialogResult.No)
            //{
            //    // int DescNumToRemove = GlobalInfo.CurrentScreen.ListDescriptors.Count -
            //    for (int IdxDesc = 0; IdxDesc < DescrCount; IdxDesc++)
            //        GlobalInfo.CurrentScreening.ListDescriptors.RemoveDesc(GlobalInfo.CurrentScreening.ListDescriptors[0], GlobalInfo.CurrentScreening);
            //}

            cGlobalInfo.CurrentScreening.ListDescriptors.UpDateDisplay();
            cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate();

            for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++)
                cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax();

            //WindowFormForCellbyCellClassif.Close();
            //WindowClusteringInfo.Close();
        }