forked from nipreps/nirodents
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request nipreps#1 from eilidhmacnicol/enh/reports_cli_patch
enh: add cli args
- Loading branch information
Showing
1 changed file
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,50 @@ | ||
from niworkflows.reports.core import Report | ||
rodents_path = "/oak/stanford/groups/russpold/data/rodents/derivatives/antsai-yes/ratLCdfMRI_RAS/" | ||
Report("/home/oesteban/tmp/nirodents/out/", "madeoutuid", reportlets_dir=rodents_path, config="group.yml").generate_report() | ||
"""Command Line Interface to generate group reports""" | ||
|
||
import os | ||
from pathlib import Path | ||
|
||
def get_parser(): | ||
"""Build parser object.""" | ||
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter | ||
|
||
parser = ArgumentParser( | ||
prog="generate_group_report", | ||
description="""generate_group_report -- Create group report based on individual reportlets.""", | ||
formatter_class=ArgumentDefaultsHelpFormatter, | ||
) | ||
|
||
parser.add_argument( | ||
"-r", "--reports", type=Path, help="The location of reportlet files.", required=True | ||
) | ||
parser.add_argument( | ||
"-o", "--output", type=Path, help="The output location for report." | ||
) | ||
parser.add_argument( | ||
"-n", "--report-name", help="The output file name." | ||
) | ||
return parser | ||
|
||
def main(): | ||
"""Entry point.""" | ||
from niworkflows.reports.core import Report | ||
opts = get_parser().parse_args() | ||
if opts.output is None: | ||
opts.output = opts.reports | ||
if opts.report_name is None: | ||
opts.report_name = 'group_report.html' | ||
|
||
Report( | ||
out_dir=opts.output, | ||
run_uuid="madeoutuid", | ||
reportlets_dir=opts.reports, | ||
config="group.yml", | ||
out_filename=opts.report_name, | ||
).generate_report() | ||
|
||
|
||
if __name__ == "__main__": | ||
raise RuntimeError( | ||
"""\ | ||
nirodents/cli/group_report.py should not be run directly; | ||
Please `pip install` nirodents and use the `generate_group_report` command.""" | ||
) |