How to change patient name?

7 visualizaciones (últimos 30 días)
mohd akmal masud
mohd akmal masud el 27 de Sept. de 2021
Comentada: Walter Roberson el 28 de Sept. de 2021
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 comentarios
Image Analyst
Image Analyst el 27 de Sept. de 2021
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 el 27 de Sept. de 2021
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);

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 27 de Sept. de 2021
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 comentarios
mohd akmal masud
mohd akmal masud el 28 de Sept. de 2021
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 el 28 de Sept. de 2021
map must go before the file name.
There is no "options" parameter.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Images en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by