Skip to content

Commit ab6725e

Browse files
committed
Merge branch 'refactor' of https://github.com/josephmje/dmriprep into refactor
2 parents f15679a + de5146b commit ab6725e

21 files changed

+319
-295
lines changed

.flake8

Lines changed: 0 additions & 5 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

AUTHORS.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ Development Leads
88
- Anisha Keshavan <[email protected]> [Corresponding developer]
99
- Adam Richie-Halford <[email protected]>
1010

11-
- Michael Joseph <[email protected]> [Corresponding developer]
12-
- Salim Mansour <[email protected]>
13-
1411
Contributors
1512
------------
1613

Dockerfile

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
11
# Use Ubuntu 16.04 LTS
22
FROM ubuntu:xenial-20190610
33

4-
# Used command:
5-
# neurodocker generate docker --base=debian:stretch --pkg-manager=apt
6-
# --ants version=latest method=source --mrtrix3 version=3.0_RC3
7-
# --freesurfer version=6.0.0 method=binaries --fsl version=6.0.1 method=binaries
4+
# Prepare environment
5+
RUN apt-get update && \
6+
apt-get install -y --no-install-recommends \
7+
curl \
8+
bzip2 \
9+
ca-certificates \
10+
xvfb \
11+
cython3 \
12+
build-essential \
13+
autoconf \
14+
libtool \
15+
pkg-config \
16+
git && \
17+
curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
18+
apt-get install -y --no-install-recommends \
19+
nodejs && \
20+
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
821

922
# Getting required installation tools
1023
RUN apt-get update && \
1124
apt-get install -y --no-install-recommends \
1225
apt-utils \
13-
bzip2 \
14-
ca-certificates \
15-
curl \
1626
locales \
1727
unzip \
1828
bc \
19-
libtool \
2029
tar \
2130
dpkg \
2231
wget \
2332
gcc \
24-
git \
2533
libstdc++6
2634

2735
# Neurodocker Setup
@@ -56,27 +64,21 @@ RUN export ND_ENTRYPOINT="/neurodocker/startup.sh" \
5664

5765
ENTRYPOINT ["/neurodocker/startup.sh"]
5866

59-
# install ANTS v2.3.1
60-
curl -sSL https://github.com/ANTsX/ANTs/archive/v2.3.1.tar.gz
61-
67+
# Installing ANTS v2.3.1
68+
ENV ANTSPATH=/opt/ants
69+
RUN mkdir -p $ANTSPATH && \
70+
curl -sSL https://github.com/ANTsX/ANTs/archive/v2.3.1.tar.gz
71+
| tar -xzC $ANTSPATH --strip-components 1
72+
ENV PATH=$ANTSPATH:$PATH
6273

63-
# ANTS (used from BIDS-Apps https://github.com/BIDS-Apps/dockerfile-templates/blob/master/ANTs/Dockerfile)
64-
RUN mkdir -p /opt/ants && \
65-
curl -sSL "https://github.com/stnava/ANTs/releases/download/v2.1.0/Linux_Ubuntu14.04.tar.bz2" \
66-
| tar -xjC /opt/ants --strip-components 1 && \
67-
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
68-
69-
ENV ANTSPATH /opt/ants
70-
ENV PATH $ANTSPATH:$PATH
71-
72-
# MRtrix3 generated from Neurodocker
74+
# Installing MRtrix3
7375
ENV PATH="/opt/mrtrix3-3.0_RC3/bin:$PATH"
7476
RUN echo "Downloading MRtrix3 ..." \
7577
&& mkdir -p /opt/mrtrix3-3.0_RC3 \
7678
&& curl -fsSL --retry 5 https://dl.dropbox.com/s/2oh339ehcxcf8xf/mrtrix3-3.0_RC3-Linux-centos6.9-x86_64.tar.gz \
7779
| tar -xz -C /opt/mrtrix3-3.0_RC3 --strip-components 1
7880

