示例#1
0
 public void AutomatedRefresh(cDescriptorType CurrentDescriptorType, bool IsFullScreen)
 {
     if (IsFullScreen == false)
     {
         cExtendedTable MinMax = this.AssociatedPlate.GetMinMax(CurrentDescriptorType);
         this.GeneralMin = MinMax[0][0];
         this.GeneralMax = MinMax[0][1];
     }
 }
示例#2
0
        public FormForDescriptorInfo(cDescriptorType CurrentDesc)
        {
            this.CurrentDesc = CurrentDesc;
            InitializeComponent();
            this.textBoxNameDescriptor.Text = CurrentDesc.GetName();
            this.richTextBoxDescription.Text = CurrentDesc.description;
            this.labelDataType.Text = CurrentDesc.GetDataType();
            if (CurrentDesc.GetDataType() == "Single")
                this.numericUpDownBinValue.Visible = false;
            this.numericUpDownBinValue.Value = CurrentDesc.GetBinNumber();

            this.OriginalBinNumber = CurrentDesc.GetBinNumber();

            if (CurrentDesc.IsConnectedToDatabase)
            {
                this.labelDataBaseConnection.Text = "DataBase Connection.";
                panelForColor.BackColor = Color.LightGreen;
            }
            else
            {
                this.labelDataBaseConnection.Text = "No DataBase connection.";
                panelForColor.BackColor = Color.Red;
            }
        }
示例#3
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();
        }
示例#4
0
        public cExtendedTable GetWellValues(cWell TmpWell, cDescriptorType DescType)
        {
            List<cDescriptorType> LCDT = new List<cDescriptorType>();
            LCDT.Add(DescType);

            cExtendedTable ToReturn = new cExtendedTable(this.GetWellValues(TmpWell, LCDT));

            cListSingleBiologicalObjects ListClassesPhenotypes =
                this.GetBiologicalPhenotypes(/*this.GetWellValues(TmpWell.SQLTableName, DescType),*/ TmpWell);

            for (int i = 0; i < ToReturn.Count; i++)
            {
                ToReturn[i].ListTags = new List<object>();

                for (int j = 0; j < ListClassesPhenotypes.Count; j++)
                    ToReturn[i].ListTags.Add(ListClassesPhenotypes[j]);
            }

            return ToReturn;
        }
示例#5
0
        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;
        }
示例#6
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);
        }
示例#7
0
        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();
        }
示例#8
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);
        }
示例#9
0
        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();
        }
示例#10
0
文件: cPlate.cs 项目: cyrenaique/HCSA
        public cExtendedTable GetAverageValueTable(cDescriptorType DescriptorType, bool OnlySelectedWells)
        {
            cExtendedTable DV = new cExtendedTable(ParentScreening.Columns, ParentScreening.Rows, double.NaN);

            DV.ListRowNames = new List<string>();

            for (int i = 0; i < ParentScreening.Columns; i++)
            {
                DV[i].Name = (i + 1).ToString();
                DV[i].ListTags = new List<object>();
                for (int j = 0; j < ParentScreening.Rows; j++)
                {
                    if (i == 0)
                    {
                        byte[] strArray = new byte[1];
                        strArray[0] = (byte)(j + 65);

                        string Chara = Encoding.UTF7.GetString(strArray);
                        DV.ListRowNames.Add(String.Format("{0}\t", Chara));
                    }
                    cWell TmpWell = this.GetWell(i, j, OnlySelectedWells);

                    if (TmpWell != null)
                    {
                        DV[i].ListTags.Add(TmpWell);
                        DV[i][j] = TmpWell.GetAverageValue(DescriptorType);
                    }
                }
            }

            DV.Name = this.GetName() + " - " + DescriptorType.GetName();

            return DV;
        }
