Code Monkey home page Code Monkey logo

Comments (5)

rexcardan avatar rexcardan commented on June 4, 2024

The difference is that if the tag is not in the tag dictionary, the library does not know how to interpret the data. It stores it as an Unknown VR type. What I should add is a method of the Unknown VR type that does something like :

var success = UnknownVR.TryAs<>(out fpsValue);

In the meantime, you can use the data parser to get the data. Unknown VR types just store the raw bytes of the data along with the tag, so you could use:

var vals= dcm.FindAll("30091047")
.Select(d => d as Unknown)
.Select(u=> new FloatingPointSingle(u.Tag, LittleEndianReader.ReadSinglePrecision(u.Data));
.ToList();

from evil-dicom.

phillipgsmith avatar phillipgsmith commented on June 4, 2024

I tried what you suggested (several different ways actually...)

            var vals = dcm.FindAll("30091047")
                          .Select(d => d as Unknown)
                          .Select(u=> new FloatingPointSingle(u.Tag, LittleEndianReader.ReadSinglePrecision(u.Data))
                          .ToList());

It shows: u.Data shows - Argument type "System.Collections.Generic.List" is not assignable to parameter type byte[]

And also .ToList is not available. I thought that you may have meant _DData.

from evil-dicom.

phillipgsmith avatar phillipgsmith commented on June 4, 2024

I wish I could specify a VR on the call to FindAll or somehow add my private elements which I assume I could do but I would have to rebuild the library.

from evil-dicom.

rexcardan avatar rexcardan commented on June 4, 2024

I'm sorry. I should have tested my code before posting here. This works for me.

        var found = dcm.FindAll("30091047")
            .Select(f => f as Unknown)
            .Select(u=>new FloatingPointSingle(u.Tag, LittleEndianReader.ReadSinglePrecision(u.Data_.ToArray())))
            .ToList();

Here is the full test:

        var dcm = new DICOMObject();
        var fs = new FloatingPointSingle(new Tag("30091047"), 25.0f);
        dcm.Add(fs);
        dcm.Write("test.dcm", new EvilDICOM.Core.IO.Writing.DICOMWriteSettings() { TransferSyntax = EvilDICOM.Core.Enums.TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN });


        dcm = DICOMObject.Read("test.dcm");
        var found = dcm.FindAll("30091047")
            .Select(f => f as Unknown)
            .Select(u=>new FloatingPointSingle(u.Tag, LittleEndianReader.ReadSinglePrecision(u.Data_.ToArray())))
            .ToList();

        Assert.IsTrue(found.First() is FloatingPointSingle);

from evil-dicom.

phillipgsmith avatar phillipgsmith commented on June 4, 2024

That did the trick. Thanks so much.

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.