Code Monkey home page Code Monkey logo

Comments (3)

rexcardan avatar rexcardan commented on May 23, 2024

The EvilDICOM library does not currently have Tag descriptions. I am not sure it is worth the time it would take to aggregate all of the descriptions into a class or dictionary. Why do you need those in your software?

The library is open source. You could roll your own. Something like :

public class TagDescriptionHelper {
public static string GetTagDescription(string completeId){
//Look up in xml file with the maps...the hard part is to create this file
}
}

On the untyped data thing, can you show me what you are trying to do? I don't think you should have to use that.

from evil-dicom.

CBrianMarks avatar CBrianMarks commented on May 23, 2024

I wasn't very clear on my requirements. The tag name actually was what I was looking for. Here's a section of my code where I figured out how to retrieve it using your library. The FirstOrDefault linq enumerable method was used to pull the TagInfo for the tag associated with the IDICOMElement. From the TagInfo I was able to pull the tag name, e.g. TagInfo.Name. In addition, I needed to get the DICOM standard short VR code, which was accomplished using the VRDictionary. Is there an easier way to get at this info?

Also, this method shows how I wound up pulling the subsequence info from the IDICOMElement. I needed to be able to loop through all elements at all levels in the DICOM data in order to keep track of parent-child relationships using a GUID in the hiarchial table I'm inserting the data into. I couldn't figure out how to get the parent info when using the AllElements method of the DICOMObject so I ended up using the Elements method and de.GetType() to determine if the multiplicity IDICOMElement could be cast to a EvilDICOM.Core.DICOMObject to get the children. It's ugly. If you can give me an example of the correct way to do this, I can figure it out. I can usually get things done, albeit the hard way, but my OOP understanding is still a work in progress! :-)

Thanks for putting together such a great open DICOM library and for all your help!

    private void processDataElement(EvilDICOM.Core.Interfaces.IDICOMElement de)
    {

        try
        {

            EvilDICOM.Core.Dictionaries.TagDictionary td = new EvilDICOM.Core.Dictionaries.TagDictionary();
            EvilDICOM.Core.Dictionaries.VRDictionary vr = new EvilDICOM.Core.Dictionaries.VRDictionary();
            EvilDICOM.Core.Dictionaries.TagInfo ti = td.Tags.FirstOrDefault(s => s.TagID == de.Tag.CompleteID);

            string deTypeName = de.GetType().Name;
            string tag = String.Format("({0},{1})", de.Tag.Group, de.Tag.Element);

            Guid dicomDataID = Guid.Empty;

            // setup temporary variables

            string desc = "Unknown";
            string vrabbr = "UN";
            if (ti != null)
            {
                desc = ti.Name.ToString();
                vrabbr = VRDictionary.GetAbbreviationFromVR(ti.VR);
            }

            System.DateTime dtNow = System.DateTime.UtcNow;
            int fileLevel = DICOMFileInfo.FileLevel;

            Guid parentDICOMDataID = Guid.Empty;
            if (DICOMFileInfo.ParentDICOMDataID != Guid.Empty)
            {
                parentDICOMDataID = DICOMFileInfo.ParentDICOMDataID;
            }

            // create a separate record for each value
            char[] delims = { '|' };
            string[] vals = de.UntypedData.ToString().Split(delims);
            foreach (string val in vals)
            {

                Norton_DICOMDataSet.tblDICOMDataRow dr = DICOMdataTable.NewtblDICOMDataRow();

                dicomDataID = Guid.NewGuid();
                dr.DICOMDataID = dicomDataID;
                dr.SOPInstanceUID = DICOMFileInfo.SOPInstanceUID;
                dr.Tag = tag;
                if (deTypeName == VR.Sequence.ToString())
                {
                    dr.Length = 0;
                }
                else
                {
                    dr.Length = val.Length;
                }
                dr.CreateDateTime = dtNow;
                dr.Level = fileLevel;
                dr.ParentDICOMDataID = parentDICOMDataID;
                dr.VR = vrabbr;
                dr.Description = desc;
                dr.Value = val;

                AddtblDICOMDataRow(dr);
            }

            // nested sequence
            if (deTypeName == VR.Sequence.ToString())
            {
                DICOMFileInfo.ParentDICOMDataID = dicomDataID;
                DICOMFileInfo.FileLevel++;

                foreach (EvilDICOM.Core.DICOMObject dobj in ((EvilDICOM.Core.DICOMData<EvilDICOM.Core.DICOMObject>)de.UntypedData).MultipicityValue)
                {
                    processDataSet(dobj);
                }

                DICOMFileInfo.ParentDICOMDataID = dicomDataID;
                DICOMFileInfo.FileLevel--;
            }

        }
        catch (Exception ex)
        {
            Console.Error.WriteLine("Unable to create DICOM data records for file:\n" +
             DICOMFileInfo.File + "\n" +
             ex.Message);
        }
    }

from evil-dicom.

cool-lanke avatar cool-lanke commented on May 23, 2024

Thanks CBrianMarks!! I had the same problem of getting TagDescription from IDICOMElement, since last two days. The code posted above got me the solution, specifically the line in your code:
EvilDICOM.Core.Dictionaries.TagInfo ti = td.Tags.FirstOrDefault(s => s.TagID == de.Tag.CompleteID);

Thank You Very Much for sharing the code!

I think rexcardan must think of providing this facility of getting TagDescription from elements.

from evil-dicom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.