Skip to content

Commit 5c8fec5

Browse files
authored
[FIX] install MACS toobox during initialisation (#1203)
* copy macs tooolbox during init * update changelog * fix and refactor
1 parent feb0705 commit 5c8fec5

File tree

7 files changed

+38
-19
lines changed

7 files changed

+38
-19
lines changed

.github/workflows/run_tests_notebooks.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ jobs:
4545
run: |
4646
git clone https://github.com/spm/spm12.git --depth 1
4747
48-
- name: Copy Macs toolbox to SPM inputs_folder
49-
run: cp -rv lib/MACS spm12/toolbox/MACS
50-
5148
- name: Test notebooks
5249
uses: matlab-actions/run-command@v2.1.0
5350
with:

.github/workflows/tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ jobs:
105105
run: |
106106
git clone https://github.com/spm/spm12.git --depth 1
107107
108-
- name: Copy Macs toolbox to SPM inputs_folder
109-
run: cp -rv lib/MACS spm12/toolbox/MACS
110-
111108
- name: Get moae fmriprep data from OSF
112109
run: |
113110
mkdir -p demos/MoAE/inputs/

.github/workflows/tests_octave.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ jobs:
8686
run: |
8787
git clone https://github.com/spm/spm12.git --depth 1
8888
89-
- name: Copy Macs toolbox to SPM inputs_folder
90-
run: cp -rv lib/MACS spm12/toolbox/MACS
91-
9289
- name: Get moae fmriprep data from OSF
9390
run: |
9491
mkdir -p demos/MoAE/inputs/

.github/workflows/tests_windows.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ jobs:
8484
run: |
8585
git clone https://github.com/spm/spm12.git --depth 1
8686
87-
- name: Copy Macs toolbox to SPM inputs_folder
88-
run: Copy-Item -Recurse -Verbose -Path ".\lib\MACS" -Destination ".\spm12\toolbox\MACS"
89-
9087
- name: Get moae fmriprep data from OSF
9188
run: |
9289
New-Item -ItemType Directory -Path ".\demos\MoAE\inputs\" -Force

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5050

5151
### Fixed
5252

53+
* [FIX] copy the MACS toolbox to the SPM toolbox folder during the initialisation #1203 by @Remi-Gau
5354
* [FIX] save onsets.mat directly in subject stats folder #1187 by @Remi-Gau
5455
* [FIX] do not compute subject level contrast when running dataset level #1102 by @Remi-Gau
5556
* [FIX] copy `RepetitionTime` in sidecar JSON after running smoothing in #1099 by @Remi-Gau

bidspm.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ function initBidspm(dev)
171171
fullfile(rootDir(), 'tests', 'utils'));
172172
end
173173

174+
% Make sure MACS toolbox used by SPM is the one from bidspm
175+
installMacstoolbox();
176+
174177
% for some reasons this folder was otherwise not added to the path in Octave
175178
BIDSPM_PATHS = cat(2, BIDSPM_PATHS, ...
176179
pathSep, ...
@@ -256,6 +259,22 @@ function initBidspm(dev)
256259

257260
end
258261

262+
function installMacstoolbox()
263+
264+
SPM_DIR = spm('dir');
265+
target_dir = fullfile(SPM_DIR, 'toolbox', 'MACS');
266+
MACS_TOOLBOX_DIR = fullfile(rootDir(), 'lib', 'MACS');
267+
268+
msg = sprintf('installing MACS toolbox in:\n%s.\n\n', target_dir);
269+
fprintf(1, msg);
270+
271+
if exist(target_dir, 'dir') == 7
272+
rmdir(target_dir, 's');
273+
end
274+
mkdir(target_dir);
275+
copyfile(MACS_TOOLBOX_DIR, target_dir);
276+
end
277+
259278
function uninitBidspm()
260279
%
261280
% Removes the added folders from the path for a given session.

src/infra/checkToolbox.m

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,7 @@
6565

6666
if ~status && install
6767

68-
msg = sprintf('installing MACS toolbox in:\n%s.\n\n', ...
69-
fullfile(spm('dir'), 'toolbox', 'MACS'));
70-
id = 'installingMacsToolbox';
71-
logger('WARNING', msg, 'id', id, 'filename', mfilename(), 'options', opt);
72-
73-
copyfile(fullfile(returnRootDir(), 'lib', 'MACS'), ...
74-
fullfile(spm('dir'), 'toolbox', 'MACS'));
68+
installMacstoolbox(opt);
7569

7670
status = checkToolbox(toolboxName);
7771

@@ -94,3 +88,20 @@
9488
end
9589

9690
end
91+
92+
function installMacstoolbox(opt)
93+
SPM_DIR = spm('dir');
94+
MACS_TOOLBOX_DIR = fullfile(returnRootDir(), 'lib', 'MACS');
95+
96+
target_dir = fullfile(SPM_DIR, 'toolbox', 'MACS');
97+
98+
msg = sprintf('installing MACS toolbox in:\n%s.\n\n', target_dir);
99+
id = 'installingMacsToolbox';
100+
logger('WARNING', msg, 'id', id, 'filename', mfilename(), 'options', opt);
101+
102+
if exist(target_dir, 'dir') == 7
103+
rmdir(target_dir, 's');
104+
end
105+
mkdir(target_dir);
106+
copyfile(MACS_TOOLBOX_DIR, target_dir);
107+
end

0 commit comments

Comments
 (0)