Python doc

class glmsingle.glmsingle.GLM_single(params=None)

Bases: object

fit(design, data, stimdur, tr, outputdir=None, figuredir=None)

Arguments:

<design> is the experimental design. There are two possible cases: 1. A where A is a matrix with dimensions time x conditions.

Each column should be zeros except for ones indicating condition onsets.

  1. [A1, A2, … An] where each of the A’s are like the previous case.

    The different A’s correspond to different runs, and different runs can have different numbers of time points. However, all A’s must have the same number of conditions.

Note that we ultimately compute single-trial response estimates (one estimate for each condition onset), and these will be provided in chronological order. However, by specifying that a given condition occurs more than one time over the course of the experiment, this information can and will be used for cross-validation purposes.

<data> is the time-series data with dimensions X x Y x Z x time or a

list vector of elements that are each X x Y x Z x time. XYZ can be collapsed such that the data are given as a 2D matrix (units x time), which is useful for surface-format data. The dimensions of <data> should mirror that of <design>. For example, <design> and <data> should have the same number of runs, the same number of time points, etc. <data> should not contain any NaNs. We automatically convert <data> to single format if not already in single format. <stimdur> is the duration of a trial in seconds. For example, 3.5 means that you expect the neural activity from a given trial to last for 3.5 s.

<tr> is the sampling rate in seconds. For example, 1 means that we get

a new time point every 1 s. Note that <tr> applies to both <design> and <data>.

<outputdir> (optional) is a directory to which data will be written.

(If the directory does not exist, we create it; if the directory already exists, we delete its contents so we can start fresh.) If you set <outputdir> to None, we will not create a directory and no files will be written. Default is ‘GLMestimatesingletrialoutputs’ (created in the current working directory).

<figuredir> (optional) is a directory to which figures will be written.

(If the directory does not exist, we create it; if the directory already exists, we delete its contents so we can start fresh.) If you set <figuredir> to None, we will not create a directory and no files will be written. Default is ‘GLMestimatesingletrialfigures’ (created in the current working directory).

Returns:

There are various outputs for each of the four model types:

<modelmd> is either
  1. the HRF (time x 1) and ON-OFF beta weights (X x Y x Z)

  2. the full set of single-trial beta weights (X x Y x Z x TRIALS)

<R2> is model accuracy expressed in terms of R^2 (percentage).

<R2run> is R2 separated by run

<meanvol> is the mean of all volumes

<FitHRFR2> is the R2 for each of the different HRFs in the library

<FitHRFR2run> is separated by run

<HRFindex> is the 1-index of the best HRF

<HRFindexrun> is HRFiniex separated by run

<noisepool> indicates voxels selected for the noise pool

<pcregressors> indicates the full set of candidate GLMdenoise

regressors that were found

<glmbadness> is cross-validation results for GLMdenoise

<pcvoxels> is the set of voxels used to summarize GLMdenoise

cross-validation results

<xvaltrend> is the summary GLMdenoise cross-validation result on which

pcnum selection is done

<pcnum> is the number of PCs that were selected for the final model

<FRACvalue> is the fractional regularization level chosen for each

voxel

<scaleoffset> is the scale and offset applied to RR estimates to best

match the unregularized result