Errors using dicomanon and dicomwrite

2 views (last 30 days)
Andria Farrens
Andria Farrens on 8 Oct 2015
Edited: Andria Farrens on 14 Oct 2015
I have two different codes that are both producing a similar error message in Matlab.
The first is pretty simple and straight from mathworks:
clc
clear
d=dir('*.dcm")
for p = 1:numel(d)
dicomanon(d(p).name, sprintf('anon%d.dcm', p));
end
This is the error message we get for this script:
Index of element to remove exceeds matrix dimensions.
Error in dicom_generate_uid.guid_to_uid (line 114)
guid(13) = '';
Error in dicom_generate_uid (line 35)
uid = guid_to_uid(ipt_root, guid_32bit);
Error in dicomuid (line 14)
uid = dicom_generate_uid('instance');
Error in dicomanon (line 81)
SuncUID = dicomuid;
Error in "name of script"
dicomanon(d(p).name, sprintf('anon%d.dcm', p))
The second code is a work around to try and avoid the previous dicomanon error :
clear;
clc;
d=dir('*.dcm');
for i = 1:numel(d)
dcmfilename = getfield( d(i), 'name');
x = dicomread(dcmfilename);
xinfo = dicominfo(dcmfilename);
fileinfo = xinfo;
fileinfo.PatientBirthDate = '00000000';
fname = ['new_', dcmfilename];
dicomwrite(x, fname, fileinfo);
end
This is the error message we get for this script:
Index of element to remove exceeds matrix dimensions.
Error in dicom_generate_uid.guid_to_uid (line 114)
guid(13) = '';
Error in dicom_generate_uid (line 35)
uid = guid_to_uid(ipt_root, guid_32bit);
Error in dicomuid (line 14)
uid = dicom_generate_uid('instance');
Error in dicom_prep_SOPCommon (line 10)
metadata.(dicom_name_lookup('0008', '0018', dictionary)) =dicomuid;
Error in dicom_prep_metadata (line 28)
metadata = dicom_prep_SOPCommon(metadata, IOD_UID, dictionary);
Error in dicom_create_IOD (line 27)
metadata = dicom_prep_metadata(IOD_UID, metadata, X, map, options.txfr, dictionary);
Error in dicomwrite>write_message (line 263)
[attrs, status] = dicom_create_IOD(SOP_UID, X, map, ...
Error in dicom write (line 200)
[status, options] = write_message(X, filename, mape, metadata, options);
Error in "scriptname" line 35
dicomwrite(x, fname, fileinfo);
The weird thing is that both codes run, and then stop after correctly processing a random number of files. Sometimes we get the error message after 27 files, sometimes 5, or even up to 350. No changes to the code are made in between these trails. Also sometimes the error messages change slightly after the third error message about line 14. Anyone have any ideas as to what might be happening?

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!