public void AssertTagValueChanged(uint tag, string valueToSet, string originalCharacterSet, string expectedNewCharacterSet)
        {
            DicomAttributeCollection dataset = new DicomAttributeCollection();

            SetupDataSet(dataset, originalCharacterSet);
            DicomFile file = new DicomFile("test", CreateMetaInfo(), dataset);

            Assert.AreEqual(originalCharacterSet, file.DataSet[DicomTags.SpecificCharacterSet].ToString());

            SetTagCommand cmd = new SetTagCommand(tag, valueToSet);

            Assert.AreEqual(cmd.CanSaveInUnicode, UnicodeAllowed, "SetTagCommand.CanSaveInUnicode returns an incorrect value");

            Assert.IsTrue(cmd.Apply(file), "SetTagCommand.Apply failed");

            var filename = string.Format("Test-{0}.dcm", DicomTagDictionary.GetDicomTag(tag).Name);

            Assert.IsTrue(file.Save(filename), "Unable to save dicom file");
            file = new DicomFile(filename);
            file.Load();

            if (valueToSet == null)
            {
                Assert.AreEqual(string.Empty, file.DataSet[tag].ToString());
            }
            else
            {
                Assert.AreEqual(valueToSet, file.DataSet[tag].ToString());
            }

            Assert.IsTrue(file.DataSet[DicomTags.SpecificCharacterSet].ToString().Equals(expectedNewCharacterSet));

            Delete(filename);
        }
示例#2
0
        private static DicomTag GetTagFromAttributeNode(XmlNode attributeNode)
        {
            String tag = attributeNode.Attributes["Tag"].Value;

            DicomTag theTag;

            if (tag.StartsWith("$"))
            {
                theTag = DicomTagDictionary.GetDicomTag(tag.Substring(1));
            }
            else
            {
                uint tagValue = uint.Parse(tag, NumberStyles.HexNumber);
                theTag = DicomTagDictionary.GetDicomTag(tagValue);
                DicomVr xmlVr = DicomVr.GetVR(attributeNode.Attributes["VR"].Value);
                if (theTag == null)
                {
                    theTag = new DicomTag(tagValue, "Unknown tag", "UnknownTag", xmlVr, false, 1, uint.MaxValue, false);
                }

                if (!theTag.VR.Equals(xmlVr))
                {
                    theTag = new DicomTag(tagValue, theTag.Name, theTag.VariableName, xmlVr, theTag.MultiVR, theTag.VMLow,
                                          theTag.VMHigh, theTag.Retired);
                }
            }
            return(theTag);
        }
        /// <summary>
        /// Routine for comparing two DICOMDIRs.  The Root Directory REcord for the two dicomdirs should be passed in.
        /// </summary>
        /// <remarks>
        /// The routine will traverse through the directory records and ensure that each record matches.
        /// </remarks>
        /// <param name="sq1"></param>
        /// <param name="sq2"></param>
        /// <param name="failureReason"></param>
        /// <returns></returns>
        private static bool Compare(DirectoryRecordSequenceItem sq1, DirectoryRecordSequenceItem sq2, out string failureReason)
        {
            if ((sq1.NextDirectoryRecord == null && sq2.NextDirectoryRecord != null) ||
                (sq2.NextDirectoryRecord == null && sq2.NextDirectoryRecord != null))
            {
                failureReason = "NextDirectoryRecord exists for one record, but not for the other";
                return(false);
            }

            if ((sq1.LowerLevelDirectoryRecord == null && sq2.LowerLevelDirectoryRecord != null) ||
                (sq2.LowerLevelDirectoryRecord == null && sq2.LowerLevelDirectoryRecord != null))
            {
                failureReason = "LowerLevelDirectoryRecord exists for one record, but not for the other";
                return(false);
            }
            List <DicomAttributeComparisonResult> failures = new List <DicomAttributeComparisonResult>();

            sq1.Equals(sq2, ref failures);

            if (failures.Count > 0)
            {
                bool     foundTag = false;
                DicomTag lower    = DicomTagDictionary.GetDicomTag(DicomTags.OffsetOfReferencedLowerLevelDirectoryEntity);
                DicomTag next     = DicomTagDictionary.GetDicomTag(DicomTags.OffsetOfTheNextDirectoryRecord);
                failureReason = string.Empty;

                foreach (DicomAttributeComparisonResult result in failures)
                {
                    if ((result.TagName == null) ||
                        (!result.TagName.Equals(lower.Name) && !result.TagName.Equals(next.Name)))
                    {
                        foundTag      = true;
                        failureReason = result.Details;
                    }
                }

                if (foundTag)
                {
                    return(false);
                }
            }

            if (sq1.LowerLevelDirectoryRecord != null)
            {
                if (!Compare(sq1.LowerLevelDirectoryRecord, sq2.LowerLevelDirectoryRecord, out failureReason))
                {
                    return(false);
                }
            }
            if (sq1.NextDirectoryRecord != null)
            {
                if (!Compare(sq1.NextDirectoryRecord, sq2.NextDirectoryRecord, out failureReason))
                {
                    return(false);
                }
            }

            failureReason = String.Empty;
            return(true);
        }
        private static void ListTagsByParentSequence(IEnumerable <FunctionalGroupMacro> functionalGroups, bool excludeMultiItemSequences)
        {
            var tagFunctionalGroupMap = functionalGroups.SelectMany(f => f.NestedTags.Select(g => new { Tag = g, ParentTag = f.DefinedTags.Single(), FunctionalGroup = f }));

            if (excludeMultiItemSequences)
            {
                tagFunctionalGroupMap = tagFunctionalGroupMap.Where(t => !t.FunctionalGroup.CanHaveMultipleItems);
            }
            foreach (var groupResults in tagFunctionalGroupMap.GroupBy(f => f.Tag).OrderByDescending(t => t.Distinct((a, b) => a.ParentTag == b.ParentTag).Count()))
            {
                var subGrouped = groupResults.GroupBy(g => g.ParentTag).ToList();
                if (subGrouped.Count() == 1 && excludeMultiItemSequences)
                {
                    continue;
                }

                Console.WriteLine(DicomTagDictionary.GetDicomTag(groupResults.Key));
                foreach (var pair in subGrouped)
                {
                    const string format = "- {0} ({1})";
                    Console.WriteLine(format, DicomTagDictionary.GetDicomTag(pair.Key), string.Join(", ", pair.Select(g => g.FunctionalGroup.GetType().Name).ToArray()));
                }
                Console.WriteLine();
            }
        }
