Skip to content

Commit

Permalink
pull v3.1.1 (#6)
Browse files Browse the repository at this point in the history
* suppPrep4stats re-write

* Fixed error when plotting more than 6 conditions

* new epp_makegrands function

* Improvments to speed when combining data

* support for plotting over time windows

+ Removed plotting t-values
+ Added control of color-map

* Fix bug when measuring from average of channels

* Fix to bad chars in condition names

* minor fix

* minor fix

* improvment to loading data

* major fix to flipped time axes

* update README

* new author
  • Loading branch information
mattansb authored May 1, 2018
1 parent 9966584 commit 164fc7c
Show file tree
Hide file tree
Showing 20 changed files with 245 additions and 141 deletions.
2 changes: 2 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ If a wavelet analysis has been preformed, the Data field is replaced with:
These functions can be used to compute new conditions or manipulate existing data:

- Merge 2 or more conditions with `epp_combineconds`.
- Make grand-average ERP/ERSP/ITC with `epp_makegrands` (useful for plotting large data sets).
- Compute differences between 2 conditions with `epp_diffwave`.
- Compute LRP with `epp_LRP`
- Compute global field potentials with `epp_GFP`.
Expand Down Expand Up @@ -411,6 +412,7 @@ The function `epp_getTF` measure the *mean* ersp / itc from selected channels, w

- **Mattan S. Ben-Shachar** [aut, cre].
- **Rachel Rac** [ctb].
- **Micael Shmueli** [ctb].

## Acknowledgments

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ If a wavelet analysis has been preformed, the Data field is replaced with:
These functions can be used to compute new conditions or manipulate existing data:

- Merge 2 or more conditions with `epp_combineconds`.
- Make grand-average ERP/ERSP/ITC with `epp_makegrands` (useful for plotting large data sets).
- Compute differences between 2 conditions with `epp_diffwave`.
- Compute LRP with `epp_LRP`
- Compute global field potentials with `epp_GFP`.
Expand Down Expand Up @@ -182,6 +183,7 @@ Authors

- **Mattan S. Ben-Shachar** \[aut, cre\].
- **Rachel Rac** \[ctb\].
- **Micael Shmueli** \[ctb\].

Acknowledgments
---------------
Expand Down
3 changes: 2 additions & 1 deletion _depricated_/suppPrep4export.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
%{
Change log:
-----------
14-04-2018 Support new jackknife function
19-01-2017 Support for saving data
19-12-2016 Support for Jackknife adjustment
25-11-2016 New function (written in MATLAB R2015a)
Expand All @@ -22,7 +23,7 @@
for c = 1:length(study) % for each condition
% Correct for jackknifing:
if pResults.jackknife
study(c).measure = suppJackknife('out',study(c).measure);
study(c).measure = suppJackknife('out',study(c).measure,1);
end

% Make variable name:
Expand Down
3 changes: 2 additions & 1 deletion _depricated_/suppPrep4stats.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
%{
Change log:
-----------
14-04-2018 Support new jackknife function
07-04-2018 Added samplingRate calculation
06-03-2018 Removed samplingRate & baseLine fields from study struct.
29-01-2017 Support for sampling interpolation
Expand All @@ -32,7 +33,7 @@

%% Jackknife
if jackknife
studyIn(c).Data = suppJackknife('in',studyIn(c).Data);
studyIn(c).Data = suppJackknife('in',studyIn(c).Data,3);
end

%% Interpolate
Expand Down
2 changes: 1 addition & 1 deletion data_reduction/epp_GFP.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
% (SES) is calculated, as per Milivojevic, Johnson,
% Hamm, & Corballis (2003).
%
% See also epp_combineconds, epp_LRP, epp_diffwave
% See also epp_combineconds, epp_LRP, epp_diffwave, epp_makegrands
%
%
% Author: Mattan S. Ben Shachar, BGU, Israel
Expand Down
2 changes: 1 addition & 1 deletion data_reduction/epp_LRP.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
% NOTE that output has only the number of selected electrodes (ordered as
% they were input).
%
% See also epp_combineconds, epp_GFP, epp_diffwave
% See also epp_combineconds, epp_GFP, epp_diffwave, epp_makegrands
%
%
% Author: Mattan S. Ben Shachar, BGU, Israel
Expand Down
15 changes: 11 additions & 4 deletions data_reduction/epp_combineconds.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
% 'name' - name of new combined condition. Defults is to
% concatenate the condition names.
%
% See also epp_LRP, epp_GFP, epp_diffwave
% See also epp_LRP, epp_GFP, epp_diffwave, epp_makegrands
%
% Author: Mattan S. Ben Shachar, BGU, Israel

Expand Down Expand Up @@ -56,9 +56,16 @@

IDs = {};
for c = 1:length(study)
IDs = {IDs{:}, study(c).IDs.ID{:}};
if ~any(isstr(study(c).IDs.ID))
study(c).IDs.ID = cellfun(@(X) num2str(X),study(c).IDs.ID,'UniformOutput',false);
end
IDs = [IDs, study(c).IDs.ID];
end
try
IDs = unique(IDs);
catch
IDs = arrayfun(@(X) {X},unique(cell2mat(IDs)));
end
IDs = unique(IDs);

%% Combine
for id = 1:length(IDs)
Expand Down Expand Up @@ -130,6 +137,6 @@
if has_erp, out.Data = data; end
if has_ersp, out.ersp = ersp; end
if has_itc, out.itc = itc; end
out.IDs = table(IDs',nTrials','VariableNames',{'ID' 'nTrials'});
out.IDs = table(IDs,nTrials','VariableNames',{'ID' 'nTrials'});

end
2 changes: 1 addition & 1 deletion data_reduction/epp_diffwave.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
% 'name' - name of new combined condition. Defults is to
% concatenate the condition names.
%
% See also epp_combineconds, epp_LRP, epp_GFP
% See also epp_combineconds, epp_LRP, epp_GFP, epp_makegrands
%
%
% Author: Mattan S. Ben Shachar, BGU, Israel
Expand Down
38 changes: 38 additions & 0 deletions data_reduction/epp_makegrands.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
% PURPOSE: Collapes all data across subjects. This is useful for plotting
% data of large data sets.
%
%
% FORMAT
% ------
% study = epp_makegrands(study)
%
%
% See also epp_combineconds, epp_GFP, epp_diffwave, epp_LRP
%
%
% Author: Mattan S. Ben Shachar & Rachel Rac, BGU, Israel

%{
Change log:
-----------
23-04-2018 Minor fix
16-04-2018 New function (written in MATLAB R2017a)
%}
function study = epp_makegrands(study)
for c = 1:length(study)
%% IDs
study(c).IDs = table(000,size(study(c).IDs,1),'VariableNames',{'ID' 'nTrials'});

%% Data
if isfield(study,'Data')
study(c).Data = mean(study(c).Data,3);
end

if isfield(study,'ersp')
study(c).ersp = mean(study(c).ersp,4);
end

if isfield(study,'itc')
study(c).itc = mean(study(c).itc,4);
end
end
89 changes: 78 additions & 11 deletions import_export/epp_loadeeglab.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
%{
Change log:
-----------
25-04-2018 Fix when combining
16-04-2018 Improvments to speed when combining data
15-04-2018 Reduced printing from eeglab pop_*
13-04-2018 A million little bug fixes
11-04-2018 Added errors when subject ID
20-03-2018 Fix naming of subject files.
Expand Down Expand Up @@ -133,13 +136,14 @@

if p.Results.wavelet || p.Results.erp
for f = 1:nFiles
fprintf('Processing file %d of %d\n',f,nFiles)
% Load and validate sub\group\condition
% =====================================
try
temp_EEG = pop_loadset('filename',EEG_list{f});
evalc('temp_EEG = pop_loadset(''filename'',EEG_list{f});');
catch
eeglab; close
temp_EEG = pop_loadset('filename',EEG_list{f});
evalc('temp_EEG = pop_loadset(''filename'',EEG_list{f});');
end

if isempty(temp_EEG.condition) && isempty(temp_EEG.group)
Expand Down Expand Up @@ -194,37 +198,100 @@

%% Combine all files

study = struct;

if p.Results.combine
% list files in savePath
all_files = dir([savePath '\\*.eppf']);
nFiles = length(all_files);

study.Condition = '';
% Load and append data
% --------------------
fprintf('\n\n')
for f = 1:nFiles
% Load
fprintf('Loading file %d of %d\n',f,nFiles)
load(fullfile(savePath, all_files(f).name), '-mat')

% Orgenize
for c = 1:length(output)
c_ind = find(strcmpi(output(c).Condition,{study.Condition}));
if isempty(c_ind)
if strcmpi(study(end).Condition,'')
if isempty(c_ind) % if there is no such condition
if isempty(study(end).Condition) % if this is the first condition
study = output(c);
else
study(end+1) = output(c);
end
else
try study(c_ind).ersp(:,:,:,end+1) = output(c).ersp; end
try study(c_ind).itc(:,:,:,end+1) = output(c).itc; end
try study(c_ind).Data(:,:,end+1) = output(c).Data; end

% build data
if isfield(study,'Data')
study(end).Data = cell([1 nFiles]);
study(end).Data{1} = output(c).Data;

end

% build ersp
if isfield(study,'ersp')
study(end).ersp = cell([1 nFiles]);
study(end).ersp{1} = output(c).ersp;
end

% build itc
if isfield(study,'itc')
study(end).itc = cell([1 nFiles]);
study(end).itc{1} = output(c).itc;
end


else % condition exists
study(c_ind).IDs = [study(c_ind).IDs;output(c).IDs];

% append data
if isfield(study,'Data')
next_ind = find(cellfun(@isempty, study(c_ind).Data),1);
study(c_ind).Data{next_ind} = output(c).Data;
end

% append ersp
if isfield(study,'ersp')
next_ind = find(cellfun(@isempty, study(c_ind).ersp),1);
study(c_ind).ersp{next_ind} = output(c).ersp;
end

% append itc
if isfield(study,'itc')
next_ind = find(cellfun(@isempty, study(c_ind).itc),1);
study(c_ind).itc{next_ind} = output(c).itc;
end
end
end
clear output c_ind
end
else
% return an empty struct
study = struct;

% Collaps Data/ersp/itc
% ---------------------
fprintf('\nCleaning up (this can take a while)..')
for c = 1:length(study)
% Collaps data
if isfield(study,'Data')
next_ind = cellfun(@(X) ~isempty(X), study(c).Data);
study(c).Data = cat(3,study(c).Data{next_ind});
end

% Collaps ersp
if isfield(study,'ersp')
next_ind = cellfun(@(X) ~isempty(X), study(c).ersp);
study(c).ersp = cat(4,study(c).ersp{next_ind});
end

% Collaps itc
if isfield(study,'itc')
next_ind = cellfun(@(X) ~isempty(X), study(c).itc);
study(c).itc = cat(4,study(c).itc{next_ind});
end
end
fprintf('. Done!\n',f,nFiles)
end


Expand Down
8 changes: 6 additions & 2 deletions measuring/epp_getTF.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
% The available parameters are as follows:
% 'average' - average across electrodes before measuring?
% (false my default).
% 'jackknife' - measure using the jackknife technique?
% (default: false)
% 'save' - 'long' / 'wide'; will save the results in the
% current directory in the specified format.
%
Expand All @@ -34,6 +36,8 @@
%{
Change log:
-----------
18-04-2018 Fix bug when sending to suppPrep4statsTF
14-04-2018 Support for jackknife
07-04-2018 Rewrite of function.
28-02-2018 ITC (abs) is now computed in function, to allow for the
combination of conditions.
Expand All @@ -56,7 +60,7 @@
addRequired(p,'freqs',@(x) isnumeric(x) && size(x,2)==2);

addParameter(p,'average',false,@islogical);
addParameter(p,'jackknife',false,@islogical); % not supported
addParameter(p,'jackknife',false,@islogical);
addParameter(p,'plot',false,@islogical);
addParameter(p,'save','no', @ischar);
parse(p, measure ,study, conditions, electrodes, timeWindow, freqs, varargin{:}); % validate
Expand All @@ -66,7 +70,7 @@

[study, timeWindow_ind, freqs_name] = suppPrep4statsTF(study, conditions, electrodes,...
timeWindow, freqs,...
p.Results.average, p.Results.average);
p.Results.average, p.Results.jackknife);

%% Get Measure

Expand Down
Loading

0 comments on commit 164fc7c

Please sign in to comment.