Given a set of voxel location (sample file provided), experimental design matrix, and a desired signal-to-noise ratio, this program generates a set of synthesized voxel activations.
Each experimental covariate (which can be activated to varying degrees during each trial, as specified in the design matrix) is assigned a single radial basis function. The basis function's center is chosen uniformly within the confines of the specified brain, and the width is also chosen uniformly. (Note: you can associate multiple radial basis functions with each covariate by giving each covariate multiple columns in the design matrix.)
The synthesized brain image for each trial is a weighted combination of the basis functions for the sources active during that trial, plus zero-mean Gaussian noise. (The standard deviation of the Gaussian noise is controlled via the SNR parameter.)
For added realism, an optional flag allows the user to specify whether the synthetic data incorporate a synthetic hemodynamic response function.
The synthetic data can be saved in NIFTI format (this relies on code, included in the download, from http://www.mathworks.com/matlabcentral/fileexchange/8797-tools-for-nifti-and-analyze-image).
Note: this code includes the "join" function available here: http://www.mathworks.com/matlabcentral/fileexchange/4872-join
Jeremy Manning (2019). Generate synthetic fMRI data (https://www.mathworks.com/matlabcentral/fileexchange/36125-generate-synthetic-fmri-data), MATLAB Central File Exchange. Retrieved .
The key to creating data that satisfy particular time series constraints is to construct an appropriate design matrix, as you noted. Each row of the design matrix corresponds to a time point. Each column corresponds to the desired activity of some brain region (for this simulation, a brain region is a randomly constructed sphere somewhere in the brain). In your case, you'll want to add a column to the design matrix for each BOLD time series that you want the simulation to mirror. (And if you want multiple simulated "brain regions" to mirror a single BOLD time series, you should replicate the corresponding columns of the design matrix.) You should set the "sim_hemo" flag to false so that the time series in your design matrix is not convolved with the HRF.
If you want to create a synthetic .nii image as a 10 by 20 by 30 voxel rectangular prism (stored at synthetic.nii), with a pre-specified design matrix (X), and with no noise (infinite signal-to-noise), you can do so using the following command:
[data, cov_images, params, meta] = generate_data([10 20 30], x, inf, 1, false, 'synthetic.nii');
Where the output parameters are described in the generate_data.m documentation ("help generate_data") and the .nii file synthetic.nii may be viewed with any standard brain image viewer (e.g. fslview).
I am using your toolbox to plot fMRI data generated with a computational DFT model (see Buss et al. 2014 for a desciption, doi: 10.1162/jocn_a_00496). For each model layer (signal source) I have an average BOLD signal per condition, so my data are already convolved with the HRF.
How can I correctly use these data for image generation with your toolbox? I tried using the layerwise standardized signal (with values within [0,1]) as a nconditions by nlayers design matrix which worked but still seems incorrect to me.
Thanks for your help!
You're having trouble downloading the brain plots package? You should add a comment to that submission page, not this one. But if you just click the "Download Submission" link and unzip the file you download, all of the .m files should be in the resulting folder. I just re-downloaded that package to verify, and it looks OK to me...
I'm searching http://www.mathworks.com/matlabcentral/fileexchange/36139-2d-and-3d-brain-plots) page, but I cant see any file which I can download.
Your file is erased, isn't it?
The "data" variable contains the images for each trial specified by the design matrix (see above). That's what you pass to plot_brain2d or plot_brain3d. The 2d plots usually work better for viewing the synthetic data. This is because, whereas in real data "interesting stuff" often happens on the outer surface, in the synthetic data the sources are equally likely to be anywhere within the brain volume.
Let's say you want to generat a simple dataset with two trials, one unique source active per trial, and infinite signal-to-noise:
[data,cov_images] = generate_data(meta,eye(2),inf);
To generate 2d plot of first trial using default settings (requires installing http://www.mathworks.com/matlabcentral/fileexchange/36139-2d-and-3d-brain-plots), use:
To generate a 3d plot of second trial using default settings, use:
In each of the above examples, "meta" is the matrix included with the download of this package. (See documentation for additional details on the meta matrix.)
so i just fed the result from the generate_data into the plot_brain3d? which to use? data or cov_images? would you mind showing the line how it works? thanks
To plot the images, you can use http://www.mathworks.com/matlabcentral/fileexchange/36139-2d-and-3d-brain-plots
sorry for such a silly question, but how can i plot the image?
I've updated the submission with some example design matrices -- I hope that helps! (Give it a day or so for the update to show up.)
The design matrix, X, must be a matrix of real numbers. Each column of X corresponds to a single covariate. Each row of X corresponds to a single trial (one image will be generated per trial). So row i, column j controls how active covariate j is during trial i. For example
X = eye(5);
corresponds to 5 trials, with one covariate active per trial.
X = rand(10,5);
gives you 10 trials, with 5 covariates randomly active during each trial. Finally,
X = [eye(5) eye(5)]
gives you 5 trials, with 2 covariates active during each trial.
i am curious how do you design the X matrix?
Substantially faster implementation, usability improvements.
updated HRF convolution, added additional files from file exchange submission #8797
updated description, added pointer to http://www.mathworks.com/matlabcentral/fileexchange/8797-tools-for-nifti-and-analyze-image
modified the meta struct so that the function produces more realistic brain images. i also added an option to output source parameters.
support convolution with hemodynamic response function, outputting to NIFTI format.
added support for SNR = 0
updated help text to include usage examples.
minor change to program description.
minor change to program description.