예제 #1
0
        public void OnData(MessageType control, Message message)
        {
            // TODO put a lock on the pdu array
            // TODO interpret the commands

            Logging.Log("CMoveServiceSCU({0}).OnData", Reflection.GetName(typeof(SOPClass), this.SOPClassUId));

            DataSet dicom = message.Dicom;

            if (MessageControl.IsCommand(control))
            {
                ushort status = (ushort)dicom[t.Status].Value;
                bool   last   = !(status == 0xFF00);

                DataSetType present = (DataSetType)dicom[t.CommandDataSetType].Value;

                Logging.Log("<< {0} {1},{2}", Enum.Parse(typeof(CommandType), dicom[t.CommandField].Value.ToString()), (last) ? "LAST FRAGMENT" : "NOT-LAST FRAGMENT", present.ToString());
                //dicom.Dump();

                string text = String.Empty;
                if (dicom.Contains(t.NumberofRemainingSuboperations))
                {
                    text += String.Format("remaining={0} ", dicom[t.NumberofRemainingSuboperations].Value);
                    results.Set(t.NumberofRemainingSuboperations, dicom[t.NumberofRemainingSuboperations].Value);
                }
                if (dicom.Contains(t.NumberofCompletedSuboperations))
                {
                    text += String.Format("completed={0} ", dicom[t.NumberofCompletedSuboperations].Value);
                    results.Set(t.NumberofCompletedSuboperations, dicom[t.NumberofCompletedSuboperations].Value);
                }
                if (dicom.Contains(t.NumberofFailedSuboperations))
                {
                    text += String.Format("failed={0} ", dicom[t.NumberofFailedSuboperations].Value);
                    results.Set(t.NumberofFailedSuboperations, dicom[t.NumberofFailedSuboperations].Value);
                }
                if (dicom.Contains(t.NumberofWarningSuboperations))
                {
                    text += String.Format("warning={0} ", dicom[t.NumberofWarningSuboperations].Value);
                    results.Set(t.NumberofWarningSuboperations, dicom[t.NumberofWarningSuboperations].Value);
                }

                if (this.ImageMoved != null)
                {
                    ImageMoved(this, new CMoveEventArgs(dicom));
                }

                Logging.Log(text);

                if (last)
                {
                    dicom.Remove(t.NumberofRemainingSuboperations);
                    // TODO do we reset the state to Open here
                    completeEvent.Set();
                }
            }
            else
            {
                Logging.Log("<< P-DATA-TF");
            }
        }
예제 #2
0
파일: CFind.cs 프로젝트: 1059444127/Dicom-4
        public void OnData(MessageType control, Message message)
        {
            // TODO put a lock on the pdu array
            // TODO interpret the commands

            Logging.Log("CFindServiceSCU({0}).OnData", Reflection.GetName(typeof(SOPClass), this.SOPClassUId));

            DataSet dicom = message.Dicom;

            if (MessageControl.IsCommand(control))
            {
                ushort status = (ushort)dicom[t.Status].Value;
                bool   last   = !(status == 0xFF00 || status == 0xFF01);

                //if (!last && status == 0xFF01)
                //{
                //    Logging.Log("Warning that one or more Optional Keys were not supported for existence and/or matching for this Identifier.");
                //}

                DataSetType present = (DataSetType)dicom[t.CommandDataSetType].Value;

                Logging.Log("<< C-FIND-RSP {0},{1}", (last) ? "LAST FRAGMENT" : "NOT-LAST FRAGMENT", present.ToString());
                //dicom.Dump();

                if (last)
                {
                    // TODO do we reset the state to Open here
                    completeEvent.Set();
                }
            }
            else
            {
                Logging.Log("<< P-DATA-TF");
                if (records == null)
                {
                    records = new RecordCollection();
                }
                records.Add(dicom.Elements);
            }
        }
