dicom write to change the header info without any further modification

조회 수: 17 (최근 30일)
Noelia Martínez
Noelia Martínez 2019년 8월 4일
댓글: Rik 2019년 8월 9일
Dear Matlab experts,
I need to change the value of the StudyInstanceUID in my DICOM images so that is equal to that of the first DICOM. I´m doing this because I need to convert them into BIDS format using Heudiconv and the conversion is only possible if they all have the same StudyInstanceUID. So I was adviced to do this change in the Heudiconv forum (more info here: heudiconv).
This is the code I´m using in Matlab for this:
% Get initial study unique identifier
info= dicominfo((fullfile(path,alldcm{1,1})));
studyID=info.StudyInstanceUID;
clear info
% Make study identifiers from dicom headers 2-960 equal to initial study identifier
for j=2:length(alldcm)
info= dicominfo((fullfile(path,alldcm{j,1})));
info.StudyInstanceUID=studyID;
X=dicomread(fullfile(path,alldcm{j,1}));
cd (path)
dicomwrite(X, 'test.IMA', info, 'CreateMode', 'Copy','CompressionMode','None');
clear X info j
end
However, though the StudyInstanceUID has been successfully changed in the output image (test.IMA) the image size goes from 272KB to 131KB (so approx. half size). Also, the attibutes from the header in test.IMA are not completely recognized by Heudiconv and the conversion is still not possible.
Could anyone suggest any idea to make this change in the header of my DICOM files without any further modification?
Thank you in advance for your time.
Best,
Noelia
  댓글 수: 1
Rik
Rik 2019년 8월 9일
The dicom format is very tricky. It might be the easiest to read as binary, find the position you want to change and what to change it to, and process the files only in binary form.

댓글을 달려면 로그인하십시오.

답변 (2개)

Harsha Priya Daggubati
Harsha Priya Daggubati 2019년 8월 7일
Hi,
I think you can modify fields of the structure info in your case as you desire, and create a new dicom-file by specifying an empty image instead of X.
dicomwrite([], 'test.IMA', info, 'CreateMode', 'Copy','CompressionMode','None');
Hope this helps!

Noelia Martínez
Noelia Martínez 2019년 8월 9일
Hi Harsha!
Thank you for your reply. However, that didn´t solve the problem. I run the following code as you recommended:
dicomwrite([], 'test.IMA', info, 'CreateMode', 'Copy','CompressionMode','None');
But this returned a 3KB DICOM image instead of the original 272KB. I´m sure that someone else within the community have also had the need to modify the metadata from a DICOM file.
I just hope we can eventually find what the solution is because I´ve run out of ideas and the clock is ticking...
Best,
Noelia

카테고리

Help CenterFile Exchange에서 DICOM Format에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by