How to change patient name?

15 ビュー (過去 30 日間)
mohd akmal masud
mohd akmal masud 2021 年 9 月 27 日
コメント済み: Walter Roberson 2021 年 9 月 28 日
Hi all,
I have 263 images dicom. But I want to change the patient name every images. I wrote this code but failed.
P = zeros(256, 256, 263);
for K = 263 : -1 : 1
petname = sprintf('%03d.dcm', K);
info(K) = dicominfo(petname);
P(:,:,K) = dicomread(petname);
end
newname = 'example'
dicomwrite(P, 'Q.dcm', newname, info)
but failed
Anyone can help me?
  2 件のコメント
Image Analyst
Image Analyst 2021 年 9 月 27 日
What failed? You should know by now that you need to show us ALL the red text. I have no idea if dicominfo() failed because a file did not exist, or if dicomwrite failed for some reason, or if the insertion of the array into the k'th slice of P failed (maybe because the size is wrong).
mohd akmal masud
mohd akmal masud 2021 年 9 月 27 日
this is the red text sir
Error using dicom_prep_ImagePixel>getPhotometricInterp (line 134)
Cannot determine photometric interpretation.
Error in dicom_prep_ImagePixel (line 9)
metadata.(dicom_name_lookup('0028', '0004', dictionary)) = getPhotometricInterp(metadata, X, map, txfr, dictionary);
Error in dicom_prep_metadata (line 51)
metadata = dicom_prep_ImagePixel(metadata, X, map, txfr, useMetadataBitDepths, dictionary);
Error in dicom_create_IOD (line 26)
metadata = dicom_prep_metadata(IOD_UID, metadata, X, map, options.txfr, options.usemetadatabitdepths, dictionary);
Error in dicomwrite>write_message (line 275)
[attrs, status] = dicom_create_IOD(SOP_UID, X, map, ...
Error in dicomwrite (line 211)
[status, options] = write_message(X, filename, map, metadata, options);

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2021 年 9 月 27 日
P = zeros(256, 256, 263);
for K = 263 : -1 : 1
petname = sprintf('%03d.dcm', K);
info(K) = dicominfo(petname);
So info will end up being a non-scalar struct array. (There is also a risk of problems as not all dicom images have the same field names.)
P(:,:,K) = dicomread(petname);
You are storing data for all of the files into one array.
end
newname = 'example'
dicomwrite(P, 'Q.dcm', newname, info)
You are trying to use the non-scalar struct array info, but the metadata must be a scalar struct array, as far as I know.
The syntax you used for dicomwrite() with four parameters, would have to match one of
dicomwrite(X,cmap,filename,meta_struct)
dicomwrite(X,cmap,filename,info)
dicomwrite(X,filename,NAME,VALUE)
but cmap cannot be a character vector such as 'Q.dcm', so the first two are ruled out. So we have to check: is the variable newname a character vector or string? Yes, it is. So the third form must be the interpretation. So would be trying to look for a dicomwrite option named example and info would be the value associated with it. Which is not going to work.
Perhaps you were thinking of setting the PatientName fields
[info.PatientName] = deal(struct('FamilyName', newname, 'GivenName', newname));
and then doing
dicomwrite(P, 'Q.dcm', info)
But... (A) I do not know if you can use non-scalar info; and (B) the info you have is for a 2D image, but P is a 3D array, which is a miss-match.
  8 件のコメント
mohd akmal masud
mohd akmal masud 2021 年 9 月 28 日
It is PET sir. Yes.
but have error
Error using dicomwrite>write_message (line 266)
Unsupported value for CreateMode.
Error in dicomwrite (line 211)
[status, options] = write_message(X, filename, map, metadata, options);
Walter Roberson
Walter Roberson 2021 年 9 月 28 日
map must go before the file name.
There is no "options" parameter.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by