示例#5
0
        protected static void Parse(string tagPath, out List <DicomTag> parentTags, out DicomTag tag)
        {
            Platform.CheckForNullReference(tagPath, "tagPath");

            parentTags = null;
            tag        = null;

            string[] tagPathComponents = tagPath.Split(',');
            if (tagPathComponents != null)
            {
                uint tagValue;
                if (tagPathComponents.Length > 1)
                {
                    parentTags = new List <DicomTag>();

                    for (int i = 0; i < tagPathComponents.Length - 1; i++)
                    {
                        tagValue = uint.Parse(tagPathComponents[i], NumberStyles.HexNumber);
                        DicomTag parent = DicomTagDictionary.GetDicomTag(tagValue);
                        if (parent == null)
                        {
                            throw new Exception(String.Format("Specified tag {0} is not in the dictionary", parent));
                        }
                        parentTags.Add(parent);
                    }
                }

                tagValue = uint.Parse(tagPathComponents[tagPathComponents.Length - 1], NumberStyles.HexNumber);
                tag      = DicomTagDictionary.GetDicomTag(tagValue);
                if (tag == null)
                {
                    throw new Exception(String.Format("Specified tag {0} is not in the dictionary", tag));
                }
            }
        }
示例#6
0
        public static DicomTagPath operator +(DicomTagPath left, uint right)
        {
            List <DicomTag> tags = new List <DicomTag>(left.TagsInPath);

            tags.Add(DicomTagDictionary.GetDicomTag(right));
            return(new DicomTagPath(tags));
        }
