public void Add_PrivateTag_GetsCorrectVR() { var privCreatorDictEntry = new DicomDictionaryEntry( new DicomTag(0x0011, 0x0010), "Private Creator", "PrivateCreator", DicomVM.VM_1, false, DicomVR.LO); DicomDictionary.Default.Add(privCreatorDictEntry); DicomPrivateCreator privateCreator1 = DicomDictionary.Default.GetPrivateCreator("TESTCREATOR1"); DicomDictionary privDict1 = DicomDictionary.Default[privateCreator1]; var dictEntry = new DicomDictionaryEntry( DicomMaskedTag.Parse("0011", "xx10"), "TestPrivTagName", "TestPrivTagKeyword", DicomVM.VM_1, false, DicomVR.CS); privDict1.Add(dictEntry); var ds = new DicomDataset { { dictEntry.Tag, "VAL1" } }; Assert.Equal(DicomVR.CS, ds.Get <DicomVR>(ds.GetPrivateTag(dictEntry.Tag))); }
public void AddOrUpdate_DicomItemOnExistingPrivateTag_PrivateGroupShouldCorrespondToPrivateCreator() { var dataset = new DicomDataset(); var tag1 = new DicomTag(0x3001, 0x08, "PRIVATE"); var tag2 = new DicomTag(0x3001, 0x12, "PRIVATE"); var tag3 = new DicomTag(0x3001, 0x08, "ALSOPRIVATE"); // By using the .Add(DicomTag, ...) method, private tags get automatically updated so that a private // creator group number is generated (if private creator is new) and inserted into the tag element. dataset.Add(tag1, 1); dataset.Add(tag2, 3.14); dataset.Add(tag3, "COOL"); var tag1Private = dataset.GetPrivateTag(tag1); var contained = dataset.SingleOrDefault(item => item.Tag.Group == tag1Private.Group && item.Tag.Element == tag1Private.Element); Assert.NotNull(contained); // Should confirm that element of the tag is not updated to include the private creator group number. dataset.AddOrUpdate(new DicomIntegerString(tag1, 50)); contained = dataset.SingleOrDefault(item => item.Tag.Group == tag1Private.Group && item.Tag.Element == tag1Private.Element); Assert.NotNull(contained); var thirdItem = dataset.ElementAt(2); Assert.Equal(thirdItem, contained); }
private void ReadDicomAttribute(fo.DicomDataset ds, XElement element, int level) { XAttribute vrNode; fo.DicomTag tag; fo.DicomDictionaryEntry dicEntry; fo.DicomVR dicomVR; vrNode = element.Attribute(Constants.ATTRIBUTE_VR); tag = fo.DicomTag.Parse(element.Attribute(Constants.ATTRIBUTE_TAG).Value); dicomVR = null; //if ( tag.ToString ("J") == "00020010" ) //{ // ds.InternalTransferSyntax = ReadValue ( element ).FirstOrDefault ( ) ; //} if (vrNode != null && !string.IsNullOrEmpty(vrNode.Value)) { dicomVR = fo.DicomVR.Parse(vrNode.Value); } if (tag.IsPrivate) { tag = ds.GetPrivateTag(tag); if (null != vrNode) { dicomVR = fo.DicomVR.Parse(vrNode.Value); } } if (null == dicomVR) { dicEntry = fo.DicomDictionary.Default[tag]; dicomVR = dicEntry.ValueRepresentations.FirstOrDefault( ); } if (dicomVR == fo.DicomVR.SQ) { ReadSequence(ds, element, tag, level); } else { ReadElement(ds, element, tag, dicomVR, level); } }