This repository provides the code for neural field simulations, generation of simulated BOLD signals and reconstruction of spatial patterns from Schneegans & Bays 2017 . The reconstruction closely emulates the procedure proposed by Sprague, Ester & Serences 2016 , and uses code from these authors published on the Open Science Framework at https://osf.io/s5r6g/files/ (files: build_basis_pts.m, make_channel_responses.m, make_grid.m, make_hex.m, make_stim_mask.m, make2dcos_grid.m, rad2fwhm.m; also some snippets of code in other files). The neural field model is implemented using the free Matlab toolbox cosivina, which is hosted on bitbucket (https://bitbucket.org/sschneegans/cosivina). You need to install this toolbox to run the simulations provided here. If you want to use this toolbox for your own work, take a look at the wiki or the pdf documentation on the linked bitbucket page (in particular the section "Tutorials and Examples"), and try out the examples provided in the toolbox. You can find additional software, lectures, and tutorials on the topic under http://www.dynamicfieldtheory.org/. The architecture and parameter values of the neural field model are fully specified in the file params.json. To see the neural field in operation (running a shortened version of the experimental task) and change parameters online, run dnfModel_runGUI. To run a small sample of trials from the experiment and get some idea what the reconstructions will look like, run dnfModel_runSingleTestTrial (this does not perform the actual reconstruction, but only applies some filters to the neural model output that roughly match the effects of reconstruction from simulated BOLD signals). To run a block of the actual experiment (for a single condition), a block of the mapping task, and perform the reconstruction, run dnfModel_runTestSims, dnfModel_runTrainingSims, and dnfModel_reconstruct. This will probably take several minutes and generates around 100 MB of data. To run the full emulation of the experiment (around 2000 trials in total, with several blocks of the mapping task), run the "Batch" version of these three files. This will probably take several hours and generate about 4GB of data. Additional versions are provided to run the task and model variants (these usually use the same training data and reconstruction functions, except for the version with unreliable cues which has its own reconstruction function).  Schneegans, S., & Bays, P. M. (2017). Restoration of fMRI Decodability Does Not Imply Latent Working Memory States. *Journal of Cognitive Neuroscience*, 29(12), 1977-1994.  Sprague, T. C., Ester, E. F., & Serences, J. T. (2016). *Restoring latent visual working memory representations in human cortex*. Neuron, 91(3), 694-707.