How to write edited DICOMRT header info to file

Hi,
I'm attempting to edit dwell position coordinates of a DICOMRT file of a brachytherapy plan.
I am using dicominfo to read in the metadata containing the plan information, then attempting to use dicomwrite to save a new dicom file with the edited dwell positions.
I can't seem however to get dicomwrite to work properly. I tested by just creating a copy of the original dicom file and it works fine, but when attempting to save the edited file it is either not saving all the relevant information or throwing up an error.
An example of what I'm attempting to do is below
%Read in DICOM metadata for RTPlan file
info = dicominfo('filename');
%Edit X coordinate of first dwell position in catheter 1 to be 0.5 cm
info.ApplicationSetupSequence.Item_1.ChannelSequence.Item_1.BrachyControlPointSequence.Item_1.ControlPoint3DPosition(1) = 0.5
%Now write to file
%This option works fine but just copies the original file
dicomwrite([],'newfilename', 'CreateMode', 'Copy')
%This gives an error
dicomwrite([],'newfilename', info, 'CreateMode', 'Copy')
%This gives an error
dicomwrite([],'newfilename', info)
%This doesn't write back any of the plan information to the new file
dicomwrite([],'newfilename')
Any information on how I can implement this would be greatly appreciated.

5 Comments

what's the error and output here:
wrtstatus = dicomwrite([],'newfilename', info, 'CreateMode', 'Copy')
also, can you share the info.mat?
It would not surprise me if you needed to pull out the image data from the input file and pass it as the first parameter for dicomwrite() . empty data is not compatible with the parameters that are in the info you are copying.
Dear Ridwan and Walter,
Please accept my apologies, the code below actually works correctly.
%This gives an error
dicomwrite([],'newfilename', info, 'CreateMode', 'Copy')
It seems that the problem is within my assignment of the new value to the variable. For example, the code below works correctly.
info.ApplicationSetupSequence.Item_1.ChannelSequence.Item_1.BrachyControlPointSequence.Item_1.ControlPoint3DPosition(1) = 0.5
But if I try the following, the value is not updated correctly
info.ApplicationSetupSequence.Item_1.ChannelSequence.Item_1.BrachyControlPointSequence.Item_1.ControlPoint3DPosition(1) = info.ApplicationSetupSequence.Item_1.ChannelSequence.Item_1.BrachyControlPointSequence.Item_1.ControlPoint3DPosition(1) - 0.5
Is there a problem in the line of code above in the way I am trying to change this value?
I don’t think there’s a problem with this current version of assignment. But, there might be another way of setting values to the info struct. With the earlier assignment, I was also suspecting the same. And that is why I asked for the info.mat. Anyway, glad that you figured it out.
info.ApplicationSetupSequence.Item_1.ChannelSequence.Item_1.BrachyControlPointSequence.Item_1.ControlPoint3DPosition(1) = info.ApplicationSetupSequence.Item_1.ChannelSequence.Item_1.BrachyControlPointSequence.Item_1.ControlPoint3DPosition(1) - 0.5
I wonder if that is potentially creating negative values, and if so if that would be a problem? More generally, perhaps it is generating a value outside the permitted range ?

Sign in to comment.

Answers (0)

Products

Release

R2017b

Asked:

on 16 Dec 2019

Commented:

on 18 Dec 2019

Community Treasure Hunt

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

Start Hunting!