Example #1
0
        internal void AddAttributeCollectionsInformationUsingDynamicCompare(AttributeCollections attributeCollections, CompareRules compareRules)
        {
            //
            // Iterate through all attributes of all AttributeSets.
            //


            GeneratorDynamicCompare generatorDynamicCompare = new GeneratorDynamicCompare(attributeCollections, compareRules);

            AttributeList attributeList = null;

            while ((attributeList = generatorDynamicCompare.GetNextAttributes()) != null)
            {
                AddAttributesInformation(attributeList);

                if (this.addEmptyRowAfterEachDynamicComparedList)
                {
                    NewRow();

                    for (int columnIndex = 0; columnIndex < this.numberOfColumns; columnIndex++)
                    {
                        SetCellOK(columnIndex + 1, ".");
                    }
                }
            }
        }
Example #2
0
        internal int DetermineColumnIndices(AttributeCollections attributeCollections)
        {
            int columnIndex = 1;

            if (this.displayCommonTag)
            {
                this.columnIndexCommonTag = columnIndex;
                columnIndex++;
            }

            if (this.displayCommonName)
            {
                this.columnIndexCommonName = columnIndex;
                columnIndex++;
            }

            for (int index = 0; index < attributeCollections.Count; index++)
            {
                if (this.displayAttributeTag)
                {
                    this.columnIndexAttributeTag.Add(columnIndex);
                    columnIndex++;
                }

                if (this.displayAttributeName && (attributeCollections[index] is DicomAttributeCollection))
                {
                    this.columnIndexAttributeName.Add(columnIndex);
                    columnIndex++;
                }

                if (this.displayAttributePresent)
                {
                    this.columnIndexAttributePresent.Add(columnIndex);
                    columnIndex++;
                }

                if (this.displayAttributeVR && (attributeCollections[index] is DicomAttributeCollection))
                {
                    this.columnIndexAttributeVR.Add(columnIndex);
                    columnIndex++;
                }

                if (this.displayAttributeValues)
                {
                    this.columnIndexAttributeValues.Add(columnIndex);
                    columnIndex++;
                }
            }

            if (this.displayComments)
            {
                this.columnIndexComments = columnIndex;
                columnIndex++;
            }

            this.numberOfColumns = columnIndex - 1;

            return(columnIndex - 1);
        }
Example #3
0
        internal AttributeCollections Clone()
        {
            AttributeCollections clonedAttributeCollections = new AttributeCollections();

            clonedAttributeCollections.attributeCollections = this.attributeCollections.Clone() as ArrayList;

            return(clonedAttributeCollections);
        }
