forked from e0404/matRad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First developments on independent GUI widgets
- Loading branch information
1 parent
b926ed9
commit 922c349
Showing
18 changed files
with
8,429 additions
and
10 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,318 @@ | ||
classdef importGUI_alsKlasse | ||
|
||
properties | ||
guiHandle | ||
end | ||
|
||
methods | ||
function this = importGUI_alsKlasse() | ||
|
||
this.guiHandle = this.createLayout(); | ||
|
||
% assign guidata like in guide | ||
handles = guihandles(this.guiHandle); | ||
guidata(this.guiHandle,handles); | ||
|
||
this.initialize(); | ||
end | ||
|
||
function guiHandle = createLayout(this) | ||
|
||
h1 = figure(... | ||
'PaperUnits','inches',... | ||
'MenuBar','none',... | ||
'Units','characters',... | ||
'Position',[135.8 56.7692307692308 89.2 18.3846153846154],... | ||
'Color',[0.5 0.5 0.5],... | ||
'Name','Import Patient',... | ||
'HandleVisibility','callback',... | ||
'Tag','figure_importDialog',... | ||
'WindowStyle','normal',... | ||
'PaperSize',[8.5 11],... | ||
'PaperType','usletter'); | ||
|
||
guiHandle = h1; | ||
|
||
h2 = uicontrol(... | ||
'Parent',h1,... | ||
'Units','normalized',... | ||
'String','Patient CT file [HU]:',... | ||
'BackgroundColor', [0.5 0.5 0.5],... | ||
'HorizontalAlignment','left',... | ||
'Style','text',... | ||
'Position',[0.03 0.85 0.4 0.1],... | ||
'Tag','text2'); | ||
|
||
|
||
h3 = uicontrol(... | ||
'Parent',h1,... | ||
'Units','normalized',... | ||
'Style','edit',... | ||
'Position',[0.03 0.78 0.73 0.1],... | ||
'BackgroundColor',[1 1 1],... | ||
'Callback',@(hObject,eventdata)this.edit_ctPath_Callback(hObject,eventdata,guidata(hObject)),... | ||
'Tag','edit_ctPath'); | ||
|
||
|
||
h4 = uicontrol(... | ||
'Parent',h1,... | ||
'Units','normalized',... | ||
'String','Browse...',... | ||
'BackgroundColor', [0.5 0.5 0.5],... | ||
'Position',[0.78 0.78 0.2 0.1],... | ||
'Callback',@(hObject,eventdata)this.pushbutton_ctPath_Callback(hObject,eventdata,guidata(hObject)),... | ||
'Tag','pushbutton_ctPath'); | ||
|
||
|
||
h5 = uicontrol(... | ||
'Parent',h1,... | ||
'Units','normalized',... | ||
'String','Binary Masks/Segmentations',... | ||
'HorizontalAlignment','left',... | ||
'BackgroundColor', [0.5 0.5 0.5],... | ||
'Style','text',... | ||
'Position',[0.03 0.435 0.5 0.1],... | ||
'Tag','text_masks'); | ||
|
||
|
||
h6 = uicontrol(... | ||
'Parent',h1,... | ||
'Units','normalized',... | ||
'Max',2,... | ||
'Style','listbox',... | ||
'Position',[0.03 0.15 0.73 0.32],... [1.8 3.38461538461539 66.2 4.69230769230769],... | ||
'BackgroundColor',[1 1 1],... | ||
'Callback',@(hObject,eventdata)this.listbox_maskPaths_Callback(hObject,eventdata,guidata(hObject)),... | ||
'Tag','listbox_maskPaths',... | ||
'KeyPressFcn',@(hObject,eventdata)matRad_importGUI('listbox_maskPaths_KeyPressFcn',hObject,eventdata,guidata(hObject))); | ||
|
||
|
||
h7 = uicontrol(... | ||
'Parent',h1,... | ||
'Units','normalized',... | ||
'String','Add File(s)...',... | ||
'Style',get(0,'defaultuicontrolStyle'),... | ||
'BackgroundColor', [0.5 0.5 0.5],... | ||
'Position',[0.78 0.37 0.2 0.1],... | ||
'Callback',@(hObject,eventdata)this.pushbutton_addMaskPaths_Callback(hObject,eventdata,guidata(hObject)),... | ||
'Tag','pushbutton_addMaskPaths'); | ||
|
||
|
||
h8 = uicontrol(... | ||
'Parent',h1,... | ||
'Units','normalized',... | ||
'String','Import',... | ||
'BackgroundColor', [0.5 0.5 0.5],... | ||
'Position',[0.55 0.02 0.2 0.1],... | ||
'Callback',@(hObject,eventdata)this.pushbutton_import_Callback(hObject,eventdata,guidata(hObject)),... | ||
'Tag','pushbutton_import'); | ||
|
||
|
||
h9 = uicontrol(... | ||
'Parent',h1,... | ||
'Units','normalized',... | ||
'String','Cancel',... | ||
'BackgroundColor', [0.5 0.5 0.5],... | ||
'Callback',@(hObject,eventdata)this.pushbutton_cancel_Callback(hObject,eventdata,guidatahObject),... | ||
'Position',[0.78 0.02 0.2 0.1],... | ||
'Tag','pushbutton_cancel'); | ||
|
||
|
||
h10 = uicontrol(... | ||
'Parent',h1,... | ||
'Units','normalized',... | ||
'String','Add Folder...',... | ||
'BackgroundColor', [0.5 0.5 0.5],... | ||
'Position',[0.78 0.22 0.2 0.1],... | ||
'Callback',@(hObject,eventdata)this.pushbutton_addMaskFolders_Callback(hObject,eventdata,guidata(hObject)),... | ||
'Tag','pushbutton_addMaskFolders'); | ||
|
||
|
||
h11 = uicontrol(... | ||
'Parent',h1,... | ||
'Units','normalized',... | ||
'String','Convert from HU?',... | ||
'BackgroundColor', [0.5 0.5 0.5],... | ||
'Style','checkbox',... | ||
'Position',[0.03 0.68 0.4 0.1],... | ||
'Callback',@(hObject, eventdata)this.checkbox_huConvert_Callback(hObject,eventdata,guidata(hObject)),... | ||
'Tooltip','If this is checked, the import assumes that this is a CT given in HU and will convert with the given (or the default) HLUT',... | ||
'TooltipString','If this is checked, the import assumes that this is a CT given in HU and will convert with the given (or the default) HLUT',... | ||
'Tag','checkbox_huConvert'); | ||
|
||
|
||
h12 = uicontrol(... | ||
'Parent',h1,... | ||
'Units','normalized',... | ||
'String','matRad_default.hlut',... | ||
'HorizontalAlignment','left',... | ||
'Style','edit',... | ||
'Position',[0.03 0.57 0.73 0.1],... | ||
'BackgroundColor',[1 1 1],... | ||
'Callback',@(hObject,eventdata)this.edit_hlut_Callback(hObject,eventdata,guidata(hObject)),... | ||
'Tag','edit_hlut'); | ||
|
||
|
||
h13 = uicontrol(... | ||
'Parent',h1,... | ||
'Units','normalized',... | ||
'String','HLUT file...',... | ||
'BackgroundColor', [0.5 0.5 0.5],... | ||
'Position',[0.78 0.57 0.2 0.1],... [69.8 10.6923076923077 18.2 1.76923076923077],... | ||
'Callback',@(hObject,eventdata)this.pushbutton_hlutFile_Callback(hObject,eventdata,guidata(hObject)),... | ||
'Tag','pushbutton_hlutFile'); | ||
end | ||
|
||
%OPENING/INITIALIZE FUNKTION | ||
function this = initialize(this) | ||
handles = guidata(this.guiHandle); % READ FROM GUIDATA | ||
handles.output = this.guiHandle; | ||
guidata(this.guiHandle, handles); | ||
end | ||
|
||
%OUTPUT FUNKTION | ||
function varargout = OutputFcn(hObject, eventdata, handles) | ||
varargout{1} = handles.output; | ||
end | ||
|
||
%CALLBACK FOR H3 EDIT CREATE PATH | ||
function this = edit_ctPath_Callback(this, hObject, event,handles) | ||
varargout{1} = handles.output; | ||
|
||
end | ||
|
||
%CALLBACK FOR H4 PUSHBUTTON CREATE PATH | ||
function this = pushbutton_ctPath_Callback(this, hObject, event, handles) | ||
[importCTFile,importCTPath,~] = uigetfile({'*.nrrd', 'NRRD-Files'}, 'Choose the CT file...'); | ||
|
||
if importCTFile ~= 0 | ||
set(handles.edit_ctPath,'String',fullfile(importCTPath,importCTFile)); % NON EXISTING FIELD 'edit_ctPath' | ||
% Update handles structure | ||
guidata(hObject, handles); | ||
end | ||
end | ||
|
||
%CALLBACK FOR H6 LISTBOX MASK PATHS | ||
function this = listbox_maskPaths_Callback(this, hObject, event, handles) | ||
|
||
end | ||
|
||
%CALLBACK FOR H7 PUSHBUTTON ADD MASKPATHS | ||
function this = pushbutton_addMaskPaths_Callback(this, hObject, event, handles) | ||
[importMaskFile,importMaskPath,~] = uigetfile({'*.nrrd', 'NRRD-Files'}, 'Choose the binary mask files...','MultiSelect','on'); | ||
if ~isempty(importMaskFile) | ||
if ~iscell(importMaskFile) | ||
tmpName = importMaskFile; | ||
importMaskFile = cell(1); | ||
importMaskFile{1} = tmpName; | ||
end | ||
importMaskFile = cellfun(@(filename) fullfile(importMaskPath,filename),importMaskFile,'UniformOutput',false); | ||
entries = get(handles.listbox_maskPaths,'String'); | ||
newEntries = [entries importMaskFile]; | ||
set(handles.listbox_maskPaths,'String',newEntries); | ||
% Update handles structure | ||
guidata(hObject, handles); | ||
end | ||
end | ||
|
||
function cst = showCheckDialog(this,cst) | ||
|
||
handle = dialog('Position', [100 100 400 250],'WindowStyle','modal','Name','Confirm Segmentations'); | ||
|
||
%Create Table | ||
hTable = uitable('Parent',handle,'Units','normal','Position',[0.1 0.2 0.8 0.8]); | ||
set(hTable,'Data',cst(:,2:3)); | ||
set(hTable,'ColumnName',{'Name','Type'}); | ||
set(hTable,'ColumnWidth',{150,'auto'}); | ||
set(hTable,'RowName',char([])); | ||
set(hTable,'ColumnEditable',[true true]); | ||
set(hTable,'ColumnFormat',{'char',{'TARGET', 'OAR', 'IGNORED'}}); | ||
|
||
%Create Button | ||
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}); | ||
try | ||
uiwait(handle); | ||
tmp = get(hTable,'Data'); | ||
cst(:,2:3) = tmp(:,:); | ||
catch | ||
warning('Closed checkdialog without confirmation! Using default cst information!'); | ||
end | ||
delete(handle); | ||
end | ||
|
||
%CALLBACK FOR H8 PUSHBUTTON IMPORT | ||
function this = pushbutton_import_Callback(this, hObject, event, handles) | ||
ctFile = get(handles.edit_ctPath,'String'); | ||
maskFiles = get(handles.listbox_maskPaths,'String'); | ||
|
||
if isempty(ctFile) || isempty(maskFiles) | ||
errordlg('Please sepecify a CT and at least one mask!'); | ||
end | ||
|
||
convertHU = get(handles.checkbox_huConvert,'Value'); | ||
|
||
if convertHU | ||
[ct,cst] = matRad_importPatient(ctFile,maskFiles,get(handles.edit_hlut,'String')); | ||
else | ||
[ct,cst] = matRad_importPatient(ctFile,maskFiles); | ||
end | ||
|
||
cst = this.showCheckDialog(cst); | ||
|
||
assignin('base', 'ct', ct); | ||
assignin('base', 'cst', cst); | ||
|
||
delete(handles.figure_importDialog); | ||
end | ||
|
||
%CALLBACK FOR H9 PUSHBUTTON CANCEL | ||
function this = pushbutton_cancel_Callback(this, hObject, event, handles) | ||
delete(handles.figure_importDialog); | ||
end | ||
|
||
%CALLBACK FOR H10 PUSHBUTTON ADD MASK FOLDERS | ||
function this = pushbutton_addMaskFolders_Callback(this, hObject, event, handles) | ||
importMaskPath = uigetdir('./', 'Choose the folder containing binary mask files...'); | ||
importMaskPath = [importMaskPath filesep]; | ||
if ~isempty(importMaskPath) | ||
entries = get(handles.listbox_maskPaths,'String'); | ||
newEntries = [entries cellstr(importMaskPath)]; | ||
set(handles.listbox_maskPaths,'String',newEntries); | ||
% Update handles structure | ||
guidata(hObject, handles); | ||
end | ||
end | ||
|
||
%CALLBACK FOR H11 CHECKBOX HU CONVERT | ||
function this = checkbox_huConvert_Callback(this, hObject, event, handles) | ||
checked = get(hObject,'Value'); | ||
|
||
if checked | ||
fieldState = 'on'; | ||
else | ||
fieldState = 'off'; | ||
end | ||
|
||
set(handles.edit_hlut,'Enable',fieldState); | ||
set(handles.pushbutton_hlutFile,'Enable',fieldState); | ||
end | ||
|
||
%CALLBACK FOR H12 EDIT HLUT | ||
function this = edit_hlut_Callback(this, hObject, event, handles) | ||
%bleibt leer | ||
end | ||
|
||
%CALLBACK FOR H13 PUSHBUTTON HLUT FILE | ||
function this = pushbutton_hlutFile_Callback(this, hObject, event, handles) | ||
[importHLUTFile,importHLUTPath,~] = uigetfile({'*.hlut', 'matRad HLUT-Files'}, 'Choose the HLUT file...'); | ||
if importHLUTFile ~= 0 | ||
set(handles.edit_hlut,'String',fullfile(importHLUTPath,importHLUTFile)); | ||
% Update handles structure | ||
guidata(hObject, handles); | ||
end | ||
end | ||
|
||
|
||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.