Skip to content

Prototype cli#218

Open
arnaudbore wants to merge 4 commits into
ANTsX:masterfrom
arnaudbore:prototype_cli
Open

Prototype cli#218
arnaudbore wants to merge 4 commits into
ANTsX:masterfrom
arnaudbore:prototype_cli

Conversation

@arnaudbore
Copy link
Copy Markdown

@arnaudbore arnaudbore commented Apr 21, 2026

Here is a prototype of a cli: antsMouseBrainExtraction

Even tho I've been told @cookpa would take care of it, I took few minutes to give it a try. Sorry not sorry I guess 😅

#217

@ntustison
Copy link
Copy Markdown
Member

Hey, thanks for this @arnaudbore . I'll defer to @cookpa to provide any feedback on this since it's a bit out of my wheelhouse.

@arnaudbore
Copy link
Copy Markdown
Author

Hey @cookpa !
Any update on this side ?

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a first prototype command-line interface for running ANTsPyNet’s mouse_brain_extraction utility via an installed console script, along with a unit test that verifies the CLI wiring (read → extract → write).

Changes:

  • Add antspynet.cli.mouse_brain_extraction implementing an argparse-based CLI wrapper around antspynet.mouse_brain_extraction.
  • Register a console script entry point in pyproject.toml.
  • Add a lightweight unit test that patches I/O/model calls to validate argument routing.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
antspynet/cli/mouse_brain_extraction.py New CLI implementation (parser, run wrapper, main entry).
antspynet/cli/__init__.py Introduces cli package and re-exports main.
pyproject.toml Adds a console script entry point for the new CLI.
tests/test_mouse_cli.py Adds a unit test validating CLI → mouse_brain_extraction call routing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyproject.toml
license-files = []

[project.scripts]
antsMouseBrainExtraction = "antspynet.cli.mouse_brain_extraction:main"
Comment on lines +61 to +76
def main(argv=None):
parser = build_parser()
args = parser.parse_args(argv)

try:
run(
args.input_image,
args.output_image,
modality=args.modality,
isotropic_output=args.isotropic_output,
axis=args.axis,
verbose=args.verbose,
)
except Exception as error:
parser.exit(1, f"Error: {error}\n")

Comment on lines +23 to +39
parser.add_argument(
"--modality",
type=str,
default="t2",
help='Mouse image modality passed to mouse_brain_extraction (default: "t2").',
)
parser.add_argument(
"--isotropic-output",
action="store_true",
help="Return the probability image in isotropic space before writing it.",
)
parser.add_argument(
"--axis",
type=int,
default=2,
help="Axis index used for ex5 modalities (default: 2).",
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is important. The documentation needs to be complete and explanatory, which does introduce some duplication with function documentation, but I don't see how it can be avoided.

Comment thread antspynet/cli/__init__.py Outdated
@@ -0,0 +1,3 @@
"""Command-line interfaces for ANTsPyNet."""

from .mouse_brain_extraction import main
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure how this helps exactly, but I think it does make sense to alias imports since other cli scripts would also have a main

Copy link
Copy Markdown
Author

@arnaudbore arnaudbore May 19, 2026

Choose a reason for hiding this comment

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

Usually I don't put anything in this init file. I will delete the content, it should not change anything.

@arnaudbore
Copy link
Copy Markdown
Author

@cookpa it should be ready 👍

@cookpa
Copy link
Copy Markdown
Member

cookpa commented May 19, 2026

Thanks, I will start the tests. They take a while because of data downloads

@arnaudbore arnaudbore changed the title [WIP] Test prototype cli Prototype cli May 19, 2026
@arnaudbore arnaudbore requested a review from cookpa May 20, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants