Skip to content

Commit

Permalink
Merge pull request nipreps#141 from oesteban/fix/NoScansFound
Browse files Browse the repository at this point in the history
[FIX] mriqc crashes if no anatomical scans are found
  • Loading branch information
oesteban committed Jul 21, 2016
2 parents ff849f6 + 9935480 commit 3c0379b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 8 additions & 1 deletion mriqc/utils/mriqc_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# @Author: oesteban
# @Date: 2015-11-19 16:44:27
# @Last Modified by: oesteban
# @Last Modified time: 2016-05-06 11:14:22
# @Last Modified time: 2016-07-20 18:28:25

"""
=====
Expand All @@ -24,11 +24,14 @@
from argparse import ArgumentParser
from argparse import RawTextHelpFormatter
from nipype import config as ncfg
from nipype import logging

from mriqc.reports.generators import workflow_report
from mriqc.workflows import core as mwc
from mriqc import __version__

LOGGER = logging.getLogger('workflow')


def main():
"""Entry point"""
Expand Down Expand Up @@ -131,6 +134,10 @@ def main():
ms_func = getattr(mwc, 'ms_' + dtype)
workflow = ms_func(subject_id=opts.subject_id, session_id=opts.session_id,
run_id=opts.run_id, settings=settings)
if workflow is None:
LOGGER.warn('No {} scans were found in {}', dtype, settings['bids_root'])
continue

workflow.base_dir = settings['work_dir']
if settings.get('write_graph', False):
workflow.write_graph()
Expand Down
7 changes: 4 additions & 3 deletions mriqc/workflows/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# @Date: 2016-01-05 11:24:05
# @Email: code@oscaresteban.es
# @Last modified by: oesteban
# @Last Modified time: 2016-05-04 14:53:43
# @Last Modified time: 2016-07-20 17:32:24
""" The core module combines the existing workflows """
from six import string_types
from nipype.pipeline import engine as pe
Expand All @@ -17,6 +17,7 @@
from mriqc.workflows.functional import fmri_qc_workflow
from mriqc.utils.misc import gather_bids_data


def ms_anat(settings=None, subject_id=None, session_id=None, run_id=None):
""" Multi-subject anatomical workflow wrapper """
# Run single subject mode if only one subject id is provided
Expand All @@ -33,7 +34,7 @@ def ms_anat(settings=None, subject_id=None, session_id=None, run_id=None):
sub_list = [s for s in sub_list if s[2] == run_id]

if not sub_list:
raise RuntimeError('No scans found in %s' % settings['bids_root'])
return None

inputnode = pe.Node(niu.IdentityInterface(fields=['data']),
name='inputnode')
Expand Down Expand Up @@ -70,7 +71,7 @@ def ms_func(settings=None, subject_id=None, session_id=None, run_id=None):
sub_list = [s for s in sub_list if s[2] == run_id]

if not sub_list:
raise RuntimeError('No scans found in %s' % settings['bids_root'])
return None

inputnode = pe.Node(niu.IdentityInterface(fields=['data']),
name='inputnode')
Expand Down

0 comments on commit 3c0379b

Please sign in to comment.