Can't open files

3 次查看(过去 30 天)
Nora A
Nora A 2019-7-9
Hi,
I'm not really familiar with MATLAB, but I need it to extract some information for my project.
I'm using a code (CGITA) that aimes to open and analys medical images (DICOM).
But I'm not able to open these images as I got the following error:
Unable to perform assignment because dot indexing is not supported for variables of this type.
Error in parse_directory_for_dicom (line 97)
fileinfo.PatientName.GivenName = 'N/A';
Error in CGITA_GUI>load_Primary_btn_Callback (line 450)
[filelist fusion_filelist] = parse_directory_for_dicom(Primary_dir);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in CGITA_GUI (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)CGITA_GUI('load_Primary_btn_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
Appreciate your help.
  4 个评论
Rik
Rik 2019-7-9
This code seems very much a work in progress. There is a lot of commented code, and not all comments accurately describe what the code is doing.
The Image Processing Toolbox function dicominfo apparently has a different output from that custom function dcmreadfile. The code below should reproduce your error.
clc
clear fileinfo
fileinfo.PatientName='foo';
if ~isfield(fileinfo.PatientName, 'GivenName')
fileinfo.PatientName.GivenName = 'N/A';
else
disp('condition returned false')
end
This example shows the probable root cause: fileinfo.PatientName is already a char array, instead of a struct, as that assignment assumes.
mahmoud hafez
mahmoud hafez 2023-2-4
This code old work and agree with old Matlab version, so, you can use an older version of MATLAB to avoid this error.

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2023-2-4
Try changing the first few lines of the function to this
function varargout = parse_directory_for_dicom(dirname)
dirListing = dir(fullfile(dirname, '*.dcm'));
all_files_list = fullfile(dirname, {dirListing.name})

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by