79-
# Freesurfer generated from Neurodocker
81+
# Installing Freesurfer
8082
ENV FREESURFER_HOME="/opt/freesurfer-6.0.0" \
8183
PATH="/opt/freesurfer-6.0.0/bin:$PATH"
8284
RUN apt-get update -qq \
@@ -108,6 +110,7 @@ RUN apt-get update -qq \
108110
--exclude='freesurfer/trctrain' \
109111
&& sed -i '$isource "/opt/freesurfer-6.0.0/SetUpFreeSurfer.sh"' "$ND_ENTRYPOINT"
110112

113+
# Installing FSL
111114
ENV FSLDIR="/opt/fsl-6.0.1" \
112115
PATH="/opt/fsl-6.0.1/bin:$PATH"
113116
RUN apt-get update -qq \
@@ -183,15 +186,6 @@ RUN echo '{ \
183186
\n ] \
184187
\n}' > /neurodocker/neurodocker_specs.json
185188

186-
#All of the examples below use debian:stretch as the base image, but any Docker image can be used as a base.
187-
#Common base images (and their packages managers) are ubuntu:16.04 (apt), centos:7 (yum), neurodebian:nd16.04 (apt), and neurodebian:stretch (apt).
188-
189-
# FSL 6.0.1
190-
# Freesurfer 6.0.0
191-
# MRtrix3
192-
# ANTS
193-
# Python 3
194-
195189
# add credentials on build
196190
RUN mkdir ~/.ssh && ln -s /run/secrets/host_ssh_key ~/.ssh/id_rsa
197191
# Getting required installation tools

README.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
.. highlight:: shell
2-
3-
===========
1+
========
42
dmriprep
5-
===========
6-
7-
.. image:: https://codecov.io/gh/TIGRLab/dmriprep/branch/master/graph/badge.svg
8-
:alt: Codecov Badge
9-
:target: https://codecov.io/gh/TIGRLab/dmriprep
10-
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
11-
:alt: Black Badge
12-
:target: https://github.com/python/black
13-
.. image:: https://api.codacy.com/project/badge/Grade/f45ec5c64894427a8860cc87cda1910a
14-
:alt: Codacy Badge
15-
:target: https://app.codacy.com/app/josephmje/dmriprep?utm_source=github.com&utm_medium=referral&utm_content=TIGRLab/dmriprep&utm_campaign=Badge_Grade_Dashboard
3+
========
4+
5+
6+
.. image:: https://img.shields.io/pypi/v/dmriprep.svg
7+
:target: https://pypi.python.org/pypi/dmriprep
8+
9+
.. image:: https://img.shields.io/travis/akeshavan/dmriprep.svg
10+
:target: https://travis-ci.org/akeshavan/dmriprep
11+
12+
.. image:: https://readthedocs.org/projects/dmriprep/badge/?version=latest
13+
:target: https://dmriprep.readthedocs.io/en/latest/?badge=latest
14+
:alt: Documentation Status
15+
1616

1717
Preprocessing of neuroimaging data in preparation for AFQ analysis
1818
------------------------------------------------------------------

dmriprep/_version.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
196196
if verbose:
197197
print("likely tags: %s" % ",".join(sorted(tags)))
198198
for ref in sorted(tags):
199-
# sorting will prefer e.g. "2.0" over "2.0rc1"
199+
# sorting will prefer e.g., "2.0" over "2.0rc1"
200200
if ref.startswith(tag_prefix):
201201
r = ref[len(tag_prefix):]
202202
if verbose:
@@ -483,6 +483,20 @@ def get_versions():
483483

484484
cfg = get_config()
485485
verbose = cfg.verbose
486+
root = os.path.realpath(__file__)
487+
488+
root_dir = os.path.dirname(root)
489+
if os.path.isfile(os.path.join(root_dir, 'VERSION')):
490+
with open(os.path.join(root_dir, 'VERSION')) as vfile:
491+
version = vfile.readline().strip()
492+
493+
return {
494+
"version": version,
495+
"full-revisionid": None,
496+
"dirty": None,
497+
"error": None,
498+
"date": None
499+
}
486500