예제 #3
0
        /// <summary>
        /// Creates a GeoPackage database with the OpenTNF extension.
        /// </summary>
        /// <param name="srid">Default SRS ID.</param>
        /// <param name="gtransSystem">The name identifying the coordinate system for GTrans coordinate transformations.</param>
        /// <param name="datasetIdentifier">
        /// Identifier of the creator of the dataset.
        /// Will be stored in the metadata key 'TNF_DATASET_IDENTIFIER'.
        /// </param>
        /// <param name="dataSetType">
        /// A <see cref="DataSetType"/> declaring what type of dataset the database contains.
        /// Will be stored in the metadata key 'TNF_DATASET_TYPE'.
        /// </param>
        /// <param name="viewDate">The view date of the dataset. If set, it will be stored in the metadata key 'TNF_VIEW_DATE'.</param>
        /// <param name="hasTopologyLevel">If set, will create columns in tnf_link to store topology level information.</param>
        /// <param name="createTables">If set, create all OpenTNF tables. If not set, only create OpenTNF tables when inserting data.</param>
        /// <param name="spatialRefSysUrlFormat">Spatial reference system information will be automatically downloaded from the given URL.</param>
        public bool CreateGeoPackageDatabase(int srid, string gtransSystem, string datasetIdentifier, DataSetType dataSetType, DateTime?viewDate,
                                             bool hasTopologyLevel = false, bool createTables = false, string spatialRefSysUrlFormat = GpkgSpatialRefSysManager.DefaultSpatialRefSysUrlFormat)
        {
            HasTopologyLevel = hasTopologyLevel;
            m_srid           = srid;

            if (File.Exists(m_filename))
            {
                try
                {
                    File.Delete(m_filename);
                }
                catch (IOException)
                {
                    return(false);
                }
            }

            File.WriteAllBytes(m_filename, Resource.origin);

            OpenGeoPackageDatabase();

            var tnfMetadataManager = GetTableManager <TnfMetadataManager>();

            tnfMetadataManager.Add(new TnfMetadata {
                MetaKey = "TNF_VERSION", MetaValue = Resource.OpenTNFVersion
            });
            tnfMetadataManager.Add(new TnfMetadata {
                MetaKey = "TNF_DATASET_IDENTIFIER", MetaValue = datasetIdentifier
            });
            tnfMetadataManager.Add(new TnfMetadata
            {
                MetaKey   = "TNF_DATASET_TIMESTAMP",
                MetaValue = DateTime.Now.ToString("O")
            });
            tnfMetadataManager.Add(new TnfMetadata
            {
                MetaKey   = "TNF_VIEW_DATE",
                MetaValue = viewDate?.ToString("O") ?? string.Empty
            });
            tnfMetadataManager.Add(new TnfMetadata {
                MetaKey = "TNF_CRS_NAME", MetaValue = "EPSG:" + srid
            });
            tnfMetadataManager.Add(new TnfMetadata
            {
                MetaKey   = "TNF_DATASET_TYPE",
                MetaValue = dataSetType.ToString().ToUpper()
            });
            tnfMetadataManager.Add(new TnfMetadata {
                MetaKey = "TNF_SPATIAL_ATTRIBUTE_ENCODING", MetaValue = Resource.SpatialAttributeEncoding
            });
            if (gtransSystem != null)
            {
                tnfMetadataManager.Add(new TnfMetadata {
                    MetaKey = "GT_COORD_SYSTEM_ID", MetaValue = gtransSystem
                });
            }
            if (createTables)
            {
                CreateAllTables();
            }
            var gpkgContentsManager = GetTableManager <GpkgContentsManager>();

            gpkgContentsManager.UpdateSrid(srid);

            var gpkgGeometryColumnsManager = GetTableManager <GpkgGeometryColumnsManager>();

            gpkgGeometryColumnsManager.UpdateSrid(srid);

            var gpkgSpatialRefSysManager = GetTableManager <GpkgSpatialRefSysManager>();

            gpkgSpatialRefSysManager.AddOrUpdateFromUrl(spatialRefSysUrlFormat ?? GpkgSpatialRefSysManager.DefaultSpatialRefSysUrlFormat, srid);
            return(true);
        }
