<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
""" Helper functions """

def bids_getfile(bids_root, data_type, subject_id, session_id=None, run_id=None):
    """
    A simple function to select files from a BIDS structure

    Example::

    >>> from mriqc.data import get_ds003_downsampled
    >>> bids_getfile(get_ds003_downsampled(), 'anat', '05') #doctest: +ELLIPSIS
    u'...ds003_downsampled/sub-05/anat/sub-05_T1w.nii.gz'

    """
    import os.path as op
    import glob

    if data_type == 'anat':
        scan_type = 'T1w'

    if data_type == 'func':
        scan_type = 'bold'

    out_file = op.join(bids_root, subject_id)

    onesession = (session_id is None or session_id == 'single_session')
    onerun = (run_id is None or run_id == 'single_run')

    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:
        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))<commit_msg>fix #118<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
""" Helper functions """

def bids_getfile(bids_root, data_type, subject_id, session_id=None, run_id=None):
    """
    A simple function to select files from a BIDS structure

    Example::

    >>> from mriqc.data import get_ds003_downsampled
    >>> bids_getfile(get_ds003_downsampled(), 'anat', '05') #doctest: +ELLIPSIS
    u'...ds003_downsampled/sub-05/anat/sub-05_T1w.nii.gz'

    """
    import os.path as op
    import glob

    if data_type == 'anat':
        scan_type = 'T1w'

    if data_type == 'func':
        scan_type = 'bold'

    out_file = op.join(bids_root, subject_id)

    onesession = (session_id is None or session_id == 'single_session')
    onerun = (run_id is None or run_id == 'single_run')

    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:
        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))
{'fraction_non_alphanumeric': 0.14399733954107083, 'fraction_numerical': 0.015630196208846026, 'mean_word_length': 2.6153846153846154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5777223', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1105, 'n_words': 238}