Exemple #1
0
 public bool OnElement(DicomElement element)
 {
     StringBuilder sb = new StringBuilder();
     if (_depth > 0) sb.Append(_pad).Append("> ");
     sb.Append(element.Tag);
     sb.Append(' ');
     sb.Append(element.ValueRepresentation.Code);
     sb.Append(' ');
     if (element.Length == 0)
     {
         sb.Append("(no value available)");
     }
     else if (element.ValueRepresentation.IsString)
     {
         sb.Append('[');
         string val = element.Get<string>();
         if (val.Length > (_value - 2 - sb.Length))
         {
             sb.Append(val.Substring(0, _value - 2 - sb.Length));
             sb.Append(')');
         }
         else
         {
             sb.Append(val);
             sb.Append(']');
         }
     }
     else if (element.Length >= 1024)
     {
         sb.Append("<skipping large element>");
     }
     else
     {
         var val = String.Join("/", element.Get<string[]>());
         if (val.Length > (_value - sb.Length))
         {
             sb.Append(val.Substring(0, _value - sb.Length));
         }
         else
         {
             sb.Append(val);
         }
     }
     while (sb.Length < _value) sb.Append(' ');
     sb.Append('#');
     string name = element.Tag.DictionaryEntry.Keyword;
     sb.AppendFormat(
         "{0,6}, {1}",
         element.Length,
         name.Substring(0, System.Math.Min(_width - sb.Length - 9, name.Length)));
     _log.Log(_level, sb.ToString());
     return true;
 }
		public bool OnElement(DicomElement element)
		{
			var tag = String.Format("{0}  {1}", element.Tag.ToString().ToUpper(), element.Tag.DictionaryEntry.Name);

			var value = element.Length <= 2048 ? String.Join("\\", element.Get<string[]>()) : "<large value not displayed>";

			if (element.ValueRepresentation == DicomVR.UI && element.Count > 0)
			{
				var uid = element.Get<DicomUID>(0);
				var name = uid.Name;
				if (name != "Unknown")
					value = String.Format("{0} ({1})", value, name);
			}

			TextItems.Add(new DicomTextItem(_level, tag, element.ValueRepresentation.Code, element.Length, value));
			return true;
		}
Exemple #3
0
        /// <summary>
        /// Handler for traversing a DICOM element.
        /// </summary>
        /// <param name="element">Element to traverse.</param>
        /// <returns>true if traversing completed without issues, false otherwise.</returns>
        /// <remarks>On false return value, the method will invoke the callback method passed in <see cref="IDicomDatasetWalker.OnBeginWalk"/> before returning.</remarks>
        public bool OnElement(DicomElement element)
        {
            WriteTagHeader(element.Tag, element.ValueRepresentation, element.Length);

            IByteBuffer buffer = element.Buffer;
            if (buffer is EndianByteBuffer)
            {
                EndianByteBuffer ebb = buffer as EndianByteBuffer;
                if (ebb.Endian != Endian.LocalMachine && ebb.Endian == _target.Endian) buffer = ebb.Internal;
            }
            else if (_target.Endian != Endian.LocalMachine)
            {
                if (element.ValueRepresentation.UnitSize > 1) buffer = new SwapByteBuffer(buffer, element.ValueRepresentation.UnitSize);
            }

            _target.Write(buffer.Data, 0, buffer.Size);

            return true;
        }
Exemple #4
0
        /// <summary>
        /// Asynchronous handler for traversing a DICOM element.
        /// </summary>
        /// <param name="element">Element to traverse.</param>
        /// <returns>true if traversing completed without issues, false otherwise.</returns>
        public async Task<bool> OnElementAsync(DicomElement element)
        {
            WriteTagHeader(element.Tag, element.ValueRepresentation, element.Length);

            IByteBuffer buffer = element.Buffer;
            if (buffer is EndianByteBuffer)
            {
                EndianByteBuffer ebb = buffer as EndianByteBuffer;
                if (ebb.Endian != Endian.LocalMachine && ebb.Endian == _target.Endian) buffer = ebb.Internal;
            }
            else if (_target.Endian != Endian.LocalMachine)
            {
                if (element.ValueRepresentation.UnitSize > 1) buffer = new SwapByteBuffer(buffer, element.ValueRepresentation.UnitSize);
            }

            if (element.Length < this._options.LargeObjectSize)
            {
                _target.Write(buffer.Data, 0, buffer.Size);
            }
            else
            {
                await _target.WriteAsync(buffer.Data, 0, buffer.Size).ConfigureAwait(false);
            }

            return true;
        }
