예제 #1
0
        private void AddDICONDEAttributeToTree(TreeViewItem theParentNode, XElement theXElement)
        {
            string aTag     = theXElement.Attribute("Tag").Value;
            string aTagName = theXElement.Attribute("TagName").Value;
            string aTagData = theXElement.Attribute("Data").Value;

            // Enrich the Transfer Syntax attribute (0002,0010) with human-readable string from dictionary
            if (aTag.Equals("(0002,0010)"))
            {
                aTagData = string.Format("{0} ({1})", aTagData, TransferSyntaxDictionary.GetTransferSyntaxName(aTagData));
            }

            // Enrich the SOP Class UID attribute (0008,0016) with human-readable string from dictionary
            if (aTag.Equals("(0008,0016)"))
            {
                aTagData = string.Format("{0} ({1})", aTagData, SOPClassDictionary.GetSOPClassName(aTagData));
            }

            string s = string.Format("{0} {1}", aTag, aTagName);

            // Do some cut-off in order to allign the TagData
            if (s.Length > 50)
            {
                s = s.Remove(50);
            }
            else
            {
                s = s.PadRight(50);
            }

            s = string.Format("{0} {1}", s, aTagData);

            TreeViewItem aNewItem = new TreeViewItem()
            {
                Header = s
            };

            theParentNode.Items.Add(aNewItem);

            // In case the DICOM attributes has childrens (= Sequence), call the helper method recursively.
            if (theXElement.HasElements)
            {
                foreach (XElement xe in theXElement.Elements("DataElement"))
                {
                    AddDICONDEAttributeToTree(aNewItem, xe);
                }
            }
        }
예제 #2
0
파일: IOD.cs 프로젝트: AndrDm/uImage
        public IOD(string theFileName)
        {
            DICONDEParser aDICONDEParser = new DICONDEParser(theFileName);

            this.XDocument = aDICONDEParser.GetXDocument();

            this.FileName = theFileName;

            this.StudyInstanceUID  = DICONDEParserUtility.GetDICONDEAttributeAsString(this.XDocument, "(0020,000D)");
            this.SeriesInstanceUID = DICONDEParserUtility.GetDICONDEAttributeAsString(this.XDocument, "(0020,000E)");

            this.SOPInstanceUID = DICONDEParserUtility.GetDICONDEAttributeAsString(this.XDocument, "(0008,0018)");

            this.SOPClassUID  = DICONDEParserUtility.GetDICONDEAttributeAsString(this.XDocument, "(0008,0016)");
            this.SOPClassName = SOPClassDictionary.GetSOPClassName(this.SOPClassUID);
            //DICONDE:Component
            this.ComponentName = DICONDEParserUtility.GetDICONDEAttributeAsString(this.XDocument, "(0010,0010)");

            this.TransferSyntaxUID = DICONDEParserUtility.GetDICONDEAttributeAsString(this.XDocument, "(0002,0010)");

            // The SortOrder attribute is used for sorting the CT Slices within one series.
            // For all other IOD's, the SortOrder attribute has no meaning.
            // For sorting the CT Slices, the Z-Value is used.
            // The Z-Value is tried to be determined either from
            //    - 'Image Position Component' attribute (0020,0032) or from
            //    - 'Slice Location' attribute (0020,1041)
            if (DICONDEParserUtility.DoesDICONDEAttributeExist(this.XDocument, "(0020,0032)"))              //"(0020,0032)", "Image Position (Component)"
            // 'Image Position Component' attribute will be encoded as "x\y\z"
            {
                string   aImagePositionComponent = DICONDEParserUtility.GetDICONDEAttributeAsString(this.XDocument, "(0020,0032)");
                string[] split = aImagePositionComponent.Split(new Char[] { '\\' });
                this.SortOrder = Convert.ToDouble(split[2], CultureInfo.InvariantCulture);
            }
            else
            {
                if (DICONDEParserUtility.DoesDICONDEAttributeExist(this.XDocument, "(0020,1041)"))
                {
                    this.SortOrder = DICONDEParserUtility.GetDICONDEAttributeAsDouble(this.XDocument, "(0020,1041)");
                }
            }
        }