Skip to content

Commit a839556

Browse files
committed
throw error when neurosy th map does not have a neurosynth name
1 parent 4922936 commit a839556

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

src/roi/renameNeuroSynth.m

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function outputImage = renameNeuroSynth(inputImage)
22
%
3-
% give a neurosynth map a name that is more bids friendly
3+
% rename a neurosynth map a name that is more bids friendly
44
%
55
% USAGE::
66
%
@@ -18,18 +18,29 @@
1818
%
1919
% (C) Copyright 2021 CPP ROI developers
2020

21-
p.filename = spm_file(inputImage, 'filename');
21+
basename = spm_file(inputImage, 'basename');
22+
match = regexp(basename, '.*_((association)|(uniformity))-test_z_FDR_0\.01.*', 'match');
23+
if isempty(match)
24+
err = struct('identifier', 'renameNeuroSynth:nonValidNeurosynthZmap', ...
25+
'message', sprintf(['Not a valid neurosynth Z map name.\n'...
26+
'Must be a of the shape: ".*_((association)|(uniformity))-test_z_FDR_0\\.01.*"']));
27+
error(err);
28+
end
29+
2230
p.suffix = 'probseg';
31+
2332
p.ext = '.nii';
2433
if strcmp(spm_file(inputImage, 'ext'), 'gz')
2534
p.ext = [p.ext '.gz'];
2635
end
36+
2737
% TODO: find the actual MNI space neurosynth images are in
2838
p.entities.space = 'MNI';
2939

30-
basename = spm_file(inputImage, 'basename');
3140
parts = strsplit(basename, '_');
41+
3242
p.entities.atlas = 'neurosynth';
43+
3344
p.entities.label = bids.internal.camel_case(parts{1});
3445

3546
bidsFile = bids.File(p);

tests/test_unit_renameNeuroSynth.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
initTestSuite;
99
end
1010

11+
function test_renameNeuroSynth_error()
12+
13+
inputImage = fullfile(pwd, 'hMT.nii.gz');
14+
system(['touch ' inputImage]);
15+
16+
assertExceptionThrown(@()renameNeuroSynth(inputImage), ...
17+
'renameNeuroSynth:nonValidNeurosynthZmap');
18+
19+
delete(inputImage);
20+
21+
end
22+
1123
function test_renameNeuroSynth()
1224

1325
inputImage = fullfile(pwd, 'motion_association-test_z_FDR_0.01.nii.gz');

0 commit comments

Comments
 (0)