Skip to content

Commit

Permalink
Fix for timeDriftPP to run in the background in auto mode without any…
Browse files Browse the repository at this point in the history
… input required.
  • Loading branch information
ggalibert committed Jun 13, 2017
1 parent 0939b9b commit 41460b6
Showing 1 changed file with 74 additions and 72 deletions.
146 changes: 74 additions & 72 deletions Preprocessing/timeDriftPP.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,86 +105,88 @@
end
end

f = figure(...
'Name', 'Time start and end drift calculations in seconds',...
'Visible', 'off',...
'MenuBar' , 'none',...
'Resize', 'off',...
'WindowStyle', 'Modal',...
'NumberTitle', 'off');

cancelButton = uicontrol('Style', 'pushbutton', 'String', 'Cancel');
confirmButton = uicontrol('Style', 'pushbutton', 'String', 'Ok');

setCheckboxes = [];
startOffsetFields = [];
endOffsetFields = [];

for k = 1:nSample
if ~auto
f = figure(...
'Name', 'Time start and end drift calculations in seconds',...
'Visible', 'off',...
'MenuBar' , 'none',...
'Resize', 'off',...
'WindowStyle', 'Modal',...
'NumberTitle', 'off');

setCheckboxes(k) = uicontrol(...
'Style', 'checkbox',...
'String', descs{k},...
'Value', 1, ...
'UserData', k);
cancelButton = uicontrol('Style', 'pushbutton', 'String', 'Cancel');
confirmButton = uicontrol('Style', 'pushbutton', 'String', 'Ok');

startOffsetFields(k) = uicontrol(...
'Style', 'edit',...
'UserData', k, ...
'String', num2str(startOffsets(k)));
setCheckboxes = [];
startOffsetFields = [];
endOffsetFields = [];

endOffsetFields(k) = uicontrol(...
'Style', 'edit',...
'UserData', k, ...
'String', num2str(endOffsets(k)));
for k = 1:nSample

setCheckboxes(k) = uicontrol(...
'Style', 'checkbox',...
'String', descs{k},...
'Value', 1, ...
'UserData', k);

startOffsetFields(k) = uicontrol(...
'Style', 'edit',...
'UserData', k, ...
'String', num2str(startOffsets(k)));

endOffsetFields(k) = uicontrol(...
'Style', 'edit',...
'UserData', k, ...
'String', num2str(endOffsets(k)));

end

end

% set all widgets to normalized for positioning
set(f, 'Units', 'normalized');
set(cancelButton, 'Units', 'normalized');
set(confirmButton, 'Units', 'normalized');
set(setCheckboxes, 'Units', 'normalized');
set(startOffsetFields, 'Units', 'normalized');
set(endOffsetFields, 'Units', 'normalized');

set(f, 'Position', [0.2 0.35 0.6 0.0222 * (nSample + 1)]); % need to include 1 extra space for the row of buttons

rowHeight = 1 / (nSample + 1);

set(cancelButton, 'Position', [0.0 0.0 0.5 rowHeight]);
set(confirmButton, 'Position', [0.5 0.0 0.5 rowHeight]);

for k = 1:nSample
% set all widgets to normalized for positioning
set(f, 'Units', 'normalized');
set(cancelButton, 'Units', 'normalized');
set(confirmButton, 'Units', 'normalized');
set(setCheckboxes, 'Units', 'normalized');
set(startOffsetFields, 'Units', 'normalized');
set(endOffsetFields, 'Units', 'normalized');

set(f, 'Position', [0.2 0.35 0.6 0.0222 * (nSample + 1)]); % need to include 1 extra space for the row of buttons

rowHeight = 1 / (nSample + 1);

set(cancelButton, 'Position', [0.0 0.0 0.5 rowHeight]);
set(confirmButton, 'Position', [0.5 0.0 0.5 rowHeight]);

for k = 1:nSample

rowStart = 1.0 - k * rowHeight;

set(setCheckboxes (k), 'Position', [0.0 rowStart 0.6 rowHeight]);
set(startOffsetFields (k), 'Position', [0.6 rowStart 0.2 rowHeight]);
set(endOffsetFields (k), 'Position', [0.8 rowStart 0.2 rowHeight]);
end

% set back to pixels
set(f, 'Units', 'normalized');
set(cancelButton, 'Units', 'normalized');
set(confirmButton, 'Units', 'normalized');
set(setCheckboxes, 'Units', 'normalized');
set(startOffsetFields, 'Units', 'normalized');
set(endOffsetFields, 'Units', 'normalized');

rowStart = 1.0 - k * rowHeight;
% set widget callbacks
set(f, 'CloseRequestFcn', @cancelCallback);
set(f, 'WindowKeyPressFcn', @keyPressCallback);
set(setCheckboxes, 'Callback', @checkboxCallback);
set(startOffsetFields, 'Callback', @startoffsetFieldCallback);
set(endOffsetFields, 'Callback', @endoffsetFieldCallback);
set(cancelButton, 'Callback', @cancelCallback);
set(confirmButton, 'Callback', @confirmCallback);

set(setCheckboxes (k), 'Position', [0.0 rowStart 0.6 rowHeight]);
set(startOffsetFields (k), 'Position', [0.6 rowStart 0.2 rowHeight]);
set(endOffsetFields (k), 'Position', [0.8 rowStart 0.2 rowHeight]);
set(f, 'Visible', 'on');

uiwait(f);
end

% set back to pixels
set(f, 'Units', 'normalized');
set(cancelButton, 'Units', 'normalized');
set(confirmButton, 'Units', 'normalized');
set(setCheckboxes, 'Units', 'normalized');
set(startOffsetFields, 'Units', 'normalized');
set(endOffsetFields, 'Units', 'normalized');

% set widget callbacks
set(f, 'CloseRequestFcn', @cancelCallback);
set(f, 'WindowKeyPressFcn', @keyPressCallback);
set(setCheckboxes, 'Callback', @checkboxCallback);
set(startOffsetFields, 'Callback', @startoffsetFieldCallback);
set(endOffsetFields, 'Callback', @endoffsetFieldCallback);
set(cancelButton, 'Callback', @cancelCallback);
set(confirmButton, 'Callback', @confirmCallback);

set(f, 'Visible', 'on');

uiwait(f);

% calculate the drift and apply to the selected datasets
for k = 1:nSample

Expand Down

0 comments on commit 41460b6

Please sign in to comment.