matRad_importDicomGUI

Purpose ^

MATRAD_IMPORTDICOMGUI MATLAB code for matRad_importDicomGUI.fig

Synopsis ^

function varargout = matRad_importDicomGUI(varargin)

Description ^

 MATRAD_IMPORTDICOMGUI MATLAB code for matRad_importDicomGUI.fig
      MATRAD_IMPORTDICOMGUI, by itself, creates a new MATRAD_IMPORTDICOMGUI or raises the existing
      singleton*.

      H = MATRAD_IMPORTDICOMGUI returns the handle to a new MATRAD_IMPORTDICOMGUI or the handle to
      the existing singleton*.

      MATRAD_IMPORTDICOMGUI('CALLBACK',hObject,eventData,handles,...) calls the local
      function named CALLBACK in MATRAD_IMPORTDICOMGUI.M with the given input arguments.

      MATRAD_IMPORTDICOMGUI('Property','Value',...) creates a new MATRAD_IMPORTDICOMGUI or raises the
      existing singleton*.  Starting from the left, property value pairs are
      applied to the GUI before matRad_importDicomGUI_OpeningFcn gets called.  An
      unrecognized property name or invalid value makes property application
      stop.  All inputs are passed to matRad_importDicomGUI_OpeningFcn via varargin.

      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
      instance to run (singleton)".

 See also: GUIDE, GUIDATA, GUIHANDLES

Cross-reference information ^

This function calls: This function is called by:

Subfunctions ^

Source code ^

