Skip to content

Commit

Permalink
Merge pull request nipreps#108 from oesteban/enh/new-datasinks
Browse files Browse the repository at this point in the history
ENH: Use new ``DerivativesDataSink`` from NiWorkflows 1.2.0
  • Loading branch information
oesteban authored May 7, 2020
2 parents f2df371 + de14073 commit 25a20ba
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 72 deletions.
6 changes: 0 additions & 6 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
# General
include CHANGES.rst
include LICENSE

# versioneer
include versioneer.py
include dmriprep/_version.py
1 change: 0 additions & 1 deletion dmriprep/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def main():
failed_reports = generate_reports(
config.execution.participant_label,
config.execution.output_dir,
config.execution.work_dir,
config.execution.run_uuid,
config=pkgrf("dmriprep", "config/reports-spec.yml"),
packagename="dmriprep",
Expand Down
1 change: 0 additions & 1 deletion dmriprep/cli/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def build_workflow(config_file, retval):
retval["return_code"] = generate_reports(
subject_list,
config.execution.output_dir,
config.execution.work_dir,
config.execution.run_uuid,
config=pkgrf("dmriprep", "config/reports-spec.yml"),
packagename="dmriprep",
Expand Down
16 changes: 8 additions & 8 deletions dmriprep/config/reports-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,40 @@ package: dmriprep
sections:
- name: Summary
reportlets:
- bids: {datatype: anat, desc: summary, suffix: T1w}
- bids: {datatype: figures, desc: summary, suffix: T1w}
- name: Anatomical
reportlets:
- bids:
datatype: anat
datatype: figures
desc: conform
extension: [.html]
suffix: T1w
- bids: {datatype: anat, suffix: dseg}
- bids: {datatype: figures, suffix: dseg}
caption: This panel shows the template T1-weighted image (if several T1w images
were found), with contours delineating the detected brain mask and brain tissue
segmentations.
subtitle: Brain mask and brain tissue segmentation of the T1w
- bids: {datatype: anat, space: .*, suffix: T1w, regex_search: True}
- bids: {datatype: figures, space: .*, suffix: T1w, regex_search: True}
caption: Spatial normalization of the T1w image to the <code>{space}</code> template.
description: Results of nonlinear alignment of the T1w reference one or more template
space(s). Hover on the panels with the mouse pointer to transition between both
spaces.
static: false
subtitle: Spatial normalization of the anatomical T1w reference
- bids: {datatype: anat, desc: reconall, suffix: T1w}
- bids: {datatype: figures, desc: reconall, suffix: T1w}
caption: Surfaces (white and pial) reconstructed with FreeSurfer (<code>recon-all</code>)
overlaid on the participant's T1w template.
subtitle: Surface reconstruction
- name: Diffusion
ordering: session,acquisition,run
reportlets:
- bids: {datatype: dwi, desc: validation, suffix: dwi}
- bids: {datatype: dwi, desc: brain, suffix: mask}
- bids: {datatype: figures, desc: validation, suffix: dwi}
- bids: {datatype: figures, desc: brain, suffix: mask}
caption: Average b=0 that serves for reference in early preprocessing steps.
descriptions: The reference b=0 is obtained as the voxel-wise median across
all b=0 found in the dataset, after accounting for signal drift.
The red contour shows the brain mask calculated using this reference b=0.
subtitle: Reference b=0 and brain mask
- name: About
reportlets:
- bids: {datatype: anat, desc: about, suffix: T1w}
- bids: {datatype: figures, desc: about, suffix: T1w}
11 changes: 4 additions & 7 deletions dmriprep/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def init_single_subject_wf(subject_id):
"""
spaces = config.workflow.spaces
reportlets_dir = str(config.execution.work_dir / "reportlets")
output_dir = config.execution.output_dir

fsinputnode = pe.Node(niu.IdentityInterface(fields=["subjects_dir"]),
name="fsinputnode")
Expand All @@ -185,13 +185,11 @@ def init_single_subject_wf(subject_id):
name="about", run_without_submitting=True)

ds_report_summary = pe.Node(
DerivativesDataSink(base_directory=reportlets_dir,
desc="summary", keep_dtype=True),
DerivativesDataSink(base_directory=str(output_dir), desc="summary", datatype="figures"),
name="ds_report_summary", run_without_submitting=True)

ds_report_about = pe.Node(
DerivativesDataSink(base_directory=reportlets_dir,
desc="about", keep_dtype=True),
DerivativesDataSink(base_directory=str(output_dir), desc="about", datatype="figures"),
name="ds_report_about", run_without_submitting=True)

anat_derivatives = config.execution.anat_derivatives
Expand All @@ -214,8 +212,7 @@ def init_single_subject_wf(subject_id):
hires=config.workflow.hires,
longitudinal=config.workflow.longitudinal,
omp_nthreads=config.nipype.omp_nthreads,
output_dir=str(config.execution.output_dir),
reportlets_dir=reportlets_dir,
output_dir=str(output_dir),
skull_strip_fixed_seed=config.workflow.skull_strip_fixed_seed,
skull_strip_mode="force",
skull_strip_template=Reference.from_string(
Expand Down
3 changes: 1 addition & 2 deletions dmriprep/workflows/dwi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ def init_early_b0ref_wf(
])

# REPORTING ############################################################
reportlets_dir = str(config.execution.work_dir / 'reportlets')
reportlets_wf = init_reportlets_wf(reportlets_dir)
reportlets_wf = init_reportlets_wf(str(config.execution.output_dir))
workflow.connect([
(inputnode, reportlets_wf, [('dwi_file', 'inputnode.source_file')]),
(dwi_reference_wf, reportlets_wf, [
Expand Down
9 changes: 4 additions & 5 deletions dmriprep/workflows/dwi/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from ...interfaces import DerivativesDataSink


def init_reportlets_wf(reportlets_dir, name='reportlets_wf'):
def init_reportlets_wf(output_dir, name='reportlets_wf'):
"""Set up a battery of datasinks to store reports in the right location."""
from niworkflows.interfaces.masks import SimpleShowMaskRPT
workflow = Workflow(name=name)
Expand All @@ -17,12 +17,11 @@ def init_reportlets_wf(reportlets_dir, name='reportlets_wf'):
mask_reportlet = pe.Node(SimpleShowMaskRPT(), name='mask_reportlet')

ds_report_mask = pe.Node(
DerivativesDataSink(base_directory=reportlets_dir,
desc='brain', suffix='mask'),
DerivativesDataSink(base_directory=output_dir, desc='brain', suffix='mask',
datatype="figures"),
name='ds_report_mask', run_without_submitting=True)
ds_report_validation = pe.Node(
DerivativesDataSink(base_directory=reportlets_dir,
desc='validation', keep_dtype=True),
DerivativesDataSink(base_directory=output_dir, desc='validation', datatype="figures"),
name='ds_report_validation', run_without_submitting=True)

workflow.connect([
Expand Down
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ git+https://github.com/AleksandarPetrov/napoleon.git@0dc3f28a309ad602be5f44a9049
git+https://github.com/rwblair/sphinxcontrib-versioning.git@39b40b0b84bf872fc398feff05344051bbce0f63#egg=sphinxcontrib-versioning
nbsphinx
nipype ~= 1.4
niworkflows >=1.2.0rc1,<1.3
git+https://github.com/nipreps/niworkflows.git@master#egg=niworkflows
packaging
pydot>=1.2.3
pydotplus
smriprep >=0.6.0rc2
git+https://github.com/poldracklab/smriprep.git@master#egg=smriprep
sphinx-argparse
sphinx >=2.1.2,<3.0
sphinx_rtd_theme
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[build-system]
# setuptools can be configured with setup.cfg when >=30.3
# Most bugfixes regarding setup.cfg are included before 38.3
requires = ["setuptools >= 40.8.0", "wheel"]
56 changes: 31 additions & 25 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
[metadata]
url = https://github.com/nipreps/dmriprep
author = The dMRIPrep developers
author_email = [email protected]
maintainer = Oscar Esteban
maintainer_email = [email protected]
description = dMRIPrep is a robust and easy-to-use pipeline for preprocessing of diverse dMRI data.
long_description = file:README.rst
long_description_content_type = text/x-rst; charset=UTF-8
license = Apache License, Version 2.0
author = The NiPreps developers
author_email = [email protected]
classifiers =
Development Status :: 3 - Alpha
Intended Audience :: Science/Research
Expand All @@ -16,28 +9,51 @@ classifiers =
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
description = dMRIPrep is a robust and easy-to-use pipeline for preprocessing of diverse dMRI data.
license = Apache License, Version 2.0
long_description = file:README.rst
long_description_content_type = text/x-rst; charset=UTF-8
name = dmriprep
project_urls =
Home = https://github.com/nipreps/dmriprep
Documentation = https://www.nipreps.org/dmriprep

[options]
python_requires = >=3.5
python_requires = >=3.6
install_requires =
dipy >=1.0.0
indexed_gzip >=0.8.8
nibabel ~= 3.0
nipype ~= 1.4
niworkflows >=1.2.0rc4,<1.3
niworkflows @ git+https://github.com/nipreps/niworkflows.git@master
numpy
pybids >=0.10.2
pyyaml
sdcflows >= 1.2.3
smriprep >=0.6.0rc4,<0.7
templateflow >= 0.4.2
sdcflows @ git+https://github.com/nipreps/sdcflows.git@master
smriprep @ git+https://github.com/poldracklab/smriprep.git@master
templateflow ~= 0.6
toml
setup_requires =
setuptools >= 40.8.0
test_requires =
codecov
coverage
pytest
packages = find:
include_package_data = True

[options.packages.find]
exclude =
*.tests

[options.package_data]
dmriprep =
VERSION
config/reports-spec.yml
data/boilerplate.bib
data/tests/config.toml
data/tests/THP/*
data/tests/THP/sub-THP0005/anat/*
data/tests/THP/sub-THP0005/dwi/*

[options.exclude_package_data]
* = tests
Expand Down Expand Up @@ -77,16 +93,6 @@ all =
%(popylar)s
%(tests)s

[options.package_data]
dmriprep =
VERSION
config/reports-spec.yml
data/boilerplate.bib
data/tests/config.toml
data/tests/THP/*
data/tests/THP/sub-THP0005/anat/*
data/tests/THP/sub-THP0005/dwi/*

[options.entry_points]
console_scripts =
dmriprep=dmriprep.cli.run:main
Expand Down
23 changes: 8 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@
from setuptools import setup
import versioneer

# Give setuptools a hint to complain if it's too old a version
# 30.3.0 allows us to put most metadata in setup.cfg
# Should match pyproject.toml
# Not going to help us much without numpy or new pip, but gives us a shot
SETUP_REQUIRES = ['setuptools >= 40.8']
# This enables setuptools to install wheel on-the-fly
SETUP_REQUIRES += ['wheel'] if 'bdist_wheel' in sys.argv else []


if __name__ == '__main__':
setup(name='dmriprep',
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
setup_requires=SETUP_REQUIRES,
)
if __name__ == "__main__":
setupargs = {
"version": versioneer.get_version(),
"cmdclass": versioneer.get_cmdclass(),
}
if "bdist_wheel" in sys.argv:
setupargs["setup_requires"] = ["setuptools >= 40.8", "wheel"]
setup(**setupargs)

0 comments on commit 25a20ba

Please sign in to comment.