Exemplo n.º 1
0
        public SeriesMINTXml(
            StudyLoaderArgs studyLoaderArgs,
            string metaUri,
            XmlElement seriesElem,
            DicomAttributeCollection studyAttributes)
        {
            _seriesAttributes =
                MINTAttributeCollectionParser.ParseAttributes(studyLoaderArgs, metaUri, seriesElem,
                                                              "attributes").Attributes;
            var normalizedInstanceAttributes =
                MINTAttributeCollectionParser.ParseAttributes(studyLoaderArgs, metaUri, seriesElem,
                                                              "normalizedInstanceAttributes").Attributes;

            foreach (var subNode in seriesElem)
            {
                var subElem = subNode as XmlElement;
                if ((subElem != null) && subElem.Name.Equals("instances"))
                {
                    foreach (var instanceNode in subElem)
                    {
                        var instanceElem = instanceNode as XmlElement;
                        if ((instanceElem != null) && instanceElem.Name.Equals("instance"))
                        {
                            _instances.Add(new InstanceMINTXml(studyLoaderArgs, metaUri, instanceElem, studyAttributes,
                                                               _seriesAttributes, normalizedInstanceAttributes));
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public InstanceMINTXml(
            StudyLoaderArgs studyLoaderArgs,
            string metaUri,
            XmlElement instanceElem,
            DicomAttributeCollection studyAttributes,
            DicomAttributeCollection seriesAttributes,
            DicomAttributeCollection normalizedInstanceAttributes)
        {
            var trfAttr = instanceElem.Attributes["transferSyntaxUID"];

            _transferSyntax = (trfAttr != null)
                ? TransferSyntax.GetTransferSyntax(trfAttr.Value)
                : TransferSyntax.ExplicitVrLittleEndian;

            var result = MINTAttributeCollectionParser.ParseAttributes(studyLoaderArgs, metaUri,
                                                                       instanceElem, "attributes");

            _collection = result.Attributes;

            if (result.PixelDataBid != null)
            {
                var uriString = string.Format("{0}/{1}",
                                              metaUri.Replace("metadata", "binaryitems"), result.PixelDataBid);
                _pixelDataUri = new Uri(uriString);
            }
            else
            {
                Platform.Log(LogLevel.Error, "No pixel data item found for instance {0}!",
                             _collection[DicomTags.SopInstanceUid].GetString(0, ""));
            }

            Merge(_collection, normalizedInstanceAttributes);
            Merge(_collection, seriesAttributes);
            Merge(_collection, studyAttributes);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Populate this <see cref="StudyXml"/> object based on the supplied XML document.
        /// </summary>
        /// <param name="theDocument"></param>
        public void SetMemento(string metaUri, XmlDocument theDocument)
        {
            if (!theDocument.HasChildNodes)
            {
                throw new LoadStudyException(_studyLoaderArgs.StudyInstanceUid, "Empty Study XML document");
            }

            // There should be one root node.
            var rootNode = theDocument.DocumentElement;

            if (!rootNode.Name.Equals(MINTApi.RootTag))
            {
                throw new LoadStudyException(_studyLoaderArgs.StudyInstanceUid, "Document root element name must be '" + MINTApi.RootTag + "'");
            }
            _studyAttributes = MINTAttributeCollectionParser.ParseAttributes(_studyLoaderArgs, metaUri,
                                                                             (XmlElement)rootNode, "attributes").Attributes;
            foreach (var node in rootNode)
            {
                var elem = node as XmlElement;
                if (elem == null)
                {
                    continue;
                }
                // Just search for the first study node, parse it, then break
                if (elem.Name.Equals("seriesList"))
                {
                    if (_studyAttributes == null)
                    {
                        throw new LoadStudyException(_studyLoaderArgs.StudyInstanceUid,
                                                     "Malformed Study XML document: 'seriesList' found before 'attributes'");
                    }

                    foreach (var subNode in elem)
                    {
                        var seriesElem = subNode as XmlElement;
                        if (seriesElem != null)
                        {
                            var series = new SeriesMINTXml(_studyLoaderArgs, metaUri, seriesElem, _studyAttributes);
                            _seriesList[series[DicomTags.SeriesInstanceUid].GetString(0, "")] = series.Instances;
                        }
                    }
                }
            }
        }