Skip to content

Commit a0ad9e8

Browse files
committed
Merge branch 'master' into dev
2 parents de3d381 + 27cbf33 commit a0ad9e8

14 files changed

+171
-58
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
33
version: 2
44
updates:
5-
- package-ecosystem: "github-actions"
6-
directory: "/"
5+
- package-ecosystem: 'github-actions'
6+
directory: '/'
77
schedule:
8-
interval: "weekly"
8+
interval: 'monthly'
9+
10+
- package-ecosystem: 'gitsubmodule'
11+
directory: '/'
12+
schedule:
13+
interval: 'monthly'

.github/workflows/run_tests_matlab.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ jobs:
1919
steps:
2020

2121
- name: Install MATLAB
22-
uses: matlab-actions/setup-matlab@v1.0.1
22+
uses: matlab-actions/setup-matlab@v1.2.2
2323
with:
2424
# MATLAB release to set up R2020a
2525
release: R2020a
2626

2727
- name: Clone spm_2_bids
28-
uses: actions/checkout@v2
28+
uses: actions/checkout@v3
2929
with:
3030
submodules: true
3131
fetch-depth: 2
@@ -36,11 +36,10 @@ jobs:
3636
git clone https://github.com/MOcov/MOcov.git --depth 1
3737
3838
- name: get bids-matlab and JSONio
39-
run: |
40-
make install_dev
39+
run: make install_dev
4140

4241
- name: Run commands
43-
uses: matlab-actions/run-command@v1.0.1
42+
uses: matlab-actions/run-command@v1.1.1
4443
with:
4544
command: cd(fullfile(getenv('GITHUB_WORKSPACE'), '.github', 'workflows')); run tests_matlab;
4645

@@ -50,7 +49,7 @@ jobs:
5049
bash <(curl -s https://codecov.io/bash)
5150
5251
- name: Code coverage
53-
uses: codecov/codecov-action@v1
52+
uses: codecov/codecov-action@v3
5453
with:
5554
file: coverage.xml # optional
5655
flags: unittests # optional
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: tests_octave
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- dev
8+
pull_request:
9+
branches: ['*']
10+
11+
jobs:
12+
test:
13+
14+
runs-on: ubuntu-20.04
15+
16+
steps:
17+
18+
- name: Install dependencies
19+
run: |
20+
sudo apt-get -y -qq update
21+
sudo apt-get -y install octave liboctave-dev
22+
23+
- name: Clone spm_2_bids
24+
uses: actions/checkout@v3
25+
with:
26+
submodules: true
27+
fetch-depth: 2
28+
29+
- name: get bids-matlab and JSONio
30+
run: make install_dev_octave
31+
32+
- name: MOxUnit Action
33+
uses: joergbrech/[email protected]
34+
with:
35+
tests: tests
36+
src: src src/defaults src/utils
37+
ext: lib/JSONio lib/bids-matlab tests/utils
38+
with_coverage: false

.github/workflows/validate_cff.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: validate CITATION.cff
2+
3+
on:
4+
push:
5+
branches: ['*']
6+
paths:
7+
- 'CITATION.cff'
8+
pull_request:
9+
branches: ['*']
10+
paths:
11+
- 'CITATION.cff'
12+
13+
jobs:
14+
15+
validate_cff:
16+
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
21+
- uses: actions/checkout@v3
22+
23+
- name: Check whether the citation metadata from CITATION.cff is valid
24+
uses: citation-file-format/[email protected]
25+
with:
26+
args: "--validate"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.vscode
44

55
*.json
6+
mapping.md
67

78
env/
89

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ repos:
2828
additional_dependencies: [miss_hit]
2929

3030
- repo: https://github.com/pre-commit/pre-commit-hooks
31-
rev: v4.2.0
31+
rev: v4.3.0
3232
hooks:
3333
- id: trailing-whitespace
3434
- id: end-of-file-fixer

init_spm_2_bids.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function init_spm_2_bids(add_dev)
6262
pth = fileparts(mfilename('fullpath'));
6363
addpath(genpath(fullfile(pth, 'src')));
6464

65-
disp('Correct matlab/octave verions and added to the path!');
65+
disp('Correct matlab/octave versions and added to the path!');
6666

6767
end
6868

miss_hit.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ copyright_entity: "spm_2_bids developers"
1717
# metric for code quality
1818
metric "cnest": limit 5
1919
metric "file_length": limit 500
20-
metric "cyc": limit 16
20+
metric "cyc": limit 15
2121
metric "parameters": limit 6

src/Mapping.m

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,26 +102,26 @@
102102
% filter.ext
103103
%
104104

105-
p = inputParser;
105+
args = inputParser;
106106

107-
addParameter(p, 'prefix', obj.default_value);
108-
addParameter(p, 'suffix', obj.default_value);
109-
addParameter(p, 'entities', obj.default_value);
110-
addParameter(p, 'ext', obj.default_value);
111-
addParameter(p, 'name_spec', obj.default_value);
107+
addParameter(args, 'prefix', obj.default_value);
108+
addParameter(args, 'suffix', obj.default_value);
109+
addParameter(args, 'entities', obj.default_value);
110+
addParameter(args, 'ext', obj.default_value);
111+
addParameter(args, 'name_spec', obj.default_value);
112112

113-
parse(p, varargin{:});
113+
parse(args, varargin{:});
114114

115-
prefix = p.Results.prefix;
115+
prefix = args.Results.prefix;
116116
if ~iscell(prefix)
117117
prefix = {prefix};
118118
end
119119

120120
obj.mapping(end + 1, 1).prefix = prefix;
121-
obj.mapping(end, 1).suffix = p.Results.suffix;
122-
obj.mapping(end, 1).entities = p.Results.entities;
123-
obj.mapping(end, 1).ext = p.Results.ext;
124-
obj.mapping(end, 1).name_spec = p.Results.name_spec;
121+
obj.mapping(end, 1).suffix = args.Results.suffix;
122+
obj.mapping(end, 1).entities = args.Results.entities;
123+
obj.mapping(end, 1).ext = args.Results.ext;
124+
obj.mapping(end, 1).name_spec = args.Results.name_spec;
125125

126126
end
127127

@@ -322,6 +322,8 @@ function print_mapping(obj, filename)
322322
[obj.smooth, obj.norm, obj.unwarp], ...
323323
[obj.smooth, obj.norm, obj.realign] }, obj.cfg.smooth_norm};
324324