Exemple #5
0
 private bool DicomElementEquals(DicomElement x, DicomElement y)
 {
     return(DicomItemEquals(x, y) && x.Count == y.Count && ByteBufferEquals(x.Buffer, y.Buffer));
 }
Exemple #6
0
 public Task <bool> OnElementAsync(DicomElement element)
 {
     return(Task.FromResult(this.OnElement(element)));
 }
Exemple #7
0
 public Task <bool> OnElementAsync(DicomElement element)
 {
     return(null);
 }
            public bool OnElement(DicomElement element)
            {
                if (element.Tag.Equals(DicomTag.NumberOfContourPoints))
                {
                    this.numberOfCountourPoints = element.Get<int>();
                }
                if (element.Tag.Equals(DicomTag.FinalCumulativeMetersetWeight))
                {
                    this.maxFinalCumulativeMetersetWeight = Math.Max(
                        element.Get<double>(),
                        this.maxFinalCumulativeMetersetWeight);
                }

                var success = !element.Tag.Equals(DicomTag.AcquisitionDate);

                return success;
            }
Exemple #9
0
 public Task<bool> OnElementAsync(DicomElement element)
 {
     return null;
 }
Exemple #10
0
        /// <summary>
        /// Handler for traversing a DICOM element.
        /// </summary>
        /// <param name="element">Element to traverse.</param>
        /// <returns>true if traversing completed without issues, false otherwise.</returns>
        public bool OnElement(DicomElement element)
        {
            StringBuilder sb = new StringBuilder();

            if (_depth > 0)
            {
                sb.Append(_pad).Append("> ");
            }
            sb.Append(element.Tag);
            sb.Append(' ');
            sb.Append(element.ValueRepresentation.Code);
            sb.Append(' ');
            if (element.Length == 0)
            {
                sb.Append("(no value available)");
            }
            else if (element.ValueRepresentation.IsString)
            {
                sb.Append('[');
                string val = element.Get <string>();
                if (val.Length > (_value - 2 - sb.Length))
                {
                    sb.Append(val.Substring(0, _value - 2 - sb.Length));
                    sb.Append(')');
                }
                else
                {
                    sb.Append(val);
                    sb.Append(']');
                }
            }
            else if (element.Length >= 1024)
            {
                sb.Append("<skipping large element>");
            }
            else
            {
                var val = String.Join("/", element.Get <string[]>());
                if (val.Length > (_value - sb.Length))
                {
                    sb.Append(val.Substring(0, _value - sb.Length));
                }
                else
                {
                    sb.Append(val);
                }
            }
            while (sb.Length < _value)
            {
                sb.Append(' ');
            }
            sb.Append('#');
            string name = element.Tag.DictionaryEntry.Keyword;

            sb.AppendFormat(
                "{0,6}, {1}",
                element.Length,
                name.Substring(0, System.Math.Min(_width - sb.Length - 9, name.Length)));
            _log.Log(_level, sb.ToString());
            return(true);
        }
