Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions subfun/BIDS_copyRawFolder.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 10 additions & 5 deletions subfun/pmCon.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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
Expand Down
Binary file not shown.
35 changes: 35 additions & 0 deletions test/dummyData/model/model-visMotionLoc_smdl.json
Original file line number Diff line number Diff line change
@@ -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"]
}
]
}
29 changes: 29 additions & 0 deletions test/test_pmCon.m
Original file line number Diff line number Diff line change
@@ -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