0001 function varargout = matRad_importDicomGUI(varargin)
0002 % MATRAD_IMPORTDICOMGUI MATLAB code for matRad_importDicomGUI.fig
0003 %      MATRAD_IMPORTDICOMGUI, by itself, creates a new MATRAD_IMPORTDICOMGUI or raises the existing
0004 %      singleton*.
0005 %
0006 %      H = MATRAD_IMPORTDICOMGUI returns the handle to a new MATRAD_IMPORTDICOMGUI or the handle to
0007 %      the existing singleton*.
0008 %
0009 %      MATRAD_IMPORTDICOMGUI('CALLBACK',hObject,eventData,handles,...) calls the local
0010 %      function named CALLBACK in MATRAD_IMPORTDICOMGUI.M with the given input arguments.
0011 %
0012 %      MATRAD_IMPORTDICOMGUI('Property','Value',...) creates a new MATRAD_IMPORTDICOMGUI or raises the
0013 %      existing singleton*.  Starting from the left, property value pairs are
0014 %      applied to the GUI before matRad_importDicomGUI_OpeningFcn gets called.  An
0015 %      unrecognized property name or invalid value makes property application
0016 %      stop.  All inputs are passed to matRad_importDicomGUI_OpeningFcn via varargin.
0017 %
0018 %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
0019 %      instance to run (singleton)".
0020 %
0021 % See also: GUIDE, GUIDATA, GUIHANDLES
0022 
0023 % Edit the above text to modify the response to help matRad_importDicomGUI
0024 
0025 % Last Modified by GUIDE v2.5 02-Jun-2017 00:45:04
0026 
0027 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0028 %
0029 % Copyright 2015 the matRad development team.
0030 %
0031 % This file is part of the matRad project. It is subject to the license
0032 % terms in the LICENSE file found in the top-level directory of this
0033 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part
0034 % of the matRad project, including this file, may be copied, modified,
0035 % propagated, or distributed except according to the terms contained in the
0036 % LICENSE file.
0037 %
0038 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0039 
0040 % Begin initialization code - DO NOT EDIT
0041 gui_Singleton = 1;
0042 gui_State = struct('gui_Name',       mfilename, ...
0043     'gui_Singleton',  gui_Singleton, ...
0044     'gui_OpeningFcn', @matRad_importDicomGUI_OpeningFcn, ...
0045     'gui_OutputFcn',  @matRad_importDicomGUI_OutputFcn, ...
0046     'gui_LayoutFcn',  [] , ...
0047     'gui_Callback',   []);
0048 if nargin && ischar(varargin{1})
0049     gui_State.gui_Callback = str2func(varargin{1});
0050 end
0051 
0052 % if nargout
0053     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0054 % else
0055 %     gui_mainfcn(gui_State, varargin{:});
0056 % end
0057 % End initialization code - DO NOT EDIT
0058 
0059 
0060 % --- Executes just before matRad_importDicomGUI is made visible.
0061 function matRad_importDicomGUI_OpeningFcn(hObject, eventdata, handles, varargin)
0062 % This function has no output args, see OutputFcn.
0063 % hObject    handle to figure
0064 % eventdata  reserved - to be defined in a future version of MATLAB
0065 % handles    structure with handles and user data (see GUIDATA)
0066 % varargin   command line arguments to matRad_importDicomGUI (see VARARGIN)
0067 
0068 % Choose default command line output for matRad_importDicomGUI
0069 handles.output = hObject;
0070 
0071 axes(handles.axesMatRadLogo)
0072 [im, ~, alpha] = imread('matrad_logo.png');
0073 q = image(im);
0074 axis equal off
0075 set(q, 'AlphaData', alpha);
0076 % show dkfz logo
0077 axes(handles.axesDKFZLogo)
0078 [im, ~, alpha] = imread('DKFZ_Logo.png');
0079 p = image(im);
0080 axis equal off
0081 set(p, 'AlphaData', alpha);
0082 % Update handles structure
0083 guidata(hObject, handles);
0084 
0085 % UIWAIT makes matRad_importDicomGUI wait for user response (see UIRESUME)
0086 % uiwait(handles.figure1);
0087 
0088 
0089 % --- Outputs from this function are returned to the command line.
0090 function varargout = matRad_importDicomGUI_OutputFcn(hObject, eventdata, handles)
0091 % varargout  cell array for returning output args (see VARARGOUT);
0092 % hObject    handle to figure
0093 % eventdata  reserved - to be defined in a future version of MATLAB
0094 % handles    structure with handles and user data (see GUIDATA)
0095 
0096 % Get default command line output from handles structure
0097 varargout{1} = handles.output;
0098 
0099 
0100 % --- Executes on button press in browse_button.
0101 function patDir = browse_button_Callback(hObject, eventdata, handles)
0102 % hObject    handle to browse_button (see GCBO)
0103 % eventdata  reserved - to be defined in a future version of MATLAB
0104 % handles    structure with handles and user data (see GUIDATA)
0105 %uiwait(warndlg('Choose the input directory'));
0106 patDir = uigetdir('', 'Choose the input directory...');
0107 if patDir ~= 0
0108     patDir = [patDir filesep];
0109     %handles.dir_path_field.String = patDir;
0110     set(handles.dir_path_field,'String',patDir);
0111     % Update handles structure
0112     guidata(hObject, handles);
0113     scan(hObject, eventdata, handles)
0114 end
0115 
0116 function scan(hObject, eventdata, handles)
0117 [fileList, patient_listbox] = matRad_scanDicomImportFolder(get(handles.dir_path_field,'String'));
0118 if iscell(patient_listbox)
0119     handles.fileList =  fileList;
0120     %handles.patient_listbox.String = patient_listbox;
0121     set(handles.patient_listbox,'String',patient_listbox,'Value',1);
0122     guidata(hObject, handles);
0123 end
0124 
0125 % --- Executes on selection change in patient_listbox.
0126 function patient_listbox_Callback(hObject, eventdata, handles)
0127 % hObject    handle to patient_listbox (see GCBO)
0128 % eventdata  reserved - to be defined in a future version of MATLAB
0129 % handles    structure with handles and user data (see GUIDATA)
0130 
0131 % Hints: contents = cellstr(get(hObject,'String')) returns patient_listbox contents as cell array
0132 %        contents{get(hObject,'Value')} returns selected item from patient_listbox
0133 
0134 if ~isempty(get(hObject,'String'))
0135     % enable Import button
0136     set(handles.import_button,'Enable','on');
0137     
0138     % handles.filelist:
0139     %   1. Filepath
0140     %   2. Modality
0141     %   3. PatientID
0142     %   4. SeriesUID
0143     %   5. SeriesNumber
0144     %   9. res_x
0145     %   10. res_y
0146     %   11. res_z
0147     %   12. detailed dose description - currently not in use for GUI user
0148     patient_listbox = get(handles.patient_listbox,'String');
0149     selected_patient = patient_listbox(get(handles.patient_listbox,'Value'));
0150     % this gets a list of rtss series for this patient
0151     set(handles.rtseries_listbox,'Value',1); % set dummy value to one
0152     set(handles.rtseries_listbox,'String',handles.fileList(strcmp(handles.fileList(:,2), 'RTSTRUCT') & strcmp(handles.fileList(:,3), selected_patient),4));
0153     % this gets a list of rt plan series for this patient
0154     set(handles.rtplan_listbox,'Value',[]); % set dummy value to none
0155     set(handles.rtplan_listbox,'String',handles.fileList(strcmp(handles.fileList(:,2), 'RTPLAN') & strcmp(handles.fileList(:,3), selected_patient),4));
0156     % this gets a list of dose series for this patient
0157     set(handles.doseseries_listbox,'Value',[]); % set dummy value to none
0158     set(handles.doseseries_listbox,'String',handles.fileList(strcmp(handles.fileList(:,2), 'RTDOSE') & strcmp(handles.fileList(:,3), selected_patient),4));
0159     % selectedDose
0160 
0161     if get(handles.SeriesUID_radiobutton,'Value') == 1
0162         % this gets a list of ct series for this patient
0163         set(handles.ctseries_listbox,'Value',1); % set dummy value to one
0164         set(handles.ctseries_listbox,'String',unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient),4)));
0165         
0166         selectedDoseSeriesString = get(handles.doseseries_listbox,'String');
0167         % this gets a resolution for this patient
0168         selectedCtSeriesString = get(handles.ctseries_listbox,'String');
0169         if ~isempty(selectedCtSeriesString)
0170             res_x = unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,4), selectedCtSeriesString{get(handles.ctseries_listbox,'Value')}),9));
0171             res_y = unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,4), selectedCtSeriesString{get(handles.ctseries_listbox,'Value')}),10));
0172             res_z = unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,4), selectedCtSeriesString{get(handles.ctseries_listbox,'Value')}),11));
0173         else
0174             res_x = NaN; res_y = NaN; res_z = NaN;
0175         end
0176     else
0177         set(handles.ctseries_listbox,'Value',1); % set dummy value to one
0178         set(handles.ctseries_listbox,'String',unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient),5)));
0179         selectedCtSeriesString = get(handles.ctseries_listbox,'String');
0180         if ~isempty(selectedCtSeriesString)
0181             res_x = unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,5), selectedCtSeriesString{get(handles.ctseries_listbox,'Value')}),9));
0182             res_y = unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,5), selectedCtSeriesString{get(handles.ctseries_listbox,'Value')}),10));
0183             res_z = unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,5), selectedCtSeriesString{get(handles.ctseries_listbox,'Value')}),11));
0184         else
0185             res_x = NaN; res_y = NaN; res_z = NaN;
0186         end
0187     end
0188     set(handles.resx_edit,'String',res_x);
0189     set(handles.resy_edit,'String',res_y);
0190     if numel(res_z) > 1
0191         set(handles.resz_edit,'String','not equi');
0192     else
0193         set(handles.resz_edit,'String',res_z);
0194     end
0195     % Update handles structure
0196     guidata(hObject, handles);
0197 end
0198 
0199 % --- Executes during object creation, after setting all properties.
0200 function patient_listbox_CreateFcn(hObject, eventdata, handles)
0201 % hObject    handle to patient_listbox (see GCBO)
0202 % eventdata  reserved - to be defined in a future version of MATLAB
0203 % handles    empty - handles not created until after all CreateFcns called
0204 
0205 % Hint: listbox controls usually have a white background on Windows.
0206 %       See ISPC and COMPUTER.
0207 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0208     set(hObject,'BackgroundColor','white');
0209 end
0210 
0211 
0212 % --- Executes on selection change in ctseries_listbox.
0213 function ctseries_listbox_Callback(hObject, eventdata, handles)
0214 % hObject    handle to ctseries_listbox (see GCBO)
0215 % eventdata  reserved - to be defined in a future version of MATLAB
0216 % handles    structure with handles and user data (see GUIDATA)
0217 
0218 % Hints: contents = cellstr(get(hObject,'String')) returns ctseries_listbox contents as cell array
0219 %        contents{get(hObject,'Value')} returns selected item from ctseries_listbox
0220 
0221 
0222 % --- Executes during object creation, after setting all properties.
0223 function ctseries_listbox_CreateFcn(hObject, eventdata, handles)
0224 % hObject    handle to ctseries_listbox (see GCBO)
0225 % eventdata  reserved - to be defined in a future version of MATLAB
0226 % handles    empty - handles not created until after all CreateFcns called
0227 
0228 % Hint: listbox controls usually have a white background on Windows.
0229 %       See ISPC and COMPUTER.
0230 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0231     set(hObject,'BackgroundColor','white');
0232 end
0233 
0234 
0235 % --- Executes on selection change in rtseries_listbox.
0236 function rtseries_listbox_Callback(hObject, eventdata, handles)
0237 % hObject    handle to rtseries_listbox (see GCBO)
0238 % eventdata  reserved - to be defined in a future version of MATLAB
0239 % handles    structure with handles and user data (see GUIDATA)
0240 
0241 % Hints: contents = cellstr(get(hObject,'String')) returns rtseries_listbox contents as cell array
0242 %        contents{get(hObject,'Value')} returns selected item from rtseries_listbox
0243 
0244 
0245 % --- Executes during object creation, after setting all properties.
0246 function rtseries_listbox_CreateFcn(hObject, eventdata, handles)
0247 % hObject    handle to rtseries_listbox (see GCBO)
0248 % eventdata  reserved - to be defined in a future version of MATLAB
0249 % handles    empty - handles not created until after all CreateFcns called
0250 
0251 % Hint: listbox controls usually have a white background on Windows.
0252 %       See ISPC and COMPUTER.
0253 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0254     set(hObject,'BackgroundColor','white');
0255 end
0256 
0257 
0258 % --- Executes on button press in import_button.
0259 function import_button_Callback(hObject, eventdata, handles)
0260 % hObject    handle to import_button (see GCBO)
0261 % eventdata  reserved - to be defined in a future version of MATLAB
0262 % handles    structure with handles and user data (see GUIDATA)
0263 
0264 patient_listbox = get(handles.patient_listbox,'String');
0265 ctseries_listbox = get(handles.ctseries_listbox,'String');
0266 rtplan_listbox = get(handles.rtplan_listbox,'String');
0267 doseseries_listbox = get(handles.rtplan_listbox,'String');
0268 if ~isempty(patient_listbox)
0269     selected_patient = patient_listbox(get(handles.patient_listbox,'Value'));
0270 end
0271 if ~isempty(ctseries_listbox)
0272     selected_ctseries = ctseries_listbox(get(handles.ctseries_listbox,'Value'));
0273 end
0274 if ~isempty(rtplan_listbox)
0275     selected_rtplan = rtplan_listbox(get(handles.rtplan_listbox,'Value'));
0276 end
0277 
0278 if get(handles.SeriesUID_radiobutton,'Value') == 1
0279     files.ct = handles.fileList(strcmp(handles.fileList(:,3), selected_patient) & ...
0280         strcmp(handles.fileList(:,4), selected_ctseries),:);
0281     
0282     %files.rtss = handles.fileList(strcmp(handles.fileList(:,3), selected_patient) & ...
0283     %    strcmp(handles.fileList(:,4), selected_rtseries),:);
0284 else
0285       files.ct = handles.fileList(strcmp(handles.fileList(:,3), selected_patient) & ...
0286         strcmp(handles.fileList(:,5), selected_ctseries) & strcmp(handles.fileList(:,2),'CT'),:);    
0287     
0288     %files.rtss = handles.fileList(strcmp(handles.fileList(:,3), selected_patient) & ...
0289     %    strcmp(handles.fileList(:,5), selected_rtseries),:);
0290 end
0291 
0292 allRtss = handles.fileList(strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,2),'RTSTRUCT'),:);
0293 if ~isempty(allRtss)
0294     files.rtss = allRtss(get(handles.rtseries_listbox,'Value'),:);
0295 else
0296     files.rtss = [];
0297 end
0298 
0299 files.resx = str2double(get(handles.resx_edit,'String'));
0300 files.resy = str2double(get(handles.resy_edit,'String'));
0301 % check if valid assignment is made when z slices are not equi-distant
0302 if strcmp(get(handles.resz_edit,'String'),'not equi')
0303     msgbox('Ct data not sliced equi-distantly in z direction! Chose uniform resolution.', 'Error','error');
0304     return;
0305 else
0306     files.resz = str2double(get(handles.resz_edit,'String'));
0307 end
0308 % selected RT Plan
0309 rtplan = handles.fileList(strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,2),'RTPLAN'),:);
0310 if ~isempty(rtplan) && ~isempty(get(handles.rtplan_listbox,'Value'))
0311     files.rtplan = rtplan(get(handles.rtplan_listbox,'Value'),:);
0312 end
0313 
0314 % selected RT Dose
0315 rtdose = handles.fileList(strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,2),'RTDOSE'),:);
0316 if ~isempty(rtdose) && ~isempty(get(handles.doseseries_listbox,'Value'))
0317     selectedRtDose   = get(handles.doseseries_listbox,'String');
0318     selectedRtDoseIx = NaN*ones(1,numel(selectedRtDose));
0319     for i = 1:numel(selectedRtDose)
0320         selectedRtDoseIx(i) = find(strcmp(rtdose(:,4),selectedRtDose{i}));
0321     end
0322     files.rtdose = rtdose(selectedRtDoseIx,:);
0323 end
0324 
0325 % check if we should use the dose grid resolution
0326 files.useDoseGrid = get(handles.checkbox3,'Value');
0327 
0328 % dicomMetaBool: store complete DICOM information and patientName or not
0329 dicomMetaBool = logical(get(handles.checkPatientName,'Value'));
0330 matRad_importDicom(files, dicomMetaBool);
0331 
0332 
0333 % --- Executes on button press in cancel_button.
0334 function cancel_button_Callback(hObject, eventdata, handles)
0335 % hObject    handle to cancel_button (see GCBO)
0336 % eventdata  reserved - to be defined in a future version of MATLAB
0337 % handles    structure with handles and user data (see GUIDATA)
0338 close(handles.figure1);
0339 
0340 
0341 % --- Executes on button press in rescan_button.
0342 function rescan_button_Callback(hObject, eventdata, handles)
0343 % hObject    handle to rescan_button (see GCBO)
0344 % eventdata  reserved - to be defined in a future version of MATLAB
0345 % handles    structure with handles and user data (see GUIDATA)
0346 
0347 
0348 % --- Executes on mouse press over figure background.
0349 function figure1_ButtonDownFcn(hObject, eventdata, handles)
0350 % hObject    handle to figure1 (see GCBO)
0351 % eventdata  reserved - to be defined in a future version of MATLAB
0352 % handles    structure with handles and user data (see GUIDATA)
0353 
0354 
0355 
0356 function dir_path_field_Callback(hObject, eventdata, handles)
0357 % hObject    handle to dir_path_field (see GCBO)
0358 % eventdata  reserved - to be defined in a future version of MATLAB
0359 % handles    structure with handles and user data (see GUIDATA)
0360 
0361 % Hints: get(hObject,'String') returns contents of dir_path_field as text
0362 %        str2double(get(hObject,'String')) returns contents of dir_path_field as a double
0363 
0364 patDir = get(handles.dir_path_field,'String');
0365 if patDir(end) ~= filesep;
0366     patDir = [patDir filesep];
0367     set(handles.dir_path_field,'String',patDir);
0368     guidata(hObject, handles);
0369 end
0370 scan(hObject, eventdata, handles);
0371 
0372 
0373 % --- Executes on button press in SeriesUID_radiobutton.
0374 function SeriesUID_radiobutton_Callback(hObject, eventdata, handles)
0375 % hObject    handle to SeriesUID_radiobutton (see GCBO)
0376 % eventdata  reserved - to be defined in a future version of MATLAB
0377 % handles    structure with handles and user data (see GUIDATA)
0378 
0379 if get(hObject,'Value') == 1
0380     set(handles.SeriesNumber_radiobutton,'Value',0);
0381 else
0382     set(hObject,'Value',1);
0383     set(handles.SeriesNumber_radiobutton,'Value',0);
0384 end
0385 if isfield(handles, 'fileList')
0386     patient_listbox = get(handles.patient_listbox,'String');
0387     selected_patient = patient_listbox(get(handles.patient_listbox,'Value'));
0388     set(handles.ctseries_listbox,'String',unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient),4)));
0389     set(handles.rtseries_listbox,'String',unique(handles.fileList(strcmp(handles.fileList(:,2), 'RTSTRUCT') & strcmp(handles.fileList(:,3), selected_patient),4)));
0390     set(handles.doseseries_listbox,'String',handles.fileList(strcmp(handles.fileList(:,2), 'RTDOSE') & strcmp(handles.fileList(:,3), selected_patient),4));
0391     set(handles.rtplan_listbox,'String',unique(handles.fileList(strcmp(handles.fileList(:,2), 'RTPLAN') & strcmp(handles.fileList(:,3), selected_patient),4)));
0392 else
0393     fprintf('No patient loaded, so just switching default display option to SeriesUID. \n');
0394 end
0395 guidata(hObject, handles);
0396 
0397 % --- Executes on button press in SeriesNumber_radiobutton.
0398 function SeriesNumber_radiobutton_Callback(hObject, eventdata, handles)
0399 % hObject    handle to SeriesNumber_radiobutton (see GCBO)
0400 % eventdata  reserved - to be defined in a future version of MATLAB
0401 % handles    structure with handles and user data (see GUIDATA)
0402 if get(hObject,'Value') == 1
0403     set(handles.SeriesUID_radiobutton,'Value',0);
0404 else
0405     set(hObject,'Value',1);
0406     set(handles.SeriesUID_radiobutton,'Value',0);
0407 end
0408 if isfield(handles, 'fileList')
0409     patient_listbox = get(handles.patient_listbox,'String');
0410     selected_patient = patient_listbox(get(handles.patient_listbox,'Value'));
0411     set(handles.ctseries_listbox,'String',unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient),5)));
0412 else
0413     fprintf('No patient loaded, so just switching default display option to SeriesNumber. \n');
0414 end
0415 guidata(hObject, handles);
0416 
0417 
0418 
0419 function resx_edit_Callback(hObject, eventdata, handles)
0420 % hObject    handle to resx_edit (see GCBO)
0421 % eventdata  reserved - to be defined in a future version of MATLAB
0422 % handles    structure with handles and user data (see GUIDATA)
0423 
0424 % Hints: get(hObject,'String') returns contents of resx_edit as text
0425 %        str2double(get(hObject,'String')) returns contents of resx_edit as a double
0426 
0427 
0428 % --- Executes during object creation, after setting all properties.
0429 function resx_edit_CreateFcn(hObject, eventdata, handles)
0430 % hObject    handle to resx_edit (see GCBO)
0431 % eventdata  reserved - to be defined in a future version of MATLAB
0432 % handles    empty - handles not created until after all CreateFcns called
0433 
0434 % Hint: edit controls usually have a white background on Windows.
0435 %       See ISPC and COMPUTER.
0436 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0437     set(hObject,'BackgroundColor','white');
0438 end
0439 
0440 
0441 
0442 function resy_edit_Callback(hObject, eventdata, handles)
0443 % hObject    handle to resy_edit (see GCBO)
0444 % eventdata  reserved - to be defined in a future version of MATLAB
0445 % handles    structure with handles and user data (see GUIDATA)
0446 
0447 % Hints: get(hObject,'String') returns contents of resy_edit as text
0448 %        str2double(get(hObject,'String')) returns contents of resy_edit as a double
0449 
0450 
0451 % --- Executes during object creation, after setting all properties.
0452 function resy_edit_CreateFcn(hObject, eventdata, handles)
0453 % hObject    handle to resy_edit (see GCBO)
0454 % eventdata  reserved - to be defined in a future version of MATLAB
0455 % handles    empty - handles not created until after all CreateFcns called
0456 
0457 % Hint: edit controls usually have a white background on Windows.
0458 %       See ISPC and COMPUTER.
0459 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0460     set(hObject,'BackgroundColor','white');
0461 end
0462 
0463 
0464 
0465 function resz_edit_Callback(hObject, eventdata, handles)
0466 % hObject    handle to resz_edit (see GCBO)
0467 % eventdata  reserved - to be defined in a future version of MATLAB
0468 % handles    structure with handles and user data (see GUIDATA)
0469 
0470 % Hints: get(hObject,'String') returns contents of resz_edit as text
0471 %        str2double(get(hObject,'String')) returns contents of resz_edit as a double
0472 
0473 
0474 % --- Executes during object creation, after setting all properties.
0475 function resz_edit_CreateFcn(hObject, eventdata, handles)
0476 % hObject    handle to resz_edit (see GCBO)
0477 % eventdata  reserved - to be defined in a future version of MATLAB
0478 % handles    empty - handles not created until after all CreateFcns called
0479 
0480 % Hint: edit controls usually have a white background on Windows.
0481 %       See ISPC and COMPUTER.
0482 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0483     set(hObject,'BackgroundColor','white');
0484 end
0485 
0486 %
0487 % % --- Executes on selection change in ctseries_listbox.
0488 % function ctseries_listbox_Callback(hObject, eventdata, handles)
0489 % % hObject    handle to ctseries_listbox (see GCBO)
0490 % % eventdata  reserved - to be defined in a future version of MATLAB
0491 % % handles    structure with handles and user data (see GUIDATA)
0492 %
0493 % % Hints: contents = cellstr(get(hObject,'String')) returns ctseries_listbox contents as cell array
0494 % %        contents{get(hObject,'Value')} returns selected item from ctseries_listbox
0495 %
0496 %
0497 % % --- Executes during object creation, after setting all properties.
0498 % function ctseries_listbox_CreateFcn(hObject, eventdata, handles)
0499 % % hObject    handle to ctseries_listbox (see GCBO)
0500 % % eventdata  reserved - to be defined in a future version of MATLAB
0501 % % handles    empty - handles not created until after all CreateFcns called
0502 %
0503 % % Hint: listbox controls usually have a white background on Windows.
0504 % %       See ISPC and COMPUTER.
0505 % if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0506 %     set(hObject,'BackgroundColor','white');
0507 % end
0508 %
0509 %
0510 % % --- Executes on selection change in rtseries_listbox.
0511 % function rtseries_listbox_Callback(hObject, eventdata, handles)
0512 % % hObject    handle to rtseries_listbox (see GCBO)
0513 % % eventdata  reserved - to be defined in a future version of MATLAB
0514 % % handles    structure with handles and user data (see GUIDATA)
0515 %
0516 % % Hints: contents = cellstr(get(hObject,'String')) returns rtseries_listbox contents as cell array
0517 % %        contents{get(hObject,'Value')} returns selected item from rtseries_listbox
0518 %
0519 %
0520 % % --- Executes during object creation, after setting all properties.
0521 % function rtseries_listbox_CreateFcn(hObject, eventdata, handles)
0522 % % hObject    handle to rtseries_listbox (see GCBO)
0523 % % eventdata  reserved - to be defined in a future version of MATLAB
0524 % % handles    empty - handles not created until after all CreateFcns called
0525 %
0526 % % Hint: listbox controls usually have a white background on Windows.
0527 % %       See ISPC and COMPUTER.
0528 % if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0529 %     set(hObject,'BackgroundColor','white');
0530 % end
0531 
0532 
0533 % --- Executes on selection change in doseseries_listbox.
0534 function doseseries_listbox_Callback(hObject, eventdata, handles)
0535 % hObject    handle to doseseries_listbox (see GCBO)
0536 % eventdata  reserved - to be defined in a future version of MATLAB
0537 % handles    structure with handles and user data (see GUIDATA)
0538 
0539 % Hints: contents = cellstr(get(hObject,'String')) returns doseseries_listbox contents as cell array
0540 %        contents{get(hObject,'Value')} returns selected item from doseseries_listbox
0541 
0542 if ~isempty(get(hObject,'Value'))
0543     set(handles.checkbox3,'Enable','on');
0544 else
0545     set(handles.checkbox3,'Value',0);
0546     set(handles.checkbox3,'Enable','off');
0547     % retrieve and display resolution for DICOM ct cube
0548     patient_listbox = get(handles.patient_listbox,'String');
0549     selected_patient = patient_listbox(get(handles.patient_listbox,'Value'));
0550     selectedCtSeriesString = get(handles.ctseries_listbox,'String');
0551     if get(handles.SeriesUID_radiobutton,'Value') == 1
0552         if ~isempty(selectedCtSeriesString)
0553             res_x = unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,4), selectedCtSeriesString{get(handles.ctseries_listbox,'Value')}),9));
0554             res_y = unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,4), selectedCtSeriesString{get(handles.ctseries_listbox,'Value')}),10));
0555             res_z = unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,4), selectedCtSeriesString{get(handles.ctseries_listbox,'Value')}),11));
0556         else
0557             res_x = NaN; res_y = NaN; res_z = NaN;
0558         end
0559     else
0560         if ~isempty(selectedCtSeriesString)
0561             res_x = unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,5), selectedCtSeriesString{get(handles.ctseries_listbox,'Value')}),9));
0562             res_y = unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,5), selectedCtSeriesString{get(handles.ctseries_listbox,'Value')}),10));
0563             res_z = unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,5), selectedCtSeriesString{get(handles.ctseries_listbox,'Value')}),11));
0564         else
0565             res_x = NaN; res_y = NaN; res_z = NaN;
0566         end
0567     end
0568     set(handles.resx_edit,'String',res_x);
0569     set(handles.resy_edit,'String',res_y);
0570     if numel(res_z) > 1
0571         set(handles.resz_edit,'String','not equi');
0572     else
0573         set(handles.resz_edit,'String',res_z);
0574     end
0575     
0576 end
0577 
0578 % --- Executes during object creation, after setting all properties.
0579 function doseseries_listbox_CreateFcn(hObject, eventdata, handles)
0580 % hObject    handle to doseseries_listbox (see GCBO)
0581 % eventdata  reserved - to be defined in a future version of MATLAB
0582 % handles    empty - handles not created until after all CreateFcns called
0583 
0584 % Hint: listbox controls usually have a white background on Windows.
0585 %       See ISPC and COMPUTER.
0586 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0587     set(hObject,'BackgroundColor','white');
0588 end
0589 
0590 % --- Executes on selection change in rtplan_listbox.
0591 function rtplan_listbox_Callback(hObject, eventdata, handles)
0592 % hObject    handle to rtplan_listbox (see GCBO)
0593 % eventdata  reserved - to be defined in a future version of MATLAB
0594 % handles    structure with handles and user data (see GUIDATA)
0595 
0596 contents = cellstr(get(hObject,'String'));
0597 if ~isempty(get(hObject,'Value')) && numel(get(hObject,'Value')) == 1
0598 
0599     selectedPlan = contents{get(hObject,'Value')};
0600     % point at plan in listbox
0601     selectedPlanLoc = strcmp(handles.fileList(:,4),selectedPlan);
0602     
0603     % show only the doses corresponding to the plan
0604     corrDoses = [handles.fileList{selectedPlanLoc,13}];
0605     numOfDoses = numel(corrDoses);
0606     corrDosesLoc = zeros(size(handles.fileList(:,1),1),1);
0607     for j = 1:numOfDoses
0608         if ~isnan(corrDoses{j})
0609             corrDosesLoc = corrDosesLoc | strcmp(handles.fileList(:,4),corrDoses{j});
0610         end
0611     end
0612     
0613     if sum(corrDosesLoc) == 0
0614         warndlg('no rt dose file directly associated to plan file. showing all rt dose files.');
0615         corrDosesLoc = strcmp(handles.fileList(:,2),'RTDOSE');
0616     end
0617 
0618     set(handles.doseseries_listbox,'Value',[]); % set dummy value to one
0619     set(handles.doseseries_listbox,'String',handles.fileList(corrDosesLoc,4));
0620     
0621     % disable checkbox for use dose grid is currently checked
0622     if get(handles.checkbox3,'Value') == 1
0623         set(handles.checkbox3,'Value',0);
0624         checkbox3_Callback(handles.checkbox3,[], handles);
0625     end
0626     set(handles.checkbox3,'Enable','off');
0627 
0628     
0629 elseif numel(get(hObject,'Value')) >=2
0630     warning('More than one RTPLAN selected. Unsetting selection ...');
0631     patient_listbox_Callback(hObject, eventdata, handles)
0632 else
0633     patient_listbox_Callback(hObject, eventdata, handles)
0634 end
0635 
0636 
0637 % --- Executes during object creation, after setting all properties.
0638 function rtplan_listbox_CreateFcn(hObject, eventdata, handles)
0639 % hObject    handle to rtplan_listbox (see GCBO)
0640 % eventdata  reserved - to be defined in a future version of MATLAB
0641 % handles    empty - handles not created until after all CreateFcns called
0642 
0643 % Hint: listbox controls usually have a white background on Windows.
0644 %       See ISPC and COMPUTER.
0645 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0646     set(hObject,'BackgroundColor','white');
0647 end
0648 
0649 
0650 % --- Executes on button press in checkPatientName.
0651 function checkPatientName_Callback(hObject, eventdata, handles)
0652 % hObject    handle to checkPatientName (see GCBO)
0653 % eventdata  reserved - to be defined in a future version of MATLAB
0654 % handles    structure with handles and user data (see GUIDATA)
0655 %A = get(hObject,'Value');
0656 
0657 % Hint: get(hObject,'Value') returns toggle state of checkPatientName
0658 %guidata(hObject, handles);
0659 
0660 
0661 % --- Executes on button press in checkbox3.
0662 function checkbox3_Callback(hObject, eventdata, handles)
0663 % hObject    handle to checkbox3 (see GCBO)
0664 % eventdata  reserved - to be defined in a future version of MATLAB
0665 % handles    structure with handles and user data (see GUIDATA)
0666 
0667 % Hint: get(hObject,'Value') returns toggle state of checkbox3
0668 
0669 if get(hObject,'Value')
0670     set(handles.resx_edit,'Enable', 'off');
0671     set(handles.resy_edit,'Enable', 'off');
0672     set(handles.resz_edit,'Enable', 'off');
0673     % retrieve and display resolution for DICOM dose cube
0674     doseFilesInList = get(handles.doseseries_listbox,'String');
0675     selectedDoseFiles = get(handles.doseseries_listbox,'Value');
0676     if isempty(selectedDoseFiles)
0677         set(hObject,'Value',0)
0678         errordlg('no dose file selected');
0679         return;
0680     end
0681     for i = 1:numel(selectedDoseFiles)
0682         selectedDoseFile = doseFilesInList{selectedDoseFiles(i)};
0683         if verLessThan('matlab','9')
0684             dicomDoseInfo = dicominfo(handles.fileList{find(strcmp(handles.fileList(:,4),selectedDoseFile)),1});
0685         else
0686             dicomDoseInfo = dicominfo(handles.fileList{find(strcmp(handles.fileList(:,4),selectedDoseFile)),1},'UseDictionaryVR',true);
0687         end
0688         res_x{i} = dicomDoseInfo.PixelSpacing(1);
0689         res_y{i} = dicomDoseInfo.PixelSpacing(2);
0690         res_z{i} = dicomDoseInfo.SliceThickness;
0691     end
0692 
0693     if numel(unique(cell2mat(res_x)))*numel(unique(cell2mat(res_y)))*numel(unique(cell2mat(res_z))) ~= 1
0694         set(handles.checkbox3,'Value',0);
0695         warndlg('Different resolutions in dose file(s)');
0696         set(handles.resx_edit,'Enable', 'on');
0697         set(handles.resy_edit,'Enable', 'on');
0698         set(handles.resz_edit,'Enable', 'on');
0699     else
0700         set(handles.resx_edit,'String',num2str(res_x{1}));
0701         set(handles.resy_edit,'String',num2str(res_y{1}));
0702         set(handles.resz_edit,'String',num2str(res_z{1}));
0703     end
0704     
0705 else
0706     set(handles.resx_edit,'Enable', 'on');
0707     set(handles.resy_edit,'Enable', 'on');
0708     set(handles.resz_edit,'Enable', 'on');
0709     % retrieve and display resolution for DICOM ct cube
0710     patient_listbox = get(handles.patient_listbox,'String');
0711     selected_patient = patient_listbox(get(handles.patient_listbox,'Value'));
0712     selectedCtSeriesString = get(handles.ctseries_listbox,'String');
0713     if get(handles.SeriesUID_radiobutton,'Value') == 1
0714         if ~isempty(selectedCtSeriesString)
0715             res_x = unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,4), selectedCtSeriesString{get(handles.ctseries_listbox,'Value')}),9));
0716             res_y = unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,4), selectedCtSeriesString{get(handles.ctseries_listbox,'Value')}),10));
0717             res_z = unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,4), selectedCtSeriesString{get(handles.ctseries_listbox,'Value')}),11));
0718         else
0719             res_x = NaN; res_y = NaN; res_z = NaN;
0720         end
0721     else
0722         if ~isempty(selectedCtSeriesString)
0723             res_x = unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,5), selectedCtSeriesString{get(handles.ctseries_listbox,'Value')}),9));
0724             res_y = unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,5), selectedCtSeriesString{get(handles.ctseries_listbox,'Value')}),10));
0725             res_z = unique(handles.fileList(strcmp(handles.fileList(:,2), 'CT') & strcmp(handles.fileList(:,3), selected_patient) & strcmp(handles.fileList(:,5), selectedCtSeriesString{get(handles.ctseries_listbox,'Value')}),11));
0726         else
0727             res_x = NaN; res_y = NaN; res_z = NaN;
0728         end
0729     end
0730     set(handles.resx_edit,'String',res_x);
0731     set(handles.resy_edit,'String',res_y);
0732     if numel(res_z) > 1
0733         set(handles.resz_edit,'String','not equi');
0734     else
0735         set(handles.resz_edit,'String',res_z);
0736     end
0737     
0738 end

| Generated by m2html © 2005