Skip to content

Commit eb94500

Browse files
authored
Merge pull request #10 from josephmje/nipreps_tests
FIX: Remove count of dwi scans according to task_id
2 parents 9afaf0c + d3d2d76 commit eb94500

File tree

3 files changed

+9
-42
lines changed

3 files changed

+9
-42
lines changed

dmriprep/interfaces/reports.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,18 @@
55
import os
66
import time
77

8-
from collections import Counter
98
from nipype.interfaces.base import (
109
traits, TraitedSpec, BaseInterfaceInputSpec,
1110
File, Directory, InputMultiObject, Str, isdefined,
1211
SimpleInterface)
1312
from nipype.interfaces import freesurfer as fs
14-
from niworkflows.utils.bids import BIDS_NAME
1513

1614

1715
SUBJECT_TEMPLATE = """\
1816
\t<ul class="elem-desc">
1917
\t\t<li>Subject ID: {subject_id}</li>
2018
\t\t<li>Structural images: {n_t1s:d} T1-weighted {t2w}</li>
2119
\t\t<li>Diffusion Weighted Images: {n_dwi:d}</li>
22-
{tasks}
2320
\t\t<li>Standard output spaces: {std_spaces}</li>
2421
\t\t<li>Non-standard output spaces: {nstd_spaces}</li>
2522
\t\t<li>FreeSurfer reconstruction: {freesurfer_status}</li>
@@ -105,28 +102,14 @@ def _generate_segment(self):
105102
if self.inputs.t2w:
106103
t2w_seg = '(+ {:d} T2-weighted)'.format(len(self.inputs.t2w))
107104

108-
# Add list of tasks with number of runs
109105
dwi_files = self.inputs.dwi if isdefined(self.inputs.dwi) else []
110106
dwi_files = [s[0] if isinstance(s, list) else s for s in dwi_files]
111107

112-
counts = Counter(BIDS_NAME.search(series).groupdict()['task_id'][5:]
113-
for series in dwi_files)
114-
115-
tasks = ''
116-
if counts:
117-
header = '\t\t<ul class="elem-desc">'
118-
footer = '\t\t</ul>'
119-
lines = ['\t\t\t<li>Task: {task_id} ({n_runs:d} run{s})</li>'.format(
120-
task_id=task_id, n_runs=n_runs, s='' if n_runs == 1 else 's')
121-
for task_id, n_runs in sorted(counts.items())]
122-
tasks = '\n'.join([header] + lines + [footer])
123-
124108
return SUBJECT_TEMPLATE.format(
125109
subject_id=self.inputs.subject_id,
126110
n_t1s=len(self.inputs.t1w),
127111
t2w=t2w_seg,
128112
n_dwi=len(dwi_files),
129-
tasks=tasks,
130113
std_spaces=', '.join(self.inputs.std_spaces),
131114
nstd_spaces=', '.join(self.inputs.nstd_spaces),
132115
freesurfer_status=freesurfer_status)

dmriprep/utils/bids.py

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
from bids import BIDSLayout
99

1010

11-
def collect_data(bids_dir, participant_label, task=None, echo=None,
12-
bids_validate=True):
11+
def collect_data(bids_dir, participant_label, bids_validate=True):
1312
"""Replacement for niworkflows' version."""
1413
if isinstance(bids_dir, BIDSLayout):
1514
layout = bids_dir
@@ -19,20 +18,12 @@ def collect_data(bids_dir, participant_label, task=None, echo=None,
1918
queries = {
2019
'fmap': {'datatype': 'fmap'},
2120
'dwi': {'datatype': 'dwi', 'suffix': 'dwi'},
22-
'bold': {'datatype': 'func', 'suffix': 'bold'},
23-
'sbref': {'datatype': 'func', 'suffix': 'sbref'},
2421
'flair': {'datatype': 'anat', 'suffix': 'FLAIR'},
2522
't2w': {'datatype': 'anat', 'suffix': 'T2w'},
2623
't1w': {'datatype': 'anat', 'suffix': 'T1w'},
2724
'roi': {'datatype': 'anat', 'suffix': 'roi'},
2825
}
2926

30-
if task:
31-
queries['bold']['task'] = task
32-
33-
if echo:
34-
queries['bold']['echo'] = echo
35-
3627
subj_data = {
3728
dtype: sorted(layout.get(return_type='file', subject=participant_label,
3829
extension=['nii', 'nii.gz'], **query))
@@ -60,10 +51,10 @@ def write_derivative_description(bids_dir, deriv_dir):
6051
}
6152

6253
# Keys that can only be set by environment
63-
if 'FMRIPREP_DOCKER_TAG' in os.environ:
64-
desc['DockerHubContainerTag'] = os.environ['FMRIPREP_DOCKER_TAG']
65-
if 'FMRIPREP_SINGULARITY_URL' in os.environ:
66-
singularity_url = os.environ['FMRIPREP_SINGULARITY_URL']
54+
if 'DMRIPREP_DOCKER_TAG' in os.environ:
55+
desc['DockerHubContainerTag'] = os.environ['DMRIPREP_DOCKER_TAG']
56+
if 'DMRIPREP_SINGULARITY_URL' in os.environ:
57+
singularity_url = os.environ['DMRIPREP_SINGULARITY_URL']
6758
desc['SingularityContainerURL'] = singularity_url
6859

6960
singularity_md5 = _get_shub_version(singularity_url)
@@ -88,7 +79,7 @@ def write_derivative_description(bids_dir, deriv_dir):
8879

8980

9081
def validate_input_dir(exec_env, bids_dir, participant_label):
91-
# Ignore issues and warnings that should not influence FMRIPREP
82+
# Ignore issues and warnings that should not influence dMRIPrep
9283
import tempfile
9384
import subprocess
9485
validator_config_dict = {
@@ -98,25 +89,20 @@ def validate_input_dir(exec_env, bids_dir, participant_label):
9889
"TSV_EQUAL_ROWS",
9990
"TSV_EMPTY_CELL",
10091
"TSV_IMPROPER_NA",
101-
"VOLUME_COUNT_MISMATCH",
102-
"BVAL_MULTIPLE_ROWS",
103-
"BVEC_NUMBER_ROWS",
104-
"DWI_MISSING_BVAL",
10592
"INCONSISTENT_SUBJECTS",
10693
"INCONSISTENT_PARAMETERS",
107-
"BVEC_ROW_LENGTH",
108-
"B_FILE",
10994
"PARTICIPANT_ID_COLUMN",
11095
"PARTICIPANT_ID_MISMATCH",
11196
"TASK_NAME_MUST_DEFINE",
11297
"PHENOTYPE_SUBJECTS_MISSING",
11398
"STIMULUS_FILE_MISSING",
114-
"DWI_MISSING_BVEC",
99+
"BOLD_NOT_4D",
115100
"EVENTS_TSV_MISSING",
116101
"TSV_IMPROPER_NA",
117102
"ACQTIME_FMT",
118103
"Participants age 89 or higher",
119104
"DATASET_DESCRIPTION_JSON_MISSING",
105+
"TASK_NAME_CONTAIN_ILLEGAL_CHARACTER",
120106
"FILENAME_COLUMN",
121107
"WRONG_NEW_LINE",
122108
"MISSING_TSV_COLUMN_CHANNELS",
@@ -131,8 +117,6 @@ def validate_input_dir(exec_env, bids_dir, participant_label):
131117
"ACQTIME_FMT",
132118
"SUSPICIOUSLY_LONG_EVENT_DESIGN",
133119
"SUSPICIOUSLY_SHORT_EVENT_DESIGN",
134-
"MALFORMED_BVEC",
135-
"MALFORMED_BVAL",
136120
"MISSING_TSV_COLUMN_EEG_ELECTRODES",
137121
"MISSING_SESSION"
138122
],

dmriprep/workflows/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def init_single_subject_wf(
314314
# for documentation purposes
315315
subject_data = {
316316
't1w': ['/completely/made/up/path/sub-01_T1w.nii.gz'],
317-
'dwi': ['/completely/made/up/path/sub-01_task-nback_bold.nii.gz']
317+
'dwi': ['/completely/made/up/path/sub-01_dwi.nii.gz']
318318
}
319319
else:
320320
subject_data = collect_data(layout, subject_id)[0]

0 commit comments

Comments
 (0)