Example #4
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="attributeCollections">The attribute sets to compare.</param>
        public GeneratorStaticDicomCompare(AttributeCollections attributeCollections)
        {
            this.attributeCollections = attributeCollections;

            for (int index = 0; index < attributeCollections.Count; index++)
            {
                this.currentAttributeIndices.Add(0);
            }
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="attributeCollections">The attribute sets to compare.</param>
        public GeneratorStaticDicomCompare(AttributeCollections attributeCollections)
        {
            this.attributeCollections = attributeCollections;

            for (int index = 0; index < attributeCollections.Count; index++)
            {
                this.currentAttributeIndices.Add(0);
            }
        }
Example #6
0
        //
        // - Properties -
        //



        //
        // - Methods -
        //



        /// <summary>
        /// Do a static compare for the attribute sets supplied.
        ///
        /// Note that the parameters attributeSets, attributeSetDescriptions and compareFlagsForAttributeSets
        /// must have the same size and must be at least size 2.
        /// </summary>
        /// <param name="tableDescription">Description of the table.</param>
        /// <param name="attributeCollections">The attribute sets to compare with each other.</param>
        /// <param name="attributeCollectionDescriptions">The descriptions of the attribute sets.</param>
        /// <param name="flags">
        /// The compare flags that may be supplied. The following combination of flags may be supplied (using bitwise Or):
        /// - CompareFlags.None: when only supplying this flag, the attributes are only displayed and no compare is performed.
        /// - CompareFlags.Compare_present: a check is performed if all attributes with the same tag are present.
        /// - CompareFlags.Compare_values: a check is performed if all attributes with the same tag have the same values.
        /// - CompareFlags.Compare_VR: a check is performed if all attributes with the same tag have the same VR.
        /// </param>
        /// <returns>The results of the static compare presented as a table (that may be converted to HTML).</returns>
        public CompareResults CompareAttributeSets(String tableDescription, AttributeCollections attributeCollections, StringCollection attributeCollectionDescriptions, FlagsDicomAttribute flags)
        {
            CompareResults compareResults = null;

            for (int index = 0; index < attributeCollections.Count; index++)
            {
                (attributeCollections[index] as DicomAttributeCollection).Flags |= FlagsConvertor.ConvertToFlagsBase(flags);
            }

            compareResults = CompareAttributeSets(tableDescription, attributeCollections, attributeCollectionDescriptions);

            return(compareResults);
        }
Example #7
0
        //
        // - Properties -
        //
        //
        // - Methods -
        //
        /// <summary>
        /// Do a static compare for the attribute sets supplied.
        /// 
        /// Note that the parameters attributeSets, attributeSetDescriptions and compareFlagsForAttributeSets
        /// must have the same size and must be at least size 2.
        /// </summary>
        /// <param name="tableDescription">Description of the table.</param>
        /// <param name="attributeCollections">The attribute sets to compare with each other.</param>
        /// <param name="attributeCollectionDescriptions">The descriptions of the attribute sets.</param>
        /// <param name="flags">
        /// The compare flags that may be supplied. The following combination of flags may be supplied (using bitwise Or):
        /// - CompareFlags.None: when only supplying this flag, the attributes are only displayed and no compare is performed.
        /// - CompareFlags.Compare_present: a check is performed if all attributes with the same tag are present.
        /// - CompareFlags.Compare_values: a check is performed if all attributes with the same tag have the same values.
        /// - CompareFlags.Compare_VR: a check is performed if all attributes with the same tag have the same VR.
        /// </param>
        /// <returns>The results of the static compare presented as a table (that may be converted to HTML).</returns>
        public CompareResults CompareAttributeSets(String tableDescription, AttributeCollections attributeCollections, StringCollection attributeCollectionDescriptions, FlagsDicomAttribute flags)
        {
            CompareResults compareResults = null;

            for (int index = 0; index < attributeCollections.Count; index++)
            {
                (attributeCollections[index] as DicomAttributeCollection).Flags |= FlagsConvertor.ConvertToFlagsBase(flags);
            }

            compareResults = CompareAttributeSets(tableDescription, attributeCollections, attributeCollectionDescriptions);

            return(compareResults);
        }
Example #8
0
        /// <summary>
        /// Compare the supplied attribute sets.
        /// </summary>
        /// <param name="tableDescription">The table description.</param>
        /// <param name="attributeCollections">The attribute collections.</param>
        /// <param name="attributeCollectionDescriptions">The description of the attribute collections.</param>
        /// <returns></returns>
        public CompareResults CompareAttributeSets(String tableDescription, AttributeCollections attributeCollections, StringCollection attributeCollectionDescriptions)
        {
            //
            // Sanity check.
            //

            if (attributeCollections.Count < 2)
            {
                throw new System.Exception("Parameter attributeSets supplied to the method StaticCompare.CompareAttributeSets has size smaller than 2.");
            }

            if (attributeCollections.Count != attributeCollectionDescriptions.Count)
            {
                throw new System.Exception("Parameters attributeSets and attributeSetDescriptions supplied to the method StaticCompare.CompareAttributeSets have different size.");
            }


            //
            // Do the actual compare.
            //

            this.compareResults = null;

            // Determine the index of the different columns in the table.
            int numberOfColumns = DetermineColumnIndices(attributeCollections);

            // To be able to compare correctly, we first make sure the attributes in all attributesets are ascending.
            attributeCollections.DicomMakeAscending();

            // Determine the table headers and comlumn widths.
            this.compareResults = CreateCompareResults(numberOfColumns, attributeCollections, tableDescription, attributeCollectionDescriptions);

            ArrayList dicomAttributeFlagsForAttributeSets = new ArrayList();
            ArrayList displayAttributeSets = new ArrayList();

            // Do the actual comparison.
            AddAttributeCollectionsInformationUsingStaticDicomCompare(attributeCollections);

            if (this.differenceFound)
            {
                this.compareResults.DifferencesCount++;
                this.differenceFound = false;
            }

            return(this.compareResults);
        }
Example #9
0
        internal void AddAttributeCollectionsInformationUsingDynamicCompare(AttributeCollections attributeCollections, CompareRules compareRules)
        {
            //
            // Iterate through all attributes of all AttributeSets.
            //

            GeneratorDynamicCompare generatorDynamicCompare = new GeneratorDynamicCompare(attributeCollections, compareRules);

            AttributeList attributeList = null;

            while ((attributeList = generatorDynamicCompare.GetNextAttributes()) != null)
            {
                AddAttributesInformation(attributeList);

                if (this.addEmptyRowAfterEachDynamicComparedList)
                {
                    NewRow();

                    for (int columnIndex = 0; columnIndex < this.numberOfColumns; columnIndex++)
                    {
                        SetCellOK(columnIndex + 1, ".");
                    }
                }
            }
        }
Example #10
0
        protected override void Execute()
        {
            try
            {
                WriteHtmlInformation("<br />");
                WriteInformation(string.Format("Reading reference media file from {0}",DCMCompareForm.firstDCMFile));
                WriteHtmlInformation("<br />");

                // Read the DCM File
                DicomFile dcmFile = new DicomFile();

                DataSet refDataset = new DataSet();

                if ((DCMCompareForm.firstDCMFile.ToLower().IndexOf("dicomdir")) != -1)
                {
                    // Read the DICOMDIR dataset
                    refDataset.DvtkDataDataSet = Dvtk.DvtkDataHelper.ReadDataSetFromFile(DCMCompareForm.firstDCMFile);
                }
                else
                {
                    dcmFile.Read(DCMCompareForm.firstDCMFile, this);
                    refDataset = dcmFile.DataSet;
                }

                refDataset.UnVrDefinitionLookUpWhenReading = false;

                FileMetaInformation refFMI = dcmFile.FileMetaInformation;

                WriteInformation(string.Format("Reading source media file from {0}",DCMCompareForm.secondDCMFile));
                WriteHtmlInformation("<br />");

                DataSet srcDataset = new DataSet();

                if ((DCMCompareForm.secondDCMFile.ToLower().IndexOf("dicomdir")) != -1)
                {
                    // Read the DICOMDIR dataset
                    srcDataset.DvtkDataDataSet = Dvtk.DvtkDataHelper.ReadDataSetFromFile(DCMCompareForm.secondDCMFile);
                }
                else
                {
                    dcmFile.Read(DCMCompareForm.secondDCMFile, this);
                    srcDataset = dcmFile.DataSet;
                }

                srcDataset.UnVrDefinitionLookUpWhenReading = false;

                FileMetaInformation srcFMI = dcmFile.FileMetaInformation;

                // Now get the list of filtered attribute
                if(DCMCompareForm.attributesTagList.Count != 0)
                {
                    foreach(string filterAttr in DCMCompareForm.attributesTagList)
                    {
                        try
                        {
                            if(srcDataset.Exists(filterAttr))
                            {
                                srcDataset.Delete(filterAttr);
                            }
                            if(refDataset.Exists(filterAttr))
                            {
                                refDataset.Delete(filterAttr);
                            }
                        }
                        catch(Exception exception)
                        {
                            MessageBox.Show(exception.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    DCMCompareForm.attributesTagList.Clear();
                }

                WriteInformation(string.Format("Comparing the Media files - {0} and {1}",DCMCompareForm.firstDCMFile,DCMCompareForm.secondDCMFile));
                WriteHtmlInformation("<br />");

                StaticDicomCompare staticDicomCompare = new StaticDicomCompare();

                //Determine the VR display based on Transfer syntax
                string srcTransferSyntax = "";
                string refTransferSyntax = "";

                if((srcFMI != null) && srcFMI.Exists("0x00020010"))
                {
                    // Get the Transfer syntax
                    DvtkHighLevelInterface.Dicom.Other.Attribute tranferSyntaxAttr = srcFMI["0x00020010"];
                    srcTransferSyntax = tranferSyntaxAttr.Values[0];
                }
                else
                {
                    WriteHtmlInformation(string.Format("Couldn't retrieve the Transfer syntax from DCM File {0}",DCMCompareForm.secondDCMFile));
                    WriteHtmlInformation("<br />");
                }

                if((refFMI != null) && refFMI.Exists("0x00020010"))
                {
                    // Get the Transfer syntax
                    DvtkHighLevelInterface.Dicom.Other.Attribute tranferSyntaxAttr = refFMI["0x00020010"];
                    refTransferSyntax = tranferSyntaxAttr.Values[0];
                }
                else
                {
                    WriteHtmlInformation(string.Format("Couldn't retrieve the Transfer syntax from DCM File {0}",DCMCompareForm.firstDCMFile));
                    WriteHtmlInformation("<br />");
                }

                FlagsDicomAttribute flags = FlagsDicomAttribute.Compare_values | FlagsDicomAttribute.Compare_present | FlagsDicomAttribute.Include_sequence_items;
                if(( srcTransferSyntax == "1.2.840.10008.1.2") ||
                    ( refTransferSyntax == "1.2.840.10008.1.2"))
                {
                    staticDicomCompare.DisplayAttributeVR = false;
                }
                else
                {
                    flags |= FlagsDicomAttribute.Compare_VR;
                }

                //Check for group length attributes option
                if(DCMCompareForm.filterGroupLengthAttributes)
                {
                    /*for( int i=0; i < srcDataset.Count; i++ )
                    {
                        HLI.Attribute attribute   = srcDataset[i];
                        if(attribute.ElementNumber == 0x0000)
                            srcDataset.Delete(DCMCompareForm.TagString(attribute.GroupNumber,attribute.ElementNumber));
                    }

                    for( int i=0; i < refDataset.Count; i++ )
                    {
                        HLI.Attribute attribute   = refDataset[i];
                        if(attribute.ElementNumber == 0x0000)
                            refDataset.Delete(DCMCompareForm.TagString(attribute.GroupNumber,attribute.ElementNumber));
                    }*/
                    staticDicomCompare.DisplayGroupLength = false;
                }

                int differences = 0;

                if((refFMI != null) && (srcFMI != null))
                {
                    AttributeCollections fmis = new AttributeCollections();
                    fmis.Add(refFMI);
                    fmis.Add(srcFMI);

                    StringCollection fmiDescriptions = new StringCollection();
                    fmiDescriptions.Add("Ref FMI");
                    fmiDescriptions.Add("Src FMI");

                    HLIStaticCompare.CompareResults fmiCompareResults = staticDicomCompare.CompareAttributeSets("FMI compare results", fmis, fmiDescriptions, flags);
                    WriteHtmlInformation(fmiCompareResults.Table.ConvertToHtml());

                    differences += fmiCompareResults.DifferencesCount;
                    NrOfValidationErrors+= (uint)fmiCompareResults.DifferencesCount;
                }

                AttributeCollections datasets = new AttributeCollections();
                datasets.Add(refDataset);
                datasets.Add(srcDataset);

                StringCollection dsDescriptions = new StringCollection();
                dsDescriptions.Add("Ref Dataset");
                dsDescriptions.Add("Src Dataset");

                HLIStaticCompare.CompareResults dsCompareResults = staticDicomCompare.CompareAttributeSets("DataSet compare results", datasets, dsDescriptions, flags);

                WriteHtmlInformation(dsCompareResults.Table.ConvertToHtml());

                differences += dsCompareResults.DifferencesCount;

                WriteHtmlInformation("<b>");
                WriteInformation("Differences found: " + differences.ToString());
                WriteHtmlInformation("</b><br />");

                NrOfValidationErrors+= (uint)dsCompareResults.DifferencesCount;
            }
            catch(Exception exception)
            {
                MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Example #11
0
        //
        // - Constructors -
        //

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="compareRules">All the CcompareRules that will be applied to the attributeCollections.</param>
        /// <param name="attributeCollections">All the AttributeCollections on which the CcompareRules will be applied.</param>
        ///


        public GeneratorDynamicCompare(AttributeCollections attributeCollections, CompareRules compareRules)
        {
            this.compareRules         = compareRules;
            this.attributeCollections = attributeCollections;
        }
 public void TearDown()
 {
     this.attributeCollections = null;
 }
Example #13
0
 public void TearDown()
 {
     this.attributeCollections = null;
 }
Example #14
0
        internal int DetermineColumnIndices(AttributeCollections attributeCollections)
        {
            int columnIndex = 1;

            if (this.displayCommonTag)
            {
                this.columnIndexCommonTag = columnIndex;
                columnIndex++;
            }

            if (this.displayCommonName)
            {
                this.columnIndexCommonName = columnIndex;
                columnIndex++;
            }

            for (int index = 0; index < attributeCollections.Count; index++)
            {
                if (this.displayAttributeTag)
                {
                    this.columnIndexAttributeTag.Add(columnIndex);
                    columnIndex++;
                }

                if (this.displayAttributeName && (attributeCollections[index] is DicomAttributeCollection))
                {
                    this.columnIndexAttributeName.Add(columnIndex);
                    columnIndex++;
                }

                if (this.displayAttributePresent)
                {
                    this.columnIndexAttributePresent.Add(columnIndex);
                    columnIndex++;
                }

                if (this.displayAttributeVR && (attributeCollections[index] is DicomAttributeCollection))
                {
                    this.columnIndexAttributeVR.Add(columnIndex);
                    columnIndex++;
                }

                if (this.displayAttributeValues)
                {
                    this.columnIndexAttributeValues.Add(columnIndex);
                    columnIndex++;
                }
            }

            if (this.displayComments)
            {
                this.columnIndexComments = columnIndex;
                columnIndex++;
            }

            this.numberOfColumns = columnIndex - 1;

            return(columnIndex - 1);
        }
Example #15
0
        private void RetrievingFilesFromDirectory()
        {
            try
            {
                String indexFileName = initialDirectory + @"/index1.htm";
                StringBuilder indexContent = new StringBuilder();
                indexContent.Append("<center><font size='5' color='#0000ff'>");
                if(utility.AnonymizationType)
                {
                    indexContent.Append("Anonymized DCM files (Basic)</font></center>");
                }
                else
                {
                    indexContent.Append("Anonymized DCM files (Complete)</font></center>");
                }

                indexContent.Append("<left><font color='black' size = '4'><br></br> Input Directory: " + inputDirectory);
                indexContent.Append("</font>");
                indexContent.Append("</left>");
                indexContent.Append("<br></br>");
                indexContent.Append("<font size='3'>");

                HLI.DataSet srcDataset = null;
                DicomFile dcmFile = null;

                allDCMFilesTemp = new ArrayList();
                FileInfo mediaInputFileInfo = null;
                string mediaFileDir = inputDirectory;
                DirectoryInfo theDirectoryInfo = new DirectoryInfo(mediaFileDir);
                allDCMFilesTemp = utility.GetFilesRecursively(theDirectoryInfo);
                foreach ( string fileName in allDCMFilesTemp)
                {
                    mediaInputFileInfo = new FileInfo(fileName);

                    counter++;

                    dcmFile = new DicomFile();
                    dcmFile.Read(fileName, mainThread);

                    // Get the Data set from the selected DCM file
                    srcDataset = dcmFile.DataSet;

                    indexContent.Append("<li><a href='" + mediaInputFileInfo.Name + "_" + counter.ToString() +".html'>" + fileName.Substring(inputDirectory.Length) + "</a></li>");

                    HLI.DataSet annonymizedDataset = srcDataset.Clone();

                    utility.PatientAttributes(annonymizedDataset);
                    for ( int number = 0; number < annonymizedDataset.Count; number++)
                    {
                        HLI.Attribute attribute =  annonymizedDataset[number];
                        if (attribute.VR == VR.SQ)
                        {
                            utility.SequenceAttribute_recursive(attribute);
                        }
                        else
                        {
                            utility.CacheAndRepairIdentifyingAttribute(attribute);
                            utility.UpdateAnonymizedAttributes(attribute);
                        }
                    }

                    //Save annonymized data to selected directory
                    string savedFileName = "";
                    if(mediaInputFileInfo.Extension != "")
                    {
                        string srcFileNameWithoutExtn = mediaInputFileInfo.Name.Substring(0,(mediaInputFileInfo.Name.Length-4));
                        savedFileName = outputDirectory + "\\" + srcFileNameWithoutExtn + "_an";
                    }
                    else
                        savedFileName = outputDirectory + "\\" + mediaInputFileInfo.Name + "_an";

                    dcmFile.DataSet = annonymizedDataset;
                    dcmFile.Write(savedFileName);

                    datasets = new AttributeCollections();
                    datasets.Add(srcDataset);
                    datasets.Add(annonymizedDataset);

                    //Cleanup temp file
                    utility.cleanup();

                    resultFileName = mediaInputFileInfo.Name;

                    CreateTableWithoutNav();
                }

                StreamWriter writer = new StreamWriter(indexFileName);
                indexContent.Append("</font>");
                indexContent.Append("<left><font color='black' size = '4'><br></br> Output Directory: " + outputDirectory);

                indexContent.Append("</font>");
                indexContent.Append("</left>");
                writer.Write(indexContent.ToString());
                writer.Close();

                dvtkWebBrowser.Navigate(indexFileName);
            }
            catch ( Exception e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #16
0
        //
        // - Methods -
        //
        /// <summary>
        /// Do a dynamic compare for the attribute sets supplied.
        /// 
        /// Note that the parameters attributeSets, attributeSetDescriptions and each compareRule instance in
        /// the parameter compareRules must have the same size and have a size at least 2.
        /// </summary>
        /// <param name="tableDescription">Description of the table.</param>
        /// <param name="attributeCollections">The attribute sets to compare with each other.</param>
        /// <param name="attributeCollectionDescriptions">The descriptions of the attribute sets.</param>
        /// <param name="compareRules">
        /// Specifies which attributes with what tags should be compared with each other.
        /// Also specifies how the attributes should be compared with each other.
        /// </param>
        /// <returns>The results of the dynamic compare presented as a table (that may be converted to HTML).</returns>
        public CompareResults CompareAttributeCollections(String tableDescription, AttributeCollections attributeCollections, StringCollection attributeCollectionDescriptions, CompareRules compareRules)
        {
            //
            // Sanity check.
            //

            if (attributeCollections.Count < 2)
            {
                throw new System.Exception("Parameter attributeSets supplied to the method StaticCompare.CompareAttributeSets has size smaller than 2.");
            }

            if (attributeCollections.Count != attributeCollectionDescriptions.Count)
            {
                throw new System.Exception("Parameters attributeSets and attributeSetDescriptions supplied to the method StaticCompare.CompareAttributeSets have different size.");
            }

            for (int index = 0; index < compareRules.Count; index++)
            {
                CompareRule compareRule = compareRules[index];

                if (attributeCollections.Count != compareRule.Count)
                {
                    throw new System.Exception("Method StaticCompare.CompareAttributeSets: each CompareRule instance present in the parameter compareRules must have the same size as the parameter attributeCollections.");
                }
            }

            // Todo change taking the possibility of null into account for the attribute collections.

            //
            // Remove the attribute collections that are null and adjust the compare rules.
            //

            for (int index = attributeCollections.Count - 1; index >= 0; index--)
            {
                AttributeCollectionBase attributeCollection = attributeCollections[index];

                if (attributeCollection == null)
                {
                    // Clone the collections because we don't want to change the supplied collections.
                    attributeCollections = attributeCollections.Clone();
                    attributeCollections.RemoveAt(index);

                    StringCollection newAttributeCollectionDescriptions = new StringCollection();
                    foreach(String description in attributeCollectionDescriptions)
                    {
                        newAttributeCollectionDescriptions.Add(description);
                    }
                    attributeCollectionDescriptions = newAttributeCollectionDescriptions;
                    attributeCollectionDescriptions.RemoveAt(index);

            #pragma warning disable 0618
                    CompareRules newCompareRules = new CompareRules();
            #pragma warning restore 0618

                    for (int compareRuleIndex = 0; compareRuleIndex < compareRules.Count; compareRuleIndex++)
                    {
                        CompareRule compareRule = compareRules[compareRuleIndex].Clone();
                        compareRule.RemoveAt(index);
                        newCompareRules.Add(compareRule);
                    }

                    compareRules = newCompareRules;
                }
            }

            //
            // Do the actual compare.
            //

            this.compareResults = null;

            // Determine the index of the different columns in the table.
            int numberOfColumns = DetermineColumnIndices(attributeCollections);

            // To be able to compare correctly, we first make sure the attributes in all DicomAttributeCollections are ascending.
            attributeCollections.DicomMakeAscending();

            // Determine the table headers and comlumn widths.
            this.compareResults = CreateCompareResults(numberOfColumns, attributeCollections, tableDescription, attributeCollectionDescriptions);

            // Do the actual comparison.
            AddAttributeCollectionsInformationUsingDynamicCompare(attributeCollections, compareRules);

            if (this.differenceFound)
            {
                this.compareResults.DifferencesCount++;
                this.differenceFound = false;
            }

            return(this.compareResults);
        }
Example #17
0
        internal CompareResults CreateCompareResults(int numberOfColumns, AttributeCollections attributeCollections, String tableDescription, StringCollection attributeSetDescriptions)
        {
            CompareResults compareResults = new CompareResults(numberOfColumns);

            compareResults.Table.CellItemSeperator = "<br>";
            compareResults.Table.EmptyCellPrefix   = BACKGROUND_GREY;

            int index = 0;

            String[] header1      = new String[numberOfColumns];
            String[] header2      = new String[numberOfColumns];
            String[] header3      = new String[numberOfColumns];
            int[]    columnWidths = new int[numberOfColumns];

            if (this.displayCommonTag)
            {
                header1[index]      = tableDescription;
                header2[index]      = "Common info";
                header3[index]      = TAG_STRING;
                columnWidths[index] = PIXEL_WIDTH_TAG;
                index++;
            }

            if (this.displayCommonName)
            {
                header1[index]      = tableDescription;
                header2[index]      = "Common info";
                header3[index]      = NAME_STRING;
                columnWidths[index] = PIXEL_WIDTH_NAME;
                index++;
            }

            for (int attributeSetsIndex = 0; attributeSetsIndex < attributeCollections.Count; attributeSetsIndex++)
            {
                if (this.displayAttributeTag)
                {
                    header1[index]      = tableDescription;
                    header2[index]      = attributeSetDescriptions[attributeSetsIndex];
                    header3[index]      = TAG_STRING;
                    columnWidths[index] = PIXEL_WIDTH_TAG;
                    index++;
                }

                if (this.displayAttributeName && (attributeCollections[attributeSetsIndex] is DicomAttributeCollection))
                {
                    header1[index]      = tableDescription;
                    header2[index]      = attributeSetDescriptions[attributeSetsIndex];
                    header3[index]      = NAME_STRING;
                    columnWidths[index] = PIXEL_WIDTH_NAME;
                    index++;
                }

                if (this.displayAttributePresent)
                {
                    header1[index]      = tableDescription;
                    header2[index]      = attributeSetDescriptions[attributeSetsIndex];
                    header3[index]      = PRESENT_STRING;
                    columnWidths[index] = PIXEL_WIDTH_PRESENT;
                    index++;
                }

                if (this.displayAttributeVR && (attributeCollections[attributeSetsIndex] is DicomAttributeCollection))
                {
                    header1[index]      = tableDescription;
                    header2[index]      = attributeSetDescriptions[attributeSetsIndex];
                    header3[index]      = VR_STRING;
                    columnWidths[index] = PIXEL_WIDTH_VR;
                    index++;
                }

                if (this.displayAttributeValues)
                {
                    header1[index]      = tableDescription;
                    header2[index]      = attributeSetDescriptions[attributeSetsIndex];
                    header3[index]      = VALUES_STRING;
                    columnWidths[index] = PIXEL_WIDTH_VALUES;
                    index++;
                }
            }

            if (this.displayComments)
            {
                header1[index]      = tableDescription;
                header2[index]      = "-";
                header3[index]      = "Comments";
                columnWidths[index] = PIXEL_WIDTH_COMMENTS;
                index++;
            }

            compareResults.Table.AddHeader(header1);
            compareResults.Table.AddHeader(header2);
            compareResults.Table.AddHeader(header3);
            compareResults.Table.SetColumnPixelWidths(columnWidths);
            return(compareResults);
        }
Example #18
0
        /// <summary>
        /// Add rows to the tables in which the results are displayed for comparing attribute collections
        /// using static compare.
        /// </summary>
        /// <param name="attributeCollections">The attribute collections.</param>
        internal protected void AddAttributeCollectionsInformationUsingStaticDicomCompare(AttributeCollections attributeCollections)
        {
            //
            // Iterate through all attributes of all AttributeCollections. Only AttributeCollections containing
            // Dicom attributes will be taken into account.
            //

            GeneratorStaticDicomCompare generatorStaticDicomCompare = new GeneratorStaticDicomCompare(attributeCollections);

            AttributeList attributeList     = null;
            TagSequence   lowestTagSequence = null;

            while ((attributeList = generatorStaticDicomCompare.GetNextAttributes(out lowestTagSequence)) != null)
            {
                bool displayAttributes = true;

                if (!this.displayGroupLength)
                {
                    if (lowestTagSequence.LastTag.ElementNumber == 0)
                    {
                        displayAttributes = false;
                    }
                }

                if (displayAttributes)
                {
                    AddAttributesInformation(attributeList);
                }
            }
        }
Example #19
0
        /// <summary>
        /// Compare the DICOM files in the two directories based on there being corresponding
        /// files in each directory with the same attribute value for the matching Tag.
        /// </summary>
        /// <param name="directory1">Full directory name of first directory.</param>
        /// <param name="directory2">Full directory name of second directory.</param>
        /// <param name="matchingTag">DICOM Tag value to match in a file in each directory.</param>
        /// <returns>Total number of differences between compared files.</returns>
        public int Compare(String directory1, String directory2, DvtkData.Dimse.Tag matchingTag)
        {
            int totalDifferences = 0;

            StreamWriter htmlOutput = null;

            try
            {
                // create the output file writer if necessary
                if (_htmlOutputFilename != String.Empty)
                {
                     htmlOutput = new StreamWriter(_htmlOutputFilename);
                }

                // compare all files in directory 1 with corresponding files in directory 2
                // - the files compared is based on them having the same attribute value for the
                // Tag given.
                DirectoryInfo directoryInfo = new DirectoryInfo(directory1);
                FileInfo[] fileInfo = directoryInfo.GetFiles();
                for (int i = 0; i < fileInfo.Length; i++)
                {
                    DataSet dataset1 = new DataSet();
                    String filename1 = fileInfo[i].FullName;
                    dataset1.DvtkDataDataSet = Dvtk.DvtkDataHelper.ReadDataSetFromFile(filename1);

                    // get the attribute value for the matching tag from this dataset
                    String valueToMatch = GetAttributeValueFromDataset(dataset1, matchingTag);
                    if (valueToMatch != String.Empty)
                    {
                        // try to find a dataset (file) containing the same value in directory 2
                        String filename2 = String.Empty;
                        DataSet dataset2 = GetMatchingDatasetFromStoreDataDirectory(directory2, matchingTag, valueToMatch, out filename2);

                        // if a dataset is returned that contains the matching attribute value go on to compare all the attributes
                        // in both datasets with eachother
                        if (dataset2 != null)
                        {
                            // get a new compare instance and set the comparison flags
                            StaticDicomCompare staticDicomCompare = new StaticDicomCompare();
                            FlagsDicomAttribute flags = FlagsDicomAttribute.Compare_values | FlagsDicomAttribute.Compare_present | FlagsDicomAttribute.Include_sequence_items;
                            if (_compareVr == false)
                            {
                                staticDicomCompare.DisplayAttributeVR = false;
                            }
                            else
                            {
                                flags |= FlagsDicomAttribute.Compare_VR;
                            }
                            staticDicomCompare.DisplayGroupLength = _displayGroupLength;

                            dataset1.UnVrDefinitionLookUpWhenReading = _unVrDefinitionLookUpWhenReading;
                            dataset2.UnVrDefinitionLookUpWhenReading = _unVrDefinitionLookUpWhenReading;

                            AttributeCollections datasets = new AttributeCollections();
                            datasets.Add(dataset1);
                            datasets.Add(dataset2);

                            StringCollection datasetDescriptions = new StringCollection();
                            datasetDescriptions.Add(filename1);
                            datasetDescriptions.Add(filename2);

                            String title = String.Format("Comparison Results with matching using Tag with {0}", matchingTag.ToString());
                            DvtkHighLevelInterface.Common.Compare.CompareResults datasetCompareResults = staticDicomCompare.CompareAttributeSets(title, datasets, datasetDescriptions, flags);
                            if (htmlOutput != null)
                            {
                                if (_includeDetailedResults == true)
                                {
                                    htmlOutput.WriteLine(datasetCompareResults.Table.ConvertToHtml());
                                }
                                else
                                {
                                    htmlOutput.WriteLine("<br />");
                                    String message = String.Format("Compared {0} with {1} - number of differences: {2}", filename1, filename2, datasetCompareResults.DifferencesCount);
                                    htmlOutput.WriteLine(message);
                                    htmlOutput.WriteLine("<br />");
                                }
                            }

                            // update the total differences counter
                            totalDifferences += datasetCompareResults.DifferencesCount;
                        }
                    }
                }
            }
            catch (System.Exception)
            {
            }
            if (htmlOutput != null)
            {
                htmlOutput.Flush();
                htmlOutput.Close();
            }
            return totalDifferences;
        }
Example #20
0
        private void AddSequenceAttributesContentInformation(AttributeList attributeList)
        {
            //
            // Determine the maximum amount of sequence items for all supplied sequence attributes
            // that have the include_sequence_items flag enabled.
            //

            int maxItemCount = attributeList.DicomMaxItemCount;


            //
            // Fill the table with the information.
            //

            for (int itemIndex = 1; itemIndex <= maxItemCount; itemIndex++)
            {
                //
                // Add begin item row.
                //

                AddSequenceItemRow(attributeList, itemIndex, true);


                //
                // Add the comparison of attributes within the sequence items.
                //

                AttributeCollections attributeCollections = new AttributeCollections();

                for (int attributeIndex = 0; attributeIndex < attributeList.Count; attributeIndex++)
                {
                    if (attributeList[attributeIndex] == null)
                    {
                        attributeCollections.AddNull();
                    }
                    else if (attributeList[attributeIndex] is Hl7Attribute)
                    {
                        attributeCollections.AddNull();
                    }
                    else if (attributeList[attributeIndex] is DicomAttribute)
                    {
                        DicomAttribute dicomAttribute = attributeList[attributeIndex] as DicomAttribute;

                        if ((dicomAttribute.ValidationRule.Flags & FlagsBase.Include_sequence_items) == FlagsBase.Include_sequence_items)
                        {
                            if (dicomAttribute.AttributeOnly is ValidAttribute)
                            // Attribute is valid attribute.
                            {
                                ValidAttribute validAttribute = dicomAttribute.AttributeOnly as ValidAttribute;

                                if (validAttribute.VR == VR.SQ)
                                // Attribute is valid SQ attribute.
                                {
                                    if (validAttribute.ItemCount < itemIndex)
                                    {
                                        // Item index to high for actual item count.
                                        attributeCollections.Add(new DicomAttributeCollection(new SequenceItem(), dicomAttribute.ValidationRule.Flags));
                                    }
                                    else
                                    // Item exists.
                                    {
                                        attributeCollections.Add(new DicomAttributeCollection(validAttribute.GetItem(itemIndex), dicomAttribute.ValidationRule.Flags));
                                    }
                                }
                                else
                                // Attribute is valid attribute but not a SQ attribute.
                                {
                                    attributeCollections.Add(new DicomAttributeCollection(new SequenceItem(), dicomAttribute.ValidationRule.Flags));
                                }
                            }
                            else
                            // Attribute does not exist.
                            {
                                attributeCollections.Add(new DicomAttributeCollection(new SequenceItem(), dicomAttribute.ValidationRule.Flags));
                            }
                        }
                        else
                        // Flags specify sequence items must not be included.
                        {
                            attributeCollections.AddNull();
                        }
                    }
                }

                AddAttributeCollectionsInformationUsingStaticDicomCompare(attributeCollections);


                //
                // Add end item row.
                //

                AddSequenceItemRow(attributeList, itemIndex, false);
            }
        }
Example #21
0
        internal AttributeCollections Clone()
        {
            AttributeCollections clonedAttributeCollections = new AttributeCollections();

            clonedAttributeCollections.attributeCollections = this.attributeCollections.Clone() as ArrayList;

            return(clonedAttributeCollections);
        }
Example #22
0
        /// <summary>
        /// Add rows to the tables in which the results are displayed for comparing attribute collections
        /// using static compare.
        /// </summary>
        /// <param name="attributeCollections">The attribute collections.</param>
        protected internal void AddAttributeCollectionsInformationUsingStaticDicomCompare(AttributeCollections attributeCollections)
        {
            //
            // Iterate through all attributes of all AttributeCollections. Only AttributeCollections containing
            // Dicom attributes will be taken into account.
            //

            GeneratorStaticDicomCompare generatorStaticDicomCompare = new GeneratorStaticDicomCompare(attributeCollections);

            AttributeList attributeList = null;
            TagSequence lowestTagSequence = null;

            while ((attributeList = generatorStaticDicomCompare.GetNextAttributes(out lowestTagSequence)) != null)
            {
                bool displayAttributes = true;

                if (!this.displayGroupLength)
                {
                    if (lowestTagSequence.LastTag.ElementNumber == 0)
                    {
                        displayAttributes = false;
                    }
                }

                if (displayAttributes)
                {
                    AddAttributesInformation(attributeList);
                }
            }
        }
Example #23
0
        internal CompareResults CreateCompareResults(int numberOfColumns, AttributeCollections attributeCollections, String tableDescription, StringCollection attributeSetDescriptions)
        {
            CompareResults compareResults = new CompareResults(numberOfColumns);
            compareResults.Table.CellItemSeperator = "<br>";
            compareResults.Table.EmptyCellPrefix = BACKGROUND_GREY;

            int index = 0;
            String[] header1 = new String[numberOfColumns];
            String[] header2 = new String[numberOfColumns];
            String[] header3 = new String[numberOfColumns];
            int[] columnWidths = new int[numberOfColumns];

            if (this.displayCommonTag)
            {
                header1[index] = tableDescription;
                header2[index] = "Common info";
                header3[index] = TAG_STRING;
                columnWidths[index] = PIXEL_WIDTH_TAG;
                index++;
            }

            if (this.displayCommonName)
            {
                header1[index] = tableDescription;
                header2[index] = "Common info";
                header3[index] = NAME_STRING;
                columnWidths[index] = PIXEL_WIDTH_NAME;
                index++;
            }

            for (int attributeSetsIndex = 0; attributeSetsIndex < attributeCollections.Count; attributeSetsIndex++)
            {
                if (this.displayAttributeTag)
                {
                    header1[index] = tableDescription;
                    header2[index] = attributeSetDescriptions[attributeSetsIndex];
                    header3[index] = TAG_STRING;
                    columnWidths[index] = PIXEL_WIDTH_TAG;
                    index++;
                }

                if (this.displayAttributeName && (attributeCollections[attributeSetsIndex] is DicomAttributeCollection))
                {
                    header1[index] = tableDescription;
                    header2[index] = attributeSetDescriptions[attributeSetsIndex];
                    header3[index] = NAME_STRING;
                    columnWidths[index] = PIXEL_WIDTH_NAME;
                    index++;
                }

                if (this.displayAttributePresent)
                {
                    header1[index] = tableDescription;
                    header2[index] = attributeSetDescriptions[attributeSetsIndex];
                    header3[index] = PRESENT_STRING;
                    columnWidths[index] = PIXEL_WIDTH_PRESENT;
                    index++;
                }

                if (this.displayAttributeVR && (attributeCollections[attributeSetsIndex] is DicomAttributeCollection))
                {
                    header1[index] = tableDescription;
                    header2[index] = attributeSetDescriptions[attributeSetsIndex];
                    header3[index] = VR_STRING;
                    columnWidths[index] = PIXEL_WIDTH_VR;
                    index++;
                }

                if (this.displayAttributeValues)
                {
                    header1[index] = tableDescription;
                    header2[index] = attributeSetDescriptions[attributeSetsIndex];
                    header3[index] = VALUES_STRING;
                    columnWidths[index] = PIXEL_WIDTH_VALUES;
                    index++;
                }
            }

            if (this.displayComments)
            {
                header1[index] = tableDescription;
                header2[index] = "-";
                header3[index] = "Comments";
                columnWidths[index] = PIXEL_WIDTH_COMMENTS;
                index++;
            }

            compareResults.Table.AddHeader(header1);
            compareResults.Table.AddHeader(header2);
            compareResults.Table.AddHeader(header3);
            compareResults.Table.SetColumnPixelWidths(columnWidths);
            return(compareResults);
        }
Example #24
0
        private void AnonymizeDCMFile()
        {
            try
            {
                utility.AnonymizationType = anonymizationMode;
                CreateDICOMDIR.Enabled = true;

                OpenFileDialog fileDialog = new OpenFileDialog();
                fileDialog.Multiselect = false;
                fileDialog.ReadOnlyChecked = true;
                fileDialog.Title = "Select DCM File";
                fileDialog.Filter = "DCM files (*.dcm) |*.dcm|All files (*.*)|*.*";

                // Show the file dialog.
                // If the user pressed the OK button...
                if (fileDialog.ShowDialog() == DialogResult.OK)
                {
                    DicomFile dcmFile = new DicomFile();
                    dcmFile.Read(fileDialog.FileName, mainThread);

                    // Get the Data set from the selected DCM file
                    HLI.DataSet srcDataset = dcmFile.DataSet;

                    SaveFileDialog saveDialog = new SaveFileDialog();
                    FileInfo saveFileInfo = null;
                    saveDialog.Filter = "DCM files (*.dcm) |*.dcm|All files (*.*)|*.*";
                    if (saveDialog.ShowDialog() == DialogResult.OK)
                    {
                        HLI.DataSet annonymizedDataset = srcDataset.Clone();

                        utility.PatientAttributes(annonymizedDataset);
                        for ( int number = 0; number < annonymizedDataset.Count; number++)
                        {
                            HLI.Attribute attribute =  annonymizedDataset[number];
                            if (attribute.VR == VR.SQ)
                            {
                                utility.SequenceAttribute_recursive(attribute);
                            }
                            else
                            {
                                utility.CacheAndRepairIdentifyingAttribute(attribute);
                                utility.UpdateAnonymizedAttributes(attribute);
                            }
                        }

                        datasets = new AttributeCollections();
                        datasets.Add(srcDataset);
                        datasets.Add(annonymizedDataset);

                        //Save annonymized data to selected file
                        saveFileInfo = new FileInfo(saveDialog.FileName);
                        dcmFile.DataSet = annonymizedDataset;
                        dcmFile.Write(saveFileInfo.FullName);

                        //Cleanup temp file
                        utility.cleanup();
                    }
                    else
                    {
                        return;
                    }

                    string htmlFileName = initialDirectory + "\\" + saveFileInfo.Name + ".html";
                    XmlTextWriter writer = new XmlTextWriter(htmlFileName, System.Text.Encoding.UTF8);
                    writer.WriteStartElement("b");
                    writer.WriteRaw(@"<b><font size='3' color='#ff0000'>DCM File Anonymization Started...</font></b>");
                    writer.WriteEndElement();
                    writer.Close();
                    resultFileName = htmlFileName;
                    System.Threading.Thread t = new System.Threading.Thread(new ThreadStart(CreateTable));
                    dvtkWebBrowser.Navigate(htmlFileName);
                    t.Start();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #25
0
        private void AddSequenceAttributesContentInformation(AttributeList attributeList)
        {
            //
            // Determine the maximum amount of sequence items for all supplied sequence attributes
            // that have the include_sequence_items flag enabled.
            //

            int maxItemCount = attributeList.DicomMaxItemCount;

            //
            // Fill the table with the information.
            //

            for (int itemIndex = 1; itemIndex <= maxItemCount; itemIndex++)
            {
                //
                // Add begin item row.
                //

                AddSequenceItemRow(attributeList, itemIndex, true);

                //
                // Add the comparison of attributes within the sequence items.
                //

                AttributeCollections attributeCollections = new AttributeCollections();

                for (int attributeIndex = 0; attributeIndex < attributeList.Count; attributeIndex++)
                {
                    if (attributeList[attributeIndex] == null)
                    {
                        attributeCollections.AddNull();
                    }
                    else if (attributeList[attributeIndex] is Hl7Attribute)
                    {
                        attributeCollections.AddNull();
                    }
                    else if (attributeList[attributeIndex] is DicomAttribute)
                    {
                        DicomAttribute dicomAttribute = attributeList[attributeIndex] as DicomAttribute;

                        if ((dicomAttribute.ValidationRule.Flags & FlagsBase.Include_sequence_items) == FlagsBase.Include_sequence_items)
                        {
                            if (dicomAttribute.AttributeOnly is ValidAttribute)
                                // Attribute is valid attribute.
                            {
                                ValidAttribute validAttribute = dicomAttribute.AttributeOnly as ValidAttribute;

                                if (validAttribute.VR == VR.SQ)
                                    // Attribute is valid SQ attribute.
                                {
                                    if (validAttribute.ItemCount < itemIndex)
                                    {
                                        // Item index to high for actual item count.
                                        attributeCollections.Add(new DicomAttributeCollection(new SequenceItem(), dicomAttribute.ValidationRule.Flags));
                                    }
                                    else
                                        // Item exists.
                                    {
                                        attributeCollections.Add(new DicomAttributeCollection(validAttribute.GetItem(itemIndex), dicomAttribute.ValidationRule.Flags));
                                    }
                                }
                                else
                                    // Attribute is valid attribute but not a SQ attribute.
                                {
                                    attributeCollections.Add(new DicomAttributeCollection(new SequenceItem(), dicomAttribute.ValidationRule.Flags));
                                }
                            }
                            else
                                // Attribute does not exist.
                            {
                                attributeCollections.Add(new DicomAttributeCollection(new SequenceItem(), dicomAttribute.ValidationRule.Flags));
                            }
                        }
                        else
                            // Flags specify sequence items must not be included.
                        {
                            attributeCollections.AddNull();
                        }
                    }
                }

                AddAttributeCollectionsInformationUsingStaticDicomCompare(attributeCollections);

                //
                // Add end item row.
                //

                AddSequenceItemRow(attributeList, itemIndex, false);

            }
        }
 public void SetUp()
 {
     this.attributeCollections = new AttributeCollections();
 }
Example #27
0
        //
        // - Methods -
        //

        /// <summary>
        /// Do a dynamic compare for the attribute sets supplied.
        ///
        /// Note that the parameters attributeSets, attributeSetDescriptions and each compareRule instance in
        /// the parameter compareRules must have the same size and have a size at least 2.
        /// </summary>
        /// <param name="tableDescription">Description of the table.</param>
        /// <param name="attributeCollections">The attribute sets to compare with each other.</param>
        /// <param name="attributeCollectionDescriptions">The descriptions of the attribute sets.</param>
        /// <param name="compareRules">
        /// Specifies which attributes with what tags should be compared with each other.
        /// Also specifies how the attributes should be compared with each other.
        /// </param>
        /// <returns>The results of the dynamic compare presented as a table (that may be converted to HTML).</returns>
        public CompareResults CompareAttributeCollections(String tableDescription, AttributeCollections attributeCollections, StringCollection attributeCollectionDescriptions, CompareRules compareRules)
        {
            //
            // Sanity check.
            //

            if (attributeCollections.Count < 2)
            {
                throw new System.Exception("Parameter attributeSets supplied to the method StaticCompare.CompareAttributeSets has size smaller than 2.");
            }

            if (attributeCollections.Count != attributeCollectionDescriptions.Count)
            {
                throw new System.Exception("Parameters attributeSets and attributeSetDescriptions supplied to the method StaticCompare.CompareAttributeSets have different size.");
            }

            for (int index = 0; index < compareRules.Count; index++)
            {
                CompareRule compareRule = compareRules[index];

                if (attributeCollections.Count != compareRule.Count)
                {
                    throw new System.Exception("Method StaticCompare.CompareAttributeSets: each CompareRule instance present in the parameter compareRules must have the same size as the parameter attributeCollections.");
                }
            }



            // Todo change taking the possibility of null into account for the attribute collections.

            //
            // Remove the attribute collections that are null and adjust the compare rules.
            //

            for (int index = attributeCollections.Count - 1; index >= 0; index--)
            {
                AttributeCollectionBase attributeCollection = attributeCollections[index];

                if (attributeCollection == null)
                {
                    // Clone the collections because we don't want to change the supplied collections.
                    attributeCollections = attributeCollections.Clone();
                    attributeCollections.RemoveAt(index);

                    StringCollection newAttributeCollectionDescriptions = new StringCollection();
                    foreach (String description in attributeCollectionDescriptions)
                    {
                        newAttributeCollectionDescriptions.Add(description);
                    }
                    attributeCollectionDescriptions = newAttributeCollectionDescriptions;
                    attributeCollectionDescriptions.RemoveAt(index);

#pragma warning disable 0618
                    CompareRules newCompareRules = new CompareRules();
#pragma warning restore 0618

                    for (int compareRuleIndex = 0; compareRuleIndex < compareRules.Count; compareRuleIndex++)
                    {
                        CompareRule compareRule = compareRules[compareRuleIndex].Clone();
                        compareRule.RemoveAt(index);
                        newCompareRules.Add(compareRule);
                    }

                    compareRules = newCompareRules;
                }
            }



            //
            // Do the actual compare.
            //

            this.compareResults = null;

            // Determine the index of the different columns in the table.
            int numberOfColumns = DetermineColumnIndices(attributeCollections);

            // To be able to compare correctly, we first make sure the attributes in all DicomAttributeCollections are ascending.
            attributeCollections.DicomMakeAscending();

            // Determine the table headers and comlumn widths.
            this.compareResults = CreateCompareResults(numberOfColumns, attributeCollections, tableDescription, attributeCollectionDescriptions);

            // Do the actual comparison.
            AddAttributeCollectionsInformationUsingDynamicCompare(attributeCollections, compareRules);

            if (this.differenceFound)
            {
                this.compareResults.DifferencesCount++;
                this.differenceFound = false;
            }

            return(this.compareResults);
        }
Example #28
0
 public void SetUp()
 {
     this.attributeCollections = new AttributeCollections();
 }
Example #29
0
        /// <summary>
        /// Compare the supplied attribute sets.
        /// </summary>
        /// <param name="tableDescription">The table description.</param>
        /// <param name="attributeCollections">The attribute collections.</param>
        /// <param name="attributeCollectionDescriptions">The description of the attribute collections.</param>
        /// <returns></returns>
        public CompareResults CompareAttributeSets(String tableDescription, AttributeCollections attributeCollections, StringCollection attributeCollectionDescriptions)
        {
            //
            // Sanity check.
            //

            if (attributeCollections.Count < 2)
            {
                throw new System.Exception("Parameter attributeSets supplied to the method StaticCompare.CompareAttributeSets has size smaller than 2.");
            }

            if (attributeCollections.Count != attributeCollectionDescriptions.Count)
            {
                throw new System.Exception("Parameters attributeSets and attributeSetDescriptions supplied to the method StaticCompare.CompareAttributeSets have different size.");
            }

            //
            // Do the actual compare.
            //

            this.compareResults = null;

            // Determine the index of the different columns in the table.
            int numberOfColumns = DetermineColumnIndices(attributeCollections);

            // To be able to compare correctly, we first make sure the attributes in all attributesets are ascending.
            attributeCollections.DicomMakeAscending();

            // Determine the table headers and comlumn widths.
            this.compareResults = CreateCompareResults(numberOfColumns, attributeCollections, tableDescription, attributeCollectionDescriptions);

            ArrayList dicomAttributeFlagsForAttributeSets = new ArrayList();
            ArrayList displayAttributeSets = new ArrayList();

            // Do the actual comparison.
            AddAttributeCollectionsInformationUsingStaticDicomCompare(attributeCollections);

            if (this.differenceFound)
            {
                this.compareResults.DifferencesCount++;
                this.differenceFound = false;
            }

            return(this.compareResults);
        }
Example #30
0
 //
 // - Constructors -
 //
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="compareRules">All the CcompareRules that will be applied to the attributeCollections.</param>
 /// <param name="attributeCollections">All the AttributeCollections on which the CcompareRules will be applied.</param>
 /// 
 public GeneratorDynamicCompare(AttributeCollections attributeCollections, CompareRules compareRules)
 {
     this.compareRules = compareRules;
     this.attributeCollections = attributeCollections;
 }