|
9 | 9 | warningsState)); |
10 | 10 |
|
11 | 11 | %% Check the parameters |
12 | | - if nargin < 1 || ~isstruct(EEG) |
13 | | - error('postProcess:NotEnoughArguments', 'first argument must be a structure'); |
14 | | - elseif nargin < 2 || ~exist('postIn', 'var') || isempty(postIn) |
15 | | - postIn = struct(); |
16 | | - end |
17 | | - if ~isstruct(postIn) |
18 | | - error('postProcess:NoData', 'second argument must be a structure') |
19 | | - end |
20 | | - postOut = struct('keepFiltered', [], 'removeInterpolatedChannels', [], ... |
21 | | - 'cleanupReference', []); |
22 | | - defaults = getPrepDefaults(EEG, 'postprocess'); |
| 12 | +postOut = struct(); |
23 | 13 |
|
24 | | - [postOut, errors] = checkPrepDefaults(postIn, postOut, defaults); |
25 | | - if ~isempty(errors) |
26 | | - error('postProcess:BadParameters', ['|' sprintf('%s|', errors{:})]); |
27 | | - end |
28 | | - defaults = getPrepDefaults(EEG, 'general'); |
29 | | - [postOut, errors] = checkPrepDefaults(postOut, postOut, defaults); |
30 | | - if ~isempty(errors) |
31 | | - error('postProcess:BadGeneralParameters', ['|' sprintf('%s|', errors{:})]); |
| 14 | +%% Initial setup |
| 15 | + try |
| 16 | + %% Check the input |
| 17 | + if nargin < 1 || ~isstruct(EEG) |
| 18 | + error('postProcess:NotEnoughArguments', 'first argument must be a structure'); |
| 19 | + elseif nargin < 2 || ~exist('postIn', 'var') || isempty(postIn) |
| 20 | + postIn = struct(); |
| 21 | + end |
| 22 | + if ~isstruct(postIn) |
| 23 | + error('postProcess:NoData', 'second argument must be a structure') |
| 24 | + end |
| 25 | + if ~isfield(EEG, 'etc') || ~isfield(EEG.etc, 'noiseDetection') || ... |
| 26 | + hasPrepErrors(EEG.etc.noiseDetection) |
| 27 | + error('postProcess:NoPrep', 'Prep has not executed or has errors'); |
| 28 | + end |
| 29 | + |
| 30 | + %% Set up the output structure |
| 31 | + postOut = struct('keepFiltered', [], 'removeInterpolatedChannels', [], ... |
| 32 | + 'cleanupReference', []); |
| 33 | + defaults = getPrepDefaults(EEG, 'postprocess'); |
| 34 | + |
| 35 | + [postOut, errors] = checkPrepDefaults(postIn, postOut, defaults); |
| 36 | + if ~isempty(errors) |
| 37 | + error('postProcess:BadParameters', ['|' sprintf('%s|', errors{:})]); |
| 38 | + end |
| 39 | + defaults = getPrepDefaults(EEG, 'general'); |
| 40 | + [postOut, errors] = checkPrepDefaults(postOut, postOut, defaults); |
| 41 | + if ~isempty(errors) |
| 42 | + error('postProcess:BadGeneralParameters', ['|' sprintf('%s|', errors{:})]); |
| 43 | + end |
| 44 | + EEG.etc.noiseDetection.postProcess = postOut; |
| 45 | + |
| 46 | + catch mex |
| 47 | + errorMessages.setup = ... |
| 48 | + ['postProcessing failed due to previous issues: ' ... |
| 49 | + getReport(mex, 'basic', 'hyperlinks', 'off')]; |
| 50 | + EEG.etc.noiseDetection.errors.postProcess = errorMessages; |
| 51 | + return; |
32 | 52 | end |
33 | | - EEG.etc.noiseDetection.postProcess = postOut; |
34 | | - |
| 53 | + |
35 | 54 | %% Perform filtering if requested |
36 | 55 | try |
37 | 56 | if postOut.keepFiltered |
|
100 | 119 | end |
101 | 120 | return; |
102 | 121 | end |
| 122 | + |
| 123 | + %% If we got this far everything was good |
| 124 | + EEG.etc.noiseDetection.errors.postProcess = 0; |
103 | 125 | end |
104 | 126 |
|
105 | 127 | %% Cleanup callback |
|
0 commit comments