Skip to content

Commit

Permalink
ERPLAB v11.04
Browse files Browse the repository at this point in the history
Includes new MVPC Decoding tab in Estudio, currently in BETA.
  • Loading branch information
davidg622 committed Aug 6, 2024
1 parent 120867c commit c5450a8
Show file tree
Hide file tree
Showing 128 changed files with 16,551 additions and 2,257 deletions.
Binary file modified GUIs/binselectorGUI.mlapp
Binary file not shown.
Binary file modified GUIs/decodingGUI.mlapp
Binary file not shown.
Binary file modified GUIs/mvpa_save_multi_file.fig
Binary file not shown.
47 changes: 21 additions & 26 deletions GUIs/mvpa_save_multi_file.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ function mvpa_save_multi_file_OpeningFcn(hObject, eventdata, handles, varargin)
catch
suffix = '';
ERPLAB = [];
ERPLAB.erpname = 'No erpset was selected';
ERPLAB.filename ='No erpset was selected';
ERPLAB.bestname = 'No mvpcset was selected';
ERPLAB.filename ='No mvpcset was selected';
ERPLAB.event = [];
ERPLAB.chanlocs = [];
ERPLAB.nbchan = 0;
Expand All @@ -74,14 +74,14 @@ function mvpa_save_multi_file_OpeningFcn(hObject, eventdata, handles, varargin)
%erplab_studio_default_values;
erplab_default_values;
version = erplabver;
set(handles.gui_chassis,'Name', ['ERPLAB ' version ' - Save multiple MVPAsets GUI'])
set(handles.gui_chassis,'Name', ['ERPLAB ' version ' - Save multiple MVPCsets GUI'])


% set(handles.checkbox1_suffix,'Value',1);
set(handles.edit_suffix_name,'String',suffix);
set(handles.checkbox2_save_label,'Value',0);

ColumnName_table = {'MVPA name','File name'};
ColumnName_table = {'MVPC name','File name'};

