Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

Commit 5fdca31

Browse files
authored
Merge pull request #49 from akeshavan/new_fsl
New fsl
2 parents 58c4d81 + 547cc29 commit 5fdca31

13 files changed

+100
-17
lines changed

dmriprep/cli.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
from . import io
88
from .data import get_dataset
99
import os
10+
import warnings
11+
12+
# Filter warnings that are visible whenever you import another package that
13+
# was compiled against an older numpy than is installed.
14+
warnings.filterwarnings("ignore", message="numpy.dtype size changed")
15+
warnings.filterwarnings("ignore", message="numpy.ufunc size changed")
1016

1117

1218
@click.command()
@@ -72,8 +78,26 @@ def main(participant_label, bids_dir, output_dir,
7278
@click.command()
7379
@click.argument('output_dir',
7480
)
75-
def data(output_dir):
76-
get_dataset(os.path.abspath(output_dir))
81+
@click.option('--subject', help="subject id to download (will choose 1 subject if not specified",
82+
default="sub-NDARBA507GCT")
83+
@click.option('--study', help="which study to download. Right now we only support the HBN dataset",
84+
default="HBN")
85+
def data(output_dir, study="HBN", subject="sub-NDARBA507GCT"):
86+
"""
87+
Download dwi raw data in BIDS format from public datasets
88+
89+
:param output_dir: A directory to write files to
90+
:param study: A study name, right now we only support 'HBN'
91+
:param subject: A subject from the study, starting with 'sub-'
92+
:return: None
93+
"""
94+
if not os.path.exists(output_dir):
95+
os.makedirs(output_dir)
96+
97+
if study.upper() != 'HBN':
98+
raise NotImplementedError('We only support data downloads from the HBN dataset right now.')
99+
100+
get_dataset(os.path.abspath(output_dir), source=study.upper(), subject_id=subject)
77101
print('done')
78102

79103

dmriprep/data.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@
2020
mod_logger = logging.getLogger(__name__)
2121

2222

23-
def get_dataset(output_dir, source='HBN'):
23+
def get_dataset(output_dir, source='HBN', subject_id='sub-NDARBA507GCT'):
2424
if source in ['HBN']:
25-
get_hbn_data(output_dir)
25+
get_hbn_data(output_dir, subject_id)
2626
else:
2727
raise ValueError('Invalid dataset source')
2828

2929

30-
def get_hbn_data(output_dir):
31-
subject_id = 'sub-NDARBA507GCT'
30+
def get_hbn_data(output_dir, subject_id):
3231
hbn_study = HBN(subjects=subject_id)
3332
subject = hbn_study.subjects[0]
3433
subject.download(directory=output_dir)

dmriprep/run.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os.path as op
2+
import os
23
from shutil import copyfile
34

45

@@ -357,6 +358,10 @@ def get_dmriprep_pe_workflow():
357358

358359
eddy = prep.get_node('fsl_eddy')
359360
eddy.inputs.repol = True
361+
eddy.inputs.cnr_maps = True
362+
eddy.inputs.residuals = True
363+
import multiprocessing
364+
eddy.inputs.num_threads = multiprocessing.cpu_count()
360365

361366
def id_outliers_fn(outlier_report, threshold, dwi_file):
362367
"""Get list of scans that exceed threshold for number of outliers
@@ -669,6 +674,10 @@ def binarize_aparc(aparc_aseg):
669674
datasink, "dmriprep.qc.@eddyparamsshellalign")
670675
wf.connect(prep, "fsl_eddy.out_parameter",
671676
datasink, "dmriprep.qc.@eddyparams")
677+
wf.connect(prep, "fsl_eddy.out_cnr_maps",
678+
datasink, "dmriprep.qc.@eddycndr")
679+
wf.connect(prep, "fsl_eddy.out_residuals",
680+
datasink, "dmriprep.qc.@eddyresid")
672681

673682
# the file that told us which volumes to trop
674683
wf.connect(id_outliers_node, "outpath", datasink, "dmriprep.qc.@droppedscans")

docker/Dockerfile

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ RUN export ND_ENTRYPOINT="/neurodocker/startup.sh" \
3939

4040
ENTRYPOINT ["/neurodocker/startup.sh"]
4141

42-
ENV FSLDIR="/opt/fsl-5.0.11" \
43-
PATH="/opt/fsl-5.0.11/bin:$PATH"
42+
ENV FSLDIR="/opt/fsl-6.0.0" \
43+
PATH="/opt/fsl-6.0.0/bin:$PATH"
4444
RUN apt-get update -qq \
4545
&& apt-get install -y -q --no-install-recommends \
4646
bc \
@@ -63,15 +63,15 @@ RUN apt-get update -qq \
6363
&& apt-get clean \
6464
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
6565
&& echo "Downloading FSL ..." \
66-
&& mkdir -p /opt/fsl-5.0.11 \
67-
&& curl -fsSL --retry 5 https://fsl.fmrib.ox.ac.uk/fsldownloads/fsl-5.0.11-centos6_64.tar.gz \
68-
| tar -xz -C /opt/fsl-5.0.11 --strip-components 1 \
66+
&& mkdir -p /opt/fsl-6.0.0 \
67+
&& curl -fsSL --retry 5 https://fsl.fmrib.ox.ac.uk/fsldownloads/fsl-6.0.0-centos6_64.tar.gz \
68+
| tar -xz -C /opt/fsl-6.0.0 --strip-components 1 \
6969
&& sed -i '$iecho Some packages in this Docker container are non-free' $ND_ENTRYPOINT \
7070
&& sed -i '$iecho If you are considering commercial use of this container, please consult the relevant license:' $ND_ENTRYPOINT \
7171
&& sed -i '$iecho https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/Licence' $ND_ENTRYPOINT \
7272
&& sed -i '$isource $FSLDIR/etc/fslconf/fsl.sh' $ND_ENTRYPOINT \
7373
&& echo "Installing FSL conda environment ..." \
74-
&& bash /opt/fsl-5.0.11/etc/fslconf/fslpython_install.sh -f /opt/fsl-5.0.11
74+
&& bash /opt/fsl-6.0.0/etc/fslconf/fslpython_install.sh -f /opt/fsl-6.0.0
7575

7676
ENV CONDA_DIR="/opt/miniconda-latest" \
7777
PATH="/opt/miniconda-latest/bin:$PATH"
@@ -132,12 +132,13 @@ RUN apt-get update -qq \
132132

133133
COPY ./license.txt /opt/freesurfer-6.0.0/license.txt
134134

135+
#&& sync && conda clean -tipsy && sync
136+
135137
ADD environment.yml environment.yml
136-
RUN apt-get update && apt-get install -y git gcc
138+
RUN apt-get update && apt-get install -y git gcc libopenblas-base
137139
RUN conda env create -f environment.yml
138140

139-
#&& sync && conda clean -tipsy && sync
140-
141+
ENV LD_LIBRARY_PATH=/usr/lib/openblas-base/
141142

142143
RUN sed -i '$isource activate dmriprep' $ND_ENTRYPOINT
143144

@@ -152,7 +153,7 @@ RUN echo '{ \
152153
\n [ \
153154
\n "fsl", \
154155
\n { \
155-
\n "version": "5.0.11" \
156+
\n "version": "6.0.0" \
156157
\n } \
157158
\n ], \
158159
\n [ \

docker/environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ dependencies:
1111
- pandas
1212
- tqdm
1313
- pip:
14-
- "--editable=git+https://github.com/nipy/nipype@fa0a101fec2d010dcb68910000f66d7c64e5d03e#egg=nipype"
14+
- "--editable=git+https://github.com/nipy/nipype@35b58cdb59a900430f4b9639e220c8408341805d#egg=nipype"
1515
- bids
1616
- duecredit

kubernetes/delete_cluster.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
gcloud container clusters delete dmriprep --zone=us-west1-a

kubernetes/delete_job.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
kubectl delete -f run_dmriprep.yml

kubernetes/docker/build_tag_push.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
docker build -t dmriprep:kube1 -f dockerfile-dmriprep-kube1 .
3+
docker tag dmriprep:kube1 gcr.io/dmriprep/dmriprep:kube1
4+
docker push gcr.io/dmriprep/dmriprep:kube1

kubernetes/docker/dmriprep_all.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
mkdir inputs
3+
mkdir outputs
4+
dmriprep-data --subject $1 $PWD/inputs/
5+
dmriprep $PWD/inputs $PWD/outputs
6+
dmriprep-upload --access_key $2 --secret_key $3 $PWD/outputs preafq-hbn
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM dmriprep:prod
2+
COPY dmriprep_all.sh /dmriprep_all.sh
3+
CMD ["/neurodocker/startup.sh", "dmriprep_all.sh"]

0 commit comments

Comments
 (0)