Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Exclude DWI runs with insufficient orientations or missing bvals #1240

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mriqc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,8 @@ class workflow(_Config):
"""Turn on FFT based spike detector (slow)."""
inputs = None
"""List of files to be processed with MRIQC."""
min_len_dwi = 5
"""Minimum DWI length to be considered a "processable" dataset."""
species = 'human'
"""Subject species to choose most appropriate template"""
template_id = 'MNI152NLin2009cAsym'
Expand Down
26 changes: 22 additions & 4 deletions mriqc/workflows/diffusion/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@

This workflow is orchestrated by :py:func:`dmri_qc_workflow`.
"""
from pathlib import Path

import numpy as np
from nipype.interfaces import utility as niu
from nipype.pipeline import engine as pe

Expand Down Expand Up @@ -89,21 +92,36 @@ def dmri_qc_workflow(name='dwiMRIQC'):
mem_gb = config.workflow.biggest_file_gb

dataset = config.workflow.inputs.get('dwi', [])
full_data = []

for dwi_path in dataset:
bval = config.execution.layout.get_bval(dwi_path)
if (
bval
and Path(bval).exists()
and len(np.loadtxt(bval)) > config.workflow.min_len_dwi
):
full_data.append(dwi_path)
else:
config.loggers.workflow.warn(
f'Dismissing {dwi_path} for processing. b-values are missing or '
'insufficient in number to execute the workflow.'
)

message = BUILDING_WORKFLOW.format(
modality='diffusion',
detail=(
f'for {len(dataset)} NIfTI files.'
if len(dataset) > 2
else f"({' and '.join('<%s>' % v for v in dataset)})."
f'for {len(full_data)} NIfTI files.'
if len(full_data) > 2
else f"({' and '.join('<%s>' % v for v in full_data)})."
),
)
config.loggers.workflow.info(message)

# Define workflow, inputs and outputs
# 0. Get data, put it in RAS orientation
inputnode = pe.Node(niu.IdentityInterface(fields=['in_file']), name='inputnode')
inputnode.iterables = [('in_file', dataset)]
inputnode.iterables = [('in_file', full_data)]

datalad_get = pe.Node(
DataladIdentityInterface(fields=['in_file'], dataset_path=config.execution.bids_dir),
Expand Down
Loading