osl_ephys.utils.study#
Classes#
Class for simple file finding and looping. |
Module Contents#
- class osl_ephys.utils.study.Study(studydir)[source]#
Class for simple file finding and looping.
- Parameters:
studydir (str) – The study directory with wildcards.
- fieldnames[source]#
The wildcards in the study directory, i.e., the field names in between {braces}.
- Type:
list
Notes
This class is a simple wrapper around glob and parse. It works something like this:
>>> studydir = '/path/to/study/{subject}/{session}/{subject}_{task}.fif' >>> study = Study(studydir)
Get all files in the study directory:
>>> study.get()
Get all files for a particular subject:
>>> study.get(subject='sub-01')
Get all files for a particular subject and session:
>>> study.get(subject='sub-01', session='ses-01')
The fieldnames that are not specified in
getare replaced with wildcards (*).- get(check_exist=True, **kwargs)[source]#
Get files from the study directory that match the fieldnames.
- Parameters:
check_exist (bool) – Whether to check if the files exist.
**kwargs (dict) – The field names and values to match.
- Returns:
out – The files that match the field names and values.
- Return type:
list
Notes
Example using
StudyandStudy.get():>>> studydir = '/path/to/study/{subject}/{session}/{subject}_{task}.fif' >>> study = Study(studydir)
Get all files in the study directory:
>>> study.get()
Get all files for a particular subject:
>>> study.get(subject='sub-01')
Get all files for a particular subject and session:
>>> study.get(subject='sub-01', session='ses-01')
The fieldnames that are not specified in
getare replaced with wildcards (*).