Exemple #11
0
        public Form1()
        {
            RasterSupport.SetLicense(@"C:\LEADTOOLS 20\Common\License\LEADTOOLS.LIC", System.IO.File.ReadAllText(@"C:\LEADTOOLS 20\Common\License\LEADTOOLS.LIC.KEY"));
            InitializeComponent();
            RasterCodecs _codecs = new RasterCodecs();
            RasterImage  _image;
            string       dicomFileName = @"C:\Users\Public\Documents\LEADTOOLS Images\IMAGE3.dcm";

            // Create the medical viewer and adjust the size and the location.
            _medicalViewer          = new MedicalViewer(1, 1);
            _medicalViewer.Location = new Point(0, 0);
            _medicalViewer.Size     = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom);

            // Load an image and then add it to the control.
            _image = _codecs.Load(dicomFileName);

            DicomEngine.Startup();
            using (DicomDataSet ds = new DicomDataSet())
            {
                MedicalViewerMultiCell cell = new MedicalViewerMultiCell(_image, true, 1, 1);

                ds.Load(dicomFileName, DicomDataSetLoadFlags.None);
                string dpatientID        = GetDicomTag(ds, DicomTag.PatientID);
                string dpatientName      = GetDicomTag(ds, DicomTag.PatientName);
                string dpatientAge       = GetDicomTag(ds, DicomTag.PatientAge);
                string dpatientBirthDate = GetDicomTag(ds, DicomTag.PatientBirthDate);
                string dpatientSex       = GetDicomTag(ds, DicomTag.PatientSex);

                // add some actions that will be used to change the properties of the images inside the control.
                cell.AddAction(MedicalViewerActionType.WindowLevel);
                cell.AddAction(MedicalViewerActionType.Offset);
                cell.AddAction(MedicalViewerActionType.Stack);

                // assign the added actions to a mouse button, meaning that when the user clicks and drags the mouse button, the associated action will be activated.
                cell.SetAction(MedicalViewerActionType.Offset, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.Active);
                cell.SetAction(MedicalViewerActionType.WindowLevel, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active);
                cell.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active);

                // assign the added actions to a keyboard keys that will work like the mouse.
                MedicalViewerKeys medicalKeys = new MedicalViewerKeys(Keys.Down, Keys.Up, Keys.Left, Keys.Right, MedicalViewerModifiers.None);
                cell.SetActionKeys(MedicalViewerActionType.Offset, medicalKeys);
                medicalKeys.Modifiers = MedicalViewerModifiers.Ctrl;
                cell.SetActionKeys(MedicalViewerActionType.WindowLevel, medicalKeys);
                medicalKeys.MouseDown = Keys.PageDown;
                medicalKeys.MouseUp   = Keys.PageUp;
                cell.SetActionKeys(MedicalViewerActionType.Stack, medicalKeys);
                medicalKeys.MouseDown = Keys.Subtract;
                medicalKeys.MouseUp   = Keys.Add;
                cell.SetActionKeys(MedicalViewerActionType.Scale, medicalKeys);

                _medicalViewer.Cells.Add(cell);

                // adjust some properties of the cell and add some tags.
                cell.SetTag(1, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "Name: " + dpatientName);
                cell.SetTag(2, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "ID: " + dpatientID);
                cell.SetTag(3, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "DOB: " + dpatientBirthDate);
                cell.SetTag(4, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "Age: " + dpatientAge);
                cell.SetTag(5, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "Sex: " + dpatientSex);

                cell.SetTag(4, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame);
                cell.SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Scale);
                cell.SetTag(2, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.WindowLevelData);
                cell.SetTag(1, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.FieldOfView);
                cell.SetTag(0, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.RulerUnit);

                cell.Rows                     = 1;
                cell.Columns                  = 1;
                cell.Frozen                   = false;
                cell.DisplayRulers            = MedicalViewerRulers.Both;
                cell.ApplyOnIndividualSubCell = false;
                cell.ApplyActionOnMove        = true;
                cell.FitImageToCell           = true;
                cell.Selected                 = true;
                cell.ShowTags                 = true;
            }

            string GetDicomTag(DicomDataSet ds, long tag)
            {
                DicomElement patientElement = ds.FindFirstElement(null,
                                                                  tag,
                                                                  true);

                if (patientElement != null)
                {
                    return(ds.GetConvertValue(patientElement));
                }

                return(null);
            }

            Controls.Add(_medicalViewer);
            _medicalViewer.Dock = DockStyle.Fill;
        }
