Esempio n. 1
0
def test_get_entity_vals(entity, expected_vals, kwargs, return_bids_test_dir):
    """Test getting a list of entities."""
    bids_root = return_bids_test_dir
    if kwargs is None:
        kwargs = dict()

    if entity == 'bogus':
        with pytest.raises(ValueError, match='`key` must be one of'):
            get_entity_vals(bids_root=bids_root, entity_key=entity, **kwargs)
    else:
        vals = get_entity_vals(bids_root=bids_root, entity_key=entity,
                               **kwargs)
        assert vals == expected_vals
Esempio n. 2
0
def get_task():
    if not task:
        tasks = get_entity_vals(bids_root, entity_key='task')
        if not tasks:
            return None
        else:
            return tasks[0]
    else:
        return task
Esempio n. 3
0
def get_runs():
    runs_ = copy.deepcopy(runs)  # Avoid clash with global variable.

    if runs_ == 'all':
        runs_ = get_entity_vals(bids_root, entity_key='run')

    if not runs_:
        return [None]
    else:
        return runs_
Esempio n. 4
0
def get_sessions():
    sessions_ = copy.deepcopy(sessions)  # Avoid clash with global variable.

    if sessions_ == 'all':
        sessions_ = get_entity_vals(bids_root, entity_key='ses')

    if not sessions_:
        return [None]
    else:
        return sessions_
Esempio n. 5
0
def get_subjects():
    if subjects_list == 'all':
        s = get_entity_vals(bids_root, entity_key='sub')
    else:
        s = subjects_list

    subjects = set(s) - set(exclude_subjects)
    # Drop empty-room subject.
    subjects = subjects - set(['emptyroom'])

    return list(subjects)
Esempio n. 6
0
def test_get_entity_vals(return_bids_test_dir):
    """Test getting a list of entities."""
    bids_root = return_bids_test_dir
    with pytest.raises(ValueError, match='`key` must be one of'):
        get_entity_vals(bids_root, entity_key='bogus')

    assert get_entity_vals(bids_root, 'sub') == [subject_id]
    assert get_entity_vals(bids_root, 'ses') == [session_id]
    assert get_entity_vals(bids_root, 'run') == [run, '02']
    assert get_entity_vals(bids_root, 'acq') == []
    assert get_entity_vals(bids_root, 'task') == [task]
#   If True, the scripts will generate plots.
#   If running the scripts from a notebook or spyder
#   run %matplotlib qt in the command line to get the plots in extra windows

plot = True
# plot = False

# ``crop``: tuple or None
# If tuple, (tmin, tmax) to crop the raw data
# If None (default), do not crop.
crop = None

# BIDS params
# see: bids-specification.rtfd.io/en/latest/99-appendices/04-entity-table.html

sessions = get_entity_vals(bids_root, entity_key='ses')
sessions = sessions if sessions else [None]

# XXX: take only first task for now
task = get_entity_vals(bids_root, entity_key='task')[0]

runs = get_entity_vals(bids_root, entity_key='run')
runs = runs if runs else [None]

acq = None

proc = None

rec = None

space = None
Esempio n. 8
0
from mne_bids import read_raw_bids
from mne_bids.read import _handle_events_reading
from mne_bids.utils import get_entity_vals

layout = mne.channels.read_layout('KIT-AD.lout')
task = 'OcularLDT'
bids_root = op.join('/', 'Volumes', 'teon-backup', 'Experiments', task)
fs_home = op.join('/', 'Applications', 'freesurfer', '7.1.0')
mri_subjects_dir = op.join('/', 'Volumes', 'teon-backup', 'Experiments',
                           task + '_MRI')
derivative = 'trans'

redo = False

subjects_list = get_entity_vals(bids_root, entity_key='sub')

fname_rep_group = op.join('/', 'Users', 'tbrooks', 'codespace', f'{task}-code',
                          'output', 'preprocessing',
                          f'group_{task}_{derivative}-report.html')
rep_group = Report()

# first, copy over fsaverage from FreeSurfer
mne.coreg.create_default_subject(fs_home=fs_home,
                                 update=True,
                                 subjects_dir=mri_subjects_dir)
ss = mne.setup_source_space(subject='fsaverage',
                            spacing='ico4',
                            surface='white',
                            subjects_dir=mri_subjects_dir)
fname_src = op.join(mri_subjects_dir, 'fsaverage', 'bem',
import pathlib
from mne_bids.utils import get_entity_vals

study_name = 'Cam-CAN'
bids_root = pathlib.Path('/storage/store2/work/rhochenb/Data/Cam-CAN/BIDS')
subjects_dir = str(bids_root / 'derivatives' / 'freesurfer')
task = 'task'
# subjects_list = list(set(subjects_list) - set(exclude_subjects))
# subjects_list = 'all'

subjects_list = sorted(get_entity_vals(bids_root, entity_key='sub'))[:50]

ch_types = ['meg']
find_flat_channels_meg = True
find_noisy_channels_meg = True
use_maxwell_filter = True
mf_ctc_fname = pathlib.Path('/storage/store2/work/rhochenb/Data/Cam-CAN/'
                            'Cam-CAN_ct_sparse.fif')
mf_cal_fname = pathlib.Path('/storage/store2/work/rhochenb/Data/Cam-CAN/'
                            'Cam-CAN_sss_cal.dat')
tmin = -0.2
tmax = 0.5
baseline = (None, 0)
conditions = [
    'audiovis/300Hz', 'audiovis/600Hz', 'audiovis/1200Hz', 'audiovis'
]

N_JOBS = 72
allow_maxshield = True