From de140730f64449529374b6ddda6e9e418e07ec2e Mon Sep 17 00:00:00 2001 From: oesteban Date: Sun, 3 May 2020 08:03:01 -0700 Subject: [PATCH] enh: use new ``DerivativesDataSink`` from NiWorkflows 1.2.0 --- MANIFEST.in | 6 ---- dmriprep/cli/run.py | 1 - dmriprep/cli/workflow.py | 1 - dmriprep/config/reports-spec.yml | 16 ++++----- dmriprep/workflows/base.py | 11 +++--- dmriprep/workflows/dwi/base.py | 3 +- dmriprep/workflows/dwi/outputs.py | 9 +++-- docs/requirements.txt | 4 +-- pyproject.toml | 2 ++ setup.cfg | 56 +++++++++++++++++-------------- setup.py | 23 +++++-------- 11 files changed, 60 insertions(+), 72 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 71126fef..a24694ff 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1 @@ -# General -include CHANGES.rst -include LICENSE - -# versioneer include versioneer.py -include dmriprep/_version.py diff --git a/dmriprep/cli/run.py b/dmriprep/cli/run.py index f2d52542..ecaa2c0c 100755 --- a/dmriprep/cli/run.py +++ b/dmriprep/cli/run.py @@ -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", diff --git a/dmriprep/cli/workflow.py b/dmriprep/cli/workflow.py index d8642629..86ccb9f7 100644 --- a/dmriprep/cli/workflow.py +++ b/dmriprep/cli/workflow.py @@ -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", diff --git a/dmriprep/config/reports-spec.yml b/dmriprep/config/reports-spec.yml index cc0cc62c..a3bad5c8 100644 --- a/dmriprep/config/reports-spec.yml +++ b/dmriprep/config/reports-spec.yml @@ -2,35 +2,35 @@ 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 {space} 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 (recon-all) 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. @@ -38,4 +38,4 @@ sections: subtitle: Reference b=0 and brain mask - name: About reportlets: - - bids: {datatype: anat, desc: about, suffix: T1w} + - bids: {datatype: figures, desc: about, suffix: T1w} diff --git a/dmriprep/workflows/base.py b/dmriprep/workflows/base.py index 0a7636fb..d907ab72 100755 --- a/dmriprep/workflows/base.py +++ b/dmriprep/workflows/base.py @@ -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") @@ -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 @@ -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( diff --git a/dmriprep/workflows/dwi/base.py b/dmriprep/workflows/dwi/base.py index df770097..5ddc7569 100644 --- a/dmriprep/workflows/dwi/base.py +++ b/dmriprep/workflows/dwi/base.py @@ -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, [ diff --git a/dmriprep/workflows/dwi/outputs.py b/dmriprep/workflows/dwi/outputs.py index 64cde08e..fa2b62e2 100644 --- a/dmriprep/workflows/dwi/outputs.py +++ b/dmriprep/workflows/dwi/outputs.py @@ -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) @@ -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([ diff --git a/docs/requirements.txt b/docs/requirements.txt index 5d60f902..beb81f5e 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 10b94d6a..3a682f14 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"] diff --git a/setup.cfg b/setup.cfg index fa09ec48..8f58ddc0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,13 +1,6 @@ [metadata] -url = https://github.com/nipreps/dmriprep -author = The dMRIPrep developers -author_email = code@oscaresteban.es -maintainer = Oscar Esteban -maintainer_email = code@oscaresteban.es -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 = nipreps@gmail.com classifiers = Development Status :: 3 - Alpha Intended Audience :: Science/Research @@ -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 @@ -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 diff --git a/setup.py b/setup.py index 1783fa81..07c88269 100644 --- a/setup.py +++ b/setup.py @@ -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)