Exemple #12
0
        void FillSubTree(DicomElement element, TreeNode ParentNode)
        {
            TreeNode     node;
            string       name;
            string       temp = "";
            DicomTag     tag;
            DicomElement tempElement;

#if (LTV15_CONFIG)
            if (element.UserTag != 0)
            {
                tag = DicomTagTable.Instance.Find(element.UserTag);
            }
            else
            {
                tag = DicomTagTable.Instance.Find(element.Tag);
            }
#else
            tag = DicomTagTable.Instance.Find(element.Tag);
#endif
            if (tag != null)
            {
                name = tag.Name;
            }
            else
            {
                name = "Item";
            }

            long tagValue = 0;
#if (LTV15_CONFIG)
            if (element.UserTag != 0)
            {
                tagValue = element.UserTag;
            }
            else
            {
                tagValue = (long)element.Tag;
            }
#else
            tagValue = (long)element.Tag;
#endif
            temp = string.Format("{0:x4}:{1:x4} - ", Utils.GetGroup(tagValue), Utils.GetElement(tagValue));
            temp = temp + name;

            if (ParentNode != null)
            {
                node = ParentNode.Nodes.Add(temp);
            }
            else
            {
                node = treeViewElements.Nodes.Add(temp);
            }

            node.Tag = element;

            if (ds.IsVolatileElement(element))
            {
                node.ForeColor = Color.Red;
            }

            node.ImageIndex         = 1;
            node.SelectedImageIndex = 1;

            tempElement = ds.GetChildElement(element, true);
            if (tempElement != null)
            {
                node.ImageIndex         = 0;
                node.SelectedImageIndex = 0;
                FillSubTree(tempElement, node);
            }


            tempElement = ds.GetNextElement(element, true, true);
            if (tempElement != null)
            {
                FillSubTree(tempElement, ParentNode);
            }
        }
        public void GivenSupportedDicomElement_WhenRead_ThenShouldReturnExpectedValue(DicomElement element, object expectedValue)
        {
            DicomDataset dataset = new DicomDataset();

            dataset.Add(element);
            QueryTag tag        = new QueryTag(element.Tag.BuildExtendedQueryTagStoreEntry(vr: element.ValueRepresentation.Code));
            var      parameters = AddInstanceTableValuedParametersBuilder.Build(dataset, new QueryTag[] { tag });

            ExtendedQueryTagDataType dataType = ExtendedQueryTagLimit.ExtendedQueryTagVRAndDataTypeMapping[element.ValueRepresentation.Code];

            switch (dataType)
            {
            case ExtendedQueryTagDataType.StringData:
                Assert.Equal(expectedValue, parameters.StringExtendedQueryTags.First().TagValue);
                break;

            case ExtendedQueryTagDataType.LongData:
                Assert.Equal(expectedValue, parameters.LongExtendedQueryTags.First().TagValue);
                break;

            case ExtendedQueryTagDataType.DoubleData:
                Assert.Equal(expectedValue, parameters.DoubleExtendedQueryTags.First().TagValue);
                break;

            case ExtendedQueryTagDataType.DateTimeData:
                Assert.Equal(expectedValue, parameters.DateTimeExtendedQueryTags.First().TagValue);
                break;

            case ExtendedQueryTagDataType.PersonNameData:
                Assert.Equal(expectedValue, parameters.PersonNameExtendedQueryTags.First().TagValue);
                break;
            }
        }
        private static void FillTreeKeys(TreeView treeview, DicomDataSet ds, DicomElement ParentKeyElement, TreeNode ParentNode)
        {
            DicomElement CurrentKeyElement, CurrentKeyChildElement;
            TreeNode     node;
            string       name;
            string       temp = "";

            if (ParentKeyElement == null)
            {
                CurrentKeyElement = ds.GetFirstKey(null, true);
            }
            else
            {
                CurrentKeyElement = ds.GetChildKey(ParentKeyElement);
            }

            // Add the keys to the TreeView
            while (CurrentKeyElement != null)
            {
                // Get key name
                temp = ds.GetKeyValueString(CurrentKeyElement);

                if ((temp != null) || (temp == ""))
                {
                    name = temp;
                }
                else
                {
                    name = "UNKNOWN";
                }

                // Add at root or beneath its parent
                if (ParentNode == null)
                {
                    node = treeview.Nodes.Add(name);
                }
                else
                {
                    node = ParentNode.Nodes.Add(name);
                }

                node.Tag = CurrentKeyElement;

                // Add the current key's non-key child elements
                CurrentKeyChildElement = ds.GetChildElement(CurrentKeyElement, true);
                while (CurrentKeyChildElement != null)
                {
                    FillKeySubTree(treeview, ds, CurrentKeyChildElement, node, false);
                    CurrentKeyChildElement = ds.GetNextElement(CurrentKeyChildElement, true, true);
                }


                // Recursively add child keys
                if (ds.GetChildKey(CurrentKeyElement) != null)
                {
                    FillTreeKeys(treeview, ds, CurrentKeyElement, node);
                }

                CurrentKeyElement = ds.GetNextKey(CurrentKeyElement, true);
            }
        }
Exemple #15
0
 private bool DicomCopyCallback(DicomElement element, DicomCopyFlags flags)
 {
     //if (element.Tag == DicomTag.PixelData)
     //    return false;
     return true;
 }
