How to change patient name?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
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).
Respuesta aceptada
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
Walter Roberson
el 28 de Sept. de 2021
map must go before the file name.
There is no "options" parameter.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!