Summary
Investigating the spatially distributed information contained in fMRI data is essential for understanding brain functions. Here, we present a protocol to dynamically predict short-term changes in neural patterns using trial-by-trial blood-oxygen-level-dependent (BOLD) activity of a seed region. We describe steps for setting fMRI data acquisition parameters and quantification of changes in multivariate patterns. We then detail procedures for defining seed regions and identifying brain areas in which changes in multivariate patterns can be predicted by BOLD activity of the seed region.
For complete details on the use and execution of this protocol, please refer to Möhring et al.1
Subject areas: Health Sciences, Clinical Protocol, Neuroscience, Cognitive Neuroscience
Graphical abstract

Highlights
-
•
Quantify changes in multivariate fMRI patterns using a searchlight algorithm
-
•
Dynamically predict pattern change using trial-by-trial BOLD activity of a seed region
-
•
Investigate the temporal dynamics of changes in multivariate fMRI patterns
Publisher’s note: Undertaking any experimental protocol requires adherence to local institutional guidelines for laboratory safety and ethics.
Investigating the spatially distributed information contained in fMRI data is essential for understanding brain functions. Here, we present a protocol to dynamically predict short-term changes in neural patterns using trial-by-trial blood-oxygen-level-dependent (BOLD) activity of a seed region. We describe steps for setting fMRI data acquisition parameters and quantification of changes in multivariate patterns. We then detail procedures for defining seed regions and identifying brain areas in which changes in multivariate patterns can be predicted by BOLD activity of the seed region.
Before you begin
Institutional permissions
This study protocol was approved by the Ethics Committee of the Medical Association of Hamburg (2020-10102-B0-ff) and conducted in accordance with the Declaration of Helsinki. Any following fMRI studies will need to acquire permissions from the relevant institutions.
Predicting multivariate pattern change – Description of analysis strategy
Multivariate methods provide novel perspectives on stimulus representations in the human brain, unveiling the information embedded in spatially distributed patterns of neural activity, as measured by functional magnetic resonance imaging (fMRI). A plethora of studies have utilized machine learning algorithms to decode information about stimuli or investigate the (dis)similarity of activation patterns in relation to perceptual or categorical similarity. However, limited methods exist to explore the correlation between multivariate changes and potentially causal signals in the brain that give rise to these alterations in patterns. Our strategy of predicting multivariate pattern changes integrates both univariate and multivariate techniques. It enables the prediction of pattern alterations by leveraging preceding BOLD responses within specified regions of interest (ROIs) on a trial-by-trial basis. The protocol involves the following 4 major parts, each of them consisting of several analysis steps.
-
1.
Define a seed ROI that is hypothesized to elicit pattern change in some other brain region(s).
-
2.
Extract the trial-by-trial BOLD activations in the seed ROI.
-
3.
Calculate multivariate pattern change across the entire brain using a searchlight algorithm. This condenses the multivariate patterns into a univariate signal of change.
-
4.
Regress the pattern change images series (dependent variable) onto the BOLD activations from the seed ROI (independent variable, predictor) using a univariate GLM.
We describe these parts in more detail in the sections below.
Note: This protocol describes the specific steps to investigate pattern change following prediction errors (PE) during a reinforcement learning (RL) task. In the original publication we utilize two distinct seed ROIs exhibiting two different types of PEs to predict subsequent changes in neural patterns of other brain areas. These seed ROIs are the ventral striatum (VS), a region well known to show a reward prediction error (RPE) signal, as well as the intraparietal sulcus (IPS) which exhibits a state prediction error (SPE) signal. This enables us to detect brain regions in which pattern changes can be predicted by only one of two prediction error types. Though, the analysis does not require two seed ROIs and can also be used for hypotheses involving only a single seed ROI.
Note: The methodological approaches we present are applicable to many other types of tasks and brain regions. To apply this protocol to your studies the requirement is a seed ROI exhibiting a trial-wise explanatory BOLD response in combination with changing neural representations in other parts of the brain.
Design experimental task
Timing: 4 weeks
-
5.Choose an experimental task for the project.Note: There are a number of things to consider when designing a task for multivariate analyses in fMRI. Some of the points below apply to multivariate analyses in general; others are specific to this protocol.
-
a.Dynamics and effect strength of the seed ROI activity.
-
i.Estimate the required sample size of the project to achieve a significant effect in the seed ROI.Note: Such power analysis can be carried out with ready-made tools for fMRI, e.g. neuropowertools.org by Durnez et al.2 or fmripower by Mumford et al. (although this tool is no longer developed and updated).3
-
ii.Aim for a Gaussian distribution of BOLD response magnitudes in the seed ROI to facilitate estimation of the final GLM.
-
i.
-
b.Time interval between adjacent pattern events (i.e., the events at which multivariate patterns are extracted and used to calculate the pattern change, see Figure 1).
-
i.Slightly shift the timing of pattern events in each run to reduce temporal autocorrelation.Note: see Figure 2, the time shift is introduced by participant’s input reaction times during decision 1 (state-decision) 1.58 ± 0.77 s [mean ± SEM] and decision 2 (reward-decision) 1.07 ± 0.66 s.
-
ii.The time interval between two adjacent patterns, which will be compared in the analysis, should not be too short (temporal autocorrelation) or too long (not enough datapoints/trials, possibly greater changes in neuronal background activity masking the real pattern change of interest).Note: We were able to produce good results with an interval of around 25–30 seconds between two corresponding pattern events (see Figure 2 for event timings).
-
i.
-
c.Temporal relation of seed region event to pattern event.Note: The event eliciting the BOLD response which is hypothesized to predict pattern changes should occur between the two pattern events used to calculate the pattern change, see Figure 1.Optional: When using multiple model-informed computational signals as predictors of BOLD activity, ensure that these signals are mostly uncorrelated, which helps with the identifiability of the neural correlates of the computational variables.
-
a.
-
6.
Gather behavioral pilot data to ensure the task is capable of producing the desired behavioral response and neural effects.
Figure 1.
Analysis strategy and trial structure
The explanatory BOLD signal at event B (explanatory event) of the seed ROI, which will later be used to predict the change in neural patterns of other brain regions, occurs between both of the events A (pattern event), which elicit the patterns that are used to calculate the pattern change metric. In the final GLM the pattern change between two adjacent events A is regressed onto the explanatory BOLD responses at event B. Notably, the pattern change of the last trial is undefined, because there is no next pattern to compare the last trial’s pattern against.
Figure 2.
Trial timing and seed ROI signal distribution
(A) Timing of events in one trial of the original task design. The input of participant’s decisions is not time restricted and introduces slight shifts in timing of the pattern events, therefore reducing temporal autocorrelation.
(B) Histograms of the two seed ROI BOLD responses of all participants in the original experiment. Aim for a Gaussian distribution of BOLD responses in the seed ROI to facilitate the estimation of the final GLM that predicts pattern change using these signals.
Set fMRI scan parameters
Timing: 1 day
-
7.Balance scan parameters for functional imaging depending on your specific needs whilst retaining a reasonable temporal signal to noise ratio (tSNR).Note: We recommend performing test scans on your local MR scanner using multiple parameter combinations and calculate the tSNR of your target regions to guide your final decision (see Figure 3).Optional: Especially subcortical regions (like the ventral striatum) are susceptible to signal dropout when the scanning parameters are configured in an unfavorable way. In this case, reverting the phase encoding direction might help in recovering signal in these regions.Note: The following fMRI sequence parameters affect tSNR. We recommend selecting a combination of these parameters that maximize tSNR in the brain region with the lowest tSNR (either the seed or target region).
-
a.TR.
-
b.Voxel size.
-
c.Acceleration (e.g., Multiband, in-plane acceleration).
-
d.Scan volume (i.e., brain coverage of slice stack).Note: The scan parameters we used in this project were chosen and optimized with the intention to achieve a very short TR. However, the analysis described in this protocol should also work on conventional TR intervals of around 2 seconds. In this specific project, MRI data collection was conducted on a Siemens Prisma 3T scanner (Siemens, Erlangen, Germany) equipped with a 64-channel head coil. Each brain volume consisted of 24 axial slices (voxel size, 2.5 × 2.5 × 2.5 mm3, and 0.5 mm spacing between slices) acquired using a T2∗-weighted echo planar imaging (EPI) protocol (repetition time, TR = 627 ms; echo time, TE = 30 ms; flip angle = 45°; field of view = 224 mm, inplane acceleration factor = 2, Multiband factor = 2, Phase encoding direction P >> A). The orientation of the slice pack was tilted approximately 30° upward to the anterior commissure–posterior commissure axis to minimize susceptibility artifacts in the orbitofrontal cortex (OFC).4Note: The flip angle that maximizes SNR under repeated measurements (the “Ernst angle” is a function of the repetition time (TR) and the T1 relaxation time and is calculated as . In our Siemens Prisma scanner the T1 relaxation time of gray matter is measured as 1500 ms, which is the range reported in the literature.
-
a.
-
8.Collect additional data for later use during preprocessing of the functional images.
-
a.Field map: acquired with a gradient echo based sequence before functional EPI scanning to measure the magnetic field inhomogeneity (TE1 = 5.29 ms, TE2 = 7.75 ms).
-
b.Anatomical scan: a high-resolution anatomical image (voxel size, 1 × 1 × 1 mm3) acquired after the experiment using a T1-weighted MPRAGE protocol (FoV 256 mm, TR = 2300 ms, TE = 2,98 ms, phase encoding direction R >> L).
-
a.
Optional: Collect physiological data (e.g. ECG, breathing belt) to remove physiological noise from the BOLD data (However, this did not improve sensitivity of the multivariate analyses in our project).
Figure 3.
Different scan parameters and corresponding tSNR maps
(A) The tSNR maps for 3 different combinations of fMRI scan parameters calculated for 50 scans each.
(B) Comparison of tSNR values for different combinations of voxel sizes and multiband factors (MB) in a subcortical ROI (VS) and a cortical ROI (dorsolateral prefrontal cortex, dlPFC). Subcortical regions have lower tSNR values in general and were the limiting factor in this project. We chose to use a voxel size of 2.5 mm and MB 2 for functional imaging.
(C) Repetition times (TR) of the different fMRI scan parameter combinations.
(D) The tSNR is defined as the mean signal strength of a series of scans divided by the standard deviation of the signal.
Key resources table
Step-by-step method details
Perform experiment
Timing: 2 h
Note: In this major part the participant performs the experimental task inside the scanner and all data needed for the analysis are gathered. The participant should receive all necessary instructions to perform the task before entering the scanner.
-
1.
Position participant inside the scanner and install a 64-channel head-coil.
-
2.
Perform localizer scans.
Optional: This is a good time to check any input devices the participants will use throughout the task and run a test trial to make participants familiar with the setup.
-
3.
Acquire a field map to measure inhomogeneities of the magnetic field before collecting the functional EPI data.
Note: The positioning of the slice pack is automatically copied from the positioning of the field map measurement.
-
4.
Start task using a presentation software tool, perform task and acquire functional imaging data (EPI).
-
5.
After the experiment acquire anatomical images of the participant (MPRAGE).
Preprocess data
Timing: 30 min
Note: There are many protocols for preprocessing fMRI data in various software packages (SPM, FSL, AFNI, Brain Voyager) or using a combination of them (e.g. fMRIprep) that aims for standardization and replicability. The protocol below represents a fairly standard way of preprocessing fMRI data with SPM12, you can find the preprocessing code used in this protocol in the code depository (https://doi.org/10.5281/zenodo.8015561).
-
6.
Convert all imaging data from DICOM format into NIfTI (.nii) format (e.g., using the dcm2niix software package).
-
7.Realign and unwarp functional imaging data (to minimize noise introduced by head movement and rotation of participants in the functional imaging data).
-
a.Create a voxel displacement map (VDM) using the fieldmap data.
-
b.Perform the SPM12 realign and unwarp5 on the functional imaging data using the first functional EPI scan as reference.
-
a.
-
8.Normalization of all images to the MNI space (this step involves aligning the individual data from all participants into a common normalized space, enabling second-level group analyses).
-
a.First co-register the anatomical image to the first functional EPI scan.
-
b.Skull-strip and segment the anatomical image into gray matter, white matter, and cerebrospinal fluid (CSF) using the “Segment” tool of SPM12.
-
c.Use the results of the segmentation to create a flow-field in the DARTEL toolbox.6
-
d.Normalize the anatomical and functional image data by applying the flow-field to all images (troubleshooting 1).
-
a.
-
9.Smoothing of functional images (to enhance the signal-to-noise ratio in the functional data. We applied less smoothing specifically for use in multivariate analyses to preserve spatially distributed information).
-
a.For univariate analyses smooth with a Gaussian kernel of FWHM = 6 mm.
-
b.For multivariate analyses smooth with a Gaussian kernel of FWHM = 2 mm.
-
a.
Define ROI of seed region
Timing: 1 h
Note: The first major step is to define the Region of Interest (ROI) of the seed region which will be used to predict subsequent pattern changes in other areas of the brain. There are several ways to define a ROI for the seed region:
-
10.Anatomical ROI definition:
-
a.Anatomical mask image defined in a brain template (e.g., MNI154, Colin27).
-
b.Anatomical mask image defined individually for each participant (e.g., by tracing and anatomical region on a T1 image using the drawing tools of established software packages, e.g., MRIcroN, MRIcroGL).
-
a.
-
11.Functional ROI definition:
-
a.Localizer experiment: short fMRI run presenting stimuli that activate the intended seed region.
-
b.Localizer contrast: similar to a., except that the ROI is identified with a functional contrast in the main experiment.
-
c.Model-informed analysis: using variables (e.g., a reward prediction error) derived from a computational model (in the case of this protocol we used a reinforcement learning algorithm to model prediction error signals) as parametric modulators in the definition of the design matrix in a GLM.Note: This additional regressor will specify model-derived modulations of the height of the BOLD response (i.e., a large prediction error will result in a larger predicted BOLD response in the design matrix). This approach is similar to b., but it utilizes variables from a computational model to identify the seed ROI. In the SPM software package, which was a used in the original study, the values of these model-derived variables can be included in the onset definition during model specification.Note: In the main paper that this protocol describes, we used the option ‘Model-informed analysis’ to identify 2 ROIs that correlated with a model-derived reward and state prediction error. However, this protocol does not require 2 separate ROIs, a single explanatory seed ROI is sufficient. Below are additional details for running this analysis.
-
a.
-
12.
Specify a 1st level GLM for each participant using all experimental events in a single condition (regressor) and the model-derived computational signal as parametric modulators of these onset events.
-
13.
Estimate the model and include the beta images for the parametric modulators in a second-level group analysis.
Note: If the modulator(s) are independent of each other, a one-sample t-test as the 2nd level design is appropriate, if the ROI is only identified via a differential contrast (e. g. modulator1 > modulator2), then a paired t-test is the more appropriate design choice.
Optional: If the statistical results do not survive family-wise error correction, but the statistical map shows wide-spread activations just below the statistical threshold, refer to troubleshooting 2.
-
14.
Save the results for each ROI as a mask image and use it subsequently to extract single-trial BOLD activations of the seed ROI.
Extracting BOLD activations from the seed ROI
Timing: 2 h
Note: The goal of this part is the creation of a vector of BOLD activations in the seed ROI that can be used as a predictor to detect correlated pattern change. Thus, the result of this step is no longer a time-series in the traditional sense (i.e. a value for every EPI image in the original BOLD time series recorded in the scanner), but rather a vector of trial-by-trial estimates of the BOLD activation for each event in the experiment. It involves 2 analysis steps:
-
15.Obtain the BOLD activation at the time of the explanatory event (see event B in Figure 1) by using a first-level analysis that estimates the BOLD activation for each trial separately. There are two approaches to setup this first-level design detailed in Mumford et al.7 We found that the Least-squares Separate method was able to slightly improve the sensitivity of the pattern change analysis described in this protocol (this is especially the case for estimating first-level BOLD activations of the pattern events). However, this method is computationally intensive, see troubleshooting 3.
-
a.Least-squares All: A single first-level design with as many onset regressors as the number of trials in the experiment.Note: Each regressor contains only one trial of each event type in the experiment (i.e. it’s onset). This results in as many beta images as there are trials each representing the BOLD effect for its trial.
-
b.Least-squares Separate: one first level GLM for each trial containing the trial in question in a single onset regressor and all other trials in a second regressor.Note: This requires estimating as many first level GLM as there are trials in the experiment. Only the single trial beta image is of interest for further analyses. Although being a heavier computational burden, this approach supposedly provides more precise estimates of the single trial BOLD effect (see Mumford et al.7 for a more thorough and nuanced discussion). Figure 4 contrasts the first level designs for Least Square – Separate and Least Square – All as discussed in the Mumford paper.
-
a.
-
16.
Extract the mean BOLD effect for each trial in the seed ROI from the results of the trial-wise first-level GLM using the ROI mask image created in the previous part.
Note: This script shows how to use SPM functions to open .nii beta images, remove non numeric values (NaN, not a number) and then extract the mean BOLD signal of the ROI mask in every trial:
> ROI_mask_header = spm_vol(char(ROI_mask_filename));
> ROI_mask_vol = spm_read_vols(ROI_mask_header);
>
> for i_trial = 1:n_trials
> beta_image_header = spm_vol(char(beta_image_filename));
> vol = spm_read_vols(beta_image_header);
> vol(isnan(vol)) = 0;
> seed_ROI_BOLD(i_trial) = sum(vol .∗ ROI_mask_vol, 'all') / nnz(ROI_mask_vol) ;
> end
Figure 4.
Examples of first-level design matrices for two different analysis approaches to obtain single-trial estimates of BOLD activation
(A) In Least Square – All, each trial event is included in the design matrix as an individual regressor, but all events are included in the same first level analysis.
(B) In Least Square – Separate, the event of interest is included in a separate regressor, whereas all other events are included in another regressor. This design is repeated for every trial. From each of these first level analyses the beta image of the regressor with the single event is retained for further analyses.
Calculate pattern change maps
Timing: 2 h
Note: The result of this part is a trial-by-trial image series (across the entire brain) that contains the multivariate change in BOLD activation patterns between an event in a trial (e.g. a screen with decision cues that elicit the calculation of expected values for each option) and the same event in the next trial. This is done using a searchlight algorithm, which averages the pattern change within a searchlight and writes the resulting pattern change index into the center voxel before moving to the next voxel.
-
17.
Obtain the BOLD activation at the time of the pattern event (see event A in Figure 1) by using a first-level analysis that estimates the BOLD activation for each trial separately.
Note: The Least-squares Separate approach (see step 15) is again favorable for the sensitivity of the analysis.
-
18.Employ a searchlight algorithm to calculate the pattern change of the whole brain in every trial. We used spherical searchlights with a radius of 10 mm (4 voxels).Note: The searchlight radius should be large enough to include a sufficient number of voxels to facilitate meaningful pattern analyses, but small enough to retain spatial specificity. We found that a radius of 4 voxels is a good balance for the pattern change analysis presented in this protocol.
-
a.The Decoding Toolbox (TDT)8 provides an adaptable framework for calculating multivariate pattern change in the context of a searchlight algorithm.Note: Most searchlight algorithms are intended to be used for pattern classification. They only provide you with the patterns of all trials of a specified condition/class and discard information about the temporal relationship of patterns. However, for this analysis we need the patterns of all trials in chronological order.
-
b.To achieve a chronological order of all trial, expand the TDT with information about the trial number for each pattern.
-
c.Label all trial patterns with the same class/condition to pass them to the searchlight function in one batch.
-
d.Within the searchlight function, iterate through all trial patterns in backwards order. This implies that the resulting pattern change of two adjacent trials t and t+1 will be stored at trial t.Note: This order is beneficial for setting up the linear model in later analyses, because the pattern change[t, t+1] is already aligned with its predicting BOLD activation in the seed ROI at trial t.Note: The pattern change of the last trial in each run remains undefined (i.e. there is no trial to compare the last pattern with).
CRITICAL: The following script describes the above steps that should happen within the searchlight function. TDT passes the data of each searchlight (i.e. patterns of voxel activations for every trial) using the current_data 2D-array (the first dimension if this array are all trials and second dimension are all the voxels of the current searchlight sphere). The variable current_decoding indicates the index of the current searchlight sphere. When dealing with several runs you have to add another for-loop for all runs surrounding this code snippet.> previous_pattern = NaN(length(current_data(1,:)), 1);>> for i_trial_forward = n_trials : -1 : 1>> if(isnan(previous_pattern))> % pattern_change of the last pattern is undefined> result(i_trial, current_decoding) = 0;> else> pattern_change = [calculate pattern change here];> result(i_trial, current_decoding) = pattern_change;> end>> previous_pattern = current_data(i_trial, :);> endNote: You can find the code that uses TDT functions for this analysis in the code repository of this protocol (https://doi.org/10.5281/zenodo.8015561).
-
a.
-
19.An important choice is the multivariate distance measure that is used for calculating the pattern change. We choose to utilize a Fisher z-transformed correlation distance as explained below.
-
a.Calculate the Pearson correlation coefficient between the BOLD activation patterns in the searchlight between the same event in two adjacent trials (If some of the resulting correlation coefficients are undefined (i.e., NaN), refer to troubleshooting 4).> correlation_matrix = corrcoef(searchlight_voxels(t, :), searchlight_voxels(t+1, :));
-
b.Apply a Fisher z-transformation to improve the distribution of correlation coefficients toward a Gaussian distribution.Note:Figure 5 exemplifies the effect of this transformation: data points (voxel activation at both ends of the distribution are exaggerated, whereas those in the middle are mostly left unchanged). The Fisher-z transformation can be performed by calculating the atanh() of a correlation coefficient.
-
c.Flip the sign of the transformed correlation distance.Note: That way, two highly correlated patterns will result in a low amount of pattern change and vice versa.> pattern_change = - atanh(correlation_matrix(1,2 ));
-
d.Write the pattern change of the searchlight sphere to the center voxel.
-
a.
-
20.
Store the resulting pattern change maps of all trials in NIfTI format for subsequent analyses. This can be achieved with spm_write_vol() when using SPM.
Note: To store the data with the same volume settings (e.g. rotation, voxel size) as your input data it is easiest to use the header of existing NIfTI files (we used the ROI_mask_header here, troubleshooting 5).
> output_header = ROI_mask_header;
>
> for i_trial = 1:n_trials
> filename = sprintf('betas_%03d.nii', i_trial);
>
> output_header.fname = fullfile(output_dir, filename);
> output_header.private.dat.fname = output_header.fname;
> spm_write_vol(output_header, result(i_trial, :)
> end
Optional: There are different options when choosing the multivariate distance measure for pattern change calculation. We achieved best results when using the described Fisher z-transformed correlation distance, but here are examples of other possible distance measures to try:
Mahalanobis distance: similar to the correlation distance, but it also considers the covariance between the whole distribution of voxel activations in the searchlight sphere over all trials. First, you have to calculate the covariance matrix of all patterns (all trials in a given searchlight) to then determine the Mahalanobis distance of each individual pattern to the whole distribution of patterns in that searchlight.
Sum of squared differences: the simplest (and unscaled) distance measure corresponding to the cost function in ordinary least squares designs (e.g. multiple regression analysis)
Figure 5.
A correlation based pattern change metric
This figure illustrates how to calculate the magnitude of pattern change between two patterns.
(A) Simulated patterns of a searchlight in trials 1 to 6 with linear gradients and different gradient directions. Patterns 1 and 2 have the same direction. Patterns 2 and 3 as well as 3 and 4 have slightly different gradient directions (45°). Patterns 4 and 5 show completely opposite gradients (180°). Patterns 5 and 6 feature a medium change in gradients (90°).
(B) Scatter plots of patterns in adjacent trials to visualize the pattern correlation.
(C) Pearson’s correlation coefficients (black dashed line) and Fisher-Z transformed correlation values (blue line).
(D) The pattern change metric (red line) is a measure of the magnitude of change. Similar patterns produce low pattern change values (patterns A and B) while inverse patterns result in high pattern change (patterns D and E).
Predict pattern change using BOLD of seed ROI
Timing: 30 min
Note: In this major step of the analysis we combine the extracted BOLD signal of the seed ROI and the whole brain pattern change maps described above in a univariate GLM to localize areas of the brain in which changes in neural patterns can be predicted by the seed ROI activity.
-
21.
Specify a first-level GLM for each participant by regressing the trial-by-trial pattern change image series (dependent variable) onto the trial-by-trial BOLD activations from the seed ROI (independent variable, predictor):
> pattern_change ∼ b0 + b1 ∗ seed_ROI_BOLD
-
22.
Estimate the model and include the resulting beta images (b1) in a second-level group analysis.
-
23.
Identify brain areas in which changes in neural patterns can be significantly predicted by the BOLD activity of the seed ROI using a one-sample t-test in the second-level group analysis.
Note: If the statistical results do not survive family-wise error correction, but the statistical map shows wide-spread activations just below the statistical threshold, refer to troubleshooting 2.
-
24.
Visualize significant clusters by overlaying statistical results onto an anatomical image using established software packages (e.g., MRIcron, MRIcroGL).
Further analyses
Optional: Several analyses can be explored to further investigate the observed pattern changes, validate related hypotheses, or affirm the results of the pattern change predictions outlined in this protocol. All of the methods listed below are well established and thus we do not provide a detailed explanation for them in this protocol. Instead we want to illustrate ways to expand on the results gained in the primary analysis.
-
25.Investigate the temporal dynamics of pattern changes.
-
a.The trial-by-trial pattern change maps created in this protocol can be used to plot the trial-by-trial evolution of pattern changes in different brain regions at specific events in the task. Figure 6A plots the mean magnitude of pattern change over all subjects in the orbitofrontal cortex (OFC) before and after a reward reversal in the task.
-
a.
-
26.
Pattern classification: the pattern change analysis described in this protocol is capable of quantifying differences in neural information content over time. Other analysis strategies have to be utilized to gain insights about the information encoded in those patterns. This can be achieved through a decoding analysis (multivariate classification) or representational similarity analysis.9
-
27.Permutation analysis: confirm the results of the primary pattern change analysis by employing a permutation test in the final GLM. The concept is to simulate an analysis with many randomly shuffled combinations of the input data and then compare the test-statistic of the analysis using the real input data against the distribution of permutations (see Figure 6B).
-
a.During the first-level analysis (single subject): within each subject, permute the trial-by-trial BOLD in seed ROI (predictor) while keeping the true order of trial-by-trial pattern changes.
-
b.Calculate the second-level group analysis using all subjects and store the resulting second-level t-statistics of all permutations.
-
c.Compare the second-level t-statistic of the real analysis against the distribution of permuted t-statistics.
-
a.
-
28.
Conjunction analysis: when testing multiple hypotheses you can test the statistical significance of a combination of several analyses throughout the brain by employing a true conjunction analysis.10
Note: Conjunction analyses must not be performed on threshold-free cluster enhancement (TFCE) enhanced results.
Figure 6.
Further analyses to consider
(A) Investigate the trial-by-trial temporal dynamics of pattern changes in different brain regions at important events in the task. This figure shows the pattern change in the orbitofrontal cortex (OFC) after a reward reversal in the task. The red line depicts the mean pattern change over all subjects and the light red area illustrates the standard error.
(B) Confirm the results of the primary pattern change analysis using a permutation test in which the trial-wise predictor variable (BOLD in seed ROI) is randomly shuffled during the first-level analysis within each subject. Then plot a histogram of the second-level T-statistic and compare the T-statistic of the real data against the distribution of permutations (here we simulated the analysis with n = 10000 random permutations).
Expected outcomes
After performing all analyses described above, the expected outcome is a statistical map of the whole brain displaying the significance that pattern change in a brain region is predicted by the preceding BOLD signal strength of the seed ROI. Figure 7 depicts an overview of all major analysis steps and the final GLM, which produces the statistical map.
Figure 7.
Overview of all major analyses
Schematic overview of all major steps and the final GLM to predict changes in neural patterns using BOLD in a seed ROI. The final GLM regresses the trial-by-trial pattern change in every voxel of the brain (dependent variable) onto the trial-by-trial BOLD responses of the seed ROI (independent variable). The resulting beta images of all subjects are then tested for statistical significance in a group analysis using a one-sample T-test.
Limitations
The multivariate analysis outlined in this protocol can draw conclusions about the magnitude of pattern changes in different areas of the brain, the temporal dynamics of these changes (e.g., for how many trials the pattern change persists) and the relationship to potential seed regions inside the brain. It does not make assumptions about the information contained in the observed patterns. To explore the information content of patterns other existing analysis types can be employed (see further analyses).
The results of using this analysis strategy can also be impaired by different factors. These include weak BOLD signal in seed and target regions, problems during seed ROI definition and insufficient statistical power.
Troubleshooting
Problem 1
During the first data analysis you cannot obtain robust statistical group-analysis results for simple contrasts (e.g., motor contrasts) (step 8).
Potential solution
-
•
It might be worthwhile to manually check if the normalization process worked for all participants. You can check this by overlaying all normalized images in a viewer like MRIcroGL.
-
•
Also check if the order of your NIfTI files is correct and potential dummy scans at the start of the experiment have been removed properly.
Problem 2
The statistical results of the final second-level pattern change GLM (or other GLMs, e.g., for functional seed ROI definition) do not survive family-wise error correction (steps 13 and 23).
Potential solution
Depending on the shape of the activation clusters (e.g., wide-spread and rather flat vs. spiky with smaller peaks in a larger cluster), TFCE (threshold-free cluster enhancement), an iterative permutation-based correction for multiple comparisons, can be used.11
Problem 3
The Least-squares Separate method requires the estimation of one whole GLM per trial in the experiment. It may be extremely time and memory consuming (step 15).
Potential solution
Use parallel computing to estimate GLMs of all trials in the experiment. When a GLM is finished, directly copy the beta image of interest (i.e., the beta image of the current trial in its own regressor) into a new folder and discard the GLM to save memory.
Problem 4
The pattern change searchlight algorithm produces NaN values in the trial-by-trial pattern change maps of some subjects (step 19).
Potential solution
-
•
Corrcoef() gives NaN values as an output, when one of the input variables contains a NaN. You can use the option corrcoef(X, Y, 'rows', 'complete') or corrcoef(X, Y, 'rows', 'pairwise') to ignore NaN in the input. You should also check the cause for the existence of NaN values in the input and fix potential problems.
-
•
Corrcoef() also produces NaN values, when at least one of the input patterns contains only identical values (i.e., the standard deviation of one pattern is zero). This results in a divide by zero computation and the correlation of these two patterns is undefined. If this impairs the second level GLM results and happens rarely you can try to replace these NaN values with zeros. If there are many undefined correlation coefficients you should inspect the potential cause of that problem.
Problem 5
The stored NIfTI image has the wrong orientation or is stored in integer format so that information is lost (step 20).
Potential solution
Make sure to use the correct header file when manually saving the NIfTI images. When saving the results transforms your data into integer format you have to use the header of one of the realigned and normalized images instead of the mask image header.
Resource availability
Lead contact
Further information and requests for resources and reagents should be directed to and will be fulfilled by the lead contact, Jan Gläscher (glaescher@uke.de).
Technical contact
Questions about the technical specifics of performing the protocol should be directed to and will be answered by the technical contact, Leon Möhring (l.moehring@uke.de).
Materials availability
This study did not generate new unique reagents.
Data and code availability
-
•
Behavioral data have been deposited at Zenodo and are publicly available as of the date of publication. DOIs are listed in the key resources table. Imaging data reported in this paper will be shared by the lead contact upon request.
-
•
All original code has been deposited at Zenodo and is publicly available as of the date of publication. DOIs are listed in the key resources table.
-
•
Any additional information required to reanalyze the data reported in this paper is available from the lead contact upon request.
Acknowledgments
This work was funded by the German Research Foundation (SFB TRR 169 “Cross-modal Learning”).
Author contributions
J.G. and L.M. designed the experimental task, developed analytical protocols, and wrote the paper.
Declaration of interests
The authors declare no competing interests.
References
- 1.Möhring L., Gläscher J. Prediction errors drive dynamic changes in neural patterns that guide behavior. Cell Rep. 2023;42 doi: 10.1016/j.celrep.2023.112931. [DOI] [PubMed] [Google Scholar]
- 2.Durnez J., Degryse J., Moerkerke B., Seurinck R., Sochat V., Poldrack R.A., Nichols T.E. Power and sample size calculations for fMRI studies based on the prevalence of active peaks. bioRxiv. 2016 doi: 10.1101/049429. Preprint at. [DOI] [Google Scholar]
- 3.Mumford J.A. A power calculation guide for fMRI studies. Soc. Cogn. Affect. Neurosci. 2012;7:738–742. doi: 10.1093/scan/nss059. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 4.Deichmann R., Gottfried J.A., Hutton C., Turner R. Optimized EPI for fMRI studies of the orbitofrontal cortex. Neuroimage. 2003;19:430–441. doi: 10.1016/s1053-8119(03)00073-9. [DOI] [PubMed] [Google Scholar]
- 5.Hutton C., Bork A., Josephs O., Deichmann R., Ashburner J., Turner R. Image distortion correction in fMRI: A quantitative evaluation. Neuroimage. 2002;16:217–240. doi: 10.1006/nimg.2001.1054. [DOI] [PubMed] [Google Scholar]
- 6.Ashburner J. A fast diffeomorphic image registration algorithm. Neuroimage. 2007;38:95–113. doi: 10.1016/j.neuroimage.2007.07.007. [DOI] [PubMed] [Google Scholar]
- 7.Mumford J.A., Turner B.O., Ashby F.G., Poldrack R.A. Deconvolving BOLD activation in event-related designs for multivoxel pattern classification analyses. Neuroimage. 2012;59:2636–2643. doi: 10.1016/j.neuroimage.2011.08.076. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 8.Hebart M.N., Görgen K., Haynes J.-D. The Decoding Toolbox (TDT): a versatile software package for multivariate analyses of functional imaging data. Front. Neuroinform. 2014;8:88. doi: 10.3389/fninf.2014.00088. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 9.Freund M.C., Etzel J.A., Braver T.S. Neural Coding of Cognitive Control: The Representational Similarity Analysis Approach. Trends Cogn. Sci. 2021;25:622–638. doi: 10.1016/j.tics.2021.03.011. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 10.Nichols T., Brett M., Andersson J., Wager T., Poline J.-B. Valid conjunction inference with the minimum statistic. Neuroimage. 2005;25:653–660. doi: 10.1016/j.neuroimage.2004.12.005. [DOI] [PubMed] [Google Scholar]
- 11.Smith S.M., Nichols T.E. Threshold-free cluster enhancement: addressing problems of smoothing, threshold dependence and localisation in cluster inference. Neuroimage. 2009;44:83–98. doi: 10.1016/j.neuroimage.2008.03.061. [DOI] [PubMed] [Google Scholar]
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.
Data Availability Statement
-
•
Behavioral data have been deposited at Zenodo and are publicly available as of the date of publication. DOIs are listed in the key resources table. Imaging data reported in this paper will be shared by the lead contact upon request.
-
•
All original code has been deposited at Zenodo and is publicly available as of the date of publication. DOIs are listed in the key resources table.
-
•
Any additional information required to reanalyze the data reported in this paper is available from the lead contact upon request.

Timing: 4 weeks





