Skip to content

Commit ef79d17

Browse files
committed
update to bids matlab 0.1.0
1 parent 39b5778 commit ef79d17

File tree

7 files changed

+53
-18
lines changed

7 files changed

+53
-18
lines changed

src/roi/get_ROI_Coordinates.m renamed to demos/WIP/get_ROI_Coordinates.m

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
function mni = get_ROI_Coordinates
22
% This function gets the individual subject coordniates of the highest peak
3-
% within a specified Region of interest (usually coming from the group level univariate analysis)
4-
3+
% within a specified Region of interest (usually coming
4+
% from the group level univariate analysis)
5+
%
56
% Critical t-value for each experimental condition or mask file
6-
CriticalTs = 1; % Critical t-value for visual condition in L-V5 and R-V5 and bilateral PT
7+
% Critical t-value for visual condition in L-V5 and R-V5 and bilateral PT
8+
%
9+
% (C) Copyright 2021 CPP ROI developers
10+
11+
CriticalTs = 1;
712

813
%% load the data structure
914
WD = pwd;
@@ -52,9 +57,17 @@
5257
%% the first 4 masks are for the FACE condition, the other 4
5358
% are from the SCENE condition
5459
if iMask <= 2
55-
result_file = [data_path, '/', SubName, '/stats/ffx_visMotion/ffx_', smoothing, '/spmT_0013.nii']; % HUMAN > BIG_ENV
60+
result_file = [data_path, '/', ...
61+
SubName, ...
62+
'/stats/ffx_visMotion/ffx_', ...
63+
smoothing, ...
64+
'/spmT_0013.nii']; % HUMAN > BIG_ENV
5665
else
57-
result_file = [data_path, '/', SubName, '/stats/ffx_audMotion/ffx_', smoothing, '/spmT_0014.nii']; % BIG_ENV > HUMAN
66+
result_file = [data_path, '/', ...
67+
SubName, ...
68+
'/stats/ffx_audMotion/ffx_', ...
69+
smoothing, ...
70+
'/spmT_0014.nii']; % BIG_ENV > HUMAN
5871
end
5972

6073
%%
@@ -78,8 +91,11 @@
7891

7992
% convert space from slice number to mni
8093
mni{1, iMask}(subCounter, :) = cor2mni([x y z], mask_path);
81-
% mni{1,iMask}(iSub,1) = mni{1,iMask}(iSub,1)* -1; % If masks created from AFNI or FSL,
82-
% the x coordinate could be flipped (multiplied x -1). If this is the case, multiply x with -1.
94+
95+
% mni{1,iMask}(iSub,1) = mni{1,iMask}(iSub,1)* -1;
96+
% If masks created from AFNI or FSL,
97+
% the x coordinate could be flipped (multiplied x -1).
98+
% If this is the case, multiply x with -1.
8399

84100
mni{1, iMask}(subCounter, :);
85101

src/atlas/extractRoiByLabel.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
outputVol(vol == labelStruct.label) = true;
2424

2525
p = bids.internal.parse_filename(sourceImage);
26-
p.entities.label = labelStruct.ROI;
26+
p.entities.label = bids.internal.camel_case(labelStruct.ROI);
2727
p.suffix = 'mask';
2828

2929
bidsFile = bids.File(p);

src/roi/renameNeuroSynth.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
basename = spm_file(inputImage, 'basename');
3131
parts = strsplit(basename, '_');
32-
p.entities.label = ['neurosynth ' parts{1}];
32+
p.entities.label = bids.internal.camel_case(['neurosynth ' parts{1}]);
3333

3434
bidsFile = bids.File(p);
3535

src/roi/thresholdToMask.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
p = bids.internal.parse_filename(inputImage);
4646

4747
p.suffix = 'mask';
48-
48+
4949
% add peakThreshold and clusterSizeInfo to desc
5050
if ~isfield(p.entities, 'desc')
5151
p.entities.desc = '';

src/utils/renameFile.m

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,43 @@
11
function newName = renameFile(inputFile, specification)
22
%
33
% Renames a BIDS valid file into another BIDS valid file given some
4-
% specification.
4+
% specificationification.
55
%
66
% USAGE::
77
%
8-
% newName = renameFile(inputFile, specification)
8+
% newName = renameFile(inputFile, specificationification)
99
%
1010
% :param inputFile: better if fullfile path
1111
% :type inputFile: string
12-
% :param specification: structure specifying the details of the new name
12+
% :param specificationification: structure specificationifying the details of the new name
1313
% The structure content must resemble that of the
1414
% output of bids.internal.parse_filename
15-
% :type specification: structure
15+
% :type specificationification: structure
1616
%
1717
% (C) Copyright 2021 CPP ROI developers
1818

19-
bidsFile = bids.File(inputFile, false, specification);
20-
newName = bidsFile.filename;
19+
bf = bids.File(inputFile, 'use_schema', false);
2120

21+
if isfield(specification, 'prefix')
22+
bf.suffix = specification.prefix;
23+
end
24+
if isfield(specification, 'suffix')
25+
bf.suffix = specification.suffix;
26+
end
27+
if isfield(specification, 'ext')
28+
bf.extension = specification.ext;
29+
end
30+
if isfield(specification, 'entities')
31+
entities = fieldnames(specification.entities);
32+
for i = 1:numel(entities)
33+
bf = bf.set_entity(entities{i}, ...
34+
bids.internal.camel_case(specification.entities.(entities{i})));
35+
end
36+
end
37+
38+
bf = bf.update;
39+
40+
newName = bf.filename;
2241
outputFile = spm_file(inputFile, 'filename', newName);
2342

2443
movefile(inputFile, outputFile);

tests/space-MNI_label-neurosynth motion_probseg.nii.gz

Whitespace-only changes.

tests/test_extractRoiFromAtlas.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function test_extractRoiFromAtlas_wang()
1212

1313
roiImage = extractRoiFromAtlas(pwd, 'wang', 'V1v', 'L');
1414

15-
assertEqual(exist(fullfile(pwd, 'space-MNI_hemi-L_label-V1v_desc-wang_mask.nii'), ...
15+
assertEqual(exist(fullfile(pwd, 'hemi-L_space-MNI_label-V1v_desc-wang_mask.nii'), ...
1616
'file'), ...
1717
2);
1818

@@ -29,7 +29,7 @@ function test_extractRoiFromAtlas_neuromorphometrics()
2929
roiImage = extractRoiFromAtlas(pwd, 'neuromorphometrics', 'Amygdala', 'L');
3030

3131
assertEqual(exist(fullfile(pwd, ...
32-
'space-MNI_hemi-L_label-Amygdala_desc-neuromorphometrics_mask.nii'), ...
32+
'hemi-L_space-MNI_label-Amygdala_desc-neuromorphometrics_mask.nii'), ...
3333
'file'), ...
3434
2);
3535

0 commit comments

Comments
 (0)