Skip to content

Commit a258b35

Browse files
committed
rename identify rawsoureces
1 parent 22c1e8d commit a258b35

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

src/utils/identify_rawsource.m renamed to src/utils/identify_rawsources.m

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
1-
function rawsource = identify_rawsource(derivatives, verbose)
2-
%
1+
function rawsource = identify_rawsources(derivatives, verbose)
32
%
3+
% find the most likely files in the raw dataset
4+
% that was used to create this derivatives
45
%
56
% USAGE::
67
%
7-
% rawsource = identify_rawsource(derivatives)
8+
% rawsource = identify_rawsources(derivatives)
89
%
910
% :param file: SPM preprocessed filename (can be fullpath);
1011
% for example ``wmsub-01_ses-01_T1w.nii``
1112
% :type file: string
1213
%
13-
% :returns: - :new_filename: (string) BIDS compatible filename
14-
% for example ``sub-01_ses-01_space-IXI549Space_desc-preproc_T1w.nii``;
1514
%
1615
% (C) Copyright 2021 spm_2_bids developers
1716

17+
% TODO mean may involve several files from the source (across runs
18+
% and sessions
19+
% prefixes = {
20+
% 'mean'
21+
% 'meanu'
22+
% 'meanua'
23+
% 'wmeanu'
24+
% };
25+
1826
rawsource = '';
1927

2028
if nargin < 1 || isempty(derivatives)
@@ -35,6 +43,6 @@
3543

3644
bf.prefix = '';
3745

38-
rawsource = fullfile(bf.path, bf.bids_path, bf.filename);
46+
rawsource = fullfile(bf.bids_path, bf.filename);
3947

4048
end

tests/test_identify_rawsource.m renamed to tests/test_identify_rawsources.m

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
% (C) Copyright 2021 spm_2_bids developers
1+
% (C) Copyright 2022 spm_2_bids developers
22

3-
function test_suite = test_identify_rawsource %#ok<*STOUT>
3+
function test_suite = test_identify_rawsources %#ok<*STOUT>
44
try % assignment of 'localfunctions' is necessary in Matlab >= 2016
55
test_functions = localfunctions(); %#ok<*NASGU>
66
catch % no problem; early Matlab versions can use initTestSuite fine
77
end
88
initTestSuite;
99
end
1010

11-
function test_identify_rawsource_suffix()
11+
function test_identify_rawsources_suffix()
1212

1313
input_output = {'sub-01_T1w_seg8.mat', 'sub-01_T1w.nii'
1414
'sub-01_task-foo_bold_uw.mat', 'sub-01_task-foo_bold.nii'};
@@ -17,15 +17,15 @@ function test_identify_rawsource_suffix()
1717

1818
for i = 1:size(input_output, 1)
1919

20-
rawsource = identify_rawsource(input_output{i, 1}, verbose);
20+
rawsource = identify_rawsources(input_output{i, 1}, verbose);
2121

2222
assertEqual(rawsource, ['sub-01/' input_output{i, 2}]);
2323

2424
end
2525

2626
end
2727

28-
function test_identify_rawsource_anat()
28+
function test_identify_rawsources_anat()
2929

3030
anat_file = 'sub-01_T1w.nii';
3131

@@ -48,31 +48,27 @@ function test_identify_rawsource_anat()
4848

4949
file = [prefixes{i} anat_file];
5050

51-
rawsource = identify_rawsource(file, verbose);
51+
rawsource = identify_rawsources(fullfile(pwd, 'sub-01', file), verbose);
5252

5353
assertEqual(rawsource, 'sub-01/sub-01_T1w.nii');
5454

5555
end
5656

5757
end
5858

59-
function test_identify_rawsource_func()
59+
function test_identify_rawsources_func()
6060

6161
func_file = 'sub-01_ses-02_task-foo_bold.nii';
6262

6363
prefixes = {'a'
6464
'u'
6565
'rp_'
6666
'rp_a'
67-
'mean'
68-
'meanu'
69-
'meanua'
7067
'w'
7168
'wua'
7269
'wu'
7370
'wr'
7471
'wra'
75-
'wmeanu'
7672
'sw'
7773
'swua'
7874
'swu'
@@ -91,7 +87,7 @@ function test_identify_rawsource_func()
9187

9288
file = [prefixes{i} func_file];
9389

94-
rawsource = identify_rawsource(file, verbose);
90+
rawsource = identify_rawsources(file, verbose);
9591

9692
assertEqual(rawsource, 'sub-01/ses-02/sub-01_ses-02_task-foo_bold.nii');
9793

0 commit comments

Comments
 (0)