|
a |
|
b/functions/adminfunc/eeg_retrieve.m |
|
|
1 |
% EEG_RETRIEVE - Retrieve an EEG dataset from the variable |
|
|
2 |
% containing all datasets (standard: ALLEEG). |
|
|
3 |
% |
|
|
4 |
% Usage: >> EEG = eeg_retrieve( ALLEEG, index ); |
|
|
5 |
% |
|
|
6 |
% Inputs: |
|
|
7 |
% ALLEEG - variable containing all datasets |
|
|
8 |
% index - index of the dataset to retrieve |
|
|
9 |
% |
|
|
10 |
% Outputs: |
|
|
11 |
% EEG - output dataset. The workspace variable EEG is also updated |
|
|
12 |
% ALLEEG - updated ALLEEG structure |
|
|
13 |
% CURRENTSET - workspace variable index of the current dataset |
|
|
14 |
% |
|
|
15 |
% Note: The function performs >> EEG = ALLEEG(index); |
|
|
16 |
% It also runs EEG_CHECKSET on it. |
|
|
17 |
% |
|
|
18 |
% Author: Arnaud Delorme, CNL / Salk Institute, 2001 |
|
|
19 |
% |
|
|
20 |
% See also: EEG_STORE, EEGLAB |
|
|
21 |
|
|
|
22 |
% Copyright (C) 2001 Arnaud Delorme, Salk Institute, arno@salk.edu |
|
|
23 |
% |
|
|
24 |
% This file is part of EEGLAB, see http://www.eeglab.org |
|
|
25 |
% for the documentation and details. |
|
|
26 |
% |
|
|
27 |
% Redistribution and use in source and binary forms, with or without |
|
|
28 |
% modification, are permitted provided that the following conditions are met: |
|
|
29 |
% |
|
|
30 |
% 1. Redistributions of source code must retain the above copyright notice, |
|
|
31 |
% this list of conditions and the following disclaimer. |
|
|
32 |
% |
|
|
33 |
% 2. Redistributions in binary form must reproduce the above copyright notice, |
|
|
34 |
% this list of conditions and the following disclaimer in the documentation |
|
|
35 |
% and/or other materials provided with the distribution. |
|
|
36 |
% |
|
|
37 |
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
|
38 |
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
|
39 |
% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
|
40 |
% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
|
41 |
% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
|
42 |
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
|
43 |
% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
|
44 |
% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
|
45 |
% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
|
46 |
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
|
|
47 |
% THE POSSIBILITY OF SUCH DAMAGE. |
|
|
48 |
|
|
|
49 |
function [EEG, ALLEEG, CURRENTSET] = eeg_retrieve( ALLEEG, CURRENTSET) |
|
|
50 |
|
|
|
51 |
if nargin < 2 |
|
|
52 |
help eeg_retrieve; |
|
|
53 |
return; |
|
|
54 |
end; |
|
|
55 |
|
|
|
56 |
%try |
|
|
57 |
eeglab_options; |
|
|
58 |
|
|
|
59 |
try, % check whether recent changes to this dataset have been saved or not |
|
|
60 |
%-------------------------------------------------------------------- |
|
|
61 |
tmpsaved = { ALLEEG.saved }; |
|
|
62 |
tmpsaved = tmpsaved(CURRENTSET); |
|
|
63 |
catch, tmpsaved = 'no'; |
|
|
64 |
end |
|
|
65 |
|
|
|
66 |
if length(CURRENTSET) > 1 && option_storedisk |
|
|
67 |
[ EEG, ~ ] = eeg_checkset(ALLEEG(CURRENTSET)); % do not load data if several datasets |
|
|
68 |
if length(CURRENTSET) ~= length(ALLEEG) |
|
|
69 |
[ALLEEG, EEG, CURRENTSET] = eeg_store(ALLEEG, EEG, CURRENTSET); |
|
|
70 |
else |
|
|
71 |
ALLEEG = EEG; |
|
|
72 |
end |
|
|
73 |
else |
|
|
74 |
if CURRENTSET ~= 0 |
|
|
75 |
[ EEG, ~ ] = eeg_checkset(ALLEEG(CURRENTSET), 'loaddata'); |
|
|
76 |
[ALLEEG, EEG, CURRENTSET] = eeg_store(ALLEEG, EEG, CURRENTSET); |
|
|
77 |
else |
|
|
78 |
EEG = eeg_emptyset; % empty dataset |
|
|
79 |
return; |
|
|
80 |
end |
|
|
81 |
end |
|
|
82 |
|
|
|
83 |
% retain saved field |
|
|
84 |
% ------------------ |
|
|
85 |
for index = 1:length(CURRENTSET) |
|
|
86 |
ALLEEG(CURRENTSET(index)).saved = tmpsaved{index}; |
|
|
87 |
EEG(index).saved = tmpsaved{index}; |
|
|
88 |
end |
|
|
89 |
|
|
|
90 |
%catch |
|
|
91 |
% fprintf('Warning: cannot retrieve dataset with index %d\n', CURRENTSET); |
|
|
92 |
% return; |
|
|
93 |
%end |
|
|
94 |
|
|
|
95 |
return; |
|
|
96 |
|