Skip to content

Commit 46f4497

Browse files
authored
Merge pull request #56 from Remi-Gau/remi-dev
fix problem when task JSON file is missing from root folder
2 parents a1c737d + 50d032a commit 46f4497

File tree

5 files changed

+79
-12
lines changed

5 files changed

+79
-12
lines changed

subfun/BIDS_copyRawFolder.m

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,13 @@ function BIDS_copyRawFolder(opt, deleteZippedNii)
3939
fprintf('derivatives directory already exists. \n')
4040
end
4141

42-
% make copy dataset description file from raw folder if it doesnt exist
43-
copyfile(fullfile(rawDir, 'dataset_description.json'), derivativeDir);
44-
fprintf('dataset_description.json copied to derivatives directory \n');
42+
% copy TSV and JSON file from raw folder if it doesnt exist
43+
copyfile(fullfile(rawDir, '*.json'), derivativeDir);
44+
fprintf(' json files copied to derivatives directory \n');
4545

46-
% copy task json files from raw to derivatives
47-
copyfile(fullfile(rawDir, 'task-*_bold.json'), derivativeDir);
48-
fprintf('task JSON files copied to derivatives directory \n');
46+
copyfile(fullfile(rawDir, '*.tsv'), derivativeDir);
47+
fprintf(' tsv files copied to derivatives directory \n');
4948

50-
% copy TSV files?
5149

5250
%% Loop through the groups, subjects, sessions
5351

subfun/pmCon.m

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
C = zeros(1,size(SPM.xX.X,2));
5454

5555
% get regressors index corresponding to the HRF of that condition
56-
[cdt_name, regIdx] = getRegIdx(Step, iCon, SPM);
56+
[cdt_name, regIdx] = getRegIdx(Step.AutoContrasts, iCon, SPM);
5757

5858
% give them a value of 1
5959
C(end,regIdx) = 1;
@@ -80,7 +80,7 @@
8080
for iCdt = 1:length(Step.Contrasts(iCon).ConditionList)
8181

8282
% get regressors index corresponding to the HRF of that condition
83-
[~, regIdx] = getRegIdx(Step, iCon, SPM);
83+
[~, regIdx] = getRegIdx(Step.Contrasts, iCon, SPM, iCdt);
8484

8585
% give them a value of 1
8686
C(end,regIdx) = Step.Contrasts(iCon).weights(iCdt);
@@ -107,7 +107,7 @@
107107
for iCon = 1:length(Step.AutoContrasts)
108108

109109
% get regressors index corresponding to the HRF of that condition
110-
[cdt_name, regIdx] = getRegIdx(Step, iCon, SPM);
110+
[cdt_name, regIdx] = getRegIdx(Step.AutoContrasts, iCon, SPM);
111111

112112
regIdx = find(regIdx);
113113

@@ -140,11 +140,16 @@
140140

141141

142142

143-
function [cdt_name, regIdx] = getRegIdx(Step, iCon, SPM)
143+
function [cdt_name, regIdx] = getRegIdx(conList, iCon, SPM, iCdt)
144144
% get regressors index corresponding to the HRF of of a condition
145145

146+
if iscell(conList)
147+
cdt_name = conList{iCon};
148+
elseif isstruct(conList)
149+
cdt_name = conList(iCon).ConditionList{iCdt};
150+
end
151+
146152
% get condition name
147-
cdt_name = Step.AutoContrasts{iCon};
148153
cdt_name = strrep(cdt_name, 'trial_type.', '');
149154

150155
% get regressors index corresponding to the HRF of that condition
Binary file not shown.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"Name": "Motion localizer",
3+
"Description": "contrasts for the motion localizer dataset",
4+
"Input": {
5+
"task": "visMotion"
6+
},
7+
"Steps": [
8+
{
9+
"Level": "subject",
10+
"AutoContrasts": ["trial_type.VisMot", "trial_type.VisStat" ],
11+
"Contrasts": [
12+
{
13+
"Name": "VisMot_gt_VisStat",
14+
"ConditionList": [
15+
"trial_type.VisMot", "trial_type.VisStat"
16+
],
17+
"weights": [1, -1],
18+
"type": "t"
19+
},
20+
{
21+
"Name": "VisStat_gt_VisMot",
22+
"ConditionList": [
23+
"trial_type.VisMot", "trial_type.VisStat"
24+
],
25+
"weights": [-1, 1],
26+
"type": "t"
27+
}
28+
]
29+
},
30+
{
31+
"Level": "dataset",
32+
"AutoContrasts": ["trial_type.VisMot", "trial_type.VisStat", "VisMot_gt_VisStat", "VisStat_gt_VisMot"]
33+
}
34+
]
35+
}

test/test_pmCon.m

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
function test_pmCon()
2+
% Small test to ensure that pmCon returns what we asked for
3+
4+
addpath(genpath(fullfile(pwd, '..')))
5+
6+
opt.dataDir = fullfile(pwd, 'dummyData', 'derivatives');
7+
opt.taskName = 'visMotion';
8+
opt.model.univariate.file = fullfile(pwd, 'dummyData', 'model', 'model-visMotionLoc_smdl.json');
9+
10+
ffxDir = fullfile(opt.dataDir, 'SPM12_CPPL', 'sub-01', 'stats', 'ffx_visMotion', 'ffx_6');
11+
12+
isMVPA = 0;
13+
14+
contrasts = pmCon(ffxDir, opt.taskName, opt, isMVPA);
15+
16+
17+
assert(isequal(contrasts(1).name, 'VisMot'))
18+
assert(isequal(contrasts(1).C, [1 0 0 0 0 0 0 0 0]))
19+
20+
assert(isequal(contrasts(2).name, 'VisStat'))
21+
assert(isequal(contrasts(2).C, [0 1 0 0 0 0 0 0 0]))
22+
23+
assert(isequal(contrasts(3).name, 'VisMot_gt_VisStat'))
24+
assert(isequal(contrasts(3).C, [1 -1 0 0 0 0 0 0 0]))
25+
26+
assert(isequal(contrasts(4).name, 'VisStat_gt_VisMot'))
27+
assert(isequal(contrasts(4).C, [-1 1 0 0 0 0 0 0 0]))
28+
29+
end

0 commit comments

Comments
 (0)