From 3ffec8736192a0e83df8e7e35ea72a3f8f4999c0 Mon Sep 17 00:00:00 2001 From: oesteban Date: Fri, 27 May 2016 11:26:45 -0700 Subject: [PATCH] fixes #112 --- mriqc/__init__.py | 2 +- mriqc/utils/misc.py | 28 ++++++++++++++++------------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/mriqc/__init__.py b/mriqc/__init__.py index 9ecd6e0c7..78052b577 100644 --- a/mriqc/__init__.py +++ b/mriqc/__init__.py @@ -32,7 +32,7 @@ """ __versionbase__ = '0.8.4' -__versionrev__ = 'a1' +__versionrev__ = 'a2' __version__ = __versionbase__ + __versionrev__ __author__ = 'Oscar Esteban' __email__ = 'code@oscaresteban.es' diff --git a/mriqc/utils/misc.py b/mriqc/utils/misc.py index c5886af5a..3b1a4d685 100644 --- a/mriqc/utils/misc.py +++ b/mriqc/utils/misc.py @@ -29,22 +29,26 @@ def bids_getfile(bids_root, data_type, subject_id, session_id=None, run_id=None) onesession = (session_id is None or session_id == 'single_session') onerun = (run_id is None or run_id == 'single_run') - if onesession and onerun: - pattern = op.join(out_file, data_type, '%s_*%s.nii*' % (subject_id, scan_type)) - - elif not onesession and onerun: - pattern = op.join(out_file, session_id, data_type, - '%s_%s_*%s.nii*' % (subject_id, session_id, scan_type)) - elif onesession and not onerun: - pattern = op.join(out_file, data_type, '%s_%s*%s.nii*' % (subject_id, run_id, scan_type)) + if onesession: + if onerun: + pattern = op.join(out_file, data_type, '%s_*%s.nii*' % (subject_id, scan_type)) + else: + pattern = op.join(out_file, data_type, '%s_%s*%s.nii*' % (subject_id, run_id, scan_type)) + else: - pattern = op.join(out_file, session_id, data_type, - '%s_%s_%s*%s.nii*' % (subject_id, session_id, run_id, scan_type)) + if onerun: + pattern = op.join(out_file, session_id, data_type, + '%s_%s_*%s.nii*' % (subject_id, session_id, scan_type)) + else: + pattern = op.join(out_file, session_id, data_type, + '%s_%s_%s*%s.nii*' % (subject_id, session_id, run_id, scan_type)) results = glob.glob(pattern) if not results: - raise RuntimeError('No file found with this pattern: "%s"' % pattern) + raise RuntimeError( + 'No file found with this pattern: "%s", finding ' + 'BIDS dataset coordinates are (%s, %s, %s)' % (pattern, subject_id, session_id, run_id)) return results[0] @@ -193,7 +197,7 @@ def gather_bids_data(dataset_folder, subject_inclusion=None, include_types=None) scan_key = 'single_run' if bidsfile['run'] is not None: # TODO: consider multiple acq/recs - scan_key += '_' + bidsfile['run'] + scan_key = bidsfile['run'] sub_dict['anat'].append( (bidsfile['sub'], bidsfile['ses'], scan_key))