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

Fixes #112 #113

Merged
merged 1 commit into from
May 27, 2016
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion mriqc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"""

__versionbase__ = '0.8.4'
__versionrev__ = 'a1'
__versionrev__ = 'a2'
__version__ = __versionbase__ + __versionrev__
__author__ = 'Oscar Esteban'
__email__ = 'code@oscaresteban.es'
Expand Down
28 changes: 16 additions & 12 deletions mriqc/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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))

Expand Down