Exemple #1
0
def _check_empty_room_basename(bids_path,
                               on_invalid_er_session='raise',
                               on_invalid_er_task='raise'):
    if bids_path.task != 'noise':
        msg = (f'task must be "noise" if subject is "emptyroom", but '
               f'received: {bids_path.task}')
        if on_invalid_er_task == 'raise':
            raise ValueError(msg)
        elif on_invalid_er_task == 'warn':
            logger.critical(msg)
        else:
            pass
    try:
        datetime.strptime(bids_path.session, '%Y%m%d')
    except (ValueError, TypeError):
        msg = (f'empty-room session should be a string of format '
               f'YYYYMMDD, but received: {bids_path.session}')
        if on_invalid_er_session == 'raise':
            raise ValueError(msg)
        elif on_invalid_er_session == 'warn':
            msg = (f'{msg}. Will proceed anyway, but you should consider '
                   f'fixing your dataset.')
            logger.critical(msg)
        else:
            pass
Exemple #2
0
def _check_empty_room_basename(bids_path, on_invalid_er_task='raise'):
    # only check task entity for emptyroom when it is the sidecar/MEG file
    if bids_path.suffix == 'meg':
        if bids_path.task != 'noise':
            msg = (f'task must be "noise" if subject is "emptyroom", but '
                   f'received: {bids_path.task}')
            if on_invalid_er_task == 'raise':
                raise ValueError(msg)
            elif on_invalid_er_task == 'warn':
                logger.critical(msg)
            else:
                pass