Skip to content

Commit

Permalink
update cli for preprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi-Gau committed Jan 25, 2024
1 parent ab496d2 commit d72640e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
10 changes: 10 additions & 0 deletions demos/openneuro/ds000001_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /bin/bash

# script to run the demo via the command line
cd ../..

bidspm demos/openneuro/inputs/ds000001 demos/openneuro/outputs/ds000001/derivatives subject \
--action preprocess \
--task balloonanalogrisktask \
--fwhm 8 \
--participant_label 01 02 03
2 changes: 2 additions & 0 deletions src/bidspm.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,11 @@ def run_command(cmd: str, platform: str | None = None) -> int:

if platform is None:
if Path(matlab()).exists():
log.info(f"Using matlab found at: {matlab()}")
platform = matlab()
cmd = cmd.replace(new_line, ", ")
else:
log.info("Using octave")
platform = "octave"

if platform == "octave":
Expand Down
15 changes: 15 additions & 0 deletions src/cli/cliPreprocess.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ function cliPreprocess(varargin)
validate(args);

opt = getOptionsFromCliArgument(args);

if iscellstr(opt.taskName)
if numel(opt.taskName) > 1
logger('WARNING', ...
['Too many tasks for preprocessing.\n', ...
'bidspm can only preprocess one task at time.\n', ...
'To preprocess several tasks at once use fMRIprep.\n', ...
'Only taking the first one: ', opt.taskName{1}], ...
'options', opt, ...
'filename', mfilename, ...
'id', id);
end
opt.taskName = opt.taskName{1};
end

opt.pipeline.type = 'preproc';
opt = checkOptions(opt);

Expand Down
4 changes: 2 additions & 2 deletions src/cli/inputParserForPreprocess.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
isPositiveScalar = @(x) isnumeric(x) && numel(x) == 1 && x >= 0;
isLogical = @(x) islogical(x) && numel(x) == 1;
isEmptyOrCellstr = @(x) isempty(x) || iscellstr(x); %#ok<*ISCLSTR>
isEmptyOrisChar = @(x) isempty(x) || ischar(x); %#ok<*ISCLSTR>
isEmptyOrisCharOrCellstr = @(x) isempty(x) || ischar(x) || iscellstr(x); %#ok<*ISCLSTR>
isCellStr = @(x) iscellstr(x);

addParameter(args, 'space', {}, isCellStr);
addParameter(args, 'task', '', isEmptyOrisChar);
addParameter(args, 'task', '', isEmptyOrisCharOrCellstr);
addParameter(args, 'fwhm', 6, isPositiveScalar);
addParameter(args, 'dry_run', false, isLogical);
addParameter(args, 'anat_only', false, isLogical);
Expand Down
2 changes: 1 addition & 1 deletion src/matlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ def matlab() -> str:
The 'matlab' executable is usually in the 'bin' subdirectory.
"""
return "/usr/local/MATLAB/R2018a/ bin/matlab"
return "/usr/local/MATLAB/R2018a/bin/matlab"

0 comments on commit d72640e

Please sign in to comment.