Package: pyprf
PyPRFA free & open sourcepython packageforpopulation receptive field
(pRF) analysis. With this package you can present visual stimuli for a
retinotopic mapping fMRI experiment, and perform a pRF analysis on the
fMRI data.1. Stimulus presentationPresents visual stimuli for retinotopic mapping experiments. The stimuli
consist of bars at different locations and orientations, filled with
flickering black and white checkerboards. It is important that the
participant fixates throughout the experiment. Therefore, there is a
central fixation task. The fixation dot occasionally changes its colour,
and the task is to press a button (number1) in response. At the end
of the presentation, the participant’s hit rate is provided as feedback.2. Data analysisAnalysis tools for fMRI data from retinotopic mapping experiment. A pRF
is estimated for each voxel (see [1]). The pRF model used here is a 2D
Gaussian; the free parameters are the Gaussian’s x- and y-position, and
its width (SD). This rather simple pRF model is best suited for early
visual cortex (higher cortical areas may require more complex models).How to use - stimulus presentationInstallationThe stimulus presentation is implemented inPsychopy, so if you would like to run the
experiment, you first need to install Psychopy (if you already have fMRI
data and would like to run the analysis, you can skip this step). Ondebian, Psychopy can easily be installed
usingapt-get:sudoapt-getinstallpsychopyIf you’re running some other operating system, please refer to thePsychopy website.For the stimulus presentation, you do not need to installpyprf. You
only need a copy of the folder~/pyprf/pyprf/stimulus_presentation.
The easiest way to get thepyprfstimuli is to clone the github
repository:gitclonehttps://github.com/ingo-m/pyprf.git(Or click the download button.)Then you can simply copy the folderstimulus_presentationand all
its contents to the computer that you use for stimulus presentation. (Do
not change the folder names. )Create design matrixBefore you can run the experiment, you need to create a design matrix in
which you specify the experimental design (e.g. how many repetitions of
the stimulus, inter trial interval for target events, fMRI volume TR,
etc.). You can either open the script~/pyprf/pyprf/stimulus_presentation/code/create_design_matrix.pyin
Psychopy and run it from there, or call it directly at command line.You can specify all parameters in the GUI that will pop up. Note that
there is one stimulus per fMRI volume, so you have to know the volume TR
when creating the design matrix.Stimulus presentationIn order to present the stimuli, you can open the file~/pyprf/pyprf/stimulus_presentation/code/stimulus.pyin Psychopy and
run it from there. Alternatively, you can call the presentation script
directly from command line:python`~/pyprf/pyprf/stimulus_presentation/code/stimulus.py`A GUI will open where you can specify further experimental parameters.
Importantly, the name of the design matrix (e.g. ‘Run_01’) needs to
match that of the file you created in the previous step.After starting the script, it will wait for a trigger signal from the
fMRI scanner (default: keyboard button5).The stimuli look like this:You can interrupt the presentation by pressingeandxat the
same time.How to use - analysisInstallnumpy. For instance:pipinstallnumpy(Or, alternatively, if you’re using conda,conda install-cconda-forgenumpy.)Thepyprfpackage can directly be installed from PyPI, in the
following way:pipinstallpyprf(Alternatively, you could also installed it from the repository, like
this:git clonehttps://github.com/ingo-m/pyprf.gitfollowed bypip install /path/to/pyprf.)Data analysis:In order to prepare the analysis, you need to run the stimulus
presentation script inlogging modein order to create a log of the
stimulus presentation. Run~/pyprf/pyprf/stimulus_presentation/code/stimulus.py(as described
above, either from Psychopy or at command line). In the GUI, set
‘Logging mode’ toTrue.The stimulus presentation log is created in the folder~/pyprf/pyprf/stimulus_presentation/log/Run_*_frames/.The analysis parameters are set in a config file. An example file can be
foundhere.
See comments therein for more information.Run the analysis:pyprf-config/path/to/config.csvDependenciespyprfis implemented inPython 3.6.If you installpyprfusingpip(as described above), all of the
following dependencies except forPsychopyandnumpyare
installed automatically - you do not have to take care of this yourself.
Simply follow the above installation instructions.Stimulus presentationTested versionPsychopy1.83.04NumPy1.15.1SciPy1.1.0Pillow5.0.0Data analysisTested versionNumPy1.15.1SciPy1.1.0NiBabel2.2.1Cython¹0.27.1Pillow5.0.0Tensorflow²1.4.0h5py2.8.0¹: For considerably faster performance²: Can yield fast performance, depending on hardware. However, requires
tensorflow to be configured for GPU usage (additional tensorflow
specific dependencies, including GPU drivers).The analysis can be carried out in three different ways: usingnumpy,cython, ortensorflow. You can set this option in
theconfig.csvfile. All three approaches yield the same results,
but differ in their dependencies and computational time: -Numpyuses numpy for the model fitting. Should work out of the box. -Cythonoffers a considerable speedup by using compiled cython code
for model fitting. Should work out of the box.This approach is
recommended for most users. -Tensorflowmay outperform the other
options in terms of speed (depending on the available hardware) by
running the GLM model fitting on the graphics processing unit (GPU).
However, in order for this to work, tensorflow needs to be configured to
use the GPU (including respective drivers). See thetensorflowwebsite for information on
how to configure your system to use the GPU. If you do not configure
tensorflow to use the GPU, the analysis should still run without error
on the CPU. Because this analysis may run single-threaded, it would be
slow. Numpy is always required, no matter which option you choose.ContributionsFor contributors, we suggest the following procedure:Create your own fork (in the web interface, or bygit checkout-bnew_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_branchMake changesCommit changes to new branch (git add .andgit commit-m)Push changes to new branch (git push origin new_branch)Create a pull request using the web interfaceReferencesThis 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 thegithub
issuesfor questions or bug
reports. You can also contact us on thepyprfchannel.LicenseThe project is licensed underGNU General Public License Version
3.