function output = delete(obj, varargin) %DELETE Delete the data of a run % delete(PP) deletes the data of run PP if PP has a specified experiment % and irec. % Handle input p = inputParser(); p.addParamValue('directMode', false); p.parse(varargin{:}); p = p.Results; % Direct mode fpath = obj.datadir(); irec = obj.irec; if p.directMode fpath = obj.directdir(); irec = obj.iter; end % The object must be a specific run assert(~isempty(experiment(obj)), 'Please specify an experiment'); assert(~isempty(irec), 'Please specify a specific run'); % Handle output isDeleted = 0; % Variables flExt = obj.sim_channels; % Delete every single channel known for ii = 1:numel(flExt) % Generate a filename if irec == 0 fname = fullfile(fpath, sprintf('run_unsaved__vm_%s.txt', flExt{ii})); else fname = fullfile(fpath, sprintf('run_%05i__vm_%s.txt', irec, flExt{ii})); end % Check if file exists if exist(fname, 'file') delete(fname); isDeleted = 1; end end % Delete other files if irec == 0 fname = fullfile(fpath, sprintf('run_unsaved__evt_contra.txt')); if exist(fname, 'file') delete(fname); isDeleted = 1; end fname = fullfile(fpath, sprintf('run_unsaved__evt_ipsi.txt')); if exist(fname, 'file') delete(fname); isDeleted = 1; end fname = fullfile(fpath, sprintf('run_unsaved__properties.ppbin')); if exist(fname, 'file') delete(fname); isDeleted = 1; end else fname = fullfile(fpath, sprintf('run_%i__evt_contra.txt', irec)); if exist(fname, 'file') delete(fname); isDeleted = 1; end fname = fullfile(fpath, sprintf('run_%i__evt_ipsi.txt', irec)); if exist(fname, 'file') delete(fname); isDeleted = 1; end fname = fullfile(fpath, sprintf('run_%i__properties.ppbin', irec)); if exist(fname, 'file') delete(fname); isDeleted = 1; end end % Output output = isDeleted; if nargout == 0 switch isDeleted case 0 fprintf('Run %i is not deleted\n', irec); case 1 fprintf('Run %i is deleted\n', irec); end end end