Skip to content

Commit

Permalink
Merge pull request nipreps#1 from eilidhmacnicol/enh/reports_cli_patch
Browse files Browse the repository at this point in the history
enh: add cli args
  • Loading branch information
oesteban authored Sep 8, 2020
2 parents 0e86055 + 7c9498d commit 443b284
Showing 1 changed file with 50 additions and 3 deletions.
53 changes: 50 additions & 3 deletions nirodents/cli/group_report.py
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."""
)

0 comments on commit 443b284

Please sign in to comment.