Skip to content

Commit

Permalink
enhancement - some updates to the order of the preambles, fixed an is…
Browse files Browse the repository at this point in the history
…sue with outputfilepresent and ft_default

git-svn-id: svn+ssh://svn.fcdonders.nl/home/svnroot/fieldtrip/trunk@10556 0cf7c7f0-3615-4144-b4e6-68da3bce3cd0
  • Loading branch information
robertoostenveld committed Jul 17, 2015
1 parent 9f90359 commit 08bc4d5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ft_analysispipeline.m
Expand Up @@ -90,7 +90,7 @@
ft_defaults
ft_preamble init
ft_preamble loadvar data
ft_preamble provenance
ft_preamble provenance data
ft_preamble trackconfig
ft_preamble debug

Expand Down
10 changes: 5 additions & 5 deletions ft_math.m
Expand Up @@ -90,12 +90,12 @@

revision = '$Id$';

ft_defaults % this ensures that the path is correct and that the ft_defaults global variable is available
ft_preamble init % this will show the function help if nargin==0 and return an error
ft_preamble provenance % this records the time and memory usage at the beginning of the function
ft_preamble trackconfig % this converts the cfg structure in a config object, which tracks the cfg options that are being used
ft_defaults % this ensures that the path is correct and that the ft_defaults global variable is available
ft_preamble init % this will show the function help if nargin==0 and return an error
ft_preamble loadvar varargin % this reads the input data in case the user specified the cfg.inputfile option
ft_preamble provenance varargin % this records the time and memory usage at the beginning of the function
ft_preamble trackconfig % this converts the cfg structure in a config object, which tracks the cfg options that are being used
ft_preamble debug
ft_preamble loadvar varargin % this reads the input data in case the user specified the cfg.inputfile option

% the abort variable is set to true or false in ft_preamble_init
if abort
Expand Down
18 changes: 10 additions & 8 deletions utilities/private/ft_preamble_init.m
Expand Up @@ -28,10 +28,11 @@
%
% $Id$

if false
% disabled for now, see further down
global ft_default
end
% disabled for now, see further down
global ft_default

% this script requires some options that can be user-specified, but otherwise are obtained from ft_default
cfg = mergeconfig(cfg, keepfields(ft_default, {'outpuitfile', 'outputfilepresent'}));

if nargin==0
stack = dbstack('-completenames');
Expand All @@ -49,18 +50,19 @@

% determine whether function execution should be aborted or continued
if isfield(cfg, 'outputfile') && ~isempty(cfg.outputfile)
assert(any(strcmp(fieldnames(cfg), 'outputfilepresent')), 'cfg.outputfilepresent is a required option, please see FT_DEFAULTS');
% check whether the output file already exists
[p, f, x] = fileparts(cfg.outputfile);
if isempty(p)
% relative path was speciield
% the relative path was speciield
outputfile = fullfile(pwd, cfg.outputfile);
else
% absolute path was specified
% the absolute path was specified
outputfile = cfg.outputfile;
end
if ~exist(outputfile, 'file')
abort = false;
elseif isfield(cfg, 'outputfilepresent')
else
% the output file exists, determine how to deal with it
switch cfg.outputfilepresent
case 'keep'
Expand All @@ -83,7 +85,7 @@
end % case
end
else
% default is not to abort
% there is no reason to abort execution
abort = false;
end % if outputfile

Expand Down

0 comments on commit 08bc4d5

Please sign in to comment.