0% found this document useful (0 votes)
53 views25 pages

A Tutorial On Modeling fMRI Data Using A General Linear Model

This document provides an introduction to modeling fMRI data using the general linear model in R. It describes fMRI data, preprocessing steps, and how to translate common fMRI task analysis models implemented in specialized software into equivalent mixed effects models that can be implemented in R. The purpose is to make advanced longitudinal fMRI analysis techniques available in R to answer questions about developmental and clinical changes over time.

Uploaded by

Ankit Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views25 pages

A Tutorial On Modeling fMRI Data Using A General Linear Model

This document provides an introduction to modeling fMRI data using the general linear model in R. It describes fMRI data, preprocessing steps, and how to translate common fMRI task analysis models implemented in specialized software into equivalent mixed effects models that can be implemented in R. The purpose is to make advanced longitudinal fMRI analysis techniques available in R to answer questions about developmental and clinical changes over time.

Uploaded by

Ankit Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

A Tutorial on Modeling fMRI Data using a General Linear

Model

Introduction
Scientists from many disciplines (including psychologists, neuroscientists, biostatisticians,
engineers, and computer scientists) are interested in using, developing, and advancing
neuroimaging methods. Functional magnetic resonance imaging (fMRI) has quickly become the
most commonly used method for examining brain function. This paper describes a novel
approach for performing statistical modeling of fMRI data. In our experience, there are often
challenges in communicating statistical and analytical concepts across disciplines. A first step
towards overcoming these communication challenges is to bridge the language and tools used by
different disciplines. R is or is becoming the lingua franca of statistical analysis in diverse
disciplines (Gentleman et al. 2004; Mizumoto and Plonsky 2016; Kamvar et al. 2017); therefore,
there is didactic value to translating fMRI statistical analysis from the specialized software
packages that are currently used to analyze fMRI data into R.
R is also helpful as a language for conducting analyses reproducibly (Gandrud 2016). As a
scripting language, the R script itself can be self-documenting. Notably, R was used to drive a
large scale collaborative replication of 100 psychological studies (Open Science Collaboration
2015).
However, an important reason to look towards fMRI analysis with R is that there is a serious
disconnect between current approaches used used in psychology for data analysis and those that
are implemented in specialized fMRI software, particularly in the domain of longitudinal models.
Widely used software for analyzing task fMRI data rely predominantly on the general linear
model (GLM) approach to analyze data (Poline and Brett 2012). The GLM is a broad class of
models that assumes a linear relation between one (or more) dependent variables and one (or
more) independent variables. In fMRI analysis, the GLM estimates the BOLD time series as a
linear combination of several signal components and tests whether activity in a voxel is linked to
any known input function or stimuli (Lindquist 2008).
This model has serious limitations, particularly in modeling longitudinal data, where a vast array
of statistical models commonly used in psychology are simply not available for fMRI analysis
(T. Madhyastha et al.). For example, numerous techniques for analyzing longitudinal
developmental data are based in structural equation modeling (SEM) (Newsom 2015), which
allows growth to be modeled not only as an outcome, but as a predictor of other processes, as in
parallel process latent growth models (Cheong, MacKinnon, and Khoo 2003). Such a model
could be used, for example, to examine whether changes in neural processes predict subsequent
increases in cognitive symptoms. Neural changes across numerous time points could be
examined as outcomes, predictors, correlates of other change processes, moderators, or
mediators in SEM-based latent growth models. None of these models can be estimated in any of
the widely used fMRI analysis software packages. However, these types of approaches are
necessary for fMRI analysis to examine questions about longitudinal change such as "Does the
amygdala become more active in a month when a person experiences more stress than is typical
for them?" or "Are changes in brain networks in Parkinson disease compensatory to preserve
cognitive function?". This need for more modeling flexibility to advance the study of
developmental cognitive neuroscience, and similarly the trajectories of aging and
neurodegenerative change, also motivates this tutorial as a first step to de-mystifying the
scripting of more advanced analyses.
The purpose of this tutorial is to illustrate how statistical models commonly used for fMRI task
analysis can be translated into the linear mixed effects modeling framework (Laird and Ware
1982). Specifically, we translate fMRI task analysis models as implemented in the FMRIB
Software Library (FSL), a commonly used and representative specialized fMRI analysis
package, to equivalent mixed effects model specifications that can be implemented using the
nlme package (Pinheiro et al. 2017) in R (R Core Team 2014).
This tutorial is intended to help those with a background in the types of models used in
behavioral analysis to understand how these models are applied to fMRI data using R as a
bridging language. This tutorial is also written using Rmarkdown (see Supplemental Materials),
so that it is itself an example for writing reproducible analysis.

