How to copy the Dicom private tags in another Dicom file using the dicomwrite function accurately?

3 views (last 30 days)
Hi, I need to copy the Dicom info from one file to another. The Dicom file I have consists of many private tags and I want to copy them to the another file that I am writing using the MATLAB dicomwrite function.
info = dicominfo('ABCD.1.img'); % it has may private tags
fileID1 = fopen('data.s', 'r');
data1 = fread(fileID1); % I am writing this as a dicom file
fclose(fileID1);
dicomwrite(data1, 'new_image.img', info, 'CreateMode', 'Copy','WritePrivate', true);
metadata = dicominfo('new_image.img');
isequal(info, metadata) % .....> returns logical 0.
When I do this, all the private tags becomes uint8 and [0;0;0;0]...... format (some nonsense values). How can I copy the info accurately?
  7 Comments
Ken K
Ken K on 4 Jun 2021
I am facing the same problem. Can you elaborate on your statement about appending the dicom dictionary? How did you manage to write the private tags such that they are not in uint8? Would you mind sharing the script for this?
Cheers
Rik
Rik on 4 Jun 2021
The private tags are private, so there isn't a general definition. The definition might be standard for your specific field/application. Once you know what a specific tag means, you can define the VR and VM. The VR will ensure the data is read in the correct data type.
Doing custom work with DICOM is not trivial. Know what you're getting yourself into. There will be a lot of googling involved and a lot of conflicting information.

Sign in to comment.

Answers (0)

Categories

Find more on DICOM Format in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!