示例#7
0
 public ComparisionDifference(uint tag, string expected, string actual)
 {
     DicomTag    = DicomTagDictionary.GetDicomTag(tag);
     Description = DicomTag.Name;
     ExpectValue = expected;
     RealValue   = actual;
 }
示例#8
0
        private void ScanCollection(DicomAttributeCollection collection, string[] tagArray, int startIndex, List <DicomAttribute> attributeList)
        {
            if (startIndex >= tagArray.Length)
            {
                return;
            }

            DicomTag tag = DicomTagDictionary.GetDicomTag(tagArray[startIndex].Substring(1));

            if (tag == null)
            {
                throw new NoSuchDicomTagException(tagArray[startIndex].Substring(1));
            }

            DicomAttribute attrib;

            if (collection.TryGetAttribute(tag, out attrib))
            {
                if (attrib.Tag.VR.Equals(DicomVr.SQvr))
                {
                    var sequences = attrib.Values as DicomSequenceItem[];
                    if (sequences != null)
                    {
                        foreach (var sq in sequences)
                        {
                            ScanCollection(sq, tagArray, startIndex + 1, attributeList);
                        }
                    }
                }
                else
                {
                    attributeList.Add(attrib);
                }
            }
        }
示例#9
0
        static void InternalCompare(uint tag, string expected, string actual, int maxLength, ICollection <ComparisionDifference> list)
        {
            // reduce the strings if they exceed the max lengths
            if (maxLength > 0)
            {
                DicomTag dicomTag = null;
                if (!string.IsNullOrEmpty(expected) && expected.Length > maxLength)
                {
                    dicomTag = DicomTagDictionary.GetDicomTag(tag);
                    Platform.Log(LogLevel.Warn, string.Format("'{0}' exceeds max length allowed for {1}. Only first {2} characters are used for comparison", expected, dicomTag.Name, maxLength));
                    expected = expected.Substring(0, maxLength);
                }

                if (!string.IsNullOrEmpty(actual) && actual.Length > maxLength)
                {
                    dicomTag = dicomTag ?? DicomTagDictionary.GetDicomTag(tag);
                    Platform.Log(LogLevel.Warn, string.Format("'{0}' exceeds max length allowed for {1}. Only first {2} characters are used for comparison", actual, dicomTag.Name, maxLength));
                    actual = actual.Substring(0, maxLength);
                }
            }


            if (!StringUtils.AreEqual(expected, actual, StringComparison.InvariantCultureIgnoreCase))
            {
                list.Add(new ComparisionDifference(tag, expected, actual));
            }
        }
示例#10
0
 public DicomAttribute this[uint tag]
 {
     get
     {
         return(this[DicomTagDictionary.GetDicomTag(tag)]);
     }
 }
示例#11
0
        public override bool ReceiveMessageAsFileStream(DicomServer server, ServerAssociationParameters association, byte presentationId, DicomMessage message)
        {
            var sopClassUid = message.AffectedSopClassUid;

            if (sopClassUid.Equals(SopClass.BreastTomosynthesisImageStorageUid) ||
                sopClassUid.Equals(SopClass.EnhancedCtImageStorageUid) ||
                sopClassUid.Equals(SopClass.EnhancedMrColorImageStorageUid) ||
                sopClassUid.Equals(SopClass.EnhancedMrImageStorageUid) ||
                sopClassUid.Equals(SopClass.EnhancedPetImageStorageUid) ||
                sopClassUid.Equals(SopClass.EnhancedUsVolumeStorageUid) ||
                sopClassUid.Equals(SopClass.EnhancedXaImageStorageUid) ||
                sopClassUid.Equals(SopClass.EnhancedXrfImageStorageUid) ||
                sopClassUid.Equals(SopClass.UltrasoundMultiFrameImageStorageUid) ||
                sopClassUid.Equals(SopClass.MultiFrameGrayscaleByteSecondaryCaptureImageStorageUid) ||
                sopClassUid.Equals(SopClass.MultiFrameGrayscaleWordSecondaryCaptureImageStorageUid) ||
                sopClassUid.Equals(SopClass.MultiFrameSingleBitSecondaryCaptureImageStorageUid) ||
                sopClassUid.Equals(SopClass.MultiFrameTrueColorSecondaryCaptureImageStorageUid))
            {
                server.DimseDatasetStopTag = DicomTagDictionary.GetDicomTag(DicomTags.ReconstructionIndex);                 // Random tag at the end of group 20
                server.StreamMessage       = true;
                return(true);
            }

            return(false);
        }
 public ImageSetField this[uint tag]
 {
     get
     {
         DicomTag theTag = DicomTagDictionary.GetDicomTag(tag);
         return(this[theTag]);
     }
 }
