Skip to content

Commit

Permalink
Merge pull request #55 from DIDSR/registrationInterface
Browse files Browse the repository at this point in the history
Registration interface
1.	Edit code for dynamic start and stop. It is available for all tasks and input files
2.	Update all input files for autoreg and WSI scale.
3.	Add GetExecutableFolder.m function to solve the short cut problem
4.	Solve compiled version random order problem.
  • Loading branch information
qigongFDA authored Oct 6, 2017
2 parents 896b764 + 2acf257 commit d340f56
Show file tree
Hide file tree
Showing 55 changed files with 2,152 additions and 629 deletions.
6 changes: 4 additions & 2 deletions src/Administrator_Input_Screen.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ function Administrator_Input_Screen_OpeningFcn(hObject, eventdata, handles, vara
% that the window of this GUI is positioned to the exact center of the
% screen regardsless of the screen size of aspect ratio.
%--------------------------------------------------------------------------

ExecutableFolder = GetExecutableFolder();
cd(ExecutableFolder);
handles.output = hObject;
modes=get(handles.ModeSelectionPopUpMenu,'String'); %#ok<NASGU>

Expand All @@ -51,7 +52,8 @@ function Administrator_Input_Screen_OpeningFcn(hObject, eventdata, handles, vara
handles.myData.wsi_files = [];
handles.myData.graphics = struct;

addpath('gui_graphics', 'icc_profiles', 'tasks','stages/Prior','stages/Ludl');
%addpath('gui_graphics', 'icc_profiles', 'tasks','stages/Prior','stages/Ludl');
addpath('icc_profiles', 'tasks','stages/Prior','stages/Ludl');

handles.myData.sourcedir = [cd, '\'];

Expand Down
2 changes: 2 additions & 0 deletions src/Camera_stage_review.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ function Camera_stage_review_OpeningFcn(hObject, eventdata, handles, varargin)
% varargin command line arguments to Camera_stage_review (see VARARGIN)

% Choose default command line output for Camera_stage_review
ExecutableFolder = GetExecutableFolder();
cd(ExecutableFolder);
desc = {'\bfWelcome'...
,'Please choose the camera format'};
welcome_page(handles,desc );
Expand Down
270 changes: 180 additions & 90 deletions src/GUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ function GUI_OpeningFcn(hObj, eventdata, handles, varargin)
% The mode_index and the filename for the test are extracted from the
% cell structure varargin. varargin stores the input arguments for the
% whole Matlab application
addpath('gui_graphics', 'icc_profiles', 'tasks','stages/Prior','stages/Ludl');
%addpath('gui_graphics', 'icc_profiles', 'tasks','stages/Prior','stages/Ludl');
addpath('icc_profiles', 'tasks','stages/Prior','stages/Ludl');
handles_old = varargin{1};
handles.Administrator_Input_Screen = handles_old.Administrator_Input_Screen;
myData = handles_old.myData;
Expand All @@ -189,10 +190,10 @@ function GUI_OpeningFcn(hObj, eventdata, handles, varargin)
handles.current = struct;
% The images used in the GUI are loaded into the memory and into the
% structure myData
myData.graphics.zooming_allowed=imread('zooming_allowed.bmp');
myData.graphics.zooming_not_allowed=imread('zooming_not_allowed.bmp');
myData.graphics.moving_allowed=imread('moving_allowed.bmp');
myData.graphics.moving_not_allowed=imread('moving_not_allowed.bmp');
% myData.graphics.zooming_allowed=imread('zooming_allowed.bmp');
% myData.graphics.zooming_not_allowed=imread('zooming_not_allowed.bmp');
% myData.graphics.moving_allowed=imread('moving_allowed.bmp');
% myData.graphics.moving_not_allowed=imread('moving_not_allowed.bmp');

% save myData
handles.myData = myData;
Expand Down Expand Up @@ -364,21 +365,21 @@ function Initiate_GUI_Elements(handles)

% The image objects for the indicators for panning and zooming are
% created
handles.zooming_indication=...
image(myData.graphics.zooming_not_allowed,'Parent',handles.ZoomingInfoImage);
set(handles.zooming_indication,'visible','off');
handles.moving_indication=...
image(myData.graphics.moving_not_allowed,'Parent',handles.PanningInfoImage);
set(handles.moving_indication,'visible','off');

set(handles.ZoomingInfoImage, ...
'xtick', [], ...
'ytick', [], ...
'Visible','off');
set(handles.PanningInfoImage, ...
'xtick', [], ...
'ytick', [], ...
'Visible','off');
% handles.zooming_indication=...
% image(myData.graphics.zooming_not_allowed,'Parent',handles.ZoomingInfoImage);
% set(handles.zooming_indication,'visible','off');
% handles.moving_indication=...
% image(myData.graphics.moving_not_allowed,'Parent',handles.PanningInfoImage);
% set(handles.moving_indication,'visible','off');
%
% set(handles.ZoomingInfoImage, ...
% 'xtick', [], ...
% 'ytick', [], ...
% 'Visible','off');
% set(handles.PanningInfoImage, ...
% 'xtick', [], ...
% 'ytick', [], ...
% 'Visible','off');

% Foreground color, background color and the background color of the
% axes is adjusted in accordance with the settings acquired from the
Expand Down Expand Up @@ -484,14 +485,19 @@ function NextButtonPressed(hObj, eventdata, handles) %#ok<DEFNU>
taskinfo.duration = etime(handles.myData.EndTime, handles.myData.StartTime)+taskinfo.duration;
handles.myData.tasks_out{handles.myData.iter} = taskinfo;
guidata(handles.GUI, handles);
% Close out completed task

st = dbstack;
if ~strcmp(st(2).name,'Backbutton_Callback')
% exort output file
if ~strcmp(st(2).name,'Backbutton_Callback')

taskinfo.calling_function = st(1).name;
handles.myData.taskinfo = taskinfo;
guidata(handles.GUI, handles);
taskinfo.task_handle(handles.GUI);
handles = guidata(handles.GUI);
exportOutput(handles.GUI);
handles = guidata(handles.GUI);

end
% If the completed task was a 'finish' task, then return
switch taskinfo.id
Expand Down Expand Up @@ -569,10 +575,12 @@ function NextButtonPressed(hObj, eventdata, handles) %#ok<DEFNU>
moveEndTime = clock;
taskinfo.durationMove = etime(moveEndTime, moveStartTime);
%auto fast register
autoRegStartTime = clock;
Fast_Register_Button_Callback(hObj, eventdata, handles);
autoRegEndTime = clock;
taskinfo.durationAutoReg = etime(autoRegEndTime,autoRegStartTime);
if myData.settings.autoreg == 1
autoRegStartTime = clock;
Fast_Register_Button_Callback(hObj, eventdata, handles);
autoRegEndTime = clock;
taskinfo.durationAutoReg = etime(autoRegEndTime,autoRegStartTime);
end

end
end
Expand Down Expand Up @@ -644,7 +652,43 @@ function abortbutton_Callback(hObject, eventdata, handles) %#ok<DEFNU>
% hObject handle to abortbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Save and export current task information
% myData=handles.myData;
% taskinfo = myData.tasks_out{myData.iter};
% guidata(handles.GUI, handles);
% switch taskinfo.id
% case 'finish'
%
% close all force
% return
%
% end
% st = dbstack;
% taskinfo.calling_function = st(1).name;
% handles.myData.taskinfo = taskinfo;
% guidata(handles.GUI, handles);
% taskinfo.task_handle(handles.GUI);
% handles = guidata(handles.GUI);
%
% % Save and export rest task information
% while(handles.myData.iter<=handles.myData.ntasks)
% handles.myData.iter = handles.myData.iter+1;
% guidata(handles.GUI, handles);
% taskinfo = handles.myData.tasks_out{handles.myData.iter};
% taskinfo.calling_function = st(1).name;
% handles.myData.taskinfo = taskinfo;
% guidata(handles.GUI,handles);
% taskinfo.task_handle(handles.GUI);
% handles = guidata(handles.GUI);
% % If the current task is 'finish' task, then return
% switch taskinfo.id
% case 'finish'
% Update_GUI_Elements(handles);
% return
%
% end
% end
% fclose(handles.myData.fid);
close all force

catch ME
Expand Down Expand Up @@ -836,70 +880,70 @@ function GUI_WindowButtonMotionFcn(hObject, eventdata, handles)
% handles structure with handles and user data (see GUIDATA)
end

function winBtnMotionFcn(hObj,eventdata,handles) %#ok<DEFNU>
try
%----------------------------------------------------------------------
% winBtnMotionFcn (nested under winBtnDownFcn)
% This function is called when click-n-drag (panning) is happening
%----------------------------------------------------------------------
pt = get(handles.ImageAxes, 'currentpoint');

% Update axes limits and automatically set ticks
% Set aspect ratios
set(handles.ImageAxes, ...
'xlim', get(handles.ImageAxes, 'xlim') + ...
(handles.panning_Zooming_Tool.xy(1,1)-(pt(1,1)+pt(2,1))/2), ...
'ylim', get(handles.ImageAxes, 'ylim') + ...
(handles.panning_Zooming_Tool.xy(1,2)-(pt(1,2)+pt(2,2))/2), ...
'cameraviewanglemode', 'auto', ...
'plotboxaspectratio', handles.panning_Zooming_Tool.pbar);

guidata(hObj, handles);
catch ME
error_show(ME)
end
end
% function winBtnMotionFcn(hObj,eventdata,handles) %#ok<DEFNU>
% try
% %----------------------------------------------------------------------
% % winBtnMotionFcn (nested under winBtnDownFcn)
% % This function is called when click-n-drag (panning) is happening
% %----------------------------------------------------------------------
% pt = get(handles.ImageAxes, 'currentpoint');
%
% % Update axes limits and automatically set ticks
% % Set aspect ratios
% set(handles.ImageAxes, ...
% 'xlim', get(handles.ImageAxes, 'xlim') + ...
% (handles.panning_Zooming_Tool.xy(1,1)-(pt(1,1)+pt(2,1))/2), ...
% 'ylim', get(handles.ImageAxes, 'ylim') + ...
% (handles.panning_Zooming_Tool.xy(1,2)-(pt(1,2)+pt(2,2))/2), ...
% 'cameraviewanglemode', 'auto', ...
% 'plotboxaspectratio', handles.panning_Zooming_Tool.pbar);
%
% guidata(hObj, handles);
% catch ME
% error_show(ME)
% end
% end

function zoomMotionFcn(hObj,eventdata,handles) %#ok<DEFNU>
try
%----------------------------------------------------------------------
% zoomMotionFcn (nested under winBtnDownFcn)
% This performs the click-n-drag zooming function. The pointer
% location relative to the initial point determines the amount of
% zoom (in or out).
%----------------------------------------------------------------------
C = 50;
pt = get(handles.GUI, 'currentpoint');
r = C ^ (10*(handles.panning_Zooming_Tool.initPt(2) ...
- pt(2)) / handles.panning_Zooming_Tool.figPos(4));
newLimSpan = r * handles.panning_Zooming_Tool.curPt2;
dTemp = diff(newLimSpan); %#ok<NASGU>
pt(1) = handles.panning_Zooming_Tool.initPt(1);

% Determine new limits based on r
lims = handles.panning_Zooming_Tool.curPt + newLimSpan;

% Update axes limits and automatically set ticks
% Set aspect ratios
set(handles.ImageAxes, ...
'xlim', lims(:,1), ...
'ylim', lims(:,2), ...
'cameraviewanglemode', 'auto', ...
'plotboxaspectratio', handles.panning_Zooming_Tool.pbar);

% Update zoom indicator line
set(handles.ZoomLine, ...
'xdata', [handles.panning_Zooming_Tool.initPt(1), ...
pt(1)]/handles.panning_Zooming_Tool.figPos(3), ...
'ydata', [handles.panning_Zooming_Tool.initPt(2), ...
pt(2)]/handles.panning_Zooming_Tool.figPos(4));

guidata(hObj, handles);

catch ME
error_show(ME)
end
end
% function zoomMotionFcn(hObj,eventdata,handles) %#ok<DEFNU>
% try
% %----------------------------------------------------------------------
% % zoomMotionFcn (nested under winBtnDownFcn)
% % This performs the click-n-drag zooming function. The pointer
% % location relative to the initial point determines the amount of
% % zoom (in or out).
% %----------------------------------------------------------------------
% C = 50;
% pt = get(handles.GUI, 'currentpoint');
% r = C ^ (10*(handles.panning_Zooming_Tool.initPt(2) ...
% - pt(2)) / handles.panning_Zooming_Tool.figPos(4));
% newLimSpan = r * handles.panning_Zooming_Tool.curPt2;
% dTemp = diff(newLimSpan); %#ok<NASGU>
% pt(1) = handles.panning_Zooming_Tool.initPt(1);
%
% % Determine new limits based on r
% lims = handles.panning_Zooming_Tool.curPt + newLimSpan;
%
% % Update axes limits and automatically set ticks
% % Set aspect ratios
% set(handles.ImageAxes, ...
% 'xlim', lims(:,1), ...
% 'ylim', lims(:,2), ...
% 'cameraviewanglemode', 'auto', ...
% 'plotboxaspectratio', handles.panning_Zooming_Tool.pbar);
%
% % Update zoom indicator line
% set(handles.ZoomLine, ...
% 'xdata', [handles.panning_Zooming_Tool.initPt(1), ...
% pt(1)]/handles.panning_Zooming_Tool.figPos(3), ...
% 'ydata', [handles.panning_Zooming_Tool.initPt(2), ...
% pt(2)]/handles.panning_Zooming_Tool.figPos(4));
%
% guidata(hObj, handles);
%
% catch ME
% error_show(ME)
% end
% end

function GUI_WindowButtonUpFcn(hObj, eventdata, handles) %#ok<DEFNU>
try
Expand Down Expand Up @@ -1178,3 +1222,49 @@ function Reticlebutton_Callback(hObject, eventdata, handles)
end


function exportOutput(hObj)
try
handles = guidata(hObj);
st = dbstack;
myData = handles.myData;
exportIter = 1;
while exportIter <= myData.finshedTask+1

taskinfo = myData.tasks_out{exportIter};
taskinfo.currentWorking = -1;
% handles.myData.tasks_out{handles.myData.iter} = taskinfo;
taskinfo.calling_function = st(1).name;
handles.myData.taskinfo = taskinfo;
guidata(handles.GUI, handles);
taskinfo.task_handle(handles.GUI);
handles = guidata(handles.GUI);
exportIter = exportIter +1;
end


while(exportIter<=handles.myData.ntasks+1)

taskinfo = handles.myData.tasks_out{exportIter};
if exportIter <= handles.myData.iter
taskinfo.currentWorking = 1;
else
taskinfo.currentWorking = 0;
end
taskinfo.calling_function = st(1).name;
handles.myData.taskinfo = taskinfo;
guidata(handles.GUI,handles);
taskinfo.task_handle(handles.GUI);
handles = guidata(handles.GUI);
exportIter = exportIter+1;
% If the current task is 'finish' task, then return
switch taskinfo.id
case 'finish'
Update_GUI_Elements(handles);
return
end
end
fclose(handles.myData.fid);
catch ME
error_show(ME)
end
end
18 changes: 18 additions & 0 deletions src/GetExecutableFolder.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function [executableFolder] = GetExecutableFolder()
try
if isdeployed
% User is running an executable in standalone mode.
[status, result] = system('set PATH');
executableFolder = char(regexpi(result, 'Path=(.*?);', 'tokens', 'once'));
% fprintf(1, '\nIn function GetExecutableFolder(), currentWorkingDirectory = %s\n', executableFolder);
else
% User is running an m-file from the MATLAB integrated development environment (regular MATLAB).
executableFolder = pwd;
end
catch ME
errorMessage = sprintf('Error in function %s() at line %d.\n\nError Message:\n%s', ...
ME.stack(1).name, ME.stack(1).line, ME.message);
uiwait(warndlg(errorMessage));
end
return;
end
Loading

0 comments on commit d340f56

Please sign in to comment.