示例#11
0
文件: cPlate.cs 项目: cyrenaique/HCSA
        public cExtendedTable GetMinMax(cDescriptorType DescriptorType)
        {
            cExtendedList MinMax = new cExtendedList();
            MinMax.Name = "Min-Max";

            cExtendedTable ListValues = this.GetAverageValueList(DescriptorType, false);
            if (ListValues == null) return null;
            MinMax.Add(ListValues.Min());
            MinMax.Add(ListValues.Max());

            return new cExtendedTable(MinMax);
        }
示例#12
0
文件: cWell.cs 项目: cyrenaique/HCSA
 public double GetAverageValue(cDescriptorType DescriptorType)
 {
     return ListSignatures.GetSignature(DescriptorType).GetValue();
 }
示例#13
0
文件: cPlate.cs 项目: cyrenaique/HCSA
        public cExtendedTable GetAverageValueList(cDescriptorType DescriptorType, bool OnlySelectedWells)
        {
            List<cDescriptorType> LDesc = new List<cDescriptorType>();
            LDesc.Add(DescriptorType);

            cExtendedTable DV = this.ListActiveWells.GetAverageDescriptorValues(LDesc, false, false);

            return DV;
        }
示例#14
0
文件: cWell.cs 项目: cyrenaique/HCSA
 public cViewerStackedHistogram GetViewerStackedHistogram(cDescriptorType DT)
 {
     cListWells LW = new cListWells(this);
     return LW.GetSingleCellStackedHisto(DT,null);
 }
示例#15
0
文件: cWell.cs 项目: cyrenaique/HCSA
        public cExtendedTable GetValuesList(cDescriptorType DescriptorType)
        {
            this.AssociatedPlate.DBConnection = new cDBConnection(this.AssociatedPlate, this.SQLTableName);

            cListSingleBiologicalObjects ListPhenotypes =
                this.AssociatedPlate.DBConnection.GetBiologicalPhenotypes(this);

            cExtendedTable ET = this.AssociatedPlate.DBConnection.GetWellValues(this, DescriptorType);

            this.AssociatedPlate.DBConnection.CloseConnection();

            return ET;
        }
示例#16
0
        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);
        }
示例#17
0
        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();
        }
示例#18
0
文件: cPlate.cs 项目: cyrenaique/HCSA
        public void ComputePlateBasedDescriptors()
        {
            cDescriptorType TypeRow = new cDescriptorType("Row_Pos", true, 1);
            cDescriptorType TypeCol = new cDescriptorType("Col_Pos", true, 1);
            cDescriptorType TypeDistBorder = new cDescriptorType("Dist_To_Border", true, 1);
            cDescriptorType TypeDistCenter = new cDescriptorType("Dist_To_Center", true, 1);

            for (int j = 0; j < ParentScreening.Rows; j++)
                for (int i = 0; i < ParentScreening.Columns; i++)
                {
                    cWell TempWell = GetWell(i, j, false);
                    if (TempWell == null) continue;

                    TempWell.ListPlateBasedDescriptors = new cListSignature();

                    cSignature Descriptor0 = new cSignature(j, TypeRow, this.ParentScreening);
                    TempWell.ListPlateBasedDescriptors.Add(Descriptor0);

                    cSignature Descriptor1 = new cSignature(i, TypeCol, this.ParentScreening);
                    TempWell.ListPlateBasedDescriptors.Add(Descriptor1);

                    double MinDist = i + 1;
                    double DistToRight = ParentScreening.Columns - i;
                    if (DistToRight < MinDist) MinDist = DistToRight;
                    double DistToTop = j + 1;
                    if (DistToTop < MinDist) MinDist = DistToTop;
                    double DistToBottom = ParentScreening.Rows - j;
                    if (DistToBottom < MinDist) MinDist = DistToBottom;

                    cSignature Descriptor2 = new cSignature(MinDist, TypeDistBorder, this.ParentScreening);
                    TempWell.ListPlateBasedDescriptors.Add(Descriptor2);

                    double X_Center = ParentScreening.Columns / 2;
                    double Y_Center = ParentScreening.Rows / 2;

                    double DistToCenter = Math.Sqrt((i - X_Center) * (i - X_Center) + (j - Y_Center) * (j - Y_Center));

                    cSignature Descriptor3 = new cSignature(DistToCenter, TypeDistCenter, this.ParentScreening);
                    TempWell.ListPlateBasedDescriptors.Add(Descriptor3);

                }

            return;
        }
