Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] update cli for preprocess #1190

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions demos/openneuro/ds000001_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#! /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


bidspm demos/openneuro/inputs/ds000001 demos/openneuro/outputs/ds000001/derivatives subject \
--action stats \
--preproc_dir demos/openneuro/outputs/ds000001/derivatives/bidspm-preproc \
--task balloonanalogrisktask \
--model_file demos/openneuro/models/model-balloonanalogrisktaskDefault_smdl.json \
--fwhm 8 \
--participant_label 01 02
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()}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (llm): Logging the path to the Matlab executable is a good practice for debugging. However, calling matlab() function twice (once for logging and once for setting platform) could be inefficient if the function does any non-trivial computation or IO. Consider storing the result in a variable and reusing it.

platform = matlab()
cmd = cmd.replace(new_line, ", ")
else:
log.info("Using octave")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (llm): Consistency in logging is important for maintainability. Consider adding the path to the octave executable, similar to how the path to Matlab is logged.

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"
Loading