diff --git a/subfun/BIDS_copyRawFolder.m b/subfun/BIDS_copyRawFolder.m index fc47b176..7fcccc5d 100644 --- a/subfun/BIDS_copyRawFolder.m +++ b/subfun/BIDS_copyRawFolder.m @@ -39,15 +39,13 @@ function BIDS_copyRawFolder(opt, deleteZippedNii) fprintf('derivatives directory already exists. \n') end -% make copy dataset description file from raw folder if it doesnt exist -copyfile(fullfile(rawDir, 'dataset_description.json'), derivativeDir); -fprintf('dataset_description.json copied to derivatives directory \n'); +% copy TSV and JSON file from raw folder if it doesnt exist +copyfile(fullfile(rawDir, '*.json'), derivativeDir); +fprintf(' json files copied to derivatives directory \n'); -% copy task json files from raw to derivatives -copyfile(fullfile(rawDir, 'task-*_bold.json'), derivativeDir); -fprintf('task JSON files copied to derivatives directory \n'); +copyfile(fullfile(rawDir, '*.tsv'), derivativeDir); +fprintf(' tsv files copied to derivatives directory \n'); -% copy TSV files? %% Loop through the groups, subjects, sessions diff --git a/subfun/pmCon.m b/subfun/pmCon.m index 680134f2..80268884 100644 --- a/subfun/pmCon.m +++ b/subfun/pmCon.m @@ -53,7 +53,7 @@ C = zeros(1,size(SPM.xX.X,2)); % get regressors index corresponding to the HRF of that condition - [cdt_name, regIdx] = getRegIdx(Step, iCon, SPM); + [cdt_name, regIdx] = getRegIdx(Step.AutoContrasts, iCon, SPM); % give them a value of 1 C(end,regIdx) = 1; @@ -80,7 +80,7 @@ for iCdt = 1:length(Step.Contrasts(iCon).ConditionList) % get regressors index corresponding to the HRF of that condition - [~, regIdx] = getRegIdx(Step, iCon, SPM); + [~, regIdx] = getRegIdx(Step.Contrasts, iCon, SPM, iCdt); % give them a value of 1 C(end,regIdx) = Step.Contrasts(iCon).weights(iCdt); @@ -107,7 +107,7 @@ for iCon = 1:length(Step.AutoContrasts) % get regressors index corresponding to the HRF of that condition - [cdt_name, regIdx] = getRegIdx(Step, iCon, SPM); + [cdt_name, regIdx] = getRegIdx(Step.AutoContrasts, iCon, SPM); regIdx = find(regIdx); @@ -140,11 +140,16 @@ -function [cdt_name, regIdx] = getRegIdx(Step, iCon, SPM) +function [cdt_name, regIdx] = getRegIdx(conList, iCon, SPM, iCdt) % get regressors index corresponding to the HRF of of a condition +if iscell(conList) + cdt_name = conList{iCon}; +elseif isstruct(conList) + cdt_name = conList(iCon).ConditionList{iCdt}; +end + % get condition name -cdt_name = Step.AutoContrasts{iCon}; cdt_name = strrep(cdt_name, 'trial_type.', ''); % get regressors index corresponding to the HRF of that condition diff --git a/test/dummyData/derivatives/SPM12_CPPL/sub-01/stats/ffx_visMotion/ffx_6/SPM.mat b/test/dummyData/derivatives/SPM12_CPPL/sub-01/stats/ffx_visMotion/ffx_6/SPM.mat new file mode 100644 index 00000000..19e65bcc Binary files /dev/null and b/test/dummyData/derivatives/SPM12_CPPL/sub-01/stats/ffx_visMotion/ffx_6/SPM.mat differ diff --git a/test/dummyData/model/model-visMotionLoc_smdl.json b/test/dummyData/model/model-visMotionLoc_smdl.json new file mode 100644 index 00000000..a1c21046 --- /dev/null +++ b/test/dummyData/model/model-visMotionLoc_smdl.json @@ -0,0 +1,35 @@ +{ + "Name": "Motion localizer", + "Description": "contrasts for the motion localizer dataset", + "Input": { + "task": "visMotion" + }, + "Steps": [ + { + "Level": "subject", + "AutoContrasts": ["trial_type.VisMot", "trial_type.VisStat" ], + "Contrasts": [ + { + "Name": "VisMot_gt_VisStat", + "ConditionList": [ + "trial_type.VisMot", "trial_type.VisStat" + ], + "weights": [1, -1], + "type": "t" + }, + { + "Name": "VisStat_gt_VisMot", + "ConditionList": [ + "trial_type.VisMot", "trial_type.VisStat" + ], + "weights": [-1, 1], + "type": "t" + } + ] + }, + { + "Level": "dataset", + "AutoContrasts": ["trial_type.VisMot", "trial_type.VisStat", "VisMot_gt_VisStat", "VisStat_gt_VisMot"] + } + ] +} diff --git a/test/test_pmCon.m b/test/test_pmCon.m new file mode 100644 index 00000000..3e5d621c --- /dev/null +++ b/test/test_pmCon.m @@ -0,0 +1,29 @@ +function test_pmCon() +% Small test to ensure that pmCon returns what we asked for + +addpath(genpath(fullfile(pwd, '..'))) + +opt.dataDir = fullfile(pwd, 'dummyData', 'derivatives'); +opt.taskName = 'visMotion'; +opt.model.univariate.file = fullfile(pwd, 'dummyData', 'model', 'model-visMotionLoc_smdl.json'); + +ffxDir = fullfile(opt.dataDir, 'SPM12_CPPL', 'sub-01', 'stats', 'ffx_visMotion', 'ffx_6'); + +isMVPA = 0; + +contrasts = pmCon(ffxDir, opt.taskName, opt, isMVPA); + + +assert(isequal(contrasts(1).name, 'VisMot')) +assert(isequal(contrasts(1).C, [1 0 0 0 0 0 0 0 0])) + +assert(isequal(contrasts(2).name, 'VisStat')) +assert(isequal(contrasts(2).C, [0 1 0 0 0 0 0 0 0])) + +assert(isequal(contrasts(3).name, 'VisMot_gt_VisStat')) +assert(isequal(contrasts(3).C, [1 -1 0 0 0 0 0 0 0])) + +assert(isequal(contrasts(4).name, 'VisStat_gt_VisMot')) +assert(isequal(contrasts(4).C, [-1 1 0 0 0 0 0 0 0])) + +end