skbold.exp_model package

The exp_model subpackage contains some (pre)processing functions and classes that help in preparing to fit a first-level GLM on fMRI data across multiple subjects.

The PresentationLogfileCrawler (and its function-equivalent ‘parse_presentation_logfile’) can be used to parse Presentation-logfile, which are often used at the University of Amsterdam.

Also, there is an experimental Eprime-logfile converter, which converts the Eprime .txt-file to a tsv-file format.

parse_presentation_logfile(in_file, con_names, con_codes, con_duration=None, write_tsv=True, write_code=False, pulsecode=30)[source]

Function-interface for PresentationLogfileCrawler. Can be used to create a Nipype node.

Parameters:
  • in_file (str or list) – Absolute path to logfile (can be a list of paths).
  • con_names (list) – List with names for each condition
  • con_codes (list) – List with codes for conditions. Can be a single integer or string (in the latter case, it may be a substring) or a list with possible values.
  • con_design (list or str) – Which ‘design’ to assume for events (if ‘multivar’, all events - regardless of condition - are treated as a separate condition/regressor; if ‘univar’, all events from a single condition are treated as a single condition). Default: ‘univar’ for all conditions.
  • con_duration (list) – If the duration cannot be parsed from the logfile, you can specify them here manually (per condition).
  • pulsecode (int) – Code with which the first (or any) pulse is logged.
class PresentationLogfileCrawler(in_file, con_names, con_codes, con_duration=None, pulsecode=30, write_tsv=True, verbose=True, write_code=False)[source]

Bases: object

Logfile crawler for Presentation (Neurobs) files; cleans logfile, calculates event onsets and durations, and (optionally) writes out .bfsl files per condition.

Parameters:
  • in_file (str or list) – Absolute path to logfile (can be a list of paths).
  • con_names (list) – List with names for each condition
  • con_codes (list) – List with codes for conditions. Can be a single integer or string (in the latter case, it may be a substring) or a list with possible values.
  • con_design (list or str) – Which ‘design’ to assume for events (if ‘multivar’, all events - regardless of condition - are treated as a separate condition/regressor; if ‘univar’, all events from a single condition are treated as a single condition). Default: ‘univar’ for all conditions.
  • con_duration (list) – If the duration cannot be parsed from the logfile, you can specify them here manually (per condition).
  • pulsecode (int) – Code with which the first (or any) pulse is logged.
  • write_bfsl (bool) – Whether to write out a .bfsl file per condition.
  • verbose (bool) – Print out intermediary output.
Variables:

df (Dataframe) – Dataframe with cleaned and parsed logfile.

parse()[source]

Parses logfile, writes bfsl (optional), and return subject-info.

Returns:subject_info_list – Bunch object to be used in Nipype pipelines.
Return type:Nilearn bunch object
class Eprime2tsv(in_file)[source]

Bases: object

Converts Eprime txt-files to tsv.

Parameters:in_file (str) – Absolute path to Eprime txt-file.
Variables:df (Dataframe) – Pandas dataframe with parsed and cleaned txt-file
convert(out_dir=None)[source]

Converts txt-file to tsv.

Parameters:out_dir (str) – Absolute path to desired directory to save tsv to (default: current directory).
class FsfCrawler(data_dir, run_idf=None, template='mvpa', preprocess=True, register=True, mvpa_type='trial_wise', output_dir=None, subject_idf='sub', event_file_ext='txt', sort_by_onset=False, prewhiten=True, n_cores=1, **feat_options)[source]

Bases: object

Given an fsf-template, this crawler creates subject-specific fsf-FEAT files assuming that appropriate .bfsl files exist.

Parameters:
  • data_dir (str) – Absolute path to directory with BIDS-formatted data.
  • run_idf (str) – Identifier for run to apply template fsf to.
  • template (str) – Absolute path to template fsf-file. Default is ‘mvpa’, which models each event as a separate regressor (and contrast against baseline).
  • preprocess (bool) – Whether to apply preprocessing (as specified in template) or whether to only run statistics/GLM.
  • register (bool) – Whether to calculate registration (func -> highres, highres -> standard)
  • mvpa_type (str) – Whether to estimate patterns per trial (mvpa_type=’trial_wise’) or to estimate patterns per condition (or per run, mvpa_type=’run_wise’)
  • output_dir (str) – Path to desired output dir of first-levels.
  • subject_idf (str) – Identifier for subject-directories.
  • event_file_ext (str) – Extension for event-file; if ‘bfsl/txt’ (default, for legacy reasons), then assumes single event-file per predictor. If ‘tsv’ (cf. BIDS), then assumes a single tsv-file with all predictors.
  • sort_by_onset (bool) – Whether to sort predictors by onset (first trial = first predictor), or, when False, sort by condition (all trials condition A, all trials condition B, etc.).
  • n_cores (int) – How many CPU cores should be used for the batch-analysis.
  • feat_options (key-word arguments) –

    Which preprocessing options to set (only relevant if template=’mvpa’ or if you want to deviate from template). Examples:

    mc=‘1’ (apply motion correction), st=‘1’ (apply regular-up slice-time correction), bet_yn=‘1’ (do brain extraction of func-file), smooth=‘5.0’ (smooth with 5 mm FWHM), temphp_yn=‘1’ (do HP-filtering), paradigm_hp=‘100’ (set HP-filter to 100 seconds), prewhiten_yn=‘1’ (do prewhitening), motionevs=‘1’ (add motion-params as nuisance regressors)
crawl()[source]

Crawls subject-directories and spits out subject-specific fsf.