From 92957eb5a93596c87a2aff4832fb2b145355c971 Mon Sep 17 00:00:00 2001 From: Dung Truong Date: Tue, 30 Jun 2020 18:29:49 -0700 Subject: [PATCH] auto-populate participant info using STUDY info. Check for STUDY-dataset consistency --- pop_checkdatasetinfo.m | 25 +++++++++++++++++++++++++ pop_participantinfo.m | 22 +++++++++++++++++++--- 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 pop_checkdatasetinfo.m diff --git a/pop_checkdatasetinfo.m b/pop_checkdatasetinfo.m new file mode 100644 index 0000000..5bfb421 --- /dev/null +++ b/pop_checkdatasetinfo.m @@ -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 \ No newline at end of file diff --git a/pop_participantinfo.m b/pop_participantinfo.m index 65d5cd1..26f6f80 100644 --- a/pop_participantinfo.m +++ b/pop_participantinfo.m @@ -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 @@ -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; @@ -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 @@ -504,4 +516,8 @@ function removeLevelUI() end end end + + function studyConsistencyCheck(EEG,STUDY) + + end end