matRad_importGUI

Purpose ^

MATRAD_IMPORTGUI MATLAB code for matRad_importGUI.fig

Synopsis ^

function varargout = matRad_importGUI(varargin)

Description ^

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

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

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

      MATRAD_IMPORTGUI('Property','Value',...) creates a new MATRAD_IMPORTGUI or raises the
      existing singleton*.  Starting from the left, property value pairs are
      applied to the GUI before matRad_importGUI_OpeningFcn gets called.  An
      unrecognized property name or invalid value makes property application
      stop.  All inputs are passed to matRad_importGUI_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_importGUI(varargin)
0002 % MATRAD_IMPORTGUI MATLAB code for matRad_importGUI.fig
0003 %      MATRAD_IMPORTGUI, by itself, creates a new MATRAD_IMPORTGUI or raises the existing
0004 %      singleton*.
0005 %
0006 %      H = MATRAD_IMPORTGUI returns the handle to a new MATRAD_IMPORTGUI or the handle to
0007 %      the existing singleton*.
0008 %
0009 %      MATRAD_IMPORTGUI('CALLBACK',hObject,eventData,handles,...) calls the local
0010 %      function named CALLBACK in MATRAD_IMPORTGUI.M with the given input arguments.
0011 %
0012 %      MATRAD_IMPORTGUI('Property','Value',...) creates a new MATRAD_IMPORTGUI or raises the
0013 %      existing singleton*.  Starting from the left, property value pairs are
0014 %      applied to the GUI before matRad_importGUI_OpeningFcn gets called.  An
0015 %      unrecognized property name or invalid value makes property application
0016 %      stop.  All inputs are passed to matRad_importGUI_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_importGUI
0024 
0025 % Last Modified by GUIDE v2.5 09-Aug-2018 15:18:30
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_importGUI_OpeningFcn, ...
0045                    'gui_OutputFcn',  @matRad_importGUI_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_importGUI is made visible.
0061 function matRad_importGUI_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_importGUI (see VARARGIN)
0067 
0068 % Choose default command line output for matRad_importGUI
0069 handles.output = hObject;
0070 
0071 % Update handles structure
0072 guidata(hObject, handles);
0073 
0074 % UIWAIT makes matRad_importGUI wait for user response (see UIRESUME)
0075 % uiwait(handles.figure_importDialog);
0076 
0077 
0078 % --- Outputs from this function are returned to the command line.
0079 function varargout = matRad_importGUI_OutputFcn(hObject, eventdata, handles) 
0080 % varargout  cell array for returning output args (see VARARGOUT);
0081 % hObject    handle to figure
0082 % eventdata  reserved - to be defined in a future version of MATLAB
0083 % handles    structure with handles and user data (see GUIDATA)
0084 
0085 % Get default command line output from handles structure
0086 varargout{1} = handles.output;
0087 
0088 
0089 
0090 function edit_ctPath_Callback(hObject, eventdata, handles)
0091 % hObject    handle to edit_ctPath (see GCBO)
0092 % eventdata  reserved - to be defined in a future version of MATLAB
0093 % handles    structure with handles and user data (see GUIDATA)
0094 
0095 % Hints: get(hObject,'String') returns contents of edit_ctPath as text
0096 %        str2double(get(hObject,'String')) returns contents of edit_ctPath as a double
0097 
0098 
0099 % --- Executes during object creation, after setting all properties.
0100 function edit_ctPath_CreateFcn(hObject, eventdata, handles)
0101 % hObject    handle to edit_ctPath (see GCBO)
0102 % eventdata  reserved - to be defined in a future version of MATLAB
0103 % handles    empty - handles not created until after all CreateFcns called
0104 
0105 % Hint: edit controls usually have a white background on Windows.
0106 %       See ISPC and COMPUTER.
0107 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0108     set(hObject,'BackgroundColor','white');
0109 end
0110 
0111 
0112 % --- Executes on button press in pushbutton_ctPath.
0113 function pushbutton_ctPath_Callback(hObject, eventdata, handles)
0114 % hObject    handle to pushbutton_ctPath (see GCBO)
0115 % eventdata  reserved - to be defined in a future version of MATLAB
0116 % handles    structure with handles and user data (see GUIDATA)
0117 
0118 [importCTFile,importCTPath,~] = uigetfile({'*.nrrd', 'NRRD-Files'}, 'Choose the CT file...');
0119 if importCTFile ~= 0
0120     set(handles.edit_ctPath,'String',fullfile(importCTPath,importCTFile));
0121     % Update handles structure
0122     guidata(hObject, handles);
0123 end
0124 
0125 
0126 
0127 function listbox_maskPaths_Callback(hObject, eventdata, handles)
0128 % hObject    handle to listbox_maskPaths (see GCBO)
0129 % eventdata  reserved - to be defined in a future version of MATLAB
0130 % handles    structure with handles and user data (see GUIDATA)
0131 
0132 % Hints: get(hObject,'String') returns contents of listbox_maskPaths as text
0133 %        str2double(get(hObject,'String')) returns contents of listbox_maskPaths as a double
0134 
0135 
0136 % --- Executes during object creation, after setting all properties.
0137 function listbox_maskPaths_CreateFcn(hObject, eventdata, handles)
0138 % hObject    handle to listbox_maskPaths (see GCBO)
0139 % eventdata  reserved - to be defined in a future version of MATLAB
0140 % handles    empty - handles not created until after all CreateFcns called
0141 
0142 % Hint: edit controls usually have a white background on Windows.
0143 %       See ISPC and COMPUTER.
0144 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0145     set(hObject,'BackgroundColor','white');
0146 end
0147 
0148 set(hObject,'value',[],'max',2,'min',0,'String',cell(0));
0149 
0150 
0151 % --- Executes on button press in pushbutton_addMaskPaths.
0152 function pushbutton_addMaskPaths_Callback(hObject, eventdata, handles)
0153 % hObject    handle to pushbutton_addMaskPaths (see GCBO)
0154 % eventdata  reserved - to be defined in a future version of MATLAB
0155 % handles    structure with handles and user data (see GUIDATA)
0156 
0157 [importMaskFile,importMaskPath,~] = uigetfile({'*.nrrd', 'NRRD-Files'}, 'Choose the binary mask files...','MultiSelect','on');
0158 if ~isempty(importMaskFile)
0159     if ~iscell(importMaskFile)
0160         tmpName = importMaskFile;
0161         importMaskFile = cell(1);
0162         importMaskFile{1} = tmpName;
0163     end
0164     importMaskFile = cellfun(@(filename) fullfile(importMaskPath,filename),importMaskFile,'UniformOutput',false);
0165     entries = get(handles.listbox_maskPaths,'String');
0166     newEntries = [entries importMaskFile];
0167     set(handles.listbox_maskPaths,'String',newEntries);
0168     % Update handles structure
0169     guidata(hObject, handles);
0170 end
0171 
0172 
0173 % --- Executes on button press in pushbutton_import.
0174 function pushbutton_import_Callback(hObject, eventdata, handles)
0175 % hObject    handle to pushbutton_import (see GCBO)
0176 % eventdata  reserved - to be defined in a future version of MATLAB
0177 % handles    structure with handles and user data (see GUIDATA)
0178 
0179 ctFile = get(handles.edit_ctPath,'String');
0180 maskFiles = get(handles.listbox_maskPaths,'String');
0181 
0182 if isempty(ctFile) || isempty(maskFiles)
0183     errordlg('Please sepecify a CT and at least one mask!');
0184 end
0185 
0186 convertHU = get(handles.checkbox_huConvert,'Value');
0187 
0188 if convertHU
0189     [ct,cst] = matRad_importPatient(ctFile,maskFiles,get(handles.edit_hlut,'String'));
0190 else
0191     [ct,cst] = matRad_importPatient(ctFile,maskFiles);
0192 end
0193 
0194 cst = showCheckDialog(cst);
0195 
0196 assignin('base', 'ct', ct);
0197 assignin('base', 'cst', cst);
0198 
0199 delete(handles.figure_importDialog);
0200 
0201 
0202 % --- Executes on button press in pushbutton_cancel.
0203 function pushbutton_cancel_Callback(hObject, eventdata, handles)
0204 % hObject    handle to pushbutton_cancel (see GCBO)
0205 % eventdata  reserved - to be defined in a future version of MATLAB
0206 % handles    structure with handles and user data (see GUIDATA)
0207 delete(handles.figure_importDialog);
0208 
0209 
0210 % --- Executes on button press in pushbutton_addMaskFolders.
0211 function pushbutton_addMaskFolders_Callback(hObject, eventdata, handles)
0212 % hObject    handle to pushbutton_addMaskFolders (see GCBO)
0213 % eventdata  reserved - to be defined in a future version of MATLAB
0214 % handles    structure with handles and user data (see GUIDATA)
0215 importMaskPath = uigetdir('./', 'Choose the folder containing binary mask files...');
0216 importMaskPath = [importMaskPath filesep];
0217 if ~isempty(importMaskPath)
0218     entries = get(handles.listbox_maskPaths,'String');
0219     newEntries = [entries cellstr(importMaskPath)];
0220     set(handles.listbox_maskPaths,'String',newEntries);
0221     % Update handles structure
0222     guidata(hObject, handles);
0223 end
0224 
0225 % --- Executes on key press with focus on listbox_maskPaths and none of its controls.
0226 function listbox_maskPaths_KeyPressFcn(hObject, eventdata, handles)
0227 % hObject    handle to listbox_maskPaths (see GCBO)
0228 % eventdata  structure with the following fields (see MATLAB.UI.CONTROL.UICONTROL)
0229 %    Key: name of the key that was pressed, in lower case
0230 %    Character: character interpretation of the key(s) that was pressed
0231 %    Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
0232 % handles    structure with handles and user data (see GUIDATA)
0233 if isequal(eventdata.Key,'delete') || isequal(eventdata.Key,'backspace')
0234     selectIndex = get(hObject,'value');
0235     entries = get(hObject,'String');
0236     if numel(entries) == 0
0237         return;
0238     end
0239     entries(selectIndex) = [];
0240     if selectIndex > numel(entries) && selectIndex > 1
0241         selectIndex = selectIndex - 1;
0242     end
0243     set(hObject,'String',entries,'value',selectIndex);
0244 end
0245 
0246 % --- Creates a Dialog for the final adaptations to VOIs and CT conversion
0247 function cst = showCheckDialog(cst)
0248 
0249 handle = dialog('Position', [100 100 400 250],'WindowStyle','modal','Name','Confirm Segmentations');
0250 
0251 %Create Table
0252 hTable = uitable('Parent',handle,'Units','normal','Position',[0.1 0.2 0.8 0.8]);
0253 hTable.Data = cst(:,2:3);
0254 hTable.ColumnName = {'Name','Type'};
0255 hTable.ColumnWidth = {150,'auto'};
0256 hTable.RowName = [];
0257 hTable.ColumnEditable = [true true];
0258 hTable.ColumnFormat = {'char',{'TARGET', 'OAR', 'IGNORED'}};
0259 
0260 %Create Button
0261 hButton = uicontrol(handle,'Style','pushbutton','String','Confirm','Units','normal','Position',[0.7 0.05 0.2 0.1],'Callback','uiresume(gcbf)');%{@pushbutton_confirm_vois_callback});
0262 try
0263     uiwait(handle);
0264     cst(:,2:3) = hTable.Data(:,:);
0265 catch
0266     warning('Closed checkdialog without confirmation! Using default cst information!');
0267 end
0268 delete(handle);
0269 
0270 
0271 % --- Executes on button press in checkbox_huConvert.
0272 function checkbox_huConvert_Callback(hObject, eventdata, handles)
0273 % hObject    handle to checkbox_huConvert (see GCBO)
0274 % eventdata  reserved - to be defined in a future version of MATLAB
0275 % handles    structure with handles and user data (see GUIDATA)
0276 
0277 % Hint: get(hObject,'Value') returns toggle state of checkbox_huConvert
0278 
0279 checked = get(hObject,'Value');
0280 
0281 if checked
0282     fieldState = 'on';
0283 else
0284     fieldState = 'off';
0285 end
0286 
0287 
0288 set(handles.edit_hlut,'Enable',fieldState);
0289 set(handles.pushbutton_hlutFile,'Enable',fieldState);
0290 
0291 
0292 function edit_hlut_Callback(hObject, eventdata, handles)
0293 % hObject    handle to edit_hlut (see GCBO)
0294 % eventdata  reserved - to be defined in a future version of MATLAB
0295 % handles    structure with handles and user data (see GUIDATA)
0296 
0297 % Hints: get(hObject,'String') returns contents of edit_hlut as text
0298 %        str2double(get(hObject,'String')) returns contents of edit_hlut as a double
0299 
0300 
0301 % --- Executes during object creation, after setting all properties.
0302 function edit_hlut_CreateFcn(hObject, eventdata, handles)
0303 % hObject    handle to edit_hlut (see GCBO)
0304 % eventdata  reserved - to be defined in a future version of MATLAB
0305 % handles    empty - handles not created until after all CreateFcns called
0306 
0307 % Hint: edit controls usually have a white background on Windows.
0308 %       See ISPC and COMPUTER.
0309 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0310     set(hObject,'BackgroundColor','white');
0311 end
0312 
0313 
0314 % --- Executes on button press in pushbutton_hlutFile.
0315 function pushbutton_hlutFile_Callback(hObject, eventdata, handles)
0316 % hObject    handle to pushbutton_hlutFile (see GCBO)
0317 % eventdata  reserved - to be defined in a future version of MATLAB
0318 % handles    structure with handles and user data (see GUIDATA)
0319 
0320 [importHLUTFile,importHLUTPath,~] = uigetfile({'*.hlut', 'matRad HLUT-Files'}, 'Choose the HLUT file...');
0321 if importHLUTFile ~= 0
0322     set(handles.edit_hlut,'String',fullfile(importHLUTPath,importHLUTFile));
0323     % Update handles structure
0324     guidata(hObject, handles);
0325 end

| Generated by m2html © 2005