示例#13
0
        public bool IsStoredTag(uint tag)
        {
            DicomTag dicomTag = DicomTagDictionary.GetDicomTag(tag);

            if (dicomTag == null)
            {
                return(false);
            }
            return(IsStoredTag(dicomTag));
        }
        public static ColumnDefinition GetColumnDefinition(uint dicomTag)
        {
            DicomTag tag = DicomTagDictionary.GetDicomTag(dicomTag);

            if (tag == null)
            {
                tag = new DicomTag(dicomTag, string.Empty, string.Empty, DicomVr.UNvr, false, uint.MinValue, uint.MaxValue, false);
            }
            return(GetColumnDefinition(tag));
        }
示例#15
0
        private static DicomTag NewTag(uint tag)
        {
            DicomTag returnTag = DicomTagDictionary.GetDicomTag(tag);

            if (returnTag == null)
            {
                returnTag = new DicomTag(tag, "Unknown Tag", "UnknownTag", DicomVr.UNvr, false, 1, uint.MaxValue, false);
            }

            return(returnTag);
        }
示例#16
0
        private static string GetTagName(uint tag)
        {
            DicomTag dcmTag = DicomTagDictionary.GetDicomTag(tag);

            if (dcmTag != null)
            {
                return(dcmTag.ToString());
            }

            return(String.Format("({0}) Unknown", tag.ToString("X8")));
        }