set(handles.uitable1_erpset_table,'ColumnName',cellstr(ColumnName_table));
set(handles.uitable1_erpset_table,'RowName',cellstr(num2str(Selected_ERP_label')));
Expand Down Expand Up @@ -141,12 +141,7 @@ function checkbox1_suffix_Callback(hObject, eventdata, handles)
Selected_ERP_label = handles.Selected_ERP_label;
suffix_edit = handles.edit_suffix_name.String;

if isempty(suffix_edit)
msgboxText = 'You must enter a suffix at least!';
title = 'EStudio: f_ERP_save_multi_file() error';
errorfound(msgboxText, title);
return
end



DataString_before = handles.uitable1_erpset_table.Data;
Expand Down Expand Up @@ -217,9 +212,9 @@ function checkbox2_save_label_Callback(hObject, eventdata, handles)
fileName= char(ALLERP(Selected_ERP_label(Numofselectederp)).filename);
[pathstr, file_name, ext] = fileparts(fileName);
if isempty(file_name)
file_name = [num2str(Selected_ERP_label(Numofselectederp)),'_ERP.mvpa'];
file_name = [num2str(Selected_ERP_label(Numofselectederp)),'_ERP.mvpc'];
else
file_name = [file_name,'.mvpa'];
file_name = [file_name,'.mvpc'];
end
DataString{Numofselectederp,2} = file_name;

Expand Down Expand Up @@ -255,13 +250,13 @@ function checkbox3_filename_erpname_Callback(hObject, eventdata, handles)
DataString{Numofselectederp,1} = DataString_before{Numofselectederp,1};
fileName = char(DataString_before{Numofselectederp,1});
if isempty(fileName)
fileName = strcat(num2str(Numofselectederp),'mvpa');
fileName = strcat(num2str(Numofselectederp),'mvpc');
end
[pathstr, file_name, ext] = fileparts(fileName);
if isempty(file_name)
file_name = [num2str(Selected_ERP_label(Numofselectederp)),'_ERP.mvpa'];
file_name = [num2str(Selected_ERP_label(Numofselectederp)),'_ERP.mvpc'];
else
file_name = [file_name,'.mvpa'];
file_name = [file_name,'.mvpc'];
end
DataString{Numofselectederp,2} = file_name;
end
Expand All @@ -279,16 +274,16 @@ function uitable1_erpset_table_CellEditCallback(hObject, eventdata, handles)
DataString = handles.uitable1_erpset_table.Data;
Selected_ERP_label = handles.Selected_ERP_label;
if size(DataString,1) < numel(Selected_ERP_label)
msgboxText = 'Erpname and filename for one of erpsets are empty at least! Please give name to erpname and filename';
title = 'EStudio: f_ERP_save_multi_file empty erpname';
msgboxText = 'MVPC name and filename for one of erpsets are empty at least! Please give name to mvpcname and filename';
title = 'EStudio: mvpa_save_multi_file empty erpname';
errorfound(msgboxText, title);
return
end

for Numofselected = 1:numel(Selected_ERP_label)
if isempty(DataString{Numofselected,1})
msgboxText = 'Erpname for one of erpsets is empty at least! Please give name to that erpset';
title = 'EStudio: f_ERP_save_multi_file empty erpname';
msgboxText = 'MVPCname for one of mvpcsets is empty at least! Please give name to that mvpcset';
title = 'EStudio: mvpa_save_multi_file empty mvpcname';
errorfound(msgboxText, title);
return
end
Expand Down Expand Up @@ -326,16 +321,16 @@ function pushbutton4_okay_Callback(hObject, eventdata, handles)
Selected_ERP_label = handles.Selected_ERP_label;

if size(Data_String,1)< numel(Selected_ERP_label)%
msgboxText = 'MVPAname for one of MVPAsets is empty at least! Please give a name';
msgboxText = 'MVPCname for one of MVPCsets is empty at least! Please give a name';
title = 'ERPLAB: mvpa_save_multi_file empty MVPAname';
errorfound(msgboxText, title);
return
end


if size(Data_String,1)> numel(Selected_ERP_label)%
msgboxText = 'More MVPAname is given. Please delete it!!!';
title = 'ERPLAB: mvpa_save_multi_file empty MVPAname';
msgboxText = 'More MVPCname is given. Please delete it!!!';
title = 'ERPLAB: mvpa_save_multi_file empty MVPCname';
errorfound(msgboxText, title);
return
end
Expand All @@ -344,8 +339,8 @@ function pushbutton4_okay_Callback(hObject, eventdata, handles)

for Numofselected = 1:numel(Selected_ERP_label)
if isempty(Data_String{Numofselected,1})
msgboxText = 'MVPAname for one of MVPAsets is empty at least! Please give a name';
title = 'ERPLAB: mvpa_save_multi_file empty MVPAname';
msgboxText = 'MVPCname for one of MVPCsets is empty at least! Please give a name';
title = 'ERPLAB: mvpa_save_multi_file empty MVPCname';
errorfound(msgboxText, title);
return
end
Expand All @@ -363,9 +358,9 @@ function pushbutton4_okay_Callback(hObject, eventdata, handles)

[pathstr, file_name, ext] = fileparts(fileName);
if isempty(file_name)
file_name = [num2str(Selected_ERP_label(Numofselectederp)),'_mvpa.mvpa'];
file_name = [num2str(Selected_ERP_label(Numofselectederp)),'_mvpc.mvpc'];
else
file_name = [file_name,'.mvpa'];
file_name = [file_name,'.mvpc'];
end

ALLERP(Selected_ERP_label(Numofselectederp)).filename = file_name;
Expand Down
Binary file modified GUIs/mvpc2textGUI.mlapp
Binary file not shown.
Binary file modified GUIs/plotConfusionGUI.mlapp
Binary file not shown.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ Click the Wiki icon at the top of the page for documentation, tutorials, and FAQ
</p>
To ask questions, subscribe to the ERPLAB email list (https://erpinfo.org/erplab-email-list). Bug reports can be submitted via GitHub or by sending an email to erplab-bugreports@ucdavis.edu.

## ERPLAB v11.03
## ERPLAB v11.04

<p align="center" >
<a href="https://github.com/ucdavis/erplab/releases/download/11.0/erplab11.03.zip"><img src="https://github.com/ucdavis/erplab/blob/master/images/erplab-and-studio-logo.png">
<a href="https://github.com/ucdavis/erplab/releases/download/11.0/erplab11.04.zip"><img src="https://github.com/ucdavis/erplab/blob/master/images/erplab-and-studio-logo.png">
<br/>

<img src="https://cloud.githubusercontent.com/assets/5808953/8663301/1ff9a26a-297e-11e5-9e15-a7085569058f.png" width=300px >
Expand All @@ -25,7 +25,7 @@ We encourage most users to use this latest major version.

## Release Notes

### ERPLAB v11.03 Release Notes
### ERPLAB v11.04 Release Notes

ERPLAB can now be accessed from two different user interfaces:
- [ERPLAB Classic](https://github.com/ucdavis/erplab/wiki/Manual) (our original software, which operates as an EEGLAB plugin)
Expand Down
4 changes: 2 additions & 2 deletions erplab_default_values.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
erplabver = '11.03'; % current erplab version
erplabrel = '18-July-2024'; % DOB
erplabver = '11.04'; % current erplab version
erplabrel = '06-August-2024'; % DOB
erplabdeveloper = 'Simmons,Zhang,Garrett';
%ColorB = [170 180 195]/255; % old background color (until version 3)
%ColorB = [0.9216 0.8353 0.6078]; % background color for version 4
Expand Down
4 changes: 2 additions & 2 deletions functions/averager.m
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@
L = size(datax,2);
fnyq = fs/2;
f = fnyq*linspace(0,1,NFFT/2);
y = pagetranspose(datax);
y = datax';
tapwin = zeros(L,1);
if ~isempty(apodization)
aponame = strtrim(apodization{1}); % taper function name
Expand All @@ -485,7 +485,7 @@
y = y.*repmat(tapwin, 1, size(y,2)); % data tapered
end

Y = pagetranspose(fft(y,NFFT))/L;
Y = fft(y,NFFT)'/L;
fftepo = abs(Y(:,1:NFFT/2)).^2; % power
if rem(NFFT, 2) % odd NFFT excludes Nyquist point
fftepo(:, 2:end) = fftepo(:, 2:end).*2;
Expand Down
71 changes: 38 additions & 33 deletions functions/crossnobis.m
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@

function [MVPC, ALLMVPC] = crossnobis(ALLBEST, nIter, nCrossBlocks, DataTimes,relevantChans,classcoding,equalT,ParWorkers,method)
function [MVPC, ALLMVPC] = crossnobis(ALLBEST, nIter, nCrossBlocks, DataTimes,relevantChans,classcoding,equalT,ParWorkers,method,Tooltype)

%% Subject List:
%% Subject List:
nSubs = length(ALLBEST); % # files = # subjects

global observe_DECODE;
%% Step 9: Loop through participants
for s = 1:nSubs %crossnobis is performed within each subject independently

%% Parameters to set per subject
BEST = ALLBEST(s);
mvpc = buildMVPCstruct(BEST,relevantChans, nIter, nCrossBlocks, DataTimes,equalT,classcoding,method);
%% Parameters to set per subject
BEST = ALLBEST(s);
mvpc = buildMVPCstruct(BEST,relevantChans, nIter, nCrossBlocks, DataTimes,equalT,classcoding,method);

% for brevity in analysis
nBins = mvpc.nClasses;
nIter = mvpc.nIter;
nPerms = nchoosek(nBins,2); %total # pairwise comparisions
dataTime = BEST.times; %times of imported data
%nBlocks = mvpc.nCrossfolds;
% nElectrodes = length(mvpc.electrodes);
% nElectrodes = length(mvpc.electrodes);
nSamps = length(mvpc.times);
try
sn = BEST.mvpcname; %if data went through decoding GUI
Expand All @@ -26,19 +26,19 @@
end

%progress output to command window
fprintf('*** Currently Decoding (Crossnobis) Subject:\t%s ***\n ',sn); %is Decoding the word to use for crossnobis?
fprintf('*** Currently Decoding (Crossnobis) Subject:\t%s ***\n ',sn); %is Decoding the word to use for crossnobis?

% grab EEG data from bin-list organized data
% grab EEG data from bin-list organized data
eegs = BEST.binwise_data;
nPerBin = BEST.n_trials_per_bin;
% we create index of timpoint of interests from original data
tois = ismember(dataTime,dataTime);


% % Preallocate Matrices
final_xDist = nan(nSamps,nIter,nPerms);
% %BetaWeights_Raw = nan(nIter,nSamps,nBlocks,nElectrodes);
% %BetaWeights_Corr = BetaWeights_Raw;

% % Preallocate Matrices
final_xDist = nan(nSamps,nIter,nPerms);
% %BetaWeights_Raw = nan(nIter,nSamps,nBlocks,nElectrodes);
% %BetaWeights_Corr = BetaWeights_Raw;


if nBins ~= max(size(eegs))
Expand Down Expand Up @@ -66,18 +66,18 @@
% (NChan x nTP x nTrials(ideally randomized) x Nlabels)

for b = 1:numel(nPerBin)
ntrial = size(eegs(b).data,3);
shuff_list = randperm(ntrial);
ntrial = size(eegs(b).data,3);
shuff_list = randperm(ntrial);

%so we always allow the specified number of trials per bin
%(nPerBin) by choosing from a (potentially) larger set of trials
%within the bin

idx_list = shuff_list(1:nPerBin(b));
idx_list = shuff_list(1:nPerBin(b));

indexed_data = eegs(b).data(:,:,idx_list);
eegs(b).data = indexed_data;

eegs(b).data = indexed_data;
end


Expand All @@ -86,14 +86,19 @@
xdata = xdata(:,tois,:); %resampled data


%% Step 8: Loop through each iteration with random shuffling
%% Step 8: Loop through each iteration with random shuffling
tic % start timing iteration loop

%% Perform Cross-Nobis analysis at each requested time-point
for iter = 1:nIter
fprintf('Subject: %s, Iteration: %i / %i \n', sn, iter, nIter);
if ~strcmpi(Tooltype,'erplab')
messg = ['Subject:',32, sn,', Iteration:',32,num2str(iter),'/', num2str(nIter)]; %%GH
estudioworkingmemory('f_Decode_proces_messg',messg);
observe_DECODE.Process_messg =1;
end
parfor (nTp = 1:nSamps,ParWorkers)

% structs to hold shuffled data
a_full_bin_label= struct();
b_full_bin_label= struct();
Expand Down Expand Up @@ -162,29 +167,29 @@
final_xDist(nTp,iter,:) = xDist;
end
end

toc % stop timing the iteration loop

mvpc.details = [];
mvpc.raw_predictions = final_xDist;
mvpc.details = [];
mvpc.raw_predictions = final_xDist;

avg_distance_iter = squeeze(mean(final_xDist,2))';
avg_distance_scores = squeeze(mean(avg_distance_iter,1));
avg_distance_iter = squeeze(mean(final_xDist,2))';
avg_distance_scores = squeeze(mean(avg_distance_iter,1));

mvpc.average_score = avg_distance_scores;
mvpc = avgconfusionCM(mvpc, final_xDist);
mvpc.stderror = std(avg_distance_iter)/sqrt(size(final_xDist,1));
mvpc = avgconfusionCM(mvpc, final_xDist);
mvpc.stderror = std(avg_distance_iter)/sqrt(size(final_xDist,1));


%probably a better way
%probably a better way
if nSubs == 1

MVPC = mvpc;
ALLMVPC = mvpc;
else

MVPC = mvpc;
ALLMVPC(s) = mvpc;
MVPC = mvpc;
ALLMVPC(s) = mvpc;
end


Expand Down
23 changes: 2 additions & 21 deletions functions/erpAutoYLim.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,32 +90,13 @@
else
aux_xxlim(2) = xxlim(2);
end

elseif strcmpi(datatype, 'TFFT')

aux_xxlim(1) = 1;
if xxlim(2)>round(ERP.xmax*1000)
aux_xxlim(2) = round(ERP.xmax*1000);
else
aux_xxlim(2) = xxlim(2);
end

elseif strcmpi(datatype, 'EFFT')

aux_xxlim(1) = 0;
if xxlim(2)>round(ERP.xmax*1000)
aux_xxlim(2) = round(ERP.xmax*1000);
else
aux_xxlim(2) = xxlim(2);
end

else % fft
if xxlim(1)<5
aux_xxlim(1) = 5; % to avoid including the spectrum under 5 Hz in calculating Y auto (too big!)
else
aux_xxlim(1) = xxlim(1);
end
if xxlim(2)>round(fs/2)
if xxlim(2)>round(fs/2);
aux_xxlim(2) = round(fs/2);
else
aux_xxlim(2) = xxlim(2);
Expand All @@ -139,7 +120,7 @@
yymax = max(datresh);
yymin = min(datresh);
end

if abs(yymax)<1 && abs(yymin)<1
yylim(1:2) = [yymin*1.2 yymax*1.1]; % JLC. Mar 11, 2015
else
Expand Down
Loading

0 comments on commit c5450a8

Please sign in to comment.