Exemple #16
0
            public bool OnElement(DicomElement element)
            {
                var tag = String.Format("{0}{1}  {2}", Indent, element.Tag.ToString().ToUpper(), element.Tag.DictionaryEntry.Name);

                string value = "<large value not displayed>";
                if (element.Length <= 2048)
                    value = String.Join("\\", element.Get<string[]>());

                if (element.ValueRepresentation == DicomVR.UI && element.Count > 0)
                {
                    var uid = element.Get<DicomUID>(0);
                    var name = uid.Name;
                    if (name != "Unknown")
                        value = String.Format("{0} ({1})", value, name);
                }

                Form.appendToInfo(String.Join(
                    " ",
                    tag,
                    element.ValueRepresentation.Code,
                    element.Length.ToString(),
                    value) + "\r\n");
                return true;
            }
Exemple #17
0
        private void WriteDicomAttribute(DicomDataset ds, DicomElement element, XmlWriter writer)
        {
            if (null == element)
            {
                return;
            }

            DicomVr dicomVr = element.Tag.VR;

            writer.WriteStartElement("DiocomAttribute");

            writer.WriteAttributeString("keyword", element.Tag.VariableName);
            writer.WriteAttributeString("tag", element.Tag.Group.ToString("D4") + element.Tag.Element.ToString("D4"));
            writer.WriteAttributeString("vr", element.Tag.VR.Name);

            //VR should at least support a switch!
            if (dicomVr.Name == DicomVr.SQvr.Name)
            {
                ConvertSequence(element, writer);
            }
            else if (dicomVr.Equals(DicomVr.PNvr))
            {
                for (int index = 0; index < element.Count; index++)
                {
                    writer.WriteStartElement("PersonName");
                    WriteNumberAttrib(writer, index);

                    writer.WriteElementString("Alphabetic", element.ToString()); //TODO: check the standard
                    writer.WriteEndElement();
                }
            }
            else if (dicomVr.Equals(DicomVr.OBvr) || dicomVr.Equals(DicomVr.ODvr) ||
                     dicomVr.Equals(DicomVr.OFvr) || dicomVr.Equals(DicomVr.OWvr) ||
                     dicomVr.Equals(DicomVr.UNvr))  //TODO inline bulk
            {
                if (element.Tag.TagValue == DicomTags.PixelData)
                {
                }
                else
                {
                    byte[] data = (byte[])element.Values;
                    writer.WriteBase64(data, 0, data.Length);
                }
            }
            //else if ( dicomVr.Equals (DicomVr.PNvr) ) //TODO bulk reference
            //{

            //}
            else
            {
                ConvertValue(element, writer);
            }

            if (element.Tag.IsPrivate)
            {
                //TODO:
                //writer.WriteAttributeString ("privateCreator", ds[DicomTags.privatecreatro. ) ;
            }

            writer.WriteEndElement();
        }
Exemple #18
0
        private static void DicomElementToXml(StringBuilder xmlOutput, DicomElement item)
        {
            WriteDicomAttribute(xmlOutput, item);

            var vr = item.ValueRepresentation.Code;

            if (vr == DicomVRCode.OB || vr == DicomVRCode.OD || vr == DicomVRCode.OF || vr == DicomVRCode.OW ||
                vr == DicomVRCode.OL || vr == DicomVRCode.UN)
            {
                var binaryString = GetBinaryBase64(item);
                xmlOutput.AppendLine($@"<InlineBinary>{binaryString}</InlineBinary>");
            }
            else if (vr == DicomVRCode.PN)
            {
                for (int i = 0; i < item.Count; i++)
                {
                    xmlOutput.AppendLine($@"<PersonName number=""{i+1}"">");
                    xmlOutput.AppendLine(@"<Alphabetic>");

                    DicomPersonName person = new DicomPersonName(item.Tag, item.Get <string>(i));

                    string lastName = person.Last;
                    if (!string.IsNullOrEmpty(lastName))
                    {
                        xmlOutput.AppendLine($@"<FamilyName>{EscapeXml(lastName)}</FamilyName>");
                    }
                    string givenName = person.First;
                    if (!string.IsNullOrEmpty(givenName))
                    {
                        xmlOutput.AppendLine($@"<GivenName>{EscapeXml(givenName)}</GivenName>");
                    }
                    string middleName = person.Middle;
                    if (!string.IsNullOrEmpty(middleName))
                    {
                        xmlOutput.AppendLine($@"<MiddleName>{EscapeXml(middleName)}</MiddleName>");
                    }
                    string prefixName = person.Prefix;
                    if (!string.IsNullOrEmpty(prefixName))
                    {
                        xmlOutput.AppendLine($@"<NamePrefix>{EscapeXml(prefixName)}</NamePrefix>");
                    }
                    string suffixName = person.Suffix;
                    if (!string.IsNullOrEmpty(suffixName))
                    {
                        xmlOutput.AppendLine($@"<NameSuffix>{EscapeXml(suffixName)}</NameSuffix>");
                    }

                    xmlOutput.AppendLine(@"</Alphabetic>");
                    xmlOutput.AppendLine(@"</PersonName>");
                }
            }
            else
            {
                for (int i = 0; i < item.Count; i++)
                {
                    var valueString = EscapeXml(item.Get <string>(i));
                    xmlOutput.AppendLine($@"<Value number=""{i+1}"">{valueString}</Value>");
                }
            }

            xmlOutput.AppendLine(@"</DicomAttribute>");
        }
