Package: prfsim
# PyPRF[![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/arash-ash/pRFsim/master?filepath=pRFsim_Tutorial.ipynb)<img src="logo.svg" width=200 align="right" />A free & open source *python package* for *population receptive field (PRF) simulation*. This package is mainly developed for functional magnetic resonance imaging (fMRI) experiments.## InstallationThe `prfsim` package can directly be installed from PyPI, in the following way:```bashpip install prfsim```## Dependencies`prfsim` is implemented in [Python 3.6.4]If you install `pyprf` using `pip` (as described above), all of the following dependencies are installed automatically - you do not have to take care of this yourself. Simply follow the above installation instructions.| pRFsim dependencies                                   | Tested version ||-------------------------------------------------------|----------------|| [NumPy](http://www.numpy.org/)                        | 1.14.0         || [Pandas](https://pandas.pydata.org/)                  | 0.22.0         || [SciPy](http://www.scipy.org/)                        | 1.0.0          || [Seaborn](https://seaborn.pydata.org/)   		| 0.8.1          || [Pillow](https://pillow.readthedocs.io/)   		| 5.0.0          |## ContributionsFor contributors, we suggest the following procedure:* Create your own branch (in the web interface, or by `git checkout -b new_branch`)* If you create the branch in the web interface, pull changes to your local repository (`git pull`)* Change to new branch: `git checkout new_branch`* Make changes* Commit changes to new branch (`git add .` and `git commit -m`)* Push changes to new branch (`git push origin new_branch`)* Create a pull request using the web interface## ReferencesThis application is based on the following work:[1] Dumoulin, S. O. & Wandell, B. A. (2008). Population receptive field estimates in human visual cortex. NeuroImage 39, 647–660.## SupportPlease use the [github issues](https://github.com/arash-ash/prfsim/issues) for questions or bug reports.## LicenseThe project is licensed under [GNU General Public License Version 3](http://www.gnu.org/licenses/gpl.html).## How to use```bashimport prfsim.sim as psimimport numpy as np# experiment parametersradius = 10precision = 0.1barWidth = radius / 4angles = [-90, 45, -180, 315, 90, 225, 0, 135]nFrames = len(angles)*3TR = 3.0TRs = 5 # number of TRs for each frameduration = nFrames*TRsx, y = np.mgrid[-radius:radius:precision,-radius:radius:precision]pos = np.dstack((x, y))length = len(x[0])nVoxels = 6# parameters for double gamma distribution function hrf:n1 = 4lmbd1 = 2.0t01 = 0n2 = 7lmbd2 = 3t02 = 0a = 0.3t = np.arange(0,nFrames*TRs*TR,TR)hrf_gen = psim.hrf_double_gamma(t, n1, n2, lmbd1, lmbd2, t01, t02, a)hrf_est = hrf_genstim = psim.generateStim(radius=radius, precision=precision,barWidth=barWidth, angles=angles,nFrames=nFrames, length=length,TR=TR, TRs=TRs, isCheckerboard=False)print('stimulus generated')neuronal_responses = psim.getNeuronalResponse(stim=stim, nVoxels=nVoxels,radius=radius, precision=precision,duration=duration)print('Neuronal responses generated')bolds = psim.generateData(neuronal_responses=neuronal_responses,hrf=hrf_gen,duration=duration, nVoxels=nVoxels)print('BOLD responses generated')print('pRF estimations started...')results = psim.estimateAll(bolds=bolds, stim=stim,hrf=hrf_est, radius=radius,precision=precision,nVoxels=nVoxels, margin = 1)print('pRF estimation errors generated')```