Skip to content

Commit

Permalink
Merge pull request #111 from cpp-lln-lab/bids_matlab
Browse files Browse the repository at this point in the history
[MAINT] use bids matlab main (remove atlas entity), update RTD config
  • Loading branch information
Remi-Gau authored Dec 6, 2023
2 parents 5334bc5 + ddeb124 commit f93daa7
Show file tree
Hide file tree
Showing 21 changed files with 43 additions and 36 deletions.
6 changes: 5 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
# Required
version: 2

build:
os: ubuntu-22.04
tools:
python: '3.12'

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py
Expand All @@ -14,6 +19,5 @@ sphinx:

# Optionally set the version of Python and requirements required to build your docs
python:
version: '3.8'
install:
- requirements: requirements.txt
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ clean_lib:
rm -rf lib/bids-matlab

install_dev:
git clone https://github.com/bids-standard/bids-matlab.git --branch dev --depth 1 lib/bids-matlab
git clone https://github.com/bids-standard/bids-matlab.git --branch main --depth 1 lib/bids-matlab

version.txt: CITATION.cff
grep -w "^version" CITATION.cff | sed "s/version: /v/g" > version.txt
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions src/atlas/copyAtlasToSpmDir.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,22 @@ function copyAtlasToSpmDir(varargin)
sourceAtlasXml = fullfile(returnAtlasDir(), 'HCPex.xml');

case 'visfatlas'
sourceAtlasImage = fullfile(returnAtlasDir(atlas), 'space-MNI_atlas-visfAtlas_dseg.nii');
sourceAtlasXml = fullfile(returnAtlasDir(atlas), 'space-MNI_atlas-visfAtlas_dseg.xml');
sourceAtlasImage = fullfile(returnAtlasDir(atlas), 'space-MNI_seg-visfAtlas_dseg.nii');
sourceAtlasXml = fullfile(returnAtlasDir(atlas), 'space-MNI_seg-visfAtlas_dseg.xml');

case 'glasser'

sourceAtlasImage = fullfile(returnAtlasDir(atlas), ...
'space-MNI152ICBM2009anlin_atlas-glasser_dseg.nii');
'space-MNI152ICBM2009anlin_seg-glasser_dseg.nii');
sourceAtlasXml = fullfile(returnAtlasDir(atlas), ...
'space-MNI152ICBM2009anlin_atlas-glasser_dseg.xml');
'space-MNI152ICBM2009anlin_seg-glasser_dseg.xml');

case 'wang'
sourceAtlasImage = fullfile(returnAtlasDir(atlas), ...
'subj_vol_all', ...
'space-MNI_atlas-wang_dseg.nii');
'space-MNI_seg-wang_dseg.nii');
sourceAtlasXml = fullfile(returnAtlasDir(), ...
'space-MNI_atlas-wang_dseg.xml');
'space-MNI_seg-wang_dseg.xml');

