Code Monkey home page Code Monkey logo

Comments (5)

pieper avatar pieper commented on July 20, 2024

Thanks for reporting this. That's definitely a use case we want to make sure works.

From what I can see the DICM marker is missing (maybe the whole preamble is missing).

throw new Error("Invalid DICOM file, expected header is missing");

But it should have been written out by DicomDict.write() so something must be going on.

dcmjs/src/DicomDict.js

Lines 20 to 24 in 914b3dc

write(writeOptions = { allowInvalidVRLength: false }) {
var metaSyntax = EXPLICIT_LITTLE_ENDIAN;
var fileStream = new WriteBufferStream(4096, true);
fileStream.writeUint8Repeat(0, 128);
fileStream.writeAsciiString("DICM");

Could you look at, for example, this test and see what's different from your case? If needed could you make a PR for this use case in the form of a test that could be used to document this use case and confirm that it's (ultimately) fixed.

from dcmjs.

esmadau avatar esmadau commented on July 20, 2024

Thanks for the quick reply. I'll work on a test. Also, I noticed that when overriding the UID given the example provided, PixelData is lost. Is there a way for me to change the UID and retain PixelData?

from dcmjs.

pieper avatar pieper commented on July 20, 2024

PixelData should not be lost. Did you make a simple test case to illustrate what you are doing?

from dcmjs.

EastLight0 avatar EastLight0 commented on July 20, 2024

hi friends! I have a similar problem...

I'm trying to insert a dicom tag. A tag is inserted in the final dicom file.
but, an error occurs when opening the saved dicom file.
So I thought about my problem.
After checking that the Pixeldata is changed after saving, I looked for the problem.

let arrayBuffer = fs.readFileSync(filePath).buffer;    
let DicomDict = dcmjs.data.DicomMessage.readFile(arrayBuffer);    
console.log(DicomDict.dict['7FE00010']);    
DicomDict.upsertTag('00080005', 'CS', 'ISO_IR 192');    
console.log(DicomDict.dict['7FE00010']);   
let new_file_WriterBuffer = DicomDict.write();   
fs.writeFileSync(filePath, new Buffer.from(new_file_WriterBuffer));

If you print the log before and after modifying the dicom file, you can get the following result.

image

Since the file is a 512*512 image, byteLength 524288 should appear, but you can see that it is loaded as byteLength 519511.

Some another files are loaded so perfect
image

I think that when loading the dicom file, the PixelArray cannot be loaded correctly....
The "dcmjs.data.DicomMessage.readFile" function doesn't seem to load the file correctly.

Please... help me...

from dcmjs.

pieper avatar pieper commented on July 20, 2024

@EastLight0 Thanks for reporting. Please make a test that demonstrates the issue following the example of the other tests in the repo.

from dcmjs.

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.