Why I am not able to view the comments whichever I embedded into Dicom image as metadata?

4 次查看(过去 30 天)
% Following is my code..Here I am reading the Dicom image. And Wherever i
% want toinsert the comment I am giving the comments by locating the
% points.Then i am displaying watermarked and original image.But later if i
% view the metadata at that time am not able view that comment.Please help
% me me in this code
% Read the DICOM image
dicomImage = dicomread('ID_0000_AGE_0060_CONTRAST_1_CT.dcm');
Error using images.internal.dicom.getFileDetails
Unable to load file "ID_0000_AGE_0060_CONTRAST_1_CT.dcm".

Error in dicomread>newDicomread (line 119)
fileDetails = images.internal.dicom.getFileDetails(filename, verifyIsDICOM);

Error in dicomread (line 13)
[X, map, alpha, overlays] = newDicomread(msgname, frames, useVRHeuristic);
% Create a figure to display both images side by side
figure;
% Display the original DICOM image on the left
subplot(1, 2, 1);
imshow(dicomImage, []);
title('Original DICOM Image');
% Let the user locate the point
uiwait(msgbox('Click on the image to locate the point.'));
[x, y] = ginput(1);
% Get user input for the text message
prompt = 'Enter the comment text: ';
dlgtitle = 'Input';
dims = [1 50];
definput = {''}; % Default input is an empty string
textToInsert = inputdlg(prompt, dlgtitle, dims, definput);
% Create a DICOM metadata structure
dicomInfo = dicominfo('ID_0000_AGE_0060_CONTRAST_1_CT.dcm');
% Add comments to the metadata (you can use any appropriate DICOM field for comments)
dicomInfo.ClinicalTrialSeriesDescription = textToInsert;
% Write the DICOM image with embedded comments to a new DICOM file
dicomwrite(dicomImage, 'Watermarked_DICOM.dcm', dicomInfo);
% Read the watermarked DICOM image
watermarkedImage = dicomread('Watermarked_DICOM.dcm');
% Display the watermarked DICOM image on the right
subplot(1, 2, 2);
imshow(watermarkedImage, []);
title('Watermarked DICOM Image with Comments');
% Adjust the positions of the subplots for better visualization
%set(gca, 'Position', [0.5, 0.1, 0.4, 0.7]);

采纳的回答

Aishwarya
Aishwarya 2023-11-9
Hi Ramya,
As per my understanding, you are encountering an issue with viewing the comment you have inserted in the DICOM file.
After reviewing the provided code, here are some suggestions that might help resolve the issue.
  • Modify the “textToInsertvariable to string before assignment to “dicomInfo” metadata. In the given code, textToInsert variable is stored as cell array. The modified line of code is shown below:
% Add comments to the metadata (you can use any appropriate DICOM field for comments)
dicomInfo.ClinicalTrialSeriesDescription = textToInsert{1};
  • Check that the appropriate metadata field is used from “dicomInfo” variable to insert the comment. Use the following command to display different fields in DICOM metadata:
disp(dicomInfo);
  • When using “dicomwrite” function to create the new file, consider using “CreateMode” option set to “Copy”. This will copy all values from the input file. The modified line of code is shown below:
% Write the DICOM image with embedded comments to a new DICOM file
dicomwrite(dicomImage, 'Watermarked_DICOM.dcm', dicomInfo, 'CreateMode', 'Copy');
Please refer to below MathWorks documentations for more information on the functions used:
I hope these suggestions help resolve the issue.

更多回答(0 个)

类别

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