Can't open files

4 views (last 30 days)
Nora A
Nora A on 9 Jul 2019
Answered: Image Analyst on 4 Feb 2023
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 Comments
Rik
Rik on 9 Jul 2019
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 on 4 Feb 2023
This code old work and agree with old Matlab version, so, you can use an older version of MATLAB to avoid this error.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 4 Feb 2023
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})

Categories

Find more on File Operations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!