def test_report_session(): """Generating a report for one session should mean that no other sessions appear in any of the unique descriptions. """ report = BIDSReport(testlayout()) descriptions = report.generate(session='01') assert 'session 02' not in ' '.join(descriptions.keys())
def test_report_gen(): """Report generation should return a counter of unique descriptions in the dataset. """ report = BIDSReport(testlayout()) descriptions = report.generate() assert isinstance(descriptions, Counter)
def test_report_subject(): """Generating a report for one subject should only return one subject's description (i.e., one pattern with a count of one). """ report = BIDSReport(testlayout()) descriptions = report.generate(subject='01') assert sum(descriptions.values()) == 1
def test_report_session(testlayout): """Generating a report for one session should mean that no other sessions appear in any of the unique descriptions. """ report = BIDSReport(testlayout) descriptions = report.generate(session='01') assert 'session 02' not in ' '.join(descriptions.keys())
def test_report_session(testlayout): """Generating a report for one session should mean that no other sessions appear in any of the unique descriptions. """ report = BIDSReport(testlayout) descriptions = report.generate(session="01") assert "session 02" not in " ".join(descriptions.keys())
def test_report_subject(testlayout): """Generating a report for one subject should only return one subject's description (i.e., one pattern with a count of one). """ report = BIDSReport(testlayout) descriptions = report.generate(subject='01') assert sum(descriptions.values()) == 1
def test_report_gen(testlayout): """Report generation should return a counter of unique descriptions in the dataset. """ report = BIDSReport(testlayout) descriptions = report.generate() assert isinstance(descriptions, Counter)
def test_report_file_config(): """Report initialization should take in a config file and use that if provided. """ config_file = abspath( join(get_test_data_path(), '../../reports/config/converters.json')) report = BIDSReport(testlayout(), config=config_file) descriptions = report.generate() assert isinstance(descriptions, Counter)
def test_report_gen_from_files(testlayout): """Report generation from file list should return a counter of unique descriptions in the dataset. """ report = BIDSReport(testlayout) files = testlayout.get(extension=['nii.gz', 'nii']) descriptions = report.generate_from_files(files) assert isinstance(descriptions, Counter)
def test_report_file_config(testlayout): """Report initialization should take in a config file and use that if provided. """ config_file = abspath(join(get_test_data_path(), '../../reports/config/converters.json')) report = BIDSReport(testlayout, config=config_file) descriptions = report.generate() assert isinstance(descriptions, Counter)
def test_report_dict_config(): """Report initialization should take in a config dict and use that if provided. """ config_file = abspath( join(get_test_data_path(), '../../reports/config/converters.json')) with open(config_file, 'r') as fobj: config = json.load(fobj) report = BIDSReport(testlayout(), config=config) descriptions = report.generate() assert isinstance(descriptions, Counter)
def test_report_dict_config(testlayout): """Report initialization should take in a config dict and use that if provided. """ config_file = abspath(join(get_test_data_path(), '../../reports/config/converters.json')) with open(config_file, 'r') as fobj: config = json.load(fobj) report = BIDSReport(testlayout, config=config) descriptions = report.generate() assert isinstance(descriptions, Counter)
def test_report_init(): """Report initialization should return a BIDSReport object. """ report = BIDSReport(testlayout()) assert isinstance(report, BIDSReport)
#!/usr/bin/env python import sys from pathlib import Path from bids import BIDSLayout from bids.reports import BIDSReport cmd, bids_root, out_root, analysis_level, *opts = sys.argv layout = BIDSLayout(bids_root) reports = {} for subject in layout.get_subjects(): rep = list(BIDSReport(layout).generate(subject=subject))[0] reports.setdefault(rep, []).append(subject) with open(Path(out_root) / "report.txt", "w") as out_file: out_file.write(f"Scan parameter sets detected: {len(reports)}\n\n") for rep, subs in reports.items(): rep = "\n".join(rep.splitlines()[:-2]) out_file.write(f"-----\nParameters for subjects: {', '.join(subs)}\n\n") out_file.write(rep.replace("<deg>", "°") + "\n\n")