Skip to content

Commit ba39937

Browse files
authored
Merge pull request #31 from cpp-lln-lab/atlas
[REF & ENH] remove renameFile and deal with atlas entities
2 parents 7870fd6 + a1d719f commit ba39937

15 files changed

+39
-110
lines changed

demos/roi/label_and_extract_clusters.m

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

1111
gunzip(fullfile('inputs', '*.gz'));
1212

13-
zMap = fullfile(pwd, 'inputs', 'visual_motion_association-test_z_FDR_0.01.nii');
13+
zMap = fullfile(pwd, 'inputs', 'visual motion_association-test_z_FDR_0.01.nii');
1414
zMap = renameNeuroSynth(zMap);
1515

1616
peakThreshold = 5;

demos/roi/neurosynth_left_right_rois.m

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
run ../../initCppRoi;
77

88
gunzip(fullfile('inputs', '*.gz'));
9-
zMap = fullfile(pwd, 'inputs', 'visual_motion_association-test_z_FDR_0.01.nii');
9+
zMap = fullfile(pwd, 'inputs', 'visual motion_association-test_z_FDR_0.01.nii');
1010

1111
zMap = renameNeuroSynth(zMap);
1212
roiImage = thresholdToMask(zMap, 5);
@@ -16,11 +16,13 @@
1616
rightRoiImage = keepHemisphere(roiImage, 'R');
1717

1818
% change the label entity and remove the hs one
19-
leftRoiImage = renameFile(leftRoiImage, ...
20-
struct('entities', struct( ...
21-
'label', 'ns left motion', ...
22-
'hemi', '')));
23-
rightRoiImage = renameFile(rightRoiImage, ...
24-
struct('entities', struct( ...
25-
'label', 'ns right motion', ...
26-
'hemi', '')));
19+
specification = struct('entities', struct('label', 'ns left motion', ...
20+
'hemi', ''));
21+
bf = bids.File(leftRoiImage);
22+
bf = bf.rename('spec', specification, 'dry_run', false, 'verbose', true);
23+
leftRoiImage = fullfile(bf.path, bf.filename);
24+
25+
specification.entities.label = 'ns right motion';
26+
bf = bids.File(rightRoiImage);
27+
bf = bf.rename('spec', specification, 'dry_run', false, 'verbose', true);
28+
rightRoiImage = fullfile(bf.path, bf.filename);

demos/roi/roi_script.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
% You can use the resliceRoiImages for that.
3030

3131
%%
32-
zMap = fullfile(pwd, 'inputs', 'visual_motion_association-test_z_FDR_0.01.nii');
32+
zMap = fullfile(pwd, 'inputs', 'visual motion_association-test_z_FDR_0.01.nii');
3333
dataImage = fullfile(pwd, 'inputs', 'TStatistic.nii');
3434

3535
opt.unzip.do = true;

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
author = "the CPP ROI dev team"
2424

2525
# The full version, including alpha/beta/rc tags
26-
release = "v0.2.0"
26+
release = "v0.2.0dev"
2727

2828

2929
# -- General configuration ---------------------------------------------------

docs/source/function_description.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,3 @@ Atlas
1414
.. automodule:: src.atlas
1515

1616
.. autofunction:: returnAtlasDir
17-
18-
Utilities
19-
=========
20-
21-
.. automodule:: src.utils
22-
23-
.. autofunction:: renameFile

run_tests.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
testFolder = fullfile(fileparts(mfilename('fullpath')), 'tests');
1010

1111
addpath(fullfile(testFolder, 'utils'));
12+
addpath(fullfile(fileparts(mfilename('fullpath')), 'atlas'));
1213

1314
folderToCover = fullfile(testFolder, '..', 'src');
1415

src/atlas/extractRoiFromAtlas.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
% rename file
6262
entities = struct('hemi', hemisphere, ...
6363
'space', 'MNI', ...
64-
'label', roiName, ...
65-
'desc', atlasName);
64+
'atlas', atlasName, ...
65+
'label', roiName);
6666
nameStructure = struct('entities', entities, ...
6767
'suffix', 'mask', ...
6868
'ext', '.nii');

src/roi/keepHemisphere.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@
3838

3939
vol(discard, :, :) = NaN;
4040

41-
p = bids.internal.parse_filename(inputImage);
42-
p.entities.hemi = hemisphere;
43-
bidsFile = bids.File(p);
41+
bf = bids.File(inputImage);
42+
bf.entity_order = cat(1, 'hemi', fieldnames(bf.entities));
43+
bf.entities.hemi = hemisphere;
44+
bf = bf.reorder_entities;
4445

45-
hdr.fname = spm_file(inputImage, 'filename', bidsFile.filename);
46+
hdr.fname = spm_file(inputImage, 'filename', bf.filename);
4647

4748
spm_write_vol(hdr, vol);
4849

src/roi/renameNeuroSynth.m

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

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

3435
bidsFile = bids.File(p);
3536

src/utils/renameFile.m

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)