Exemple #1
0
        // -------------------------------
        // - Begin public methods region -
        // -------------------------------

        /// <summary>
        /// Convert a HLI Attribute Set to a AttributeLayer Attribute Set.
        /// </summary>
        /// <param name="attributeSetIn">The HLI Attribute Set.</param>
        /// <param name="attributeSetOut">The AttributeLayer Attribute Set.</param>
        public static void ToAttributeSet(DvtkHighLevelInterface.Dicom.Other.AttributeSet attributeSetIn, Dvtk.Dicom.AttributeLayer.AttributeSet attributeSetOut)
        {
            for (int index = 0; index < attributeSetIn.Count; index++)
            {
                DvtkHighLevelInterface.Dicom.Other.Attribute hliAttribute = attributeSetIn[index];

                Tag tag = new Tag(hliAttribute.GroupNumber, hliAttribute.ElementNumber);

                if (hliAttribute.VR != DvtkData.Dimse.VR.SQ)
                {
                    SingleAttribute singleAttribute = new SingleAttribute(tag, (VR)Enum.Parse(typeof(VR), hliAttribute.VR.ToString(), true), attributeSetOut);
                }
                else
                {
                    SequenceAttribute sequenceAttribute = new SequenceAttribute(tag, attributeSetOut);

                    for (int sequenceItemIndex = 1; sequenceItemIndex <= hliAttribute.ItemCount; sequenceItemIndex++)
                    {
                        DvtkHighLevelInterface.Dicom.Other.SequenceItem hliSequenceItem = hliAttribute.GetItem(sequenceItemIndex);

                        SequenceItem sequenceItem = new SequenceItem(sequenceAttribute);

                        ToAttributeSet(hliSequenceItem, sequenceItem);
                    }
                }
            }
        }
Exemple #2
0
        private void HandleDoWork(object sender, DoWorkEventArgs e)
        {
            // Report Progress
            ReportProgress(0, "Start");


            ValidatorBackgroundWorkerArgument argument = (ValidatorBackgroundWorkerArgument)e.Argument;


            //
            // Initialization of the media session and context groups.
            //

            if (this.mediaSession == null)
            {
                InitializeMediaSession();
            }

            if (this.contextGroups == null)
            {
                InitializeContextGroups();
            }


            //
            // Read DICOM file and check if this is a Structured Report file.
            //

            // Report Progress
            ReportProgress(0, "Reading DICOM file: " + argument.structuredReportPath);

            DicomFile dicomFile = new DicomFile();

            dicomFile.Read(argument.structuredReportPath);

            // Perform sanity check if this is a valid Structured Report.
            bool valueTypeRootContentItemCorrect = false;

            DvtkHighLevelInterface.Dicom.Other.Attribute valueType = dicomFile.DataSet["0x0040A040"];
            if (valueType.Exists)
            {
                if (valueType.Values[0].Trim() == "CONTAINER")
                {
                    valueTypeRootContentItemCorrect = true;
                }
            }


            //
            // Validate against the loaded Context Groups and loaded definition files.
            //

            if (valueTypeRootContentItemCorrect)
            {
                // Report Progress.
                ReportProgress(40, "Parsing DICOM Structured Report: " + argument.structuredReportPath);

                // Parse the DICOM Structured Report.
                StructuredReport structuredReport = new StructuredReport(dicomFile.DataSet);

                // Report Progress.
                ReportProgress(60, "Validating content item values...");

                // Validate Content Items Value.
                ContentItemValueValidationRule contentItemValueValidationRule = new ContentItemValueValidationRule(contextGroups);
                structuredReport.RootContentItem.Accept(contentItemValueValidationRule);

                // Report Progress.
                ReportProgress(85, "Saving results: " + e.Argument.ToString());

                // Export structured report results to Xml file.
                String xmlFullFileName = Path.Combine(argument.xmlPath, "Output.xml");
                structuredReport.ToXml(xmlFullFileName);

                // Perform part 3 validation.
                this.mediaSession.ResultsRootDirectory = argument.xmlPath;
                this.mediaSession.StartResultsGathering("Part 3 validation.xml");
                //this.mediaSession.Validate(dicomFile.DvtkDataDicomFile, Dvtk.Sessions.ValidationControlFlags.None);
                this.mediaSession.ValidateMediaFiles(new string[] { argument.structuredReportPath });
                this.mediaSession.EndResultsGathering();

                // Report Progress.
                ReportProgress(100, "");
            }
            else
            {
                // Report Progress.
                ReportProgress(100, "");

                throw new Exception("Aborting validation because DICOM file does not contain Attribute Value Type (0040,A040) with value \"CONTAINER\" for root Content Item.");
            }
        }