Prototype cli#218
Conversation
|
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. |
|
Hey @cookpa ! |
There was a problem hiding this comment.
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_extractionimplementing an argparse-based CLI wrapper aroundantspynet.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.
| license-files = [] | ||
|
|
||
| [project.scripts] | ||
| antsMouseBrainExtraction = "antspynet.cli.mouse_brain_extraction:main" |
| 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") | ||
|
|
| 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).", | ||
| ) |
There was a problem hiding this comment.
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.
| @@ -0,0 +1,3 @@ | |||
| """Command-line interfaces for ANTsPyNet.""" | |||
|
|
|||
| from .mouse_brain_extraction import main | |||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Usually I don't put anything in this init file. I will delete the content, it should not change anything.
|
@cookpa it should be ready 👍 |
|
Thanks, I will start the tests. They take a while because of data downloads |
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