74 lines
2.0 KiB
Matlab
74 lines
2.0 KiB
Matlab
function output = exist(obj, varargin)
|
|
%EXIST Check if a run exists
|
|
% exist(PP) checks the existence of run PP if PP has a specified
|
|
% experiment and irec.
|
|
%
|
|
% exist(PP, 'full', true) checks if all channels are actually present. If
|
|
% full is false, a single channel is sufficient to return true on whether
|
|
% the run exists. Eventtimes and other files are never checked. Default:
|
|
% false
|
|
%
|
|
% exist(PP, 'directMode', true) checks if there is a run in the _direct
|
|
% folder, meaning it has just completed by the neuron program. Default:
|
|
% false
|
|
|
|
% Handle input
|
|
p = inputParser();
|
|
p.addParamValue('full', false);
|
|
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
|
|
doesExist = 0;
|
|
|
|
% Variables
|
|
flExt = obj.sim_channels;
|
|
|
|
% If a single channel exists, consider the run as existing
|
|
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')
|
|
doesExist = doesExist + 1;
|
|
end
|
|
end
|
|
|
|
% Handle doesExist
|
|
if p.full
|
|
doesExist = doesExist >= numel(flExt);
|
|
else
|
|
doesExist = doesExist > 1;
|
|
end
|
|
|
|
% Output
|
|
output = doesExist;
|
|
if nargout == 0
|
|
switch doesExist
|
|
case 0
|
|
fprintf('Run %i does not exist\n', irec);
|
|
case 1
|
|
fprintf('Run %i exists\n', irec);
|
|
end
|
|
end
|
|
|
|
end
|