325+
spec_preproc = {{[obj.realign, obj.stc]}, obj.cfg.preproc};
326+
325327
spec_preproc_norm = {{obj.norm, ...
326328
[obj.norm, obj.bias_cor], ...
327329
[obj.norm, obj.stc, obj.unwarp], ...
@@ -334,6 +336,7 @@ function print_mapping(obj, filename)
334336
spec_smooth, ...
335337
spec_smooth_norm, ...
336338
spec_preproc_norm, ...
339+
spec_preproc, ...
337340
spec_mean, ...
338341
spec_norm_mean);
339342

@@ -353,15 +356,15 @@ function print_mapping(obj, filename)
353356
% idx = obj.find_mapping('prefix', str)
354357
%
355358

356-
p = inputParser;
359+
args = inputParser;
357360

358-
addParameter(p, 'prefix', @ischar);
361+
addParameter(args, 'prefix', @ischar);
359362

360-
parse(p, varargin{:});
363+
parse(args, varargin{:});
361364

362365
available_mapped_prefixes = {obj.mapping.prefix}';
363366

364-
idx = strcmp(p.Results.prefix, available_mapped_prefixes);
367+
idx = strcmp(args.Results.prefix, available_mapped_prefixes);
365368

366369
end
367370

src/spm_2_bids.m

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
function [new_filename, pth, json] = spm_2_bids(file, map, verbose)
1+
function [new_filename, pth, json] = spm_2_bids(varargin)
22
%
33
% Provides a bids derivatives name for a file preprocessed with SPM
44
%
55
% USAGE::
66
%
7-
% [new_filename, pth, json] = spm_2_bids(file)
8-
% [new_filename, pth, json] = spm_2_bids(file, map)
7+
% [new_filename, pth, json] = spm_2_bids(file [, map][, verbose])
98
%
109
% :param file: SPM preprocessed filename (can be fullpath);
1110
% for example ``wmsub-01_ses-01_T1w.nii``
1211
% :type file: string
12+
%
1313
% :param map: optional spm_2_bids map to overwrite the default
1414
% map (see Mapping)
1515
% :param map: Mapping object
1616
%
17+
% :param verbose:
18+
% :param verbose: boolean
19+
%
1720
% :returns: - :new_filename: (string) BIDS compatible filename
1821
% for example ``sub-01_ses-01_space-IXI549Space_desc-preproc_T1w.nii``;
1922
% - :pth: (string) relative BIDS path
@@ -27,15 +30,23 @@
2730

2831
% (C) Copyright 2021 spm_2_bids developers
2932

30-
if nargin < 2 || isempty(map)
33+
args = inputParser;
34+
35+
addRequired(args, 'file', @ischar);
36+
addOptional(args, 'map', []);
37+
addOptional(args, 'verbose', true, @islogical);
38+
39+
parse(args, varargin{:});
40+
41+
file = args.Results.file;
42+
map = args.Results.map;
43+
verbose = args.Results.verbose;
44+
45+
if isempty(map)
3146
map = Mapping();
3247
map = map.default();
3348
end
3449

35-
if nargin < 3
36-
verbose = true;
37-
end
38-
3950
mapping = map.mapping;
4051
cfg = map.cfg;
4152

@@ -83,22 +94,7 @@
8394
strcmp({mapping.ext}', '*')], 2);
8495
end
8596

86-
% we compare the entities-label pairs present in the file
87-
% to those required in the mapping (if any)
88-
% if no entity requirement anywhere in the mapping then anything goes
89-
entitiy_match = true(size(mapping));
90-
91-
needs_entity_check = ~cellfun('isempty', {mapping.entities}');
92-
if any(needs_entity_check)
93-
94-
entitiy_match = false(size(mapping));
95-
96-
idx = find(needs_entity_check);
97-
for i = 1:numel(idx)
98-
status = check_field_content(bf.entities, mapping(idx(i)).entities);
99-
entitiy_match(idx(i)) = status;
100-
end
101-
end
97+
entitiy_match = get_entity_match(mapping, bf);
10298

10399
this_mapping = [prefix_match, suffix_match, entitiy_match, ext_match];
104100

@@ -117,9 +113,15 @@
117113
end
118114

119115
if isempty(spec) && verbose
120-
% TODO this warning should probably go in the find_mapping methods
121-
msg = sprintf('Unknown prefix: %s', bf.prefix);
122-
warning('spm_2_bids:unknownPrefix', msg); %#ok<SPWRN>
116+
if isnan(str2double(bf.prefix(1))) && ...
117+
~bids.internal.starts_with(bf.prefix, 'c4') && ... % ALI toolbox prefixes
118+
~bids.internal.starts_with(bf.prefix, 'td_') % spmup toolbox truncated prefixes
119+
120+
% TODO this warning should probably go in the find_mapping methods
121+
msg = sprintf('Unknown prefix: %s', bf.prefix);
122+
warning('spm_2_bids:unknownPrefix', msg); %#ok<SPWRN>
123+
124+
end
123125
return
124126
end
125127

@@ -145,6 +147,25 @@
145147

146148
end
147149

150+
function entitiy_match = get_entity_match(mapping, bf)
151+
% we compare the entities-label pairs present in the file
152+
% to those required in the mapping (if any)
153+
% if no entity requirement anywhere in the mapping then anything goes
154+
entitiy_match = true(size(mapping));
155+
156+
needs_entity_check = ~cellfun('isempty', {mapping.entities}');
157+
if any(needs_entity_check)
158+
159+
entitiy_match = false(size(mapping));
160+
161+
idx = find(needs_entity_check);
162+
for i = 1:numel(idx)
163+
status = check_field_content(bf.entities, mapping(idx(i)).entities);
164+
entitiy_match(idx(i)) = status;
165+
end
166+
end
167+
end
168+
148169
function json = set_metadata(file, map, verbose, bf)
149170

150171
json = bids.derivatives_json(bf.filename);

0 commit comments

Comments
 (0)