Code Monkey home page Code Monkey logo

Comments (6)

zaxasheats avatar zaxasheats commented on May 24, 2024

Actually it looks like any of the string based VRs would have the same issue.

from evil-dicom.

rexcardan avatar rexcardan commented on May 24, 2024

I just made a unit test to do check this problem. It doesn't fail. I'm using the most recent Git repo (check the prerelease box in NuGet if thats what you are using to get the most up to date...don't know about v 2.0.0):

 [TestClass]
    public class CodeStringMultiplicityTests
    {
        [TestMethod]
        public void CanAddMultipleStringsTest()
        {
            var dcm = new DICOMObject();
            dcm.ReplaceOrAdd(DICOMForge.ImageType("Type1", "Type2", "Type3"));

            var expected = 3;
            var data = dcm.GetSelector().ImageType.Data_;
            var actual = data.Count;
            Assert.AreEqual(expected, actual);

            Assert.AreEqual("Type1", data[0]);
            Assert.AreEqual("Type2", data[1]);
            Assert.AreEqual("Type3", data[2]);
        }
    }

from evil-dicom.

zaxasheats avatar zaxasheats commented on May 24, 2024

from evil-dicom.

rexcardan avatar rexcardan commented on May 24, 2024

Interesting. I see the problem in the datacomposer class as well. I will patch today and update this thread when complete.

from evil-dicom.

zaxasheats avatar zaxasheats commented on May 24, 2024

from evil-dicom.

rexcardan avatar rexcardan commented on May 24, 2024

Well it is a little weird. I see why I made it like that. The DICOM standard is not really clear how those CodeString can have multiple values. But I did see the ImageType VM > 1 so I put it in. Not all string values can have multiple values (eg. LongText, ShortText, UniversalResourceId). Anyway, I did a first pass with it and I think it should work for you (NuGet v 2.0.0.5). Here is my new test.

  [TestMethod]
        public void CanAddMultipleStringsTest()
        {
            var dcm = new DICOMObject();
            dcm.ReplaceOrAdd(DICOMForge.ImageType("Type1", "Type2", "Type3"));

            //Memory test
            var expected = 3;
            var data = dcm.GetSelector().ImageType.Data_;
            var actual = data.Count;
            Assert.AreEqual(expected, actual);

            Assert.AreEqual("Type1", data[0]);
            Assert.AreEqual("Type2", data[1]);
            Assert.AreEqual("Type3", data[2]);


            var bytes = new byte[0];
            //Test IO
            using (var ms = new MemoryStream())
            {
                //WRITE
                using (var bw = new DICOMBinaryWriter(ms))
                {
                    DICOMObjectWriter.Write(bw, DICOMWriteSettings.Default(), dcm);
                }
                bytes = ms.ToArray();
            }

            //READ
            var dcmRead = DICOMObject.Read(bytes);
            expected = 3;
            data = dcmRead.GetSelector().ImageType.Data_;
            actual = data.Count;
            Assert.AreEqual(expected, actual);

            Assert.AreEqual("Type1", data[0]);
            Assert.AreEqual("Type2", data[1]);
            Assert.AreEqual("Type3", data[2]);

        }

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.