示例#19
0
        private void SingleCellOperationPhenotypToDesc(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 = "Phenotype Class";
            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_Class", GlobalInfo, ref CurrentPlate.ListActiveWells);

                CurrentPlate.DBConnection.CloseConnection();
                ProgressWindow.progressBar.Value = IdxProgress++;
                ProgressWindow.progressBar.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);
        }
示例#20
0
文件: cPlate.cs 项目: cyrenaique/HCSA
 public void DisplayDistribution(cDescriptorType Descriptor, bool IsFirstTime, object Sender = null)
 {
     this.DisplayDistribution(ParentScreening.ListDescriptors.GetDescriptorIndex(Descriptor), IsFirstTime, Sender);
 }
示例#21
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();
        }
示例#22
0
文件: cPlate.cs 项目: cyrenaique/HCSA
        public void ExportToHTML(cDescriptorType Desc)
        {
            if (Desc.IsConnectedToDatabase == false) return;
            List<cDescriptorType> LCDT = new List<cDescriptorType>();
            LCDT.Add(Desc);

            List<cCellularPhenotype> ListCellularPhenotypesToBeSelected = new List<cCellularPhenotype>();

            cGUI_ListClasses GUIClasses = new cGUI_ListClasses();
            GUIClasses.IsCheckBoxes = true;
            GUIClasses.IsSelectAll = true;
            GUIClasses.ClassType = eClassType.PHENOTYPE;
            if (!GUIClasses.Run().IsSucceed) return;

            int IDx = 0;
            foreach (var item in cGlobalInfo.ListCellularPhenotypes)
            {
                if ((GUIClasses.GetOutPut()[0][IDx++] != 0))
                    ListCellularPhenotypesToBeSelected.Add(item);
            }

            cExtendedTable ET = new cExtendedTable(cGlobalInfo.CurrentScreening.Columns, cGlobalInfo.CurrentScreening.Rows, 0);
            ET.Name = this.Name + " [" + Desc.GetName() + "]";
            ET.ListRowNames = new List<string>();

            for (int i = 0; i < ET[0].Count; i++)
            {
                ET.ListRowNames.Add(((char)(i + 65)).ToString());
            }

            FormForProgress MyProgressBar = new FormForProgress();

            MyProgressBar.progressBar.Maximum = this.ListActiveWells.Count;
            MyProgressBar.Show();

            //ET.ListTags = new List<object>();
            for (int i = 0; i < cGlobalInfo.CurrentScreening.Columns; i++)
            {
                ET[i].ListTags = new List<object>();
                ET[i].Name = (i + 1).ToString();

                for (int j = 0; j < cGlobalInfo.CurrentScreening.Rows; j++)
                {

                    MyProgressBar.progressBar.Update();

                    cWell TmpWell = this.GetWell(i, j, true);
                    if (TmpWell == null)
                    {
                        ET[i].ListTags.Add("n.a.");
                        continue;
                    }
                    MyProgressBar.progressBar.Value++;
                    cExtendedTable TmpET = null;
                    if (cGlobalInfo.OptionsWindow.FFAllOptions.checkBoxHTMLExportStackedHisto.Checked)
                        TmpET = TmpWell.GetValuesList(LCDT, ListCellularPhenotypesToBeSelected, true);
                    else
                        TmpET = TmpWell.GetValuesList(LCDT, ListCellularPhenotypesToBeSelected, false);
                    TmpET.Name = "[" + TmpWell.GetPos() + "] - " + TmpET[0].Count + " Objects";
                    // get the values associated to this well and descriptor

                    if (cGlobalInfo.OptionsWindow.FFAllOptions.checkBoxHTMLExportStackedHisto.Checked)
                    {
                        cExtendedTable FinalTable = new cExtendedTable();
                        FinalTable.Name = "Stacked Histogram - " + this.GetName();

                        int Idx = 0;
                        foreach (var item in cGlobalInfo.ListCellularPhenotypes)
                        {
                            FinalTable.Add(new cExtendedList());
                            FinalTable[Idx].Name = item.Name;
                            FinalTable[Idx].Tag = item;

                            for (int k = 0; k < TmpET[1].Count; k++)
                            {
                                if (TmpET[1][k] == Idx)
                                    FinalTable[Idx].Add(TmpET[0][k]);
                            }
                            Idx++;
                        }

                        cViewerStackedHistogram VSH = new cViewerStackedHistogram();
                        VSH.SetInputData(FinalTable);//TmpET);
                        VSH.Chart.LabelAxisX = Desc.GetName();
                        VSH.Chart.IsLine = false;
                        VSH.Chart.CurrentTitle.Text = TmpET.Name;
                        if ((cGlobalInfo.OptionsWindow.radioButtonHistoDisplayManualMinMax.Checked) || (cGlobalInfo.OptionsWindow.radioButtonHistoDisplayAutomatedMinMax.Checked))
                        {
                            VSH.Chart.DefaultAxisXMin = new cExtendedList();
                            VSH.Chart.DefaultAxisXMin.Add((double)cGlobalInfo.OptionsWindow.numericUpDownManualMin.Value);

                            VSH.Chart.DefaultAxisXMax = new cExtendedList();
                            VSH.Chart.DefaultAxisXMax.Add((double)cGlobalInfo.OptionsWindow.numericUpDownManualMax.Value);

                            if (cGlobalInfo.OptionsWindow.FFAllOptions.checkBoxHTMLExportBackColorClass.Checked)
                                VSH.Chart.BackgroundColor = TmpWell.GetClassColor();
                        }

                        VSH.Chart.BinNumber = Desc.GetBinNumber();
                        VSH.Chart.IsShadow = false;
                        VSH.Chart.IsBorder = false;
                        VSH.Run();
                        ET[i].ListTags.Add((Chart)VSH.Chart);
                    }
                    else
                    {
                        cViewerHistogram VH = new cViewerHistogram();
                        VH.SetInputData(TmpET);
                        VH.Chart.LabelAxisX = Desc.GetName();
                        VH.Chart.CurrentTitle.Text = TmpET.Name;
                        if ((cGlobalInfo.OptionsWindow.radioButtonHistoDisplayManualMinMax.Checked) || (cGlobalInfo.OptionsWindow.radioButtonHistoDisplayAutomatedMinMax.Checked))
                        {
                            VH.Chart.DefaultAxisXMin = new cExtendedList();
                            VH.Chart.DefaultAxisXMin.Add((double)cGlobalInfo.OptionsWindow.numericUpDownManualMin.Value);

                            VH.Chart.DefaultAxisXMax = new cExtendedList();
                            VH.Chart.DefaultAxisXMax.Add((double)cGlobalInfo.OptionsWindow.numericUpDownManualMax.Value);

                            if (cGlobalInfo.OptionsWindow.FFAllOptions.checkBoxHTMLExportBackColorClass.Checked)
                                VH.Chart.BackgroundColor = TmpWell.GetClassColor();
                        }

                        VH.Run();
                        ET[i].ListTags.Add((Chart)VH.Chart);
                    }
                }
            }

            MyProgressBar.Close();

            cTableToHTML TToHTML = new cTableToHTML();
            TToHTML.IsDisplayUIForFilePath = true;
            TToHTML.SetInputData(ET);

            TToHTML.Run();
        }
示例#23
0
        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();
        }
示例#24
0
        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();
        }
        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();
        }
示例#26
0
        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++;
            }
        }
示例#27
0
        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();
        }
示例#28
0
        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;
        }
示例#29
0
        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();
        }
示例#30
0
        /// <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++;
            }
        }