Skip to content

Commit

Permalink
auto-populate participant info using STUDY info. Check for STUDY-data…
Browse files Browse the repository at this point in the history
…set consistency
  • Loading branch information
dungscout96 committed Jul 1, 2020
1 parent 072b020 commit 92957eb
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
25 changes: 25 additions & 0 deletions pop_checkdatasetinfo.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
function pop_checkdatasetinfo(STUDY, ALLEEG)
datasetinfo = STUDY.datasetinfo;
different = 0;
for k = 1:length(ALLEEG)
if ~strcmpi(datasetinfo(k).filename, ALLEEG(k).filename), different = 1; break; end
if ~strcmpi(datasetinfo(k).subject, ALLEEG(k).subject), different = 1; break; end
if ~strcmpi(datasetinfo(k).condition, ALLEEG(k).condition), different = 1; break; end
if ~strcmpi(char(datasetinfo(k).group), char(ALLEEG(k).group)), different = 1; break; end
if ~isequal(datasetinfo(k).session, ALLEEG(k).session), different = 1; break; end
if ~isequal(datasetinfo(k).run, ALLEEG(k).run), different = 1; break; end
end

if different
supergui( 'geomhoriz', { 1 1 [1 1] }, 'uilist', { ...
{ 'style', 'text', 'string', 'Information between STUDY and single datasets is inconsistent. Would you like to overwrite dataset information with STUDY information and use that for BIDS?' }, { }, ...
{ 'style', 'pushbutton' , 'string', 'Yes', 'callback', @yesCB}, { 'style', 'pushbutton' , 'string', 'No', 'callback', @noCB } } );
end

function yesCB(src, event)
close(gcf);
end
function noCB(src,event)
close(gcf);
end
end
22 changes: 19 additions & 3 deletions pop_participantinfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
% Inputs:
% EEG - EEG dataset structure. May only contain one dataset.
%
% STUDY - (optional) If provided, subject and group information in
% the STUDY will be used to auto-populate participant id and group info.
% Outputs:
% 'EEG' - [struct] Updated EEG structure containing event BIDS information
% in each EEG structure at EEG.BIDS
Expand All @@ -16,12 +18,17 @@
% 'pInfo' - [cell] BIDS participant information.
%
% Author: Dung Truong, Arnaud Delorme
function [EEG, command] = pop_participantinfo(EEG)
function [EEG, command] = pop_participantinfo(EEG,STUDY)
command = '[EEG, command] = pop_participantinfo(EEG);';

%% check if there's already an opened window
if ~isempty(findobj('Tag','pInfoTable'))
error('A window is already openened for pop_participantinfo');
end

%% if STUDY is provided, check for consistency
studyConsistencyCheck(EEG,STUDY);

%% default settings
appWidth = 1300;
appHeight = 600;
Expand Down Expand Up @@ -64,8 +71,13 @@

end
end
elseif isfield(curEEG,'subject')
pInfoTbl.Data{i,2} = curEEG.subject;
else
if isfield(curEEG,'subject')
pInfoTbl.Data{i,strcmp(pInfoTbl.ColumnName, 'participant_id')} = curEEG.subject;
end
if isfield(curEEG,'group') && ~isempty(curEEG.group)
pInfoTbl.Data{i,strcmp(pInfoTbl.ColumnName, 'group')} = curEEG.group;
end
end

% update HeadCircumference and SubjectArtefactDescription from tInfo
Expand Down Expand Up @@ -504,4 +516,8 @@ function removeLevelUI()
end
end
end

function studyConsistencyCheck(EEG,STUDY)

end
end

0 comments on commit 92957eb

Please sign in to comment.