otherwise
error(['Only the following atlases can be copied to SPM atlas folder:\n', ...
Expand Down
2 changes: 1 addition & 1 deletion src/atlas/extractRoiFromAtlas.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
% rename file
entities = struct('hemi', hemisphere, ...
'space', 'MNI', ...
'atlas', lower(atlasName), ...
'seg', lower(atlasName), ...
'label', roiName);
nameStructure = struct('entities', entities, ...
'suffix', 'mask', ...
Expand Down
4 changes: 2 additions & 2 deletions src/atlas/getAtlasFilename.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@

case 'visfatlas'

atlasFilename = fullfile(atlasDir, 'space-MNI_atlas-visfAtlas_dseg.nii');
atlasFilename = fullfile(atlasDir, 'space-MNI_seg-visfAtlas_dseg.nii');

case 'hcpex'

atlasFilename = fullfile(atlasDir, 'HCPex.nii');

case 'glasser'

atlasFilename = fullfile(atlasDir, 'space-MNI152ICBM2009anlin_atlas-glasser_dseg.nii');
atlasFilename = fullfile(atlasDir, 'space-MNI152ICBM2009anlin_seg-glasser_dseg.nii');

end

Expand Down
5 changes: 4 additions & 1 deletion src/atlas/getLookUpTable.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
roiLabelLUT = fullfile(atlasDir, 'Anatomy_v22c_MPM.txt');

if ~exist(roiLabelLUT, 'file')
error('Did you install the spm Anatomy toolbox?\n\nDownload it from: %s', ...
error(['Could not find look up table: %s.\n'...
'Did you install the spm Anatomy toolbox?\n\n', ...
'Download it from: %s'], ...
roiLabelLUT, ...
anat_tb_URL);
end

Expand Down
4 changes: 2 additions & 2 deletions src/atlas/unzipAtlas.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ function unzipAtlas(atlas)
end

case 'glasser'
file = fullfile(atlasDir, 'Glasser', 'space-MNI152ICBM2009anlin_atlas-glasser_dseg.nii');
file = fullfile(atlasDir, 'Glasser', 'space-MNI152ICBM2009anlin_seg-glasser_dseg.nii');
gunzipAtlasIfNecessary(file);

case 'visfatlas'
file = fullfile(atlasDir, 'visfAtlas', 'space-MNI_atlas-visfAtlas_dseg.nii');
file = fullfile(atlasDir, 'visfAtlas', 'space-MNI_seg-visfAtlas_dseg.nii');
gunzipAtlasIfNecessary(file);

case 'hcpex'
Expand Down
4 changes: 2 additions & 2 deletions src/roi/createRoi.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
%
% :roiImage: - :string: fullpath of the roi image for ``'mask'``
%
% :sphere: - :structure: defines the charateristic for ``'sphere'``
% :sphere: - :structure: defines the characteristic for ``'sphere'``
% - ``sphere.location``: X Y Z coordinates in millimeters
% - ``spehere.radius``: radius in millimeters
%
% :specification: - :structure: defines the charateristic for ``'intersection'`` and ``'expand'``
% :specification: - :structure: defines the characteristic for ``'intersection'`` and ``'expand'``
% - ``sphere.location``: X Y Z coordinates in millimeters
% - ``sphere.radius``: radius in millimeters
%
Expand Down
2 changes: 1 addition & 1 deletion src/roi/renameNeuroSynth.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

parts = strsplit(basename, '_');

p.entities.atlas = 'neurosynth';
p.entities.seg = 'neurosynth';

p.entities.label = bids.internal.camel_case(parts{1});

Expand Down
12 changes: 6 additions & 6 deletions tests/test_copyAtlasToSpmDir.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ function test_copyAtlasToSpmDir_wang()
copyAtlasToSpmDir('wang', 'verbose', false);

targetAtlasImage = fullfile(spmAtlasDir(), ...
'space-MNI_atlas-wang_dseg.nii');
'space-MNI_seg-wang_dseg.nii');
targetAtlasXml = fullfile(spmAtlasDir(), ...
'space-MNI_atlas-wang_dseg.xml');
'space-MNI_seg-wang_dseg.xml');

assertEqual(exist(targetAtlasImage, 'file'), 2);
assertEqual(exist(targetAtlasXml, 'file'), 2);
Expand All @@ -28,9 +28,9 @@ function test_copyAtlasToSpmDir_visfatlas()
copyAtlasToSpmDir('visfatlas', 'verbose', false);

targetAtlasImage = fullfile(spmAtlasDir(), ...
'space-MNI_atlas-visfAtlas_dseg.nii');
'space-MNI_seg-visfAtlas_dseg.nii');
targetAtlasXml = fullfile(spmAtlasDir(), ...
'space-MNI_atlas-visfAtlas_dseg.xml');
'space-MNI_seg-visfAtlas_dseg.xml');

assertEqual(exist(targetAtlasImage, 'file'), 2);
assertEqual(exist(targetAtlasXml, 'file'), 2);
Expand All @@ -44,9 +44,9 @@ function test_copyAtlasToSpmDir_glasser()
copyAtlasToSpmDir('Glasser', 'verbose', false);

targetAtlasImage = fullfile(spmAtlasDir(), ...
'space-MNI152ICBM2009anlin_atlas-glasser_dseg.nii');
'space-MNI152ICBM2009anlin_seg-glasser_dseg.nii');
targetAtlasXml = fullfile(spmAtlasDir(), ...
'space-MNI152ICBM2009anlin_atlas-glasser_dseg.xml');
'space-MNI152ICBM2009anlin_seg-glasser_dseg.xml');

assertEqual(exist(targetAtlasImage, 'file'), 2);
assertEqual(exist(targetAtlasXml, 'file'), 2);
Expand Down
4 changes: 2 additions & 2 deletions tests/test_createRoi.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function test_createRoi_intersection_mask_sphere()

mask = createRoi('intersection', specification, volumeDefiningImage, outputDir, saveImg);

basename = 'space-MNI_atlas-neurosynth_label-visualMotionIntersection_desc-p10pt00_mask';
basename = 'space-MNI_seg-neurosynth_label-visualMotionIntersection_desc-p10pt00_mask';

assertEqual(exist(fullfile(thisDir(), [basename '.nii']), 'file'), 2);
assertEqual(exist(fullfile(thisDir(), [basename '.json']), 'file'), 2);
Expand All @@ -75,7 +75,7 @@ function test_createRoi_intersection_mask_sphere()

mask = createRoi('expand', specification, volumeDefiningImage, outputDir, saveImg);

basename = 'space-MNI_atlas-neurosynth_label-visualMotionExpandVox57_desc-p10pt00_mask';
basename = 'space-MNI_seg-neurosynth_label-visualMotionExpandVox57_desc-p10pt00_mask';

assertEqual(mask.roi.size, 57);

Expand Down
10 changes: 5 additions & 5 deletions tests/test_extractRoiFromAtlas.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function test_extractRoiFromAtlas_glasser()

roiImage = extractRoiFromAtlas(pwd, 'Glasser', 'FEF', 'L');

