Skip to content

Commit

Permalink
[FIX] install MACS toobox during initialisation (#1203)
Browse files Browse the repository at this point in the history
* copy macs tooolbox during init

* update changelog

* fix and refactor
  • Loading branch information
Remi-Gau authored Apr 4, 2024
1 parent feb0705 commit 5c8fec5
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 19 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/run_tests_notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ jobs:
run: |
git clone https://github.com/spm/spm12.git --depth 1
- name: Copy Macs toolbox to SPM inputs_folder
run: cp -rv lib/MACS spm12/toolbox/MACS

- name: Test notebooks
uses: matlab-actions/run-command@v2.1.0
with:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ jobs:
run: |
git clone https://github.com/spm/spm12.git --depth 1
- name: Copy Macs toolbox to SPM inputs_folder
run: cp -rv lib/MACS spm12/toolbox/MACS

- name: Get moae fmriprep data from OSF
run: |
mkdir -p demos/MoAE/inputs/
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/tests_octave.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ jobs:
run: |
git clone https://github.com/spm/spm12.git --depth 1
- name: Copy Macs toolbox to SPM inputs_folder
run: cp -rv lib/MACS spm12/toolbox/MACS

- name: Get moae fmriprep data from OSF
run: |
mkdir -p demos/MoAE/inputs/
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/tests_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ jobs:
run: |
git clone https://github.com/spm/spm12.git --depth 1
- name: Copy Macs toolbox to SPM inputs_folder
run: Copy-Item -Recurse -Verbose -Path ".\lib\MACS" -Destination ".\spm12\toolbox\MACS"

- name: Get moae fmriprep data from OSF
run: |
New-Item -ItemType Directory -Path ".\demos\MoAE\inputs\" -Force
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

* [FIX] copy the MACS toolbox to the SPM toolbox folder during the initialisation #1203 by @Remi-Gau
* [FIX] save onsets.mat directly in subject stats folder #1187 by @Remi-Gau
* [FIX] do not compute subject level contrast when running dataset level #1102 by @Remi-Gau
* [FIX] copy `RepetitionTime` in sidecar JSON after running smoothing in #1099 by @Remi-Gau
Expand Down
19 changes: 19 additions & 0 deletions bidspm.m
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ function initBidspm(dev)
fullfile(rootDir(), 'tests', 'utils'));
end

% Make sure MACS toolbox used by SPM is the one from bidspm
installMacstoolbox();

% for some reasons this folder was otherwise not added to the path in Octave
BIDSPM_PATHS = cat(2, BIDSPM_PATHS, ...
pathSep, ...
Expand Down Expand Up @@ -256,6 +259,22 @@ function initBidspm(dev)

end

function installMacstoolbox()

SPM_DIR = spm('dir');
target_dir = fullfile(SPM_DIR, 'toolbox', 'MACS');
MACS_TOOLBOX_DIR = fullfile(rootDir(), 'lib', 'MACS');

msg = sprintf('installing MACS toolbox in:\n%s.\n\n', target_dir);
fprintf(1, msg);

if exist(target_dir, 'dir') == 7
rmdir(target_dir, 's');
end
mkdir(target_dir);
copyfile(MACS_TOOLBOX_DIR, target_dir);
end

function uninitBidspm()
%
% Removes the added folders from the path for a given session.
Expand Down
25 changes: 18 additions & 7 deletions src/infra/checkToolbox.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,7 @@

if ~status && install

msg = sprintf('installing MACS toolbox in:\n%s.\n\n', ...
fullfile(spm('dir'), 'toolbox', 'MACS'));
id = 'installingMacsToolbox';
logger('WARNING', msg, 'id', id, 'filename', mfilename(), 'options', opt);

copyfile(fullfile(returnRootDir(), 'lib', 'MACS'), ...
fullfile(spm('dir'), 'toolbox', 'MACS'));
installMacstoolbox(opt);

status = checkToolbox(toolboxName);

Expand All @@ -94,3 +88,20 @@
end

end

function installMacstoolbox(opt)
SPM_DIR = spm('dir');
MACS_TOOLBOX_DIR = fullfile(returnRootDir(), 'lib', 'MACS');

target_dir = fullfile(SPM_DIR, 'toolbox', 'MACS');

msg = sprintf('installing MACS toolbox in:\n%s.\n\n', target_dir);
id = 'installingMacsToolbox';
logger('WARNING', msg, 'id', id, 'filename', mfilename(), 'options', opt);

if exist(target_dir, 'dir') == 7
rmdir(target_dir, 's');
end
mkdir(target_dir);
copyfile(MACS_TOOLBOX_DIR, target_dir);
end

0 comments on commit 5c8fec5

Please sign in to comment.