Exemple #19
0
 /// <summary>
 /// Use reflection to get strongly-typed constructor info from <paramref name="element"/>.
 /// </summary>
 /// <param name="element">DICOM element for which constructor info should be obtained.</param>
 /// <param name="parameterTypes">Expected parameter types in the requested constructor.</param>
 /// <returns>Constructor info corresponding to <paramref name="element"/> and <paramref name="parameterTypes"/>.</returns>
 private static ConstructorInfo GetConstructor(DicomElement element, params Type[] parameterTypes)
 {
     return(element.GetType().GetConstructor(parameterTypes));
 }
 public Task<bool> OnElementAsync(DicomElement element)
 {
     return Task.FromResult(this.OnElement(element));
 }
Exemple #21
0
        private void CheckFileMetaInfo(DicomDataSet ds)
        {
            DicomElement Temp;
            string       szValue;

            // File Meta Information Version
            DicomElement Element = ds.FindFirstElement(null, DemoDicomTags.FileMetaInformationVersion, false);

            if (Element == null)
            {
                Element = ds.InsertElement(null, false, DemoDicomTags.FileMetaInformationVersion, DicomVRType.UN, false, 0);
            }
            if (Element != null)
            {
                byte[] Values = new byte[2];
                Values[0] = 0x00;
                Values[1] = 0x01;

                ds.SetByteValue(Element, Values, 2);
            }

            // Media Storage SOP Class UID
            Element = ds.FindFirstElement(null, DemoDicomTags.MediaStorageSOPClassUID, false);
            if (Element == null)
            {
                Element = ds.InsertElement(null, false, DemoDicomTags.MediaStorageSOPClassUID, DicomVRType.UN, false, 0);
            }
            if (Element != null)
            {
                Temp = ds.FindFirstElement(null, DemoDicomTags.SOPClassUID, false);
                if (Temp != null)
                {
                    szValue = ds.GetStringValue(Temp, 0);
                    if (szValue != string.Empty)
                    {
                        ds.SetStringValue(Element, szValue, DicomCharacterSetType.Default);
                    }
                }
            }

            // Media Storage SOP Instance UID
            Element = ds.FindFirstElement(null, DemoDicomTags.MediaStorageSOPInstanceUID, false);
            if (Element == null)
            {
                Element = ds.InsertElement(null, false, DemoDicomTags.MediaStorageSOPInstanceUID, DicomVRType.UN, false, 0);
            }
            if (Element != null)
            {
                Temp = ds.FindFirstElement(null, DemoDicomTags.SOPInstanceUID, false);
                if (Temp != null)
                {
                    szValue = ds.GetStringValue(Temp, 0);
                    if (szValue != string.Empty)
                    {
                        ds.SetStringValue(Element, szValue, DicomCharacterSetType.Default);
                    }
                }
            }

            // Implementation Class UID
            Element = ds.FindFirstElement(null, DemoDicomTags.ImplementationClassUID, false);
            if (Element == null)
            {
                Element = ds.InsertElement(null, false, DemoDicomTags.ImplementationClassUID, DicomVRType.UN, false, 0);
            }
            if (Element != null)
            {
                ds.SetStringValue(Element, LEAD_IMPLEMENTATION_CLASS_UID, DicomCharacterSetType.Default);
            }

            // Implementation Version Name
            Element = ds.FindFirstElement(null, DemoDicomTags.ImplementationVersionName, false);
            if (Element == null)
            {
                Element = ds.InsertElement(null, false, DemoDicomTags.ImplementationVersionName, DicomVRType.UN, false, 0);
            }
            if (Element != null)
            {
                ds.SetStringValue(Element, LEAD_IMPLEMENTATION_VERSION_NAME, DicomCharacterSetType.Default);
            }
        }