487501
try:
488502
return git_versions_from_keywords(get_keywords(), cfg.tag_prefix,
@@ -491,7 +505,6 @@ def get_versions():
491505
pass
492506

493507
try:
494-
root = os.path.realpath(__file__)
495508
# versionfile_source is the relative path from the top of the source
496509
# tree (where the .git directory might live) to this file. Invert
497510
# this to find the root from __file__.

dmriprep/cli.py

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,29 @@ def __init__(
2323
layout,
2424
subject_list,
2525
bids_dir,
26-
work_dir,
2726
output_dir,
28-
# concat_shells,
27+
analysis_level,
28+
work_dir,
29+
ignore,
2930
b0_thresh,
30-
resize_scale,
31-
omp_nthreads,
32-
eddy_niter,
31+
output_resolution,
3332
bet_dwi,
3433
bet_mag,
35-
ignore,
36-
analysis_level,
34+
omp_nthreads,
35+
eddy_niter,
3736
synb0_dir,
38-
acqp_file,
37+
acqp_file
3938
):
39+
40+
self.layout = layout
41+
self.subject_list = subject_list
4042
self.bids_dir = bids_dir
4143
self.output_dir = output_dir
4244
self.analysis_level = analysis_level
43-
self.layout = layout
44-
self.subject_list = subject_list
4545
self.work_dir = work_dir
46-
# self.concat_shells = concat_shells
4746
self.ignore = ignore
48-
self.resize_scale = resize_scale
4947
self.b0_thresh = b0_thresh
48+
self.output_resolution = resize_scale
5049
self.bet_dwi = bet_dwi
5150
self.bet_mag = bet_mag
5251
self.omp_nthreads = omp_nthreads
@@ -95,7 +94,9 @@ def __init__(
9594
type=click.IntRange(min=0, max=10),
9695
)
9796
@click.option(
98-
"--resize_scale", help="Scale factor to resize DWI image", type=float
97+
"--output_resolution",
98+
help="The isotropic voxel size in mm the data will be resampled to before eddy.",
99+
type=float
99100
)
100101
# specific options for eddy
101102
@click.option(
@@ -153,6 +154,18 @@ def __init__(
153154
help="working directory",
154155
type=click.Path(exists=True, file_okay=False, writable=True),
155156
)
157+
@click.option(
158+
"--tbss",
159+
help="Run TBSS"
160+
is_flag=True
161+
)
162+
@click.option(
163+
"--diffusivity_meas",
164+
help="Specify which measures to calculate.",
165+
default=("FA",),
166+
type=click.Choice(["FA", "MD", "AD", "RD"]),
167+
multiple=True
168+
)
156169
@click.option(
157170
"--synb0_dir",
158171
default=None,
@@ -163,17 +176,16 @@ def main(
163176
participant_label,
164177
bids_dir,
165178
output_dir,
166-
work_dir,
167-
skip_bids_validation,
168179
analysis_level,
180+
skip_bids_validation,
181+
work_dir,
182+
ignore,
169183
b0_thresh,
170-
# concat_shells,
171-
resize_scale,
172-
omp_nthreads,
173-
eddy_niter,
184+
output_resolution,
174185
bet_dwi,
175186
bet_mag,
176-
ignore,
187+
omp_nthreads,
188+
eddy_niter,
177189
synb0_dir,
178190
acqp_file,
179191
):
@@ -195,7 +207,7 @@ def main(
195207
"is participant at the moment."
196208
)
197209

198-
layout = BIDSLayout(bids_dir, validate=False)
210+
layout = BIDSLayout(bids_dir, validate=True)
199211
all_subjects, subject_list = collect_participants(
200212
layout, participant_label=participant_label
201213
)
@@ -213,17 +225,16 @@ def main(
213225
layout=layout,
214226
subject_list=subject_list,
215227
bids_dir=bids_dir,
216-
work_dir=work_dir,
217228
output_dir=output_dir,
218-
# concat_shells=concat_shells,
229+
analysis_level=analysis_level,
230+
work_dir=work_dir,
231+
ignore=list(ignore),
219232
b0_thresh=b0_thresh,
220-
resize_scale=resize_scale,
221-
omp_nthreads=omp_nthreads,
222-
eddy_niter=eddy_niter,
233+
output_resolution=output_resolution,
223234
bet_dwi=bet_dwi,
224235
bet_mag=bet_mag,
225-
ignore=list(ignore),
226-
analysis_level=analysis_level,
236+
omp_nthreads=omp_nthreads,
237+
eddy_niter=eddy_niter,
227238
synb0_dir=synb0_dir,
228239
acqp_file=acqp_file,
229240
)

dmriprep/interfaces/mrtrix3.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class MRResizeInputSpec(MRTrix3BaseInputSpec):
1919
mandatory=True,
2020
desc="input DWI image",
2121
)
22-
size = traits.List(
22+
image_size = traits.List(
2323
traits.Int(),
2424
argstr="-size %s",
2525
desc="define the new image size for the output image. This should be "
@@ -33,7 +33,7 @@ class MRResizeInputSpec(MRTrix3BaseInputSpec):
3333
"dimensions, or as a comma-separated list of the size for each "
3434
"voxel dimension.",
3535
)
36-
scale = traits.Float(
36+
scale_factor = traits.Float(
3737
argstr="-scale %s",
3838
desc="scale the image resolution by the supplied factor. This can be "
3939
"specified either as a single value to be used for all "
@@ -75,10 +75,10 @@ class MRResize(MRTrix3Base):
7575
>>> import nipype.interfaces.mrtrix3 as mrt
7676
>>> resize = mrt.MRResize()
7777
>>> resize.inputs.in_file = 'dwi.mif'
78-
>>> denoise.inputs.mask = 'mask.mif'
79-
>>> denoise.cmdline # doctest: +ELLIPSIS
80-
'dwidenoise -mask mask.mif dwi.mif dwi_denoised.mif'
81-
>>> denoise.run() # doctest: +SKIP
78+
>>> resize.inputs.scal_factor = 2
79+
>>> resize.cmdline # doctest: +ELLIPSIS
80+
'mrresize -scale 2 dwi.mif dwi_resized.mif'
81+
>>> resize.run() # doctest: +SKIP
8282
"""
8383

8484
_cmd = "mrresize"

dmriprep/workflows/base.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def init_single_subject_wf(subject_id, name, parameters):
5454
if "session" in entities:
5555
session_id = entities["session"]
5656
else:
57-
session_id = ""
57+
session_id = None
5858
metadata = parameters.layout.get_metadata(dwi_file)
5959
dwi_preproc_wf = init_dwi_preproc_wf(
6060
subject_id=subject_id,
@@ -86,7 +86,10 @@ def init_single_subject_wf(subject_id, name, parameters):
8686
ds_inputspec.inputs.output_folder = parameters.output_dir
8787
ds_inputspec.inputs.metadata = metadata
8888

89-
wf_name = "sub_" + subject_id + "_ses_" + session_id + "_preproc_wf"
89+
if session_id:
90+
wf_name = "sub_" + subject_id + "_ses_" + session_id + "_preproc_wf"
91+
else:
92+
wf_name = "sub_" + subject_id + "_preproc_wf"
9093
full_wf = pe.Workflow(name=wf_name)
9194

9295
full_wf.connect(

dmriprep/workflows/dwi/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python
22

33
from .base import init_dwi_preproc_wf
4-
from .denoise import init_denoise_wf
5-
from .unring import init_unring_wf
4+
from .remove_artefacts import init_remove_artefacts_wf
65
from .tensor import init_tensor_wf
76
from .outputs import init_output_wf

0 commit comments

Comments
 (0)