Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Allow different types of reportlets, not only BIDS-based #60

Merged
merged 16 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions nireports/assembler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
"""
Aggregate reports into an HTML document.
"""
36 changes: 34 additions & 2 deletions nireports/assembler/data/default.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package: nireports
packagename: nireports
sections:
- name: Summary
reportlets:
Expand Down Expand Up @@ -173,5 +173,37 @@ sections:
in green; noise components in red.
subtitle: ICA Components classified by AROMA
- name: About
nested: true
reportlets:
- bids: {datatype: figures, desc: about, suffix: T1w}
- custom: boilerplate
path: '{reportlets_dir}/sub-{subject_id}/'
bibfile: ['nireports.assembler', 'data/tests/boilerplate.bib']
caption: We kindly ask to report results preprocessed with this tool using the following boilerplate.
title: Methods
- custom: errors
path: '{reportlets_dir}/sub-{subject_id}/log/{run_uuid}'
captions: <em>NiReports</em> may have recorded failure conditions.
title: Errors
- metadata:
Execution provenance:
NiReports version: '23.0.1'
NiReports command: |
<code>/opt/conda/bin/fmriprep /data /out participant --sloppy --write-graph
--mem-mb 14336 --nthreads 4 -vv --anat-derivatives /opt/smriprep/subjects
-w /scratch --output-spaces fsaverage5</code>
Date processed: '2023-03-12 03:15:45 +0000'
Dataset information:
Dataset name: 'Test example'
Participant ID: '00017'
Split Nested_key1: value1
Split Nested_key2: value1
settings:
# By default, only the first dictionary will be expanded.
# If folded is true, all will be folded. If false all expanded.
folded: true
# If an ID is not provided, one should be generated automatically
id: 'about-metadata'
caption: |
Thanks for using <em>NiReports</em>. The following information may assist in
reconstructing the provenance of the corresponding derivatives.
title: Reproducibility and provenance information
100 changes: 32 additions & 68 deletions nireports/assembler/data/report.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.12: http://docutils.sourceforge.net/" />
<title></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>

<style type="text/css">
.sub-report-title {}
.run-title {}
Expand Down Expand Up @@ -53,33 +52,38 @@ div#boilerplate pre {
padding-left: 1em;
}
</style>

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>

</head>
<body>


<nav class="navbar fixed-top navbar-expand-lg navbar-light bg-light">
<div class="collapse navbar-collapse">
<ul class="navbar-nav">
<nav class="navbar fixed-top navbar-expand-lg bg-light">
<div class="container-fluid">
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
{% for sub_report in sections %}
{% if sub_report.isnested %}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="navbar{{ sub_report.name }}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#">{{ sub_report.name }}</a>
<div class="dropdown-menu" aria-labelledby="navbar{{ sub_report.name }}">
{% for run_report in sub_report.reportlets %}
{% if run_report.title %}
<a class="dropdown-item" href="#{{run_report.name}}">{{run_report.title}}</a>
{% endif %}
{% endfor %}
</div>
<a class="nav-link dropdown-toggle" id="navbar{{ sub_report.name }}" role="button" data-bs-toggle="dropdown" aria-expanded="false" href="#{{sub_report.name}}">
{{ sub_report.name }}
</a>
<ul class="dropdown-menu">
{% for run_report in sub_report.reportlets %}
{% if run_report.title %}
<li><a class="dropdown-item" href="#{{run_report.name}}">{{run_report.title}}</a></li>
{% endif %}
{% endfor %}
</ul>
</li>
{% else %}
<li class="nav-item"><a class="nav-link" href="#{{sub_report.name}}">{{sub_report.name}}</a></li>
{% endif %}
{% endfor %}
<li class="nav-item"><a class="nav-link" href="#boilerplate">Methods</a></li>
<li class="nav-item"><a class="nav-link" href="#errors">Errors</a></li>
</ul>
</div>
</div>
</nav>
<noscript>
<h1 class="text-danger"> The navigation menu uses Javascript. Without it this report might not work as expected </h1>
Expand All @@ -106,59 +110,19 @@ div#boilerplate pre {
{% endif %}
{% endfor %}

<div id="boilerplate">
<h1 class="sub-report-title">Methods</h1>
{% if boilerplate %}
<p>We kindly ask to report results preprocessed with this tool using the following
boilerplate.</p>
<ul class="nav nav-tabs" id="myTab" role="tablist">
{% for b in boilerplate %}
<li class="nav-item">
<a class="nav-link {% if b[0] == 0 %}active{% endif %}" id="{{ b[1] }}-tab" data-toggle="tab" href="#{{ b[1] }}" role="tab" aria-controls="{{ b[1] }}" aria-selected="{% if b[0] == 0 %}true{%else%}false{% endif %}">{{ b[1] }}</a>
</li>
{% endfor %}
</ul>
<div class="tab-content" id="myTabContent">
{% for b in boilerplate %}
<div class="tab-pane fade {% if b[0] == 0 %}active show{% endif %}" id="{{ b[1] }}" role="tabpanel" aria-labelledby="{{ b[1] }}-tab">{{ b[2] }}</div>
{% endfor %}
</div>
{% else %}
<p class="text-danger">Failed to generate the boilerplate</p>
{% endif %}
</div>

<div id="errors">
<h1 class="sub-report-title">Errors</h1>
{% for error in errors %}
<details>
<summary>Node Name: {{ error.node }}</summary><br>
<div>
File: <code>{{ error.file }}</code><br>
Working Directory: <code>{{ error.node_dir }}</code><br>
Inputs: <br>
<ul>
{% for name, spec in error.inputs %}
<li>{{ name }}: <code>{{ spec }}</code></li>
{% endfor %}
</ul>
<pre>{{ error.traceback }}</pre>
</div>
</details>
{% else %}
<p>No errors to report!</p>
{% endfor %}
</div>


<script type="text/javascript">
function toggle(id) {
var element = document.getElementById(id);
if(element.style.display == 'block')
element.style.display = 'none';
else
element.style.display = 'block';
}
function toggle(id) {
var element = document.getElementById(id);
if(element.style.display == 'block')
element.style.display = 'none';
else
element.style.display = 'block';
}

<!-- $(".nav .nav-link").on("click", function(){
$(".nav").find(".active").removeClass("active");
$(this).addClass("active");
}); -->
</script>
</body>
</html>
Loading