예제 #4
0
        public static async Task <List <string> > PrintPerformance(string mlconfigPath, DataSetType dsType, DeviceDescriptor device)
        {
            try
            {
                var er = await MLEvaluator.EvaluateMLConfig(mlconfigPath, device, dsType, EvaluationType.ResultExtended);

                if (er.Actual == null)
                {
                    throw new Exception("Export has failed. No testing nor validation datatset to export.");
                }

                var pa = MLEvaluator.CalculatePerformance(er, dsType.ToString());

                //print performance result
                var strB        = new List <string>();
                var problemType = pa.Classes.Count() == 1 ? "Regression" : (pa.Classes.Count() == 2 ? "Binary" : "Multi-class");
                ///////////////////////////////REGRESSION////////////////////////////////
                strB.Add("*************               ANNdotNET                    ********************");
                strB.Add("**********************Model Performance Analysis*****************************");
                strB.Add($"Model name={"ML Config Evaluation"}");
                strB.Add($"Problem Type ={problemType}");
                strB.Add($"DataSet Name = {pa.DatSetName}");
                strB.Add(" ");
                //
                if (problemType == "Regression")
                {
                    // strB.Add($"************Performance Parameters Value*************************************");
                    strB.Add(" ");
                    strB.Add($"Squared Error={pa.SE}");
                    strB.Add($"RMSE = {pa.RMSE}");
                    strB.Add($"Correlation Coefficient={pa.CORR}");
                    strB.Add($"Determination Coefficient={pa.DETC}");
                }
                else if (problemType == "Binary")
                {
                    /////////////////////BINARY CLASS/////////////////////////////////////////////
                    // strB.Add($"************Performance Parameters Value*************************************");
                    strB.Add(" ");
                    strB.Add($"Positive Label={pa.Classes.First()} \t\t Negative Label={pa.Classes.Last()}");
                    strB.Add($" ");
                    //
                    strB.Add($"True Positive = {pa.TP} \t\t False Positive = {pa.FP}");
                    strB.Add($"True Negative = {pa.TN} \t\t False Negative = {pa.FN}");
                    strB.Add($" ");
                    //
                    strB.Add($"Accuracy = {pa.Acc}, \t\t Error = {pa.ER}");
                    strB.Add($"Precision= {pa.Precision}, \t\t  Recall = {pa.Recall}");
                    strB.Add($"F1 Score= {pa.F1Score}, \t\t   ");
                    strB.Add($" ");
                    strB.Add($"HSS={pa.HSS}; \t PSS={pa.PSS}");
                    strB.Add($" ");
                    //strB.Add($"* - Heideke Skill Score; \t **- Peirce Scill Score");
                }
                else if (problemType == "Multiclass")
                {
                    /////////////////MULTICLASS//////////////////////////////////
                    //strB.Add($"************Performance Parameters Value*************************************");
                    strB.Add(" ");
                    strB.Add($"Overall Accuracy={pa.OAcc} \t\t\t Average Accuracy={pa.AAcc}");
                    //
                    strB.Add($"Micro avg. Precision = {pa.MicPrec} \t\t Macro avg. Precision = {pa.MacPrec}");
                    strB.Add($"Micro avg. Recall = {pa.MicRcall} \t\t Macro avg. Recall = {pa.MacRcall}");
                    //
                    strB.Add($"HSS ={pa.HSS}; \t\t\t PSS ={pa.PSS}");
                    strB.Add($" ");
                    //strB.Add($"* - Heideke Skill Score; \t **- Peirce Scill Score");
                    //* - Heideke Skill Score; \t **- Peirce Scill Score;
                }
                strB.Add($"************End of Performance Report*************************************");

                return(strB);
            }
            catch (Exception)
            {
                throw;
            }
        }