fMRI Data
FMRI data is represented as a four-dimensional data file, which represents the blood oxygen
level-dependent (BOLD) signal in the brain over time. An fMRI data file is a sequence of three-
dimensional volumes. Each three-dimensional volume is an image of the brain, and the fourth
dimension is time. The BOLD signal changes in the areas of the brain that support task demands,
and the goal of fMRI task analysis is to identify these locations.
However, the variance in the fMRI signal reflects numerous physical influences besides activity-
coupled hemodynamic change. Analysis of fMRI data is complex and involves removing these
sources of noise to accurately measure the relatively small BOLD signal components. Tools to
measure the BOLD signal were developed in the early 1990s. Briefly, these tools: a) remove
sources of noise (e.g., from respiration and head motion); b) align the BOLD signal maps to each
subject's brain anatomy; c) transform each subject's brain anatomy into a standardized space; and
d) estimate the degree to which BOLD signal (i.e., neural activity) changes in response to task
demands. These changes in response are modeled at thousands of three-dimensional pixels, or
``voxels," in the brain. A test statistic is then calculated at each voxel location, resulting in
multiple tests that need to be evaluated simultaneously. Finally, these multiple statistical tests are
corrected to minimize false positives. These steps are usually performed using special-purpose
software (e.g. FSL (Jenkinson et al. 2012), AFNI (Cox 1996) or MATLAB SPM (Friston et al.
2007).
We first describe and introduce some terminology for a basic fMRI experiment. A common
fMRI experimental design is a "block design", where each subject is exposed to repeated
"blocks" of different experimental conditions (e.g. series of experimental stimuli). One of these
conditions is normally a baseline condition to which other conditions are compared. An
important way to understand whether the brain is more or less active under different conditions is
to examine a "contrast" between conditions. By examining contrasts, we can locate where the
brain is more active under one condition than another.
One complexity in modeling the stimuli for different conditions is that the BOLD response is
very slow. There is a delay of approximately 5 seconds between the time of the stimuli (i.e.,
when the neural response presumably occurs) and the corresponding BOLD signal response in
the brain; the shape of this response is called the hemodynamic response function (Huettel, Song,
and McCarthy 2014). To make the time course of the stimuli match the time course of the BOLD
signal, the stimulus time course is typically convolved with this hemodynamic response function,
so that it looks like what you would expect to see in the temporal BOLD signal. The convolved
time-series for each stimulus is called an explanatory variable, or EV. These variables are used
to explain the variability in the measured time-series data at each voxel location using statistical
modeling. The EVs together, plus any covariates, form the design matrix, or the candidate
variables that are expected to predict the BOLD signal. We will describe the form of this matrix
later (see Figure for an example) in more detail.
The changes in the BOLD signal that occur in a particular task are small compared to the
spontaneous fluctuations in the BOLD signal in the brain. Therefore, we must present a condition
enough times so that we have enough statistical power to detect a task-related effect. This often
means increasing scan time, which is a problem because participants are less likely to be able to
keep still for the entire duration of the scan. The solution is therefore to break very long scans
into multiple task "runs" that occur during a single session inside a MRI scanner (typically
lasting for a few minutes). Each participant may have multiple task runs. Ultimately, all runs are
combined across individuals to estimate the effects (or contrasts) of interest in what we call a
group-level analysis.

Preprocessing
Preprocessing refers to all the cleaning that is performed on fMRI data before any statistical
analysis. Preprocessing is absolutely necessary to reduce and remove known sources of noise in
fMRI data.
Most preprocessing steps can and should be accomplished with specialized software. Because
the field and our understanding of the downstream effects of fMRI preprocessing on subsequent
statistical analysis are still evolving, there is no exact consensus on a standard preprocessing
pipeline. It is important to note that the choice of a sequence of preprocessing steps, or
"pipeline," can affect statistical results (Carp 2012; Bright and Murphy 2015). Moreover,
processing pipelines that optimize the signal of interest may vary depending on the task being
modeled, or even the population (Churchill et al. 2017).
For an introductory description of typical fMRI preprocessing steps, see (Huettel, Song, and
McCarthy 2014; Poldrack, Mumford, and Nichols 2011). Most of these steps can be performed
using a workflow that is scripted (e.g. using bash) or using some sort of workflow management
system (Gorgolewski et al. 2011; Askren et al. 2016). This allows the interchange of
preprocessing algorithms from the different major neuroimaging packages, and the separation of
preprocessing from statistical modeling.
As part of this preprocessing workflow, several "nuisance regressors" are usually calculated.
Nuisance regressors are covariates in the model that account for sources of noise caused by
motion, respiration, changes in blood flow related to the cardiac cycle, and so on. There is
usually one nuisance regressor per volume of the 4D fMRI image. Often one also includes the
first derivatives of the EVs to account for slight differences in timing (e.g. if there are regional
differences in the precise form of the hemodynamic response function).
The BOLD signal at any particular timepoint is significantly correlated with itself at different
delays. This is called autocorrelation, and a failure to account for temporal autocorrelation in the
residual errors of a model is likely to result in the underestimation of the standard errors of the
model coefficients, and an increase in the number of false positives.
One technique commonly used to address autocorrelation in the BOLD signal is prewhitening.
This important step is typically not included in preprocessing of task-related fMRI, but is instead
performed at the same time as model fitting. This step is necessary to remove autocorrelation
between voxel time series that biases parameter estimates in task analysis, but is not
recommended for resting state analysis because it may remove the slow fluctuations that are of
interest. A common prewhitening approach is to fit an autoregressive AR( p) model to the
residuals of the regression model to obtain estimates of the autoregressive parameters. These
parameters can then be used to modify the design matrix, resulting in a regression model with
uncorrelated errors.
Several studies have established that some prewhitening approaches are better than others (e.g.
Woolrich et al. 2001). We highlight the importance of accounting for autocorrelation and
describe a way of doing so within the mixed effects model framework, but evaluating this
approach in comparison to existing implementations in dedicated fMRI analysis software is
outside the scope of this tutorial.

The General Linear Model


The basic approach to analyzing fMRI data is to fit a linear model to the time series data
measured at each voxel Y . The predictors of this model are the EVs that describe the
experimental events of interest, covariates that might account for some of the difference in the
BOLD signal (such as age or sex, or the first derivatives of the EVs), and nuisance regressors
that are of no interest, but must be controlled for to account for variance unrelated to
experimental events of interest (such as the amount of motion or physiological noise). For a more
in-depth description of assumptions and caveats of the GLM model in fMRI analysis, see (Monti
2011; Pernet 2014).

Task fMRI Example


Let us consider an example of an fMRI experiment where there are 4 conditions and one task run
per subject.
The four conditions are:
• Fixation cross ( E V b): The subject sees a white fixation cross on a black screen and lets
thoughts wander. This is the baseline condition.
• 0-Back ( E V 1): The subject sees a series of letters, and presses a button when the letter is an
"X."
• 1-Back ( E V 2): The subject sees a series of letters, and presses a button when the letter is the
same as the one that preceded it. This task engages working memory.
• 2-Back ( E V 3): The subject sees a series of letters, and presses a button when the letter is the
same as the one that was presented two letters ago. This task engages working memory and
is more difficult than 1-Back.
The stimulus corresponding to each condition is either 1 or 0 to indicate whether or not the
condition is presented at a given point in time. Each stimulus is then convolved with a
hemodynamic response function to create the EV for each condition. Typically, null events (i.e.
baseline, rest, or fixation periods during the task) are not explicitly modeled in the design matrix.
This is because including an EV that corresponds to the baseline leads to multicollinearity, where
at least one of the EVs in the design matrix can be predicted by a linear combination of the
others with a high degree of accuracy (Pernet 2014). Such a model is considered to be over-
parameterized, because there is no unique solution for the model parameters. Therefore, we often
include the baseline condition implicitly in the model by including an intercept and a term for
each of the non-baseline EV conditions (i.e. include a column of ones and E V 1, E V 2 and E V 3 in
the design matrix). By including these terms in the model, we can ask scientific questions about
the contrasts between the experimental conditions in our model. The list below is not exhaustive,
but it provides an idea of the kinds of things we may want to know.
• 0-Back ¿ baseline: Tells us when there is activity related to 0-Back that is more than just
looking at a symbol on a screen.
• 1-Back ¿ baseline: Tells us when there is activity related to 1-Back that is more than just
looking at a symbol on a screen.
• 1-Back ¿ 0-Back: Tells us when there is activity related to 1-Back that is more than just
seeing a letter and reacting to it. In this case, the difference is probably related to the
working memory component of the task.
• 1-Back ¿ 0: Tells us when there is any activity related to the 1-Back time course. But it
might just have to do with seeing a symbol on the screen.
• 2-Back ¿ 1-Back: Tells us where the brain is more active in 2-Back than in 1-Back. The
difference is probably related to the added difficulty of 2-Back.

Modeling in FSL
We briefly describe how this simple experiment is modeled in FSL. For more details, see FSL's
documentation on FEAT and GLM analysis using FSL tools.
FSL uses a two-level model. The first level is the individual subject level. For each subject k,
where k =1 … N , it models the BOLD signal at each voxel using the following equation:
Y k =X k β k + e k ( 1)

Where Y k is a vector of length T capturing the BOLD time series observed at each voxel in the
brain, X k is the T × P k design matrix that the experimenter specifies, β k is a column vector of
regression co-efficients for the EVs in the design matrix X k, and e k is a column vector of error
terms. Note that in this example, we assume only one run per subject. We further assume that the
first level errors e k ∼N (0, σ 2k V ).1 In FSL, the correlation matrix is typically used to model the
auotocorrelation in the error terms.
Next, the β k coefficients estimated for each subject are used to fit a second level model,
β k = X gk β g+ e gk (2)

Here, X gk is the design matrix for the group, indicating, for example, the presence or absence of a
disease for each subject. β g represents the population-level effects for each of the EVs included
in β k . We assume that the error term e gk ∼ N (0, R g ), where R g is the variance-covariance matrix
of the group-level errors.
In practice, when implementing this model in FSL, the user will specify the contrasts of interest
for the analysis. A contrast is a linear combination of the parameter estimates (i.e. β values) of
the EVs. Contrasts allow us to ask questions like: is the effect of 2-Back ¿ 1-Back (for the
population the study sample is drawn from)? Specifically, we are asking where in the brain the β
coefficient for the EV corresponding to the 2-Back condition is greater than the β coefficient for
the EV corresponding to the 1-Back condition.
If we assume that individual subjects are modeled at the first level and that the subjects' effects
are combined at the second level, we study differences between the relevant group level β g
parameters to draw inference about the population that we sampled from. To test the statistical
significance of these contrasts, FSL uses a Bayesian framework that derives the posterior
distribution of the second level coefficients β g . Woolrich et al. (2004) show that the posterior
distribution of β g depends on the data Y only through the first-level model summary statistics,
and this increases computational speed substantially (compared to standard linear mixed effects
model fitting procedures).
The FSL software works by "carrying up" only the summary statistic information corresponding
to the contrast of interest to the second level. This includes summary statistics like the estimated
mean, variance, and the degrees of freedom of the first level β k coefficients.

Modeling in R: The Linear Mixed Effects Model


We now introduce the Laird and Ware (Laird and Ware 1982) formulation of the GLM model as
used in the nlme package. Using matrix notation, the n k observations of individual k is modeled
as
Y k =β0 + X k 1 β 1 +…+ X kp β p + bk 0 +Z k 1 bk 1 +…+ Z kq b kq +e k (3)

for k =1 , … , M individuals.
Here, Y k is the n k ×1 column vector of observed values for individual k. The X k1 ,..., X kp are the
n k ×1 vectors for each of the p regressors included in the model. The regression coefficients β 0
,..., β p are the fixed-effect coefficients, and are identical across all individuals. The n k ×1 column
1
This notation N (0, σ 2k V ) mean this is a normal distribution with mean of 0, variance of σ 2k
and T × T correlation matrix V
vectors Z k1 ,..., Z kq are the random effect regressors and the corresponding terms b k 0, b k 1,...,b kq are
the random effects. Note that q is the total number of random effects included in the model. The
random effects reflect the variability across subjects for each of the regressors Z k1 ,..., Z kq, and are
typically assumed to be normally distributed (b k 0 , … , b kq )∼ N (0 ,ψ ), where ψ is a (q +1) ×(q+1)
variance-covariance matrix. The n k ×1 vector of within-group errors e k =(e k 1 , … , e k n ) are also
k

assumed to be normally distributed N (0, σ 2 V ), with variance σ 2 and correlation matrix V .


Using the lme function of the nlme package in R, we can fit the above model using maximum
likelihood. For our purposes, we are interested in making inferences about a contrast c ' β, where
c is the contrast vector and β=(β 0 , … , β p). The function lme will give us a test statistic for our
contrast, and allow us to calculate the corresponding p-value for that contrast of interest.

Translation Between FSL and Linear Mixed Effects Models


Here we illustrate how the FSL first-level and second-level models (equations (1) and (2))
translate into the mixed-effects model formulation (Section 4.3) for our example given above in
Section 4.1.
For our example, the first level design matrix for subject k, X k, has four columns. We assume
that there are T volumes of fMRI data in the fMRI timeseries for each subject. For simplicity, we
exclude nuisance variables in this example. If included, these would be additional columns that
would represent volume-wise regressors for motion parameters, physiological signals, the first
derivative of the EVs, and so on.

1 E V 11 E V 21 E V 31

[1 E V 12
X k = 1 EV 13
⋮ ⋮
1 E V 1T
E V 22 E V 32

⋮ ⋮
E V 2T E V 3T
]
E V 23 EV 33 =[ X k 0 X k 1 X k 2 X k3 ]( 4)

In this notation, X k 0 is a column vector of ones for the intercept, X k1 is the column vector for
E V 1, X k2 is the column vector for E V 2 and X k3 is the column vector for E V 3.

In FSL, this design matrix would be visualized as in Figure 1.


Figure 1 GLM model design for the n-back block task. On the left, the basic shapes of the stimuli
functions for each of the EVs in modeled. The right shows the stimuli functions convolved with
the double gamma hemodynamic response function. These EVs are used in the design matrix.
The corresponding vector of regression coefficients is

β k0

[]
β
β k = k1 (5)
β k2
β k3

where β k 0 is the intercept, β k 1 is the regression coefficient corresponding to EV1, β k 2 is the


coefficient corresponding to E V 2, and β k 3 is the coefficient corresponding to E V 3.
For the second-level model, assume that we are interested in estimating the average effect of
each EV for the whole group (i.e., the "population effect").
Then,
1 0 0 0
X g= 0
0
0
[ ] 1
0
0
0
1
0
0 (6)
0
1

To understand how the FSL two-level model specified above translates into a linear mixed
effects model, as specified for nlme, we substitute the second-level model (2) into the first-level
model (1):
Yk ¿ X k β k +e k
¿ ¿ X k X gk β g + X k e gk + ek (7)
¿ ¿ X k 0 β g 0 + X k 1 β g 1+ X k 2 β g 2+ X k 3 β g 3 + X k 0 e gk 0 + X k 1 e gk 1 + X k 2 e gk 2+ X k 3 e gk3 +e k

for e k ∼ N (0, σ 2k V ) and e g ∼ N (0, Rg ).

We will refer to (7) as the translated FSL model. In this model, β g 1, β g 2, and β g 3 are the
population effects for E V 1, E V 2, and E V 3, respectively. These are referred to as the fixed
effects in the linear mixed effects modeling framework. The group-level error terms e gk 0, e gk 1,
e gk 2, and e gk 3 reflect the random variability of the intercepts and slopes around their respective
populations effects. These are the random effects.
Making a direct comparison between the translated FSL model (7) and the linear mixed effects
model specified above (3), we see that β g 0 ,... β g 3 of the translated FSL model correspond to the
fixed effects β 0,..., β p (for p=3) of the mixed effects model. Likewise, the group-level errors e gk 0
,..., e gk 3 in the FSL/translated model are the b k 0,..., b kq in the mixed effects model, and q=3 (i.e.,
three random effects). Lastly, the random effect regressors Z k specified in the mixed effects
model are the columns of the design matrix X k for the translated FSL model.
It is important to recognize that this translated FSL model (7) does not fully reflect the
relationship between the two-level FSL model [(1) and (2)] and the mixed effect model (3),
because the FSL model, as implemented in FEAT, assumes a Bayesian framework for inference.
The linear mixed effects model, on the other hand, typically assumes a classical framework for
inference.

R Tutorial
In this tutorial, we will simulate and then model the time series of a single voxel for n = 10
subjects. Each subject has 180 volumes of data during which they perform an N-back experiment
as described in Section 4.1.

Description of the Experiment


First, let us load some packages that are required to run this analysis. The package nlme has
functions that will allow us to fit mixed effects models.
library(nlme)
We will also load the package fmri which contains a function that allows us to convolve our
stimulus, creating an EV.
library(fmri)

Let us specify some of the basic parameters of our experiment.


n is the number of subjects.
n <- 10

As above, T is the length of our voxel-wise time-series (i.e. number of volumes per subject). We
will collect 180 volumes per subject. Let us assume that each volume is acquired over 2 seconds.
This means that the duration in time of our subject scan is 6 minutes.
T <- 180

In 4.1, we proposed an example task with 4 conditions, and assumed one task run per subject.
The conditions are as follows:
• E V b (Fixation cross): Subject sees a white fixation cross on a black screen and lets thoughts
wander.
• E V 1 (0-Back): Subject sees a series of letters, and presses a button when the letter is "X".
• E V 2 (1-Back): Subject sees a series of letters, and presses a button when the letter is the
same as the one that preceded it. This task engages working memory.
• E V 3 (2-Back): Subject sees a series of letters, and presses a button when the letter is the
same as the one that was presented two letters ago. This task engages working memory and
is more difficult than 1-Back.

Let us assume that we present each subject first with the fixation cross, then with a 0-back
condition, a 1-back condition, and then a 2-back condition for 15 volumes (30 seconds) for each
condition. We will repeat this sequence (60 volumes total, or 120 seconds) three times.
Normally, the order of the conditions would be randomized to prevent order-dependent effects,
and we would need to obtain more data to achieve enough statistical power to actually detect an
effect. However, the design presented here is easy to visualize, and so we will continue with
these caveats.
It is now easy to describe our experiment stimuli with sequences of ones and zeros. The stimuli
corresponding to each condition are set to one for each volume that the subject is presented with
the condition, and zero at all other times.
emptyblock <- rep(0,15)
taskblock <- rep(1,15)
EVstim1 <- rep(c(emptyblock,taskblock,emptyblock,emptyblock),3)
EVstim2 <- rep(c(emptyblock,emptyblock,taskblock,emptyblock),3)
EVstim3 <- rep(c(emptyblock,emptyblock,emptyblock,taskblock),3)

We can plot these stimuli (Figure 2).


plot(1:T, EVstim1,type="n", ylab="", xlab="Volume Number")
lines(1:T,EVstim1)
lines(1:T,EVstim2,col="red")
lines(1:T,EVstim3,col="blue")
legend("topright", c("EVstim1", "EVstim2", "EVstim3"), lty=c(1,1,1), col=c("black","red", "blue",
cex=.75))

Figure 2 Boxcar plot for EV1, EV2 and EV3


While it is easy to see with this "boxcar" plot what the timings of the stimuli are, these stimuli
need to be convolved with a hemodynamic response function to account for the delay between
when stimuli are presented and when the BOLD response peaks. This can be done with the
fmri.stimulus function from the fmri package. We use the canonical double-gamma
hemodynamic function (with the specified par parameters) as an example below.
baseonsets <- c(15, 15+60, 15+2*60)
EV1 <- fmri.stimulus(scans=T, onsets=baseonsets,durations=c(10,10,10), type="canonical", par =
c(6,12,0.9,0.9,0.15))
EV2 <- fmri.stimulus(scans=T, onsets=(baseonsets+15),durations=c(10,10,10), type="canonical",par =
c(6,12,0.9,0.9,0.15))
EV3 <- fmri.stimulus(scans=T, onsets=(baseonsets+30),durations=c(10,10,10), type="canonical",par =
c(6,12,0.9,0.9,0.15))

We can plot these EVs to visualize them (Figure 3).


plot(1:T, EV1,type="n", ylab="BOLD Response", xlab="Volume Number")
lines(1:T,EV1)
lines(1:T,EV2,col="red")
lines(1:T,EV3,col="blue")
legend("topright", c("EV1", "EV2", "EV3"), lty=c(1,1,1), col=c("black","red", "blue"), cex=0.85)

Figure 3 EVs convolved with the hemodynamic response function


In summary, we expect the BOLD signal to be related to these EVs in voxels that are associated
with these task conditions.

Simulating Individual Subject Data


Now that we have created our design matrix, we need to simulate data for one voxel in 10
subjects. Recall the first level model for the BOLD signal at each voxel (1).
Y k ¿ X k β k + ek ¿ 1 β 0 + X k1 β 1+ X k 2 β 2 + X k 3 β 3+ ek ( 8)

For each subject k, where k =1 … N , the above equation models the BOLD signal at a single
voxel, Y k . X k is our design matrix of EVs that we created in the description of the experiment
(Section 4.1), β k is a column vector of beta co-efficients (that the model tries to estimate) for
each EV in the design matrix X k, and e k is a column vector of residuals for each voxel.
Remember that we do not model the baseline E V b because doing so will produce a rank
deficient design matrix (see The General Linear Model), but we do model E V 1, E V 2 and E V 3.
Including the intercept, the design matrix for the first level ( X k) has four columns. We assume
that there are T =180 volumes of fMRI data in the fMRI timeseries for each subject.

1 E V 11 E V 21 E V 31

[1 E V 12
X k = 1 EV 13
⋮ ⋮
1 E V 1T
E V 22 E V 32

⋮ ⋮
E V 2T E V 3T
]
E V 23 EV 33 =[ X k 0 X k 1 X k 2 X k3 ](9)

To simulate voxel-wise data using this matrix, we will specify fixed values for the coefficients
for the intercept & EVs.
beta0.fixed <- 3
beta1.fixed <- 2
beta2.fixed <- 5
beta3.fixed <- 4

Thus, for subject 1,

β 10 3

[ ][]
β
β 1= 11 = 2 (10)
β 12
β 13
5
4

The only thing we are missing now is e k , the residual within-subject variance. Let us assume that
this follows a normal distribution with a standard deviation for each subject of 0.5.
within.sd <- 0.5

We can now simulate the time series for a single voxel for the first subject.
y1 <- beta0.fixed + EV1*beta1.fixed + EV2*beta2.fixed + EV3*beta3.fixed + rnorm(T, 0, within.sd)

Let's have a look at the voxel time series (y1) for the first 75 time points for subject 1.
## [1] 1.5903263 1.2558602 2.1892090 1.3443287 1.9886059 1.4707932 1.7237264
## [8] 1.9949270 2.4875582 1.2506530 1.8448314 1.0584158 1.1216373 2.3909500
## [15] 1.8638761 1.5428078 1.5346109 2.4272582 3.4746526 3.3520442 3.8494725
## [22] 2.5205468 3.1230057 3.2706980 3.1348421 3.0857845 3.3620568 1.9709174
## [29] 1.5609038 1.6049231 0.9239337 2.1505524 5.1050977 5.1331810 6.1163417
## [36] 5.1543652 5.8155581 5.2455384 6.4503886 5.5245592 5.4060121 4.7727107
## [43] 3.0585893 1.8501248 1.0831575 1.0030407 1.3388728 3.4729104 4.2715891
## [50] 4.8743045 5.1663915 6.0169386 4.9571750 4.2400875 4.6665134 4.6817574
## [57] 3.3357421 2.7338918 1.2587420 1.7080126 1.6335619 1.0330638 2.0936410
## [64] 1.8693463 1.0943668 2.1501641 1.8392770 2.2784835 1.6493861 2.6741623
## [71] 1.4694260 1.3247642 2.1262054 1.5848412 1.4022314
We can simulate this voxel time series in the same way for the second subject.
y2 <- beta0.fixed + EV1*beta1.fixed + EV2*beta2.fixed + EV3*beta3.fixed + rnorm(T, 0, within.sd)

And for the third subject.


y3 <- beta0.fixed + EV1*beta1.fixed + EV2*beta2.fixed + EV3*beta3.fixed + rnorm(T, 0, within.sd)

Now, we can look at the BOLD signal for the first 3 subjects for a single voxel (4).

Each of these subjects responds exactly the same way to the EVs, with the same degree of
individual variation. In reality, this is unlikely to be the case. We need to simulate more realistic
individuals by allowing their β values to vary around this mean value.

Group-level Analysis
Now we can simulate the data for all subjects, and add between-subject variation for the beta
weights. Then, we will perform a group-level analysis for that single voxel so that we can
generalize any hypothesis testing we do to the population of interest. Note that actual fMRI
analysis is much more complex because we are usually modeling thousands of voxels at once, as
opposed to a single voxel, for a larger subject pool.
A single voxel can be modeled according to the following equation at the group level (7).
Y g=1 β0 + X 1 β 1 + X 2 β2 + X 3 β 3 +b0 + X 1( mat) b1 + X 2 (mat )b 2+ X 3 (mat )b 3+ e (11)
Where 1 is a column vector of ones, X 1 =( X 11 ,… X N 1 )' , X 2 =(X 12 , … X N 2) ' , X 3 =( X 13 , … X N 3 )' ,
b 0=( b10 ,... , b N 0 )' , b 1=(b 11 ,... , b N 1 )' , b 2=(b 12 , ... ,b N 2) ' , b 3=( b12 , ... ,b N 3) ' ,
X 1 ( mat)=diag( X 11 , X 21 , … , X N 1 ), X 2 ( mat)=diag( X 12 , X 22 , … , X N 2),
X 3 ( mat)=diag ( X 13 , X 23 , … , X N 3 ). In other words, X 1 ( mat), X 2 ( mat) and X 3 ( mat) are diagonal
matrices with the column vectors being the diagonal entries.
In this model, Y g=(Y 1 , Y 2 , … ,Y N ) is a vector that contains the time series of the voxel for all
subjects.
β 0 is the fixed intercept. β 1 represents the population effect for E V 1, β 2 is the population effect
for E V 2, and β 3 is the population effect for EV 3.
With mixed effects modeling, we can model the between-subjects variance around the
population mean for each EV. These will be the random effects that we will later on specify in
the model.
b 0 is the random effect for the intercept, b k 1 is the random effect for E V 1 (i.e. it reflects subject
to subject variability around the population effect β 1), b k 2 is the random effect for E V 2, and b k 3
is the random effect for E V 3. Finally, e k represents within-subject error.
To simulate between-subjects variance, we assume a random intercept and slopes. We specify
the variances of the intercept and slopes and then draw samples from their corresponding normal
distributions. We set a seed so that this code will run the same way repeatedly.
set.seed(123)
sd0.random <- 1.5
sd1.random <- 1
sd2.random <- .5
sd3.random <- .8

beta0.betweensub <- rnorm(n, 0, sd0.random)


beta1.betweensub <- rnorm(n, 0, sd1.random)
beta2.betweensub <- rnorm(n, 0, sd2.random)
beta3.betweensub <- rnorm(n, 0, sd3.random)

The standard deviation of the intercept across individuals was set equal to sd0.random, or 1.5.
Let's look at the actual random effect for our intercept, beta0.betweensub, for all 10 subjects.
## [1] -0.8407135 -0.3452662 2.3380625 0.1057626 0.1939316 2.5725975
## [7] 0.6913743 -1.8975919 -1.0302793 -0.6684930

The sample standard deviation of these values is 1.43.


Now, we will simulate the full timeseries Y g at a single voxel. Recall that Y g is the concatenated
time series data for all of the N subjects.
To derive the voxel time series for each subject, we have to account for the fixed effects and
random effects for each EV, the intercept, and within-subjects variability.
To create this vector, we define the function generateSubjectVoxelData, which creates the data
for a single subject using the beta weights, as well as the between- and within-subjects error
variances that we defined above. We then call this function for all n subjects using lapply. This
returns the vectors for each subject as a list.
generateSubjectVoxelData <- function(i) {
Y <- beta0.fixed + EV1*beta1.fixed + EV2*beta2.fixed + EV3*beta3.fixed + beta0.betweensub[i] +
EV1*beta1.betweensub[i] + EV2*beta2.betweensub[i] + EV3*beta3.betweensub[i] + rnorm(T, 0,
within.sd)
return(Y)
}

allsubjs <- lapply(1:n, generateSubjectVoxelData)

The lme function that we will use later expects a data frame in the long data format. Figure 5 is a
picture of what this looks like. This data frame will contain the voxel data Y.g, the EVs, and the
identifier for all subjects "stacked" on top of each other, so that each row contains the value of
the BOLD signal at a single voxel for one volume. Thus, the entire data frame will contain N*T,
or 1800 observations (Figure 5).
Figure 5 Long data frame with example voxel data for all subjects; idnum is the subject number.
Our first step towards creating this data frame is to create a single vector, Y.g, which is
equivalent to Y g from the equation above. This is a vector that contains the time series of the
voxel across all subjects. To do this, we collapse the list of subject voxel vectors using unlist.
Y.g <- unlist(allsubjs)

We will not print the entire variable Y.g because it is a very long vector that will take up a lot of
space. However, we can look at a particular subject's voxel time series by subsetting the vector.
For example, subject 2's voxel time series is located in indices (T+1 to 2*T).
print(Y.g[(T+1):(2*T)])

## [1] 0.9535715 1.5495511 1.7954823 1.5943524 1.0587296 1.2704332 0.8882600


## [8] 0.8819491 1.6828835 0.7327619 2.2182052 1.1953984 1.3478276 0.8712944
## [15] 0.9533639 0.6024283 1.5357119 2.6043498 3.1502547 2.8166607 2.8106542
## [22] 2.8921849 3.8415127 2.4980280 2.9655982 3.9859267 2.6180201 1.2209033
## [29] 0.9751949 1.3309832 0.9451520 1.6727711 3.4226746 4.8962573 6.1164010
## [36] 5.2677574 5.7245984 5.3963549 4.9686062 4.2350242 4.6986801 3.9552285
## [43] 2.6326190 2.0295679 2.0714263 1.7362875 1.6079190 2.1239203 3.8095800
## [50] 4.4223539 4.7963269 4.7567024 4.5381582 3.4556158 4.5596427 3.8790390
## [57] 3.6055628 2.3309682 1.5615419 1.0099666 0.1678214 1.4681890 1.3723892
## [64] 1.0893006 1.2996305 1.3075775 1.3510679 2.0609813 1.1310330 1.3245909
## [71] 1.8247501 1.7676487 1.8131898 0.9518242 2.2417996 1.2942868 2.5606006
## [78] 1.7194072 2.9985943 3.8323863 2.8473441 2.7669398 2.6242130 2.5404232
## [85] 2.8365442 3.2003353 1.6614023 2.0068138 1.9259171 2.1070402 1.7835414
## [92] 2.3320967 2.7312680 4.5502556 5.1411234 5.6638020 5.1313630 4.4516535
## [99] 5.8676440 5.4571708 5.0779539 4.8092181 1.9396546 1.7098787 0.6634306
## [106] 1.3043697 1.6440835 3.3186644 4.6717287 4.3813953 4.8825997 3.6812214
## [113] 3.8352013 4.9128618 4.3235151 3.0762062 2.8361427 2.1933021 1.7803482
## [120] 0.9466875 1.3136527 1.5794437 2.0149033 1.2501348 1.2145673 0.3639395
## [127] 1.2902220 0.9546332 0.7535534 1.1506051 1.7480298 0.2441840 1.0269186
## [134] 1.2988769 0.7939544 1.4278879 1.8328896 2.3783405 1.7551535 4.4931581
## [141] 3.1023155 3.4688809 3.2303656 3.5790164 3.4639537 2.9298492 2.8575914
## [148] 1.4281192 1.7360411 0.8577340 2.3413401 1.1281848 3.3626396 5.2636989
## [155] 5.5722129 5.0172995 4.6858082 5.1532157 5.0182724 4.1063345 4.9765143
## [162] 4.2952789 2.6964049 0.8519600 1.1629534 1.6517820 1.9026127 2.4343898
## [169] 3.7861472 4.5508021 4.0502976 3.1966152 4.6381289 3.7385141 3.8480410
## [176] 4.8542679 3.1310890 2.7165584 0.7171170 0.8203579

Our subjects are numbered 1 to 10. We need to generate a list of subject identifiers to correspond
to the voxel data in Y.g. By convention, the vector of subject identifiers is called idnum. We
convert these integer subject identifiers to factors.
idnum <- unlist(lapply(1:n,rep,T))
idnum <- as.factor(idnum)

Similarly, we need to replicate the EV vectors by the number of subjects to create this data
frame.
EV1.vec <- rep(EV1, n)
EV2.vec <- rep(EV2, n)
EV3.vec <- rep(EV3, n)

We can create our data frame voxeldat, for convenience. If we had additional nuisance
covariates, they would be additional columns in this structure.
voxeldat <- data.frame(idnum, Y.g, EV1.vec, EV2.vec, EV3.vec)

Now, let's use the lme function from the nlme package to fit the group level model for our single
voxel.
model1 <- lme(Y.g ~ 1 + EV1.vec + EV2.vec + EV3.vec,
random = ~1 + EV1.vec + EV2.vec + EV3.vec | idnum, data=voxeldat, method=c("ML"))

summary(model1)

## Linear mixed-effects model fit by maximum likelihood


## Data: voxeldat
## AIC BIC logLik
## 2779.958 2862.391 -1374.979
##
## Random effects:
## Formula: ~1 + EV1.vec + EV2.vec + EV3.vec | idnum
## Structure: General positive-definite, Log-Cholesky parametrization
## StdDev Corr
## (Intercept) 1.3604672 (Intr) EV1.vc EV2.vc
## EV1.vec 0.9939035 0.618
## EV2.vec 0.4019250 -0.472 -0.701
## EV3.vec 0.4566426 0.654 0.393 -0.423
## Residual 0.4989767
##
## Fixed effects: Y.g ~ 1 + EV1.vec + EV2.vec + EV3.vec
## Value Std.Error DF t-value p-value
## (Intercept) 3.123745 0.4308572 1787 7.25007 0
## EV1.vec 2.267778 0.3178050 1787 7.13575 0
## EV2.vec 4.755067 0.1348681 1787 35.25716 0
## EV3.vec 4.285305 0.1513301 1787 28.31760 0
## Correlation:
## (Intr) EV1.vc EV2.vc
## EV1.vec 0.612
## EV2.vec -0.445 -0.642
## EV3.vec 0.624 0.383 -0.354
##
## Standardized Within-Group Residuals:
## Min Q1 Med Q3 Max
## -3.004917752 -0.678730665 -0.007405163 0.665799619 3.282728023
##
## Number of Observations: 1800
## Number of Groups: 10

We simulated our data without autocorrelation. In real fMRI data, autocorrelation is typically
present. One way to account for autocorrelation in our linear mixed effects analysis is to use the
argument correlation to specify the assumed correlation structure (Pinheiro et al. 2017). As an
example, for an autoregressive process of order one, we could specify its form in the call to lme
as follows.
model2 <- lme(Y.g ~ 1 + EV1.vec + EV2.vec + EV3.vec,
random = ~1 + EV1.vec + EV2.vec + EV3.vec | idnum, data=voxeldat, method=c("ML"),
correlation=corAR1(form=~1|idnum))

We can compare these two models, and as expected, find that by the AIC, the BIC, and the log-
likelihood ratio, model 1 (without autocorrelation) is superior to model 2 (with autocorrelation).
anova(model1,model2)

## Model df AIC BIC logLik Test L.Ratio p-value


## model1 1 15 2779.958 2862.391 -1374.979
## model2 2 16 2781.691 2869.619 -1374.845 1 vs 2 0.267499 0.605
We will focus now only on model 1. When we look at the fitted beta coefficients for the intercept
and the EVs, we find that they are pretty close to the mean of the true beta values that we had
specified above. To refresh your memory, our fixed beta values were β 0=3, β 1=2, β 2=5, and β 3
=4.
The estimated fixed effects match the specified values closely. They are unlikely to match
perfectly, unless the sample size is every large.
## (Intercept) EV1.vec EV2.vec EV3.vec
## 3.124 2.268 4.755 4.285

We can also compare the estimated standard deviations of the model to the true standard
deviations that we had specified. To do this, we look at the printout summary of the model.
Under the Random effects section of the output from lme, the first column gives a readout of the
estimated standard deviations. We can also see estimated standard deviations using the VarCorr
function.
VarCorr(model1)

## idnum = pdLogChol(1 + EV1.vec + EV2.vec + EV3.vec)


## Variance StdDev Corr
## (Intercept) 1.8508709 1.3604672 (Intr) EV1.vc EV2.vc
## EV1.vec 0.9878441 0.9939035 0.618
## EV2.vec 0.1615437 0.4019250 -0.472 -0.701
## EV3.vec 0.2085225 0.4566426 0.654 0.393 -0.423
## Residual 0.2489778 0.4989767

As a reminder, let us look at the standard deviations of the simulated data.


sd(beta0.betweensub)

## [1] 1.430676

sd(beta1.betweensub)

## [1] 1.038073

sd(beta2.betweensub)

## [1] 0.4654046

sd(beta3.betweensub)

## [1] 0.4218419

within.sd

## [1] 0.5

We see that the standard deviations estimated for the random effect match closely with the
corresponding standard deviations of the simulated data. The standard deviations of the random
effects also agree well with the true values. (It is not expcted that the estimates will agree exactly
with the true values.) For reference, these were:
sd0.random

## [1] 1.5

sd1.random

## [1] 1

sd2.random

## [1] 0.5

sd3.random

## [1] 0.8

Testing a Hypothesis (for a Specific Contrast)


Let us assume that we want to test whether the 1-Back condition is associated with greater
activation in the population than the 0-Back condition. Statistically, this means we need to test
whether E V 2 is greater than E V 1 at the population level. Our null hypothesis would be that there
is no difference in the BOLD signal of the voxel between the two conditions (i.e., that they are
equal). Recall that in our simulations, we set β 1=2 and β 2=5.
Therefore,
H 0 : E V 2=E V 1

H1: E V 2> E V 1

To ask whether E V 2 > E V 1, we could reformulate the model so that the effect of this contrast is
estimated directly. This is done by simple algebraic manipulation. In our first-level model, we
could write
Y ¿ β 0 + X 1 β1 + X 2 β 2 + X 3 β3 + e
¿ ¿ β 0 + X 1 β 1+ X 2 β 1− X 2 β 1 + X 2 β 2+ X 3 β 3 +e
¿ ¿
Basically, we have now changed the EVs so that the β weight for the second EV now directly
tests the contrast of interest. We can interpret the significance of this coefficient directly.
In R, this adjusted model specification is as follows (note that we do not make use of the
voxeldat data structure here and just refer to the vectors that we create).
EV1.adj <- EV1.vec + EV2.vec
EV2.adj <- EV2.vec
model3 <- lme(Y.g ~ 1 + EV1.adj + EV2.adj + EV3.vec, random = ~1 + EV1.adj + EV2.adj + EV3.vec|
idnum, method=c("ML"))

Let's have a look at the results.


## Linear mixed-effects model fit by maximum likelihood
## Data: NULL
## AIC BIC logLik
## 2779.958 2862.391 -1374.979
##
## Random effects:
## Formula: ~1 + EV1.adj + EV2.adj + EV3.vec | idnum
## Structure: General positive-definite, Log-Cholesky parametrization
## StdDev Corr
## (Intercept) 1.3604681 (Intr) EV1.dj EV2.dj
## EV1.adj 0.9939036 0.618
## EV2.adj 1.3074703 -0.615 -0.976
## EV3.vec 0.4566427 0.654 0.393 -0.429
## Residual 0.4989767
##
## Fixed effects: Y.g ~ 1 + EV1.adj + EV2.adj + EV3.vec
## Value Std.Error DF t-value p-value
## (Intercept) 3.123745 0.4308575 1787 7.250065 0
## EV1.adj 2.267778 0.3178051 1787 7.135751 0
## EV2.adj 2.487290 0.4174228 1787 5.958683 0
## EV3.vec 4.285305 0.1513301 1787 28.317600 0
## Correlation:
## (Intr) EV1.dj EV2.dj
## EV1.adj 0.612
## EV2.adj -0.610 -0.969
## EV3.vec 0.624 0.383 -0.406
##
## Standardized Within-Group Residuals:
## Min Q1 Med Q3 Max
## -3.004917740 -0.678730633 -0.007405179 0.665799598 3.282728024
##
## Number of Observations: 1800
## Number of Groups: 10

The t-statistic and the p-value for this contrast are now the t-statistic and p-value for the fixed
effect for EV2.adj. We see here that our p-value is significant if we take α=0.05. In other words,
we can reject the null hypothesis.
You could write your EVs from the beginning of your experimental design to conform to the
contrasts of interest in the way shown above, but this kind of model rewriting of the model can
be difficult and error prone. It is normally more straightforward to specify the EVs in a logical
way and to specify the contrast directly.
In the following example, we use model 1 and set contr to be the linear combination E V 2 - E V 1.
Then, the t-statistic is calculated by dividing the linear combination of the parameter estimates
(as specified by the contrast) by the square root of the variance of this linear combination.
contr <- c(0, -1, 1, 0)
out <- anova(model1, L=contr)
tstat <- t(contr) %*% model1$coefficients$fixed / sqrt(t(contr) %*% vcov(model1) %*% contr)
pvalue <- 1 - pt(tstat, df=out$denDF)
We can see that the values obtained by specifying the contrast directly are indeed the same as we
had obtained by recoding the contrast (tstat = 5.97 and pvalue = 0).

Conclusions
We have described the structure of fMRI data, issues in pre-processing, the mixed effects
modeling framework used to analyze fMRI data, and how it is implemented in a common
specialized fMRI analysis package (FSL) and in R. Further, we have provided a self-contained
tutorial that both simulates data for a single voxel and demonstrates all the steps necessary to
create a design matrix, model the data, and evaluate a contrast using R. Thus in a single
document we have presented the information necessary to translate the language of specialized
fMRI software and analysis into an R framework. Our hope is that this tutorial can foster
interdisciplinary communication through the common and open R statistical platform. Of note,
the tutorial itself is written as a self-contained Rmarkdown document that can be used as an
example for reproducible analyses (see Supplemental Materials).
To emphasize the most important points, we have left out others. Part of the difficulty in
communicating the complexity of fMRI analyses to those in other disciplines stems from subtle
aspects of statistical methodology and an incomplete understanding of how variations in fMRI
pre-processing can alter assumptions made downstream. This document does not address these
issues; for some excellent discussion of that topic, see (Carp 2012; Churchill et al. 2017).
Importantly, because we focus on modeling a single voxel, this tutorial does not cover the vast
literature on correction for multiple comparisons, which is complicated and nuanced (Chen,
Taylor, and Cox 2017; Eklund, Nichols, and Knutsson 2016). We also do not describe common
neuroimaging file formats or how to read them into R, but this is readily accomplished by
established R packages such as oro.nifti (Whitcher, Schmid, and Thornton 2011). Finally, the
same model is likely to take far longer to run in R than in specialized software packages. At a
minimum, parallelization is required to reduce the overall execution time. This can be
accomplished in R but is not described here.

References
Askren, Mary K., Trevor K. McAllister-Day, Natalie Koh, Zoé Mestre, Jennifer N. Dines,
Benjamin A. Korman, Susan J. Melhorn, et al. 2016. “Using Make for Reproducible and Parallel
Neuroimaging Workflow and Quality-Assurance.” Frontiers in Neuroinformatics 10: 2.
doi:10.3389/fninf.2016.00002.
Bright, Molly G., and Kevin Murphy. 2015. “Is fMRI ‘Noise’ Really Noise? Resting State
Nuisance Regressors Remove Variance with Network Structure.” NeuroImage 114 (July): 158–
69. doi:10.1016/j.neuroimage.2015.03.070.
Carp, Joshua. 2012. “On the Plurality of (Methodological) Worlds: Estimating the Analytic
Flexibility of FMRI Experiments.” Frontiers in Neuroscience 6: 149.
doi:10.3389/fnins.2012.00149.
Chen, Gang, Paul A. Taylor, and Robert W. Cox. 2017. “Is the Statistic Value All We Should
Care About in Neuroimaging?” NeuroImage 147 (February): 952–59.
doi:10.1016/j.neuroimage.2016.09.066.
Cheong, JeeWon, David P. MacKinnon, and Siek Toon Khoo. 2003. “Investigation of
Mediational Processes Using Parallel Process Latent Growth Curve Modeling.” Structural
Equation Modeling : A Multidisciplinary Journal 10 (2): 238.
doi:10.1207/S15328007SEM1002_5.
Churchill, Nathan W., Pradeep Raamana, Robyn Spring, and Stephen C. Strother. 2017.
“Optimizing fMRI Preprocessing Pipelines for Block-Design Tasks as a Function of Age.”
NeuroImage 154 (July): 240–54. doi:10.1016/j.neuroimage.2017.02.028.
Cox, Robert W. 1996. “AFNI: Software for Analysis and Visualization of Functional Magnetic
Resonance Neuroimages.” Computers and Biomedical Research 29 (3). Elsevier: 162–73.
Eklund, Anders, Thomas Nichols, and Hans Knutsson. 2016. “Cluster Failure: Why FMRI
Inferences for Spatial Extent Have Inflated False Positive Rates.” Proceedings of the National
Academy of Sciences 113 (28): 7900–7905.
Friston, Karl, John Ashburner, Stefan Kiebel, Thomas Nichols, and William Penny, eds. 2007.
Statistical Parametric Mapping: The Analysis of Functional Brain Images. 1st ed. Elsevier.
Gandrud, Christopher. 2016. Reproducible Research with R and R Studio, Second Edition. CRC
Press.
Gentleman, Robert C, Vincent J Carey, Douglas M Bates, Ben Bolstad, Marcel Dettling,
Sandrine Dudoit, Byron Ellis, et al. 2004. “Bioconductor: Open Software Development for
Computational Biology and Bioinformatics.” Genome Biology 5 (10): R80. doi:10.1186/gb-
2004-5-10-r80.
Gorgolewski, Krzysztof, Christopher D. Burns, Cindee Madison, Dav Clark, Yaroslav O.
Halchenko, Michael L. Waskom, and Satrajit S. Ghosh. 2011. “Nipype: A Flexible, Lightweight
and Extensible Neuroimaging Data Processing Framework in Python.” Frontiers in
Neuroinformatics 5. doi:10.3389/fninf.2011.00013.
Huettel, Scott A., Allen W. Song, and Gregory McCarthy. 2014. Functional Magnetic
Resonance Imaging, Third Edition. 3rd edition. Sunderland, Massachusetts, U.S.A: Sinauer
Associates, Inc.
Jenkinson, Mark, C Beckmann, Timothy EJ Beherens, M. Woolrich, and Stephen M Smith.
2012. “Fsl.” Neuroimage 62 (2). Elsevier: 782–90.
Kamvar, Zhian N., Margarita M. López-Uribe, Simone Coughlan, Niklaus J. Grünwald, Hilmar
Lapp, and Stéphanie Manel. 2017. “Developing Educational Resources for Population Genetics
in R: An Open and Collaborative Approach.” Molecular Ecology Resources 17 (1): 120–28.
doi:10.1111/1755-0998.12558.
Laird, N. M., and J. H. Ware. 1982. “Random-Effects Models for Longitudinal Data.”
Biometrics 38 (4): 963–74.
Lindquist, Martin A. 2008. “The Statistical Analysis of FMRI Data.” Statist. Sci. 23 (4). The
Institute of Mathematical Statistics: 439–64. doi:10.1214/09-STS282.
Madhyastha, Tara, Matthew Peverill, Natalie Koh, Connor McCabe, John Flournoy, Kate Mills,
and Kevin King“Current Methods and Limitations for Longitudinal FMRI Analysis Across
Development.” Developmental Cognitive Neuroscience.
Mizumoto, Atsushi, and Luke Plonsky. 2016. “R as a Lingua Franca: Advantages of Using R for
Quantitative Research in Applied Linguistics.” Applied Linguistics 37 (2): 284–91.
doi:10.1093/applin/amv025.
Monti, Martin M. 2011. “Statistical Analysis of fMRI Time-Series: A Critical Review of the
GLM Approach.” Frontiers in Human Neuroscience 5 (March). doi:10.3389/fnhum.2011.00028.
Newsom, Jason T. 2015. Longitudinal Structural Equation Modeling: A Comprehensive
Introduction. New York: Routledge.
Open Science Collaboration. 2015. “Estimating the Reproducibility of Psychological Science.”
Science 349 (6251). American Association for the Advancement of Science.
doi:10.1126/science.aac4716.
Pernet, Cyril R. 2014. “Misconceptions in the Use of the General Linear Model Applied to
Functional MRI: A Tutorial for Junior Neuro-Imagers.” Frontiers in Neuroscience 8.
doi:10.3389/fnins.2014.00001.
Pinheiro, Jose, Douglas Bates, Saikat DebRoy, Deepayan Sarkar, and R Core Team. 2017. Nlme:
Linear and Nonlinear Mixed Effects Models. https://CRAN.R-project.org/package=nlme.
Poldrack, Russell A., Jeanette A. Mumford, and Thomas E. Nichols. 2011. Handbook of
Functional MRI Data Analysis. 1 edition. New York: Cambridge University Press.
Poline, Jean-Baptiste, and Matthew Brett. 2012. “The General Linear Model and fMRI: Does
Love Last Forever?” NeuroImage 62 (2): 871–80. doi:10.1016/j.neuroimage.2012.01.133.
R Core Team. 2014. “R: A Language and Environment for Statistical Computing.” Vienna,
Austria: R Foundation for Statistical Computing.
Whitcher, Brandon, Volker J. Schmid, and Andrew Thornton. 2011. “Working with the Dicom
and Nifti Data Standards in R.” Journal of Statistical Software, no. 6.
Woolrich, M., Timothy E. J. Behrens, Christian F. Beckmann, Mark Jenkinson, and Stephen M.
Smith. 2004. “Multilevel Linear Modelling for FMRI Group Analysis Using Bayesian
Inference.” NeuroImage 21 (4): 1732–47. doi:10.1016/j.neuroimage.2003.12.023.
Woolrich, M., B. D. Ripley, M. Brady, and S. M. Smith. 2001. “Temporal Autocorrelation in
Univariate Linear Modeling of FMRI Data.” NeuroImage 14 (6): 1370–86.
doi:10.1006/nimg.2001.0931.

You might also like