Hi OFFIS friends,
I want to open DICOM file, remove some tag (like Patient Name), and Save the file over the original file.
I have this simple code:
*********************************************************************
DcmFileFormat* S = NULL;
S = new DcmFileFormat();
S->loadFile( SrcName );;
// CLEAR some DICOM tags here.....
DcmDataset* dtS = S->getDataset();
E_TransferSyntax Stx = dtS->getOriginalXfer();
S->saveFile( DstName,Stx);
**********************************************************************
Everything works fine and as desired if SrcName and DstName are different.
However, when SrcName=DstName (i.e. overwrite), the function produces new file
incorrectly (and diagnostics says "Missing tags"). Also the overwritten file is drastically
smaller in size f.e. 272KB original down to 4.
Could you please let me know how to perform this operation with overwrite of the original file?
Thank you in advance,
-Artem
How to over-write a modified DICOM file?
Moderator: Moderator Team
-
- DCMTK Developer
- Posts: 2542
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: How to over-write a modified DICOM file?
By default, the call of loadFile() does not load all element values into main memory, only those that are smaller than 4 kbytes.
You could either increase this value (parameter "maxReadLength" of the method) or call loadAllDataIntoMemory() before saveFile().
You could either increase this value (parameter "maxReadLength" of the method) or call loadAllDataIntoMemory() before saveFile().
Re: How to over-write a modified DICOM file?
Just for curiosity, if loadFile(SrcName) does not load all values, how is it possible that saveFile(DstName) works fine only in case SrcName != DstName ?J. Riesmeier wrote: ↑Thu, 2021-03-25, 09:47 By default, the call of loadFile() does not load all element values into main memory, only those that are smaller than 4 kbytes.
Is saveFile() calling something like loadAllDataIntoMemory() automatically? why not do the same if SrcName == DstName ?
-
- DCMTK Developer
- Posts: 2542
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: How to over-write a modified DICOM file?
The element value is loaded on demand from the input file. The same is true when the value is accessed via one of the getXXX() methods.
Of course, loading the element values from the input file does not work if the input file is overwritten by the output file.
Of course, loading the element values from the input file does not work if the input file is overwritten by the output file.
Re: How to over-write a modified DICOM file?
That's clear, thanks!
Who is online
Users browsing this forum: Bing [Bot], Semrush [Bot] and 1 guest