assertEqual(exist(fullfile(pwd, 'hemi-L_space-MNI_atlas-glasser_label-FEF_mask.nii'), ...
assertEqual(exist(fullfile(pwd, 'hemi-L_space-MNI_seg-glasser_label-FEF_mask.nii'), ...
'file'), ...
2);

Expand All @@ -28,7 +28,7 @@ function test_extractRoiFromAtlas_wang()

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

assertEqual(exist(fullfile(pwd, 'hemi-L_space-MNI_atlas-wang_label-V1v_mask.nii'), ...
assertEqual(exist(fullfile(pwd, 'hemi-L_space-MNI_seg-wang_label-V1v_mask.nii'), ...
'file'), ...
2);

Expand All @@ -45,7 +45,7 @@ function test_extractRoiFromAtlas_neuromorphometrics()
roiImage = extractRoiFromAtlas(pwd, 'neuromorphometrics', 'Amygdala', 'L');

assertEqual(exist(fullfile(pwd, ...
'hemi-L_space-MNI_atlas-neuromorphometrics_label-Amygdala_mask.nii'), ...
'hemi-L_space-MNI_seg-neuromorphometrics_label-Amygdala_mask.nii'), ...
'file'), ...
2);

Expand All @@ -61,7 +61,7 @@ function test_extractRoiFromAtlas_visfAtlas()

roiImage = extractRoiFromAtlas(pwd, 'visfatlas', 'pFus', 'L');

assertEqual(exist(fullfile(pwd, 'hemi-L_space-MNI_atlas-visfatlas_label-pFus_mask.nii'), ...
assertEqual(exist(fullfile(pwd, 'hemi-L_space-MNI_seg-visfatlas_label-pFus_mask.nii'), ...
'file'), ...
2);

Expand All @@ -79,7 +79,7 @@ function test_extractRoiFromAtlas_hcpex()

roiImage = extractRoiFromAtlas(pwd, 'hcpex', 'MT', 'L');

assertEqual(exist(fullfile(pwd, 'hemi-L_space-MNI_atlas-hcpex_label-MT_mask.nii'), ...
assertEqual(exist(fullfile(pwd, 'hemi-L_space-MNI_seg-hcpex_label-MT_mask.nii'), ...
'file'), ...
2);

Expand Down
2 changes: 1 addition & 1 deletion tests/test_keepHemisphere.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function test_keepHemisphere_basic()
leftRoiImage = keepHemisphere(zMap, 'L');
rightRoiImage = keepHemisphere(zMap, 'R');

basename = 'space-MNI_atlas-neurosynth_label-visualMotion_probseg.nii';
basename = 'space-MNI_seg-neurosynth_label-visualMotion_probseg.nii';

assertEqual(exist(fullfile(inputDir, 'inputs', ...
['hemi-L_' basename]), ...
Expand Down
4 changes: 2 additions & 2 deletions tests/test_labelClusters.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@

labeledClusters = labelClusters(zMap, peakThreshold, extendThreshold);

expected = 'space-MNI_atlas-neurosynth_label-visualMotion_dseg.nii';
expected = 'space-MNI_seg-neurosynth_label-visualMotion_dseg.nii';
assertEqual(exist(fullfile(demoDir(), expected), 'file'), 2);

labelStruct = struct('ROI', 'ns left MT', ...
'label', 1);

roiName = extractRoiByLabel(labeledClusters, labelStruct);

expected = 'space-MNI_atlas-neurosynth_label-nsLeftMT_mask.nii';
expected = 'space-MNI_seg-neurosynth_label-nsLeftMT_mask.nii';
assertEqual(exist(fullfile(demoDir(), expected), 'file'), 2);

end
Expand Down
4 changes: 2 additions & 2 deletions tests/test_unit_renameNeuroSynth.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function test_renameNeuroSynth()

outputImage = renameNeuroSynth(inputImage);

expected = fullfile(pwd, 'space-MNI_atlas-neurosynth_label-motion_probseg.nii.gz');
expected = fullfile(pwd, 'space-MNI_seg-neurosynth_label-motion_probseg.nii.gz');
assertEqual(exist(outputImage, 'file'), 2);

assertEqual(outputImage, expected);
Expand All @@ -43,7 +43,7 @@ function test_renameNeuroSynth_unzipped()

outputImage = renameNeuroSynth(inputImage);

expected = fullfile(pwd, 'space-MNI_atlas-neurosynth_label-motion_probseg.nii');
expected = fullfile(pwd, 'space-MNI_seg-neurosynth_label-motion_probseg.nii');
assertEqual(exist(outputImage, 'file'), 2);

assertEqual(outputImage, expected);
Expand Down
2 changes: 1 addition & 1 deletion tests/test_unzipAtlas.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function test_unzipAtlas_glasser()
unzipAtlas('Glasser');

expectedFile = fullfile(returnAtlasDir('Glasser'), ...
'space-MNI152ICBM2009anlin_atlas-glasser_dseg.nii');
'space-MNI152ICBM2009anlin_seg-glasser_dseg.nii');

assertEqual(exist(expectedFile, 'file'), 2);

Expand Down

0 comments on commit f93daa7

Please sign in to comment.