Exemplo n.º 1
0
        public cFeedBackMessage Run()
        {
            if (this.Input == null)
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "No input data defined.";
                return FeedBackMessage;
            }

            this.OutPut = new cListExtendedTable(this.Input);

            return FeedBackMessage;
        }
Exemplo n.º 2
0
        public cFeedBackMessage Run()
        {
            if (base.Start() == false)
            {
                base.FeedBackMessage.IsSucceed = false;
                return base.FeedBackMessage;
            }

            #region parameters initilization
            object _firstValue = base.ListProperties.FindByName("Kernel size");
            int KernelSize = 0;
            if (_firstValue == null)
            {
                base.GenerateError("Kernel size not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                KernelSize = (int)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("Kernel size cast didn't work");
                return base.FeedBackMessage;
            }

            _firstValue = base.ListProperties.FindByName("Image width");
            int ImWidth = 0;
            if (_firstValue == null)
            {
                base.GenerateError("Image width not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                ImWidth = (int)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("Image width cast didn't work");
                return base.FeedBackMessage;
            }

            _firstValue = base.ListProperties.FindByName("Image height");
            int ImHeight = 0;
            if (_firstValue == null)
            {
                base.GenerateError("Image height not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                ImHeight = (int)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("Image height cast didn't work");
                return base.FeedBackMessage;
            }

            _firstValue = base.ListProperties.FindByName("Image depth");
            int ImDepth = 0;
            if (_firstValue == null)
            {
                base.GenerateError("Image depth not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                ImDepth = (int)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("Image depth cast didn't work");
                return base.FeedBackMessage;
            }
            #endregion

            if (this.Input[0].Count == 2) ImDepth = 1;
            if (this.Input[0].Count == 1)
            {
                ImDepth = 1;
                ImHeight = 1;
            }

            this.Output = new cImage(ImWidth, ImHeight, ImDepth, this.Input.Count);

            cImageDrawKernel GK = new cImageDrawKernel();
            GK.sigma_x = KernelSize;
            GK.sigma_y = KernelSize;
            GK.sigma_z = KernelSize;
            GK.Run();

            cImage K = GK.GetOutPut();

            for (int IdxChannel = 0; IdxChannel < this.Input.Count; IdxChannel++)
            {
                cExtendedTable CurrentTable = this.Input[IdxChannel];
                cExtendedList ListVolumes = new cExtendedList();

                double MaxX = CurrentTable[0].Max();
                double MinX = CurrentTable[0].Min();

                double MaxY = CurrentTable[1].Max();
                double MinY = CurrentTable[1].Min();

                double MaxZ = 0;
                double MinZ = 0;

                if (CurrentTable.Count>2)
                {
                    MaxZ = CurrentTable[2].Max();
                    MinZ = CurrentTable[2].Min();
                }

                this.Output.SingleChannelImage[IdxChannel].Resolution.X = (MaxX - MinX) / (double)ImWidth;
                this.Output.SingleChannelImage[IdxChannel].Resolution.Y = (MaxY - MinY) / (double)ImHeight;
                this.Output.SingleChannelImage[IdxChannel].Resolution.Z = (MaxZ - MinZ) / (double)ImDepth;

                if (CurrentTable.Count > 2)
                {
                    for (int j = 0; j < CurrentTable[0].Count; j++)
                    {
                        double TmpValueX = (ImWidth * (CurrentTable[0][j] - MinX)) / (MaxX - MinX) - K.Width / 2;
                        double TmpValueY = (ImHeight * (CurrentTable[1][j] - MinY)) / (MaxY - MinY) - K.Height / 2;
                        double TmpValueZ = (ImDepth * (CurrentTable[2][j] - MinZ)) / (MaxZ - MinZ) - K.Depth / 2;

                        this.Output.AddInto(K, (int)TmpValueX,  (int)TmpValueY, (int)TmpValueZ, IdxChannel);
                    }
                }
                else
                {
                    for (int j = 0; j < CurrentTable[0].Count; j++)
                    {
                        double TmpValueX = (ImWidth * (CurrentTable[0][j] - MinX)) / (MaxX - MinX) - K.Width / 2;
                        double TmpValueY = ImHeight - (ImHeight * (CurrentTable[1][j] - MinY)) / (MaxY - MinY) - K.Height / 2;

                        this.Output.AddInto(K, (int)TmpValueX, (int)TmpValueY, 0, IdxChannel);
                    }
                }
                cListExtendedTable TablesForDensity = new cListExtendedTable(this.Output);

                for (int idxChannel = 0; idxChannel < this.Output.GetNumChannels(); idxChannel++)
                {
                    this.Output.SingleChannelImage[idxChannel].Name = this.Input.Name;//cGlobalInfo.ListCellularPhenotypes[idxChannel].Name;
                    float Sum = 1;
                    if (IsNormalized)
                    {
                        Sum = (float)TablesForDensity[idxChannel].Sum();
                        if (Sum <= 0.0) continue;
                        for (int i = 0; i < this.Output.SingleChannelImage[idxChannel].Data.Length; i++)
                        {
                            this.Output.SingleChannelImage[idxChannel].Data[i] = (10000000 * this.Output.SingleChannelImage[idxChannel].Data[i]) / Sum;
                        }
                    }
                    //else
                    //{
                    //    for (int i = 0; i < this.Output.SingleChannelImage[idxChannel].Data.Length; i++)
                    //    {
                    //        // if (ClassPopulations[idxChannel] > 0)
                    //        this.Output.SingleChannelImage[idxChannel].Data[i] = this.Output.SingleChannelImage[idxChannel].Data[i];
                    //    }
                    //}
                }
            }

            this.Output.SingleChannelImage[0].UpDateMax();
            this.Output.SingleChannelImage[0].UpDateMin();
            base.End();
            return FeedBackMessage;
        }
Exemplo n.º 3
0
 public void SetInputData(cListExtendedTable Input)
 {
     this.Input = Input;
 }
Exemplo n.º 4
0
        private void dRC3DToolStripMenuItem_Click(object sender, EventArgs e)
        {

            if (cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptors().Count < 3)
            {
                MessageBox.Show("At least 3 descriptors are required for this operation !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            cListExtendedTable LET = new cListExtendedTable();

            //List<cListWells> ListWells = new List<cListWells>();
            //ListWells.Add(cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().ListActiveWells);

            // firstly, wells are grouped by class
            //foreach (var item in cGlobalInfo.ListWellClasses)
            //{
            //    List<cWellClassType> TypeForFilter = new List<cWellClassType>();
            //    TypeForFilter.Add(item);
            //    cListWells TmpListWells = cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().ListActiveWells.Filter(TypeForFilter);
            //    cGeneralDRC gDRC = new cGeneralDRC(TmpListWells);
            //    LET.Add(gDRC.ListAverageValues);
            //}


            for (int i = 0; i < 3; i++)
            {
                List<int> GroupForFilter = new List<int>();
                GroupForFilter.Add(i);
                cListWells TmpListWells = cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().ListActiveWells.FilterByGroup(GroupForFilter);
                cGeneralDRC gDRC = new cGeneralDRC(TmpListWells);
                LET.Add(gDRC.ListAverageValues);
            }



            cViewer3D V3D = new cViewer3D();
            c3DNewWorld MyWorld = new c3DNewWorld(new cPoint3D(1, 1, 1), new cPoint3D(1, 1, 1));

            c3DObjectScatterPoints _3DScatterPt = new c3DObjectScatterPoints();
            //_3DScatterPt.SetInputData(cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().ListActiveWells.GetDescriptorValues(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptors(), false));
            //  _3DScatterPt.GlobalInfo = this.GlobalInfo;
            _3DScatterPt.SetInputData(LET);
            // _3DScatterPt.IsLinked = true;
            _3DScatterPt.Run(MyWorld);

            cListGeometric3DObject GlobalList = _3DScatterPt.GetOutPut();

            foreach (var item in GlobalList)
            {
                MyWorld.AddGeometric3DObject(item);
            }


            MyWorld.BackGroundColor = cGlobalInfo.OptionsWindow.FFAllOptions.panelFor3DBackColor.BackColor;

            V3D.SetInputData(MyWorld);
            V3D.Run();

            cDisplayToWindow DTW = new cDisplayToWindow();
            DTW.SetInputData(V3D.GetOutPut());
            DTW.Title = "3D Dose Response Visualization";
            DTW.Run();
            DTW.Display();
        }
Exemplo n.º 5
0
        public void Run()
        {
            // define names
            string[] VarNames = new string[Input.Count];
            double[][] dataset = new double[Input.Count][];

            int Idx = 0;
            foreach (var item in Input)
            {
                dataset[Idx] = new double[item.Count];
                Array.Copy(item.ToArray(), dataset[Idx], item.Count);
                VarNames[Idx++] = item.Name;
            }

            //// define data
            data.Dataset data_Set = new data.Dataset(dataset, VarNames, 0);
            analysis.VarPairQueue Qu = new analysis.VarPairQueue(data_Set);

            for(int Idx_0=0;Idx_0<this.Input.Count;Idx_0++)
                for (int Idx_1 = 0; Idx_1 <= Idx_0; Idx_1++)
                    Qu.addPair(Idx_1,Idx_0);

            Analysis ana = new Analysis(data_Set, Qu);
            AnalysisParameters param = new AnalysisParameters();
            double resparam = param.commonValsThreshold;

            java.lang.Class t = java.lang.Class.forName("analysis.results.FullResult");

            if(this.Is_BriefReport)
                t = java.lang.Class.forName("analysis.results.BriefResult");

            ana.analyzePairs(t, param);
            analysis.results.Result[] res = ana.getSortedResults();

            List<string[]> ListValues = new List<string[]>();
            List<bool> ListIscolor = new List<bool>();

            for (Idx = 0; Idx < res.Length; Idx++)
            {
                ListValues.Add(res[Idx].toString().Split(','));
            }
            string[] ListNames = res[0].getHeader().Split(',');

            this.Output = new cListExtendedTable();

            for (int IdxTest = 2; IdxTest < ListNames.Length; IdxTest++)    // loop over all the different type of results
            {
                // remove useless informations
                if (ListNames[IdxTest] == "MI via KDE") continue;
                if (ListNames[IdxTest] == "Fisher") continue;
                if (ListNames[IdxTest] == "last value") continue;
                if (ListNames[IdxTest] == "MAS found at (X)") continue;
                if (ListNames[IdxTest] == "MAS found at (Y)") continue;
                if (ListNames[IdxTest] == "MICfound at (Y)") continue;

                double[,] TmpTable = new double[VarNames.Length, VarNames.Length];

                for (int i = 0; i < res.Length; i++)    // loop over the different pairs
                {
                    string TmpName0 = res[i].getXVar();
                    string TmpName1 = res[i].getYVar();
                    int Idx_var0 = 0;
                    int Idx_var1 = 0;

                    for (Idx_var0 = 0; Idx_var0 < VarNames.Length; Idx_var0++)
                        if(VarNames[Idx_var0]==TmpName0)
                            break;

                    for (Idx_var1 = 0; Idx_var1 < VarNames.Length; Idx_var1++)
                        if (VarNames[Idx_var1] == TmpName1)
                            break;

                    double Value=0;
                    double.TryParse(res[i].toString().Split(',')[IdxTest], out Value);
                    TmpTable[Idx_var0, Idx_var1] = TmpTable[Idx_var1, Idx_var0] = Value;
                }

                cExtendedTable NewTable = new cExtendedTable(TmpTable);
                NewTable.ListRowNames = new List<string>();
                for (int i = 0; i < VarNames.Length; i++)
                {
                    NewTable.ListRowNames.Add(VarNames[i]);
                    NewTable[i].Name = VarNames[i];

                    if (CurrentScreening != null)
                    {
                        int IdxDesc = cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorIndex(NewTable[i].Name);
                        if (IdxDesc > -1)
                        {
                            NewTable[i].Tag = cGlobalInfo.CurrentScreening.ListDescriptors[IdxDesc];
                        }
                    }

                }

                NewTable.Name = ListNames[IdxTest];
                this.Output.Add(NewTable);
            }
        }
Exemplo n.º 6
0
 public void SetInputData(cListExtendedTable ListInput)
 {
     //CurrentPanelHisto = new cPanelHisto(ListValues, true, eGraphType.LINE, this.Orientation);
       // Chart = new cChart1DGraph();
     Chart.ListInput = ListInput;
 }
Exemplo n.º 7
0
        private void ToolStripMenuItem_DisplayHistograms(object sender, EventArgs e)
        {
            cDesignerTab DT = new cDesignerTab();

            cListExtendedTable ListTables = new cListExtendedTable(this.AssociatedImage);

            for (int i = 0; i < ListTables.Count; i++)
            {
                cLinearize LI = new cLinearize();
                LI.SetInputData(ListTables[i]);
                LI.Run();

                cViewerStackedHistogram VH = new cViewerStackedHistogram();
                VH.SetInputData(LI.GetOutPut());
                VH.Title = ListTables[i].Name;
                if (!VH.Run().IsSucceed) return;

                DT.SetInputData(VH.GetOutPut());
            }
            DT.Run();

            cDisplayToWindow MyDisplay = new cDisplayToWindow();
            MyDisplay.SetInputData(DT.GetOutPut());
            MyDisplay.Title = "Histograms(" + this.AssociatedImage.Name + ")";
            MyDisplay.Run();
            MyDisplay.Display();
        }
Exemplo n.º 8
0
        public void PerformClassification()
        {
            FormForSingleCellClassifOptions FFSC = new FormForSingleCellClassifOptions();
            //cGUI_ListClasses GLC = new cGUI_ListClasses();
            //GLC.ClassType = eClassType.PHENOTYPE;
            //GLC.IsCheckBoxes = true;
            //GLC.IsSelectAll = true;
            //GLC.Run(GlobalInfo);

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

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

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

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

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

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

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

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

            int IdxProgress = 0;
            int MaxProgress = 0;

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

            cListPlates LP = PlatesSelectionPanel.GetListSelectedPlates();

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

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

            cPlate CurrentDispPlate = cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate();

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

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

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

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

                    cExtendedList ListNewClasses = new cExtendedList();

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

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

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

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

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

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

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

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

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

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

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

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

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

            DT.Run();

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

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

            DS.Run();

            ProgressWindow.Close();

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

            #endregion

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

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

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

            //WindowFormForCellbyCellClassif.Close();
            //WindowClusteringInfo.Close();
        }
Exemplo n.º 9
0
        public cFeedBackMessage Run()
        {
            if (base.Start() == false)
            {
                base.FeedBackMessage.IsSucceed = false;
                return base.FeedBackMessage;
            }

            if ((this.Input == null)||(this.Input.Count==0))
            {

                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "No input data defined.";
                return FeedBackMessage;
            }
            FeedBackMessage.IsSucceed = true;

            #region Properties Management
            object _firstValue = base.ListProperties.FindByName("Normalized ?");
            bool IsNormalized = false;
            if (_firstValue == null)
            {
                base.GenerateError("-Normalized ?- not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                IsNormalized = (bool)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("-Normalized ?- cast didn't work");
                return base.FeedBackMessage;
            }

            _firstValue = base.ListProperties.FindByName("Draw Axis ?");
            bool IsdrawAxis = true;
            if (_firstValue == null)
            {
                base.GenerateError("-Draw Axis ?- not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                IsdrawAxis = (bool)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("-Draw Axis ?- cast didn't work");
                return base.FeedBackMessage;
            }

            _firstValue = base.ListProperties.FindByName("Link Points ?");
            bool IsLinked = false;
            if (_firstValue == null)
            {
                base.GenerateError("-Link Points ?- not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                IsLinked = (bool)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("-Link Points ?- cast didn't work");
                return base.FeedBackMessage;
            }

            _firstValue = base.ListProperties.FindByName("Desc. 1");
            string Desc1;
            if (_firstValue == null)
            {
                base.GenerateError("-Desc. 1- not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                Desc1 = (string)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("-Desc. 1- cast didn't work");
                return base.FeedBackMessage;
            }
            cDescriptorType DescX = cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorByName(Desc1);
            if (DescX == null)
            {
                base.GenerateError(Desc1 + " is not a descriptor !");
                return base.FeedBackMessage;
            }

            _firstValue = base.ListProperties.FindByName("Desc. 2");
            if (_firstValue == null)
            {
                base.GenerateError("-Desc. 2- not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                Desc1 = (string)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("-Desc. 2- cast didn't work");
                return base.FeedBackMessage;
            }
            cDescriptorType DescY = cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorByName(Desc1);
            if (DescY == null)
            {
                base.GenerateError(Desc1 + " is not a descriptor !");
                return base.FeedBackMessage;
            }

            _firstValue = base.ListProperties.FindByName("Desc. 3");
            if (_firstValue == null)
            {
                base.GenerateError("-Desc. 3- not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                Desc1 = (string)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("-Desc. 2- cast didn't work");
                return base.FeedBackMessage;
            }
            cDescriptorType DescZ = cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorByName(Desc1);
            if (DescZ == null)
            {
                base.GenerateError(Desc1 + " is not a descriptor !");
                return base.FeedBackMessage;
            }

            #endregion

            List<cDescriptorType> ListDesc = new List<cDescriptorType>();
            ListDesc.Add(DescX);
            ListDesc.Add(DescY);
            ListDesc.Add(DescZ);

            cListExtendedTable LET = new cListExtendedTable();
            foreach (var item in cGlobalInfo.ListWellClasses)
            {
                List<cWellClassType> TypeForFilter = new List<cWellClassType>();
                TypeForFilter.Add(item);

                cExtendedTable TmpTable = ((cListWells)this.Input.Filter(TypeForFilter)).GetAverageDescriptorValues(ListDesc,false, false);
                if (TmpTable != null)
                    LET.Add(TmpTable);
            }

            cViewer3D V3D = new cViewer3D();
            c3DNewWorld MyWorld = new c3DNewWorld(new cPoint3D(1, 1, 1), new cPoint3D(1, 1, 1));

            c3DObjectScatterPoints _3DScatterPt = new c3DObjectScatterPoints();

            _3DScatterPt.ListProperties.FindByName("Draw Axis ?").SetNewValue(IsdrawAxis);
            _3DScatterPt.ListProperties.FindByName("Normalized ?").SetNewValue(IsNormalized);
            _3DScatterPt.ListProperties.FindByName("Link Points ?").SetNewValue(IsLinked);
            _3DScatterPt.SetInputData(LET);
            if (_3DScatterPt.Run(MyWorld).IsSucceed == false) return base.FeedBackMessage;

            cListGeometric3DObject GlobalList = _3DScatterPt.GetOutPut();

            foreach (var item in GlobalList)
            {
                MyWorld.AddGeometric3DObject(item);
            }

            MyWorld.BackGroundColor = cGlobalInfo.OptionsWindow.FFAllOptions.panelFor3DBackColor.BackColor;

            V3D.SetInputData(MyWorld);
            V3D.Run();

            cDisplayToWindow DTW = new cDisplayToWindow();
            DTW.SetInputData(V3D.GetOutPut());
               DTW.Title = "3D Scatter Plot(List "+this.Input.Count +" Wells)";
            DTW.Run();

            DTW.Display();

            return base.FeedBackMessage;
        }
Exemplo n.º 10
0
        private void ToolStripMenuItem_Display3DScatterGraph(object sender, EventArgs e)
        {
            cExtendedTable CET = new cExtendedTable();

            foreach (DataGridViewColumn item in GridView.SelectedColumns)
            {
                CET.Add(Input[item.Index]);
            }

            if (this.Input.ListTags != null)
            {
                CET.ListTags = new List<object>();
                foreach (var item in this.Input.ListTags)
                {
                    CET.ListTags.Add(item);
                }
            }

            cListExtendedTable LET = new cListExtendedTable();
            LET.Add(CET);

            //List<cListWells> ListWells = new List<cListWells>();
            //ListWells.Add(cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().ListActiveWells);

            cViewer3D V3D = new cViewer3D();
            c3DNewWorld MyWorld = new c3DNewWorld(new cPoint3D(1, 1, 1), new cPoint3D(1, 1, 1));

            c3DObjectScatterPoints _3DScatterPt = new c3DObjectScatterPoints();
            _3DScatterPt.ListProperties.FindByName("Draw Axis ?").SetNewValue((bool)true);
            _3DScatterPt.ListProperties.FindByName("Draw Axis ?").IsGUIforValue = true;
            _3DScatterPt.ListProperties.FindByName("Normalized ?").SetNewValue((bool)true);
            _3DScatterPt.ListProperties.FindByName("Normalized ?").IsGUIforValue = true;
            _3DScatterPt.ListProperties.FindByName("Link Points ?").SetNewValue((bool)false);
            _3DScatterPt.ListProperties.FindByName("Link Points ?").IsGUIforValue = true;

            //_3DScatterPt.GlobalInfo = cGlobalInfo;
            _3DScatterPt.SetInputData(LET);
            if (_3DScatterPt.Run(MyWorld).IsSucceed == false) return;

            cListGeometric3DObject GlobalList = _3DScatterPt.GetOutPut();

            foreach (var item in GlobalList)
            {
                MyWorld.AddGeometric3DObject(item);
            }

            V3D.SetInputData(MyWorld);
            V3D.Run();

            cDisplayToWindow DTW = new cDisplayToWindow();
            DTW.SetInputData(V3D.GetOutPut());
            DTW.Title = "3D Scatter Graph ("+ this.Input.Name +")";
            DTW.Run();
            DTW.Display();
        }
Exemplo n.º 11
0
        public cFeedBackMessage Run(cScreening CompleteScreening)
        {
            if (this.Input == null)
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "No input data defined.";
                return FeedBackMessage;
            }

            bool IsCurrentDescOnly = false;
            if (this.ListPlates == null)
                ListPlates = CompleteScreening.ListPlatesActive;

            cDisplayToWindow CDW1 = new cDisplayToWindow();

            cDesignerTab DT = new cDesignerTab();

            foreach (cDescriptorType CurrentDesc in CompleteScreening.ListDescriptors.GetActiveDescriptors())
            {
                cListExtendedTable CompleteListOfData = new cListExtendedTable();

                cExtendedTable FullTableAverage = new cExtendedTable();
                FullTableAverage.ListRowNames = new List<string>();

                string TableName = CurrentDesc.GetName() + " evolution\n" + Input[0].Sum() + " classes - ";

                for (int i = 0; i < Input[0].Count; i++)
                {
                    if ((Input[0][i] == 1) && (Input[0].ListTags != null) && (Input[0].ListTags[i].GetType() == typeof(cWellClassType)))
                    {
                        cWellClassType TmpWellClass = (cWellClassType)Input[0].ListTags[i];

                        CompleteListOfData.Add(new cExtendedTable());
                        CompleteListOfData[CompleteListOfData.Count - 1].Name = TmpWellClass.Name;
                        CompleteListOfData[CompleteListOfData.Count - 1].Tag = Input[0].ListTags[i];

                        FullTableAverage.Add(new cExtendedList(TmpWellClass.Name));
                        FullTableAverage[FullTableAverage.Count - 1].ListTags = new List<object>();
                        FullTableAverage[FullTableAverage.Count - 1].Name = TmpWellClass.Name;
                        FullTableAverage[FullTableAverage.Count - 1].Tag = TmpWellClass;

                        int IdxPlate = 0;
                        foreach (cPlate TmpPlate in CompleteScreening.ListPlatesActive)
                        {
                            FullTableAverage[FullTableAverage.Count - 1].Add(0);
                            FullTableAverage[FullTableAverage.Count - 1].ListTags.Add(TmpWellClass);

                            CompleteListOfData[CompleteListOfData.Count - 1].Add(new cExtendedList(TmpPlate.GetName()));
                            CompleteListOfData[CompleteListOfData.Count - 1][CompleteListOfData[CompleteListOfData.Count - 1].Count - 1].Tag = TmpPlate;
                            CompleteListOfData[CompleteListOfData.Count - 1][CompleteListOfData[CompleteListOfData.Count - 1].Count - 1].Add(IdxPlate);

                            IdxPlate++;
                        }
                    }
                }

                TableName += FullTableAverage[0].Count + " plates";
                FullTableAverage.Name = TableName;

                foreach (cPlate TmpPlate in CompleteScreening.ListPlatesActive)
                    FullTableAverage.ListRowNames.Add(TmpPlate.GetName());

              //  cDescriptorsType CurrentDesc = CompleteScreening.ListDescriptors.GetActiveDescriptor();
                int RealIdx = 0;
                for (int i = 0; i < Input[0].Count; i++)
                {
                    if (Input[0][i] == 1)
                    {
                        int IdxPlate = 0;
                        foreach (cPlate TmpPlate in ListPlates/*CompleteScreening.ListPlatesActive*/)
                        {
                            cExtendedList CurrentListValues = new cExtendedList();

                            foreach (cWell item in TmpPlate.ListActiveWells)
                                if ((item.GetCurrentClassIdx() != -1) && (item.GetCurrentClassIdx() == i))
                                {
                                    double Value = item.ListSignatures.GetSignature(CurrentDesc).GetValue();
                                    CurrentListValues.Add(Value);
                                    CompleteListOfData[RealIdx][IdxPlate].Add(Value);
                                }

                            FullTableAverage[RealIdx][IdxPlate] = CurrentListValues.Mean();
                            IdxPlate++;
                        }
                        RealIdx++;
                    }
                }

                cViewerGraph1D VG = new cViewerGraph1D();
                VG.Chart.IsLine = true;
                VG.Chart.IsShadow = true;
                VG.Chart.IsZoomableX = true;
                // VG.Chart.IsYGrid = true;
                //VG.Chart.IsDisplayValues = true;
                VG.Chart.IsLegend = true;
                //cViewerStackedHistogram CV1 = new cViewerStackedHistogram();
                //  CV1.SetInputData(NewTable);

                VG.SetInputData(FullTableAverage);
                VG.SetInputData(CompleteListOfData);

                VG.Chart.LabelAxisX = "Plate";
                VG.Chart.LabelAxisY = CurrentDesc.GetName();
                VG.Run();

                cExtendedControl TmpCtrl = VG.GetOutPut();
                TmpCtrl.Title = CurrentDesc.GetName();

                DT.SetInputData(TmpCtrl);

            }
            DT.Run();

            CDW1.Title = "Descriptor Evolution";
            CDW1.SetInputData(DT.GetOutPut());
            CDW1.Run();
            CDW1.Display();

            return FeedBackMessage;
        }
Exemplo n.º 12
0
        void BuildFromListTable(cListExtendedTable ListSources)
        {
            if (ListSources.Count == 0) return;
            if (ListSources[0].Count == 0) return;
            if (ListSources[0][0].Count == 0) return;

            //this.NumChannels = ListSources.Count;
            this.Width = ListSources[0].Count;
            this.Height = ListSources[0][0].Count;
            this.Depth = 1;
            this.SliceSize = this.Height * this.Width;

            this.SingleChannelImage = new cListSingleChannelImage();
            for (int IdxChannel = 0; IdxChannel < ListSources.Count; IdxChannel++)
            {
                this.SingleChannelImage.Add(new cSingleChannelImage(this.Width, this.Height, 1, new cPoint3D(1, 1, 1)));

                for (int i = 0; i < this.Width; i++)
                    for (int j = 0; j < this.Height; j++)
                    {
                        this.SingleChannelImage[IdxChannel].Data[i + j * this.Width] = (float)ListSources[IdxChannel][i][j];
                    }
            }
            this.Name = ListSources.Name;
        }
Exemplo n.º 13
0
 public cImage(cListExtendedTable ListSources)
 {
     this.BuildFromListTable(ListSources);
 }
Exemplo n.º 14
0
 public void SetInputData(cListExtendedTable Input)
 {
     base.Title += ": " + Input.Name;
     this.Input = Input;
 }
Exemplo n.º 15
0
 public void SetInputData(cExtendedTable Input)
 {
     this.Input = new cListExtendedTable(Input);
 }
Exemplo n.º 16
0
        private void buttonProcess_Click(object sender, EventArgs e)
        {
            ImageWidth = (int)numericUpDownMapWidth.Value;
            ImageHeight = (int)numericUpDownMapHeight.Value;

            if (this.radioButton2D.Checked) ImageDepth = 1;
            else
                ImageDepth = (int)numericUpDownMapDepth.Value;

            //GlobalInfo.ListCellularPhenotypes[(int)MachineLearning.Classes[j]]
            cImageDrawKernel GK = new cImageDrawKernel();
            GK.sigma_x = (int)numericUpDownKernelSize.Value;
            GK.sigma_y = (int)numericUpDownKernelSize.Value;
            GK.sigma_z = (int)numericUpDownKernelSize.Value;
            GK.Run();

            cImage K = GK.GetOutPut();

            if (Parent.comboBoxAxeY.SelectedIndex == -1) return;
            if (Parent.comboBoxVolume.SelectedIndex == -1) return;

            cExtendedList ListVolumes = new cExtendedList();

            ListX.Clear();
            ListY.Clear();
            ListZ.Clear();

            cExtendedTable TableForDataToBeAnalyzed = Parent.GetActiveSignatures(false);

            for (int j = 0; j < TableForDataToBeAnalyzed[0].Count; j++)
            {
                ListX.Add(TableForDataToBeAnalyzed[Parent.comboBoxAxeX.SelectedIndex][j]);
                ListY.Add(TableForDataToBeAnalyzed[Parent.comboBoxAxeY.SelectedIndex][j]);
            }

            //MaxX = ListX.Max();
            //MinX = ListX.Min();

            //MaxY = ListY.Max();
            //MinY = ListY.Min();

            MaxX = Parent.chartForPoints.ChartAreas[0].AxisX.Maximum;
            MinX = Parent.chartForPoints.ChartAreas[0].AxisX.Minimum;

            MaxY = Parent.chartForPoints.ChartAreas[0].AxisY.Maximum;
            MinY = Parent.chartForPoints.ChartAreas[0].AxisY.Minimum;

            //MaxY = Parent.MaxY;
            //MinY = Parent.MinY;

            if (this.radioButton3D.Checked)
            {
                for (int j = 0; j < TableForDataToBeAnalyzed[0].Count; j++)
                {
                    ListZ.Add(TableForDataToBeAnalyzed[Parent.comboBoxVolume.SelectedIndex][j]);
                }
                MaxZ = ListZ.Max();
                MinZ = ListZ.Min();
            }

            DensityMaps = new cImage(ImageWidth, ImageHeight, ImageDepth, cGlobalInfo.ListCellularPhenotypes.Count);

            int[] ClassPopulations = new int[cGlobalInfo.ListCellularPhenotypes.Count];

            if (this.radioButton3D.Checked)
            {
                int Idx = 0;
                for (int j = 0; j < Parent.InputTable[0].Count; j++)
                {
                    if (Parent.PanelPhenotypeSelection.GetListSelectedClass()[(int)Parent.MachineLearning.Classes[j]])
                    {
                        double TmpValueX = (ImageWidth * (ListX[Idx] - MinX)) / (MaxX - MinX) - K.Width / 2;
                        double TmpValueY = ImageHeight - (ImageHeight * (ListY[Idx] - MinY)) / (MaxY - MinY) - K.Height / 2;
                        double TmpValueZ = ImageDepth - (ImageDepth * (ListZ[Idx] - MinZ)) / (MaxZ - MinZ) - K.Depth / 2;

                        DensityMaps.AddInto(K, (int)TmpValueX, (int)TmpValueY, (int)TmpValueZ, (int)Parent.MachineLearning.Classes[j]);
                        ClassPopulations[(int)Parent.MachineLearning.Classes[j]]++;
                        Idx++;
                    }
                }
            }
            else
            {
                int Idx = 0;
                for (int j = 0; j < Parent.InputTable[0].Count; j++)
                {
                    if (Parent.PanelPhenotypeSelection.GetListSelectedClass()[(int)Parent.MachineLearning.Classes[j]])
                    {
                        double TmpValueX = (ImageWidth * (ListX[Idx] - MinX)) / (MaxX - MinX) - K.Width / 2;
                        double TmpValueY = ImageHeight - (ImageHeight * (ListY[Idx] - MinY)) / (MaxY - MinY) - K.Height / 2;

                        DensityMaps.AddInto(K, (int)TmpValueX, (int)TmpValueY, 0, (int)Parent.MachineLearning.Classes[j]);
                        ClassPopulations[(int)Parent.MachineLearning.Classes[j]]++;
                        Idx++;
                    }
                }
            }
            cListExtendedTable TablesForDensity = new cListExtendedTable(DensityMaps);

            for (int idxChannel = 0; idxChannel < DensityMaps.GetNumChannels(); idxChannel++)
            {
                DensityMaps.SingleChannelImage[idxChannel].Name = cGlobalInfo.ListCellularPhenotypes[idxChannel].Name;
                float Sum = 1;
                if (checkBoxNormalized.Checked)
                {
                    Sum = (float)TablesForDensity[idxChannel].Sum();
                    if (Sum <= 0.0) continue;
                    for (int i = 0; i < DensityMaps.SingleChannelImage[idxChannel].Data.Length; i++)
                    {
                        //if (ClassPopulations[idxChannel] > 0)
                        DensityMaps.SingleChannelImage[idxChannel].Data[i] = (100 * DensityMaps.SingleChannelImage[idxChannel].Data[i]) / Sum;
                    }
                }
                else
                {
                    for (int i = 0; i < DensityMaps.SingleChannelImage[idxChannel].Data.Length; i++)
                    {
                        // if (ClassPopulations[idxChannel] > 0)
                        DensityMaps.SingleChannelImage[idxChannel].Data[i] = DensityMaps.SingleChannelImage[idxChannel].Data[i];
                    }
                }
            }

            cDisplaySingleImage IV = new cDisplaySingleImage();
            DensityMaps.Name = "Density Maps. K["+ this.numericUpDownKernelSize.Value +"]";

            if (this.checkBoxModifyColors.Checked)
                IV.ListLinearMaxColor = new List<Color>();

            int RealIdxChannel = 0;
            for (int idxChannel = 0; idxChannel < ClassPopulations.Length; idxChannel++)
            {
                if (ClassPopulations[idxChannel] == 0)
                    DensityMaps.SingleChannelImage.RemoveAt(RealIdxChannel--);
                else
                {
                    if (this.checkBoxModifyColors.Checked)
                    IV.ListLinearMaxColor.Add(cGlobalInfo.ListCellularPhenotypes[idxChannel].ColourForDisplay);
                }
                RealIdxChannel++;
            }

            IV.SetInputData(DensityMaps);
            IV.Run();

            this.buttonApply.Enabled = true;
        }