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_design=None, con_duration=None, 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_design=None, con_duration=None, pulsecode=30, write_bfsl=False, verbose=True)[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.
-
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
-
class
FsfCrawler
(preproc_dir, run_idf, template='mvpa', mvpa_type='trial_wise', output_dir=None, subject_idf='sub', event_file_ext='bfsl', func_idf='func', prewhiten=True, derivs=False, mat_suffix=None, sort_by_onset=False, n_cores=1)[source]¶ Bases:
object
Given an fsf-template, this crawler creates subject-specific fsf-FEAT files assuming that appropriate .bfsl files exist.
Parameters: - template (str) – Absolute path to template fsf-file. Default is ‘mvpa’, which models each bfsl-file as a separate regressor (and contrast against baseline).
- 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’)
- preproc_dir (str) – Absolute path to directory with preprocessed files.
- run_idf (str) – Identifier for run to apply template fsf to.
- 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’ (default, for legacy reasons), then assumes single event-file per predictor. If ‘tsv’ (cf. BIDS), then assumes a single tsv-file with all predictors.
- func_idf (str) – Identifier for which functional should be use.
- prewhiten (bool) – Whether the data should be prewhitened in model fitting
- derivs (bool) – Whether to model derivatives of original regressors
- mat_suffix (str) – Identifier (suffix) for design.mat and batch.fsf file (such that it does not overwrite older files).
- 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.
-
class
MelodicCrawler
(preproc_dir, run_idf, template=None, output_dir=None, subject_idf='sub', func_idf='func', copy_reg=True, copy_mc=True, varnorm=True, n_cores=1)[source]¶ Bases:
object
-
__init__
(preproc_dir, run_idf, template=None, output_dir=None, subject_idf='sub', func_idf='func', copy_reg=True, copy_mc=True, varnorm=True, n_cores=1)[source]¶ Given an fsf-template (Melodic), this crawler creates subject- specific fsf-melodic files and (optionally) copies the corresponding registration and mc directories to the out-directory.
Parameters: - template (str) – Absolute path to template fsf-file
- preproc_dir (str) – Absolute path to the directory with preprocessed files
- run_idf (str) – Identifier for run to apply template fsf to
- output_dir (str) – Path to desired output dir of Melodic-ica results.
- subject_idf (str) – Identifier for subject-directories.
- func_idf (str) – Identifier for which functional should be use.
- copy_reg (bool) – Whether to copy the subjects’ registration directory
- copy_mc (bool) – Whether to copy the subjects’ mc directory
- varnorm (bool) – Whether to apply variance-normalization (melodic option)
- n_cores (int) – How many CPU cores should be used for the batch-analysis.
-