示例#17
0
 public Expression CreateExpression(string text)
 {
     if (text.StartsWith("$"))
     {
         DicomTag tag = DicomTagDictionary.GetDicomTag(text.Substring(1));
         if (tag == null)
         {
             throw new XmlSpecificationCompilerException("Invalid DICOM tag: " + text);
         }
     }
     return(new DicomExpression(text));
 }
        public bool TryGetAttribute(uint tag, out DicomAttribute attribute)
        {
            attribute = DicomTagDictionary.GetDicomTag(tag).CreateDicomAttribute();
            switch (tag)
            {
            case DicomTags.ModalitiesInStudy:
                attribute.Values = study.ModalitiesInStudy;
                return(true);

            case DicomTags.StudyDescription:
                attribute.SetStringValue(study.StudyDescription);
                return(true);

            case DicomTags.AccessionNumber:
                attribute.SetStringValue(study.AccessionNumber);
                return(true);

            case DicomTags.NumberOfStudyRelatedInstances:
                attribute.SetInt32(0, study.NumberOfStudyRelatedInstances);
                return(true);

            case DicomTags.NumberOfStudyRelatedSeries:
                attribute.SetInt32(0, study.NumberOfStudyRelatedSeries);
                return(true);

            case DicomTags.PatientsAge:
                attribute.SetStringValue(study.PatientsAge);
                return(true);

            case DicomTags.ReferringPhysiciansName:
                attribute.SetStringValue(study.ReferringPhysiciansName);
                return(true);

            case DicomTags.SopClassesInStudy:
                attribute.Values = study.SopClassesInStudy;
                return(true);

            case DicomTags.StudyId:
                attribute.SetStringValue(study.StudyId);
                return(true);

            case DicomTags.StudyDate:
                attribute.SetStringValue(study.StudyDate);
                return(true);

            case DicomTags.StudyTime:
                attribute.SetStringValue(study.StudyTime);
                return(true);

            default:
                return(false);
            }
        }
        public void TestTagMappingBySopClass()
        {
            foreach (var uid in _multiframeSopClassUids)
            {
                var sopClass         = SopClass.GetSopClass(uid).Name;
                var functionalGroups = FunctionalGroupDescriptor.GetApplicableFunctionalGroups(uid).ToList();
                var tagGroups        = functionalGroups.Select(f => f.Create())
                                       .SelectMany(f => f.NestedTags.Select(t => new { TagValue = t, FunctionalGroup = f }))
                                       .GroupBy(u => u.TagValue).OrderBy(u => u.Key).ToList();

                foreach (var group in tagGroups)
                {
                    var dcmTag = DicomTagDictionary.GetDicomTag(group.Key);

                    // asserts that any tag defined in 'singleton' functional groups (those whose sequence can have at most 1 item) should have at least some mapping
                    var fgType = FunctionalGroupDescriptor.GetFunctionalGroupByTag(uid, group.Key);
                    if (fgType == null)
                    {
                        foreach (var entry in group)
                        {
                            Assert.IsTrue(entry.FunctionalGroup.CanHaveMultipleItems, "At least one singleton functional group defines tag {0} for SOP class {1}", dcmTag, sopClass);
                        }
                    }

                    // explicitly assert the mapping for any tag defined by multiple 'singleton' functional groups - so that if new tags are introduced later, we would explicitly consider what is the correct mapping
                    if (group.Count(g => !g.FunctionalGroup.CanHaveMultipleItems) > 1)
                    {
                        const string wrongMapMsg = "SOP Class {0} maps tag {1} to the wrong functional group";

                        if (uid == SopClass.EnhancedXaImageStorageUid)
                        {
                            switch (group.Key)
                            {
                            case DicomTags.TableHorizontalRotationAngle:
                            case DicomTags.TableHeadTiltAngle:
                            case DicomTags.TableCradleTiltAngle:
                                Assert.AreEqual(new FunctionalGroupDescriptor(typeof(XRayTablePositionFunctionalGroup)), fgType, wrongMapMsg, sopClass, dcmTag);
                                break;

                            default:
                                Assert.Fail("SOP Class {0} shouldn't have an ambiguous mapping for tag {1} - if new tags were added, please explicitly update the expected mapping in this unit test", sopClass, dcmTag);
                                break;
                            }
                        }
                        else
                        {
                            Assert.Fail("SOP Class {0} shouldn't have any ambiguous mappings - if new tags were added, please explicitly update the expected mapping in this unit test", sopClass);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Creates an in-memory DICOM image
        /// </summary>
        /// <returns></returns>
        private static DicomFile CreateDicomImage(int rows = 20, int columns = 30, bool bitsAllocated16 = true, bool signed = false, int numberOfFrames = 1, Endian endian = Endian.Little, bool useOB = false)
        {
            var sopClassUid    = bitsAllocated16 ? SopClass.MultiFrameGrayscaleWordSecondaryCaptureImageStorageUid : SopClass.MultiFrameGrayscaleByteSecondaryCaptureImageStorageUid;
            var sopInstanceUid = DicomUid.GenerateUid().UID;

            var dcf = new DicomFile();

            dcf.MediaStorageSopClassUid    = sopClassUid;
            dcf.MediaStorageSopInstanceUid = sopInstanceUid;
            dcf.TransferSyntax             = endian == Endian.Little ? TransferSyntax.ExplicitVrLittleEndian : TransferSyntax.ExplicitVrBigEndian;
            dcf.DataSet[DicomTags.PatientId].SetStringValue("TEST");
            dcf.DataSet[DicomTags.PatientsName].SetStringValue("TEST");
            dcf.DataSet[DicomTags.StudyInstanceUid].SetStringValue(DicomUid.GenerateUid().UID);
            dcf.DataSet[DicomTags.StudyId].SetStringValue("TEST");
            dcf.DataSet[DicomTags.StudyDescription].SetStringValue("TEST");
            dcf.DataSet[DicomTags.SeriesInstanceUid].SetStringValue(DicomUid.GenerateUid().UID);
            dcf.DataSet[DicomTags.SeriesNumber].SetInt32(0, 1);
            dcf.DataSet[DicomTags.SeriesDescription].SetStringValue("TEST");
            dcf.DataSet[DicomTags.SopClassUid].SetStringValue(sopClassUid);
            dcf.DataSet[DicomTags.SopInstanceUid].SetStringValue(sopInstanceUid);
            dcf.DataSet[DicomTags.InstanceNumber].SetInt32(0, 1);

            var frameSize = rows * columns * (bitsAllocated16 ? 2 : 1);
            var data      = new byte[numberOfFrames * frameSize];

            for (var n = 0; n < numberOfFrames; ++n)
            {
                var value = (byte)(0xFF & (n + 0x80));

                for (var k = 0; k < frameSize; ++k)
                {
                    data[n * frameSize + k] = value;
                }
            }

            var pixelDataTag = DicomTagDictionary.GetDicomTag(DicomTags.PixelData);

            pixelDataTag = new DicomTag(pixelDataTag.TagValue, pixelDataTag.Name, pixelDataTag.VariableName, useOB ? DicomVr.OBvr : DicomVr.OWvr, pixelDataTag.MultiVR, pixelDataTag.VMLow, pixelDataTag.VMHigh, pixelDataTag.Retired);

            dcf.DataSet[DicomTags.PhotometricInterpretation].SetStringValue(PhotometricInterpretation.Monochrome2.Code);
            dcf.DataSet[DicomTags.SamplesPerPixel].SetInt32(0, 1);
            dcf.DataSet[DicomTags.PixelRepresentation].SetInt32(0, signed ? 1 : 0);
            dcf.DataSet[DicomTags.BitsAllocated].SetInt32(0, bitsAllocated16 ? 16 : 8);
            dcf.DataSet[DicomTags.BitsStored].SetInt32(0, bitsAllocated16 ? 16 : 8);
            dcf.DataSet[DicomTags.HighBit].SetInt32(0, bitsAllocated16 ? 15 : 7);
            dcf.DataSet[DicomTags.Rows].SetInt32(0, rows);
            dcf.DataSet[DicomTags.Columns].SetInt32(0, columns);
            dcf.DataSet[DicomTags.NumberOfFrames].SetInt32(0, numberOfFrames);
            dcf.DataSet[pixelDataTag].Values = data;

            return(dcf);
        }
示例#21
0
        public void ConvertAttributeToUN(DicomAttributeCollection theSet, uint tag)
        {
            ByteBuffer theData =
                theSet[tag].GetByteBuffer(TransferSyntax.ImplicitVrLittleEndian,
                                          theSet.SpecificCharacterSet);

            DicomTag baseTag = DicomTagDictionary.GetDicomTag(tag);
            DicomTag theTag  = new DicomTag(tag,
                                            baseTag.Name, baseTag.VariableName, DicomVr.UNvr, baseTag.MultiVR, baseTag.VMLow, baseTag.VMHigh, baseTag.Retired);

            DicomAttribute unAttrib = DicomVr.UNvr.CreateDicomAttribute(theTag, theData);

            theSet[tag] = unAttrib;
        }
示例#22
0
        static void AddDicomLength(uint tag)
        {
            DicomTag dTag = DicomTagDictionary.GetDicomTag(tag);

            // For PN VR tags, we're only storing 64 bit lengths, whereas the max length is 64.
            if (dTag.VR.Equals(DicomVr.PNvr))
            {
                _maxLengths.Add(tag, 64);
            }
            else
            {
                _maxLengths.Add(tag, dTag.VR.MaximumLength);
            }
        }
        /// <summary>
        /// Fixes the VR of the specified DICOM tag, which is especially important for multi-VR tags.
        /// </summary>
        private static DicomTag FixVR(uint tag, DicomVr newVR)
        {
            var dicomTag = DicomTagDictionary.GetDicomTag(tag);

            if (dicomTag.VR == newVR)
            {
                return(dicomTag);
            }
            if (!dicomTag.MultiVR)
            {
                throw new ArgumentException("The specified DICOM tag does not support multiple VRs.", "tag");
            }
            return(new DicomTag(dicomTag.TagValue, dicomTag.Name, dicomTag.VariableName, newVR, true, dicomTag.VMLow, dicomTag.VMHigh, dicomTag.Retired));
        }
        private void PopulateField(uint tag, IDicomAttributeProvider attributeProvider)
        {
            DicomAttribute attr;

            if (attributeProvider.TryGetAttribute(tag, out attr))
            {
                AddField(new ImageSetField(attr));
            }
            else
            {
                // add default value
                AddField(new ImageSetField(DicomTagDictionary.GetDicomTag(tag).CreateDicomAttribute()));
            }
        }
 public AddOriginalAttributes()
 {
     UpdateEntry =
         new ImageLevelUpdateEntry()
     {
         TagPath =
             new DicomTagPath()
         {
             Tag = DicomTagDictionary.GetDicomTag(DicomTags.OriginalAttributesSequence)
         },
         Value         = "N/A",
         OriginalValue = "N/A"
     };
 }
        private static DicomTag LookupDicomTag(string tag)
        {
            uint tagValue;

            if (uint.TryParse(tag, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out tagValue))
            {
                // very simple support for private tags, since the toolkit won't try to read it anyway
                if (DicomTag.IsPrivateGroup((ushort)(0x00FFFF & (tagValue >> 16))))
                {
                    return(new DicomTag(tagValue, "Private Tag", "PrivateTag", DicomVr.UNvr, false, 1, uint.MaxValue, false));
                }
                return(DicomTagDictionary.GetDicomTag(tagValue));
            }
            return(DicomTagDictionary.GetDicomTag(tag));
        }
示例#27
0
        /// <summary>
        /// Ensures the offset of the data set in the source stream is determined.
        /// </summary>
        internal void ParseMetaInfo()
        {
            if (MetaInfoFileLength != 0)
            {
                return;
            }

            var theFile = new DicomFile();

            const uint stopTag = DicomTags.RelatedGeneralSopClassUid;

            theFile.Load(StreamOpener, DicomTagDictionary.GetDicomTag(stopTag), DicomReadOptions.Default);

            MetaInfoFileLength = theFile.MetaInfoFileLength;
        }
示例#28
0
 public Expression CreateExpression(string text)
 {
     if (text.StartsWith("$"))
     {
         var tagArray = text.Split(new[] { '/' });
         foreach (var t in tagArray)
         {
             DicomTag tag = DicomTagDictionary.GetDicomTag(t.Substring(1));
             if (tag == null)
             {
                 throw new XmlSpecificationCompilerException("Invalid DICOM tag: " + t);
             }
         }
     }
     return(new DicomExpression(text));
 }
示例#29
0
        internal static DicomTag NewTag(uint tag, DicomVr vr)
        {
            var theTag = DicomTagDictionary.GetDicomTag(tag);

            if (theTag == null)
            {
                theTag = new DicomTag(tag, "Unknown tag", "UnknownTag", vr ?? DicomVr.UNvr, false, 1, uint.MaxValue, false);
            }
            else if (vr != null && !theTag.VR.Equals(vr))
            {
                theTag = new DicomTag(tag, theTag.Name, theTag.VariableName, vr, theTag.MultiVR, theTag.VMLow,
                                      theTag.VMHigh, theTag.Retired);
            }

            return(theTag);
        }
        protected DicomTagColumn(DicomTag dicomTag)
        {
            _tag = dicomTag.TagValue;
            _vr  = dicomTag.VR.Name;

            uint tagGroup   = (_tag >> 16) & 0x0000FFFF;
            uint tagElement = _tag & 0x0000FFFF;

            if (DicomTagDictionary.GetDicomTag(dicomTag.TagValue) == null)
            {
                _tagName = string.Format(SR.FormatUnknownDicomTag, tagGroup, tagElement);
            }
            else
            {
                _tagName = string.Format(SR.FormatDicomTag, tagGroup, tagElement, dicomTag.Name);
            }
        }