Skip to content

Commit

Permalink
fix output ROI
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi-Gau committed Jul 24, 2024
1 parent 81529f0 commit 63c4cea
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 31 deletions.
12 changes: 0 additions & 12 deletions src/bidspm/bidspm.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,13 @@ def create_roi(
preproc_dir: Path | None = None,
verbosity: str | int = 2,
participant_label: list[str] | None = None,
roi_dir: Path | None = None,
roi_atlas: str | None = "neuromorphometrics",
roi_name: str | list[str] | None = None,
space: list[str] | None = None,
bids_filter_file: Path | None = None,
options: Path | None = None,
) -> str:
roi_name = _cellify(roi_name) if roi_name is not None else None

Check warning on line 203 in src/bidspm/bidspm.py

View check run for this annotation

Codecov / codecov/patch

src/bidspm/bidspm.py#L203

Added line #L203 was not covered by tests
if roi_dir is None:
roi_dir = output_dir

cmd = generate_cmd(
bids_dir=bids_dir,
Expand All @@ -222,8 +219,6 @@ def create_roi(
)
cmd += f"{new_line}'roi_atlas', '{roi_atlas}'"
cmd += f"{new_line}'roi_name', {roi_name}"
if roi_dir:
cmd += f"{new_line}'roi_dir', '{roi_dir}'"
if preproc_dir:
cmd += f"{new_line}'preproc_dir', '{preproc_dir}'"
cmd = end_cmd(cmd)
Expand Down Expand Up @@ -393,20 +388,13 @@ def generate_command_create_roi(argv: Any) -> str:
parser = sub_command_parser()
args = parser.parse_args(argv[1:])

Check warning on line 389 in src/bidspm/bidspm.py

View check run for this annotation

Codecov / codecov/patch

src/bidspm/bidspm.py#L387-L389

Added lines #L387 - L389 were not covered by tests

if args.roi_dir is None or args.roi_dir[0] is None:
roi_dir = args.output_dir[0]
else:
roi_dir = args.roi_dir[0]
roi_dir = Path(roi_dir).absolute()

cmd = create_roi(

Check warning on line 391 in src/bidspm/bidspm.py

View check run for this annotation

Codecov / codecov/patch

src/bidspm/bidspm.py#L391

Added line #L391 was not covered by tests
bids_dir=Path(args.bids_dir[0]).absolute(),
output_dir=Path(args.output_dir[0]).absolute(),
analysis_level=args.analysis_level[0],
preproc_dir=_get_preproc_dir(args),
verbosity=_get_verbosity(args),
participant_label=args.participant_label,
roi_dir=roi_dir,
roi_atlas=_get_roi_atlas(args),
roi_name=args.roi_name,
space=args.space,
Expand Down
22 changes: 8 additions & 14 deletions src/bidspm/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ def sub_command_parser() -> ArgumentParser:
roi_parser = _add_common_arguments(roi_parser)
roi_parser = _add_boilerplate_only(roi_parser)
roi_parser = _add_space(roi_parser)
roi_parser = _add_roi_dir(roi_parser)
roi_parser.add_argument(

Check warning on line 237 in src/bidspm/parsers.py

View check run for this annotation

Codecov / codecov/patch

src/bidspm/parsers.py#L234-L237

Added lines #L234 - L237 were not covered by tests
"--roi_name",
help="""
Expand Down Expand Up @@ -290,7 +289,14 @@ def sub_command_parser() -> ArgumentParser:
action="store_true",
default=False,
)
stats_parser = _add_roi_dir(stats_parser)
stats_parser.add_argument(

Check warning on line 292 in src/bidspm/parsers.py

View check run for this annotation

Codecov / codecov/patch

src/bidspm/parsers.py#L292

Added line #L292 was not covered by tests
"--roi_dir",
help="""
Fullpath to the directory with the regions of interest.
""",
type=str,
nargs=1,
)
stats_parser.add_argument(

Check warning on line 300 in src/bidspm/parsers.py

View check run for this annotation

Codecov / codecov/patch

src/bidspm/parsers.py#L300

Added line #L300 was not covered by tests
"--roi_name",
help="""
Expand Down Expand Up @@ -419,18 +425,6 @@ def _add_skip_validation(parser: ArgumentParser) -> ArgumentParser:
return parser

Check warning on line 425 in src/bidspm/parsers.py

View check run for this annotation

Codecov / codecov/patch

src/bidspm/parsers.py#L425

Added line #L425 was not covered by tests


def _add_roi_dir(parser: ArgumentParser) -> ArgumentParser:
parser.add_argument(
"--roi_dir",
help="""
Fullpath to the directory with the regions of interest.
""",
type=str,
nargs=1,
)
return parser


def _add_task(parser: ArgumentParser) -> ArgumentParser:

Check warning on line 428 in src/bidspm/parsers.py

View check run for this annotation

Codecov / codecov/patch

src/bidspm/parsers.py#L428

Added line #L428 was not covered by tests
parser.add_argument(
"--task",
Expand Down
6 changes: 5 additions & 1 deletion src/cli/getOptionsFromCliArgument.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,12 @@
end

function opt = roiOptions(opt, args)

if isfield(args.Results, 'roi_dir')
opt.dir.roi = args.Results.roi_dir;
opt.dir.roi = args.Results.output_dir;
end
if ismember(lower(args.Results.action), {'create_roi'})
opt.dir.roi = fullfile(args.Results.output_dir, 'derivatives', 'bidspm-roi');
end
if isfield(args.Results, 'roi_atlas')
opt.roi.atlas = args.Results.roi_atlas;
Expand Down
1 change: 0 additions & 1 deletion src/cli/inputParserForCreateRoi.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
isLogical = @(x) islogical(x) && numel(x) == 1;

addParameter(args, 'space', {}, isCellStr);
addParameter(args, 'roi_dir', '', isDir);
addParameter(args, 'preproc_dir', '', isDir);
addParameter(args, 'hemisphere', {'L', 'R'}, isCellStr);
addParameter(args, 'roi_atlas', 'neuromorphometrics', isInAvailableAtlas);
Expand Down
3 changes: 0 additions & 3 deletions tests/test_bidspm.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ def test_create_roi():
preproc_dir=Path(),
verbosity=2,
participant_label=["01"],
roi_dir=Path(),
roi_atlas="neuromorphometrics",
roi_name=["foo", "bar"],
space=["MNI"],
Expand Down Expand Up @@ -263,8 +262,6 @@ def test_generate_command_create_roi(analysis_level):
"--space",
"IXI549Space",
"--boilerplate_only",
"--roi_dir",
str(Path().absolute()),
"--preproc_dir",
str(Path().absolute()),
"--hemisphere",
Expand Down

0 comments on commit 63c4cea

Please sign in to comment.