I enjoyed reading "A tutorial on the free-energy framework for modelling perception and learning" by Rafal Bogacz, which is freely available here. In particular, the author encourages to replicate the results in the paper. He is himself giving solutions in matlab, so I had to do the same in python all within a notebook...
A set of bash code to resize images to a fixed size.
Problem statement: we have a set of images with heterogeneous sizes and we want to homogenize the database to avoid problems when classifying them. Solution: ImageMagick.
We first identify the size and type of images in the database. The database is a collection of folders containing each a collection of files. We thus do a nested recursive loop:
Sometimes, you need to pick up the $N$-th extremal values in a mutli-dimensional matrix.
Let's suppose it is represented as a
nd-array (here, I further suppose you are using the numpy library from the python language). Finding extremal values is easy with
argsort but this function operated on 1d vectors... Juggling around indices is sometimes not such an easy task, but luckily, we have the
Let's unwrap an easy solution combining these functions:
It is insanely useful to create movies to illustrate a talk, blog post or just to include in a notebook:
from IPython.display import HTML HTML('<center><video controls autoplay loop src="../files/noise.mp4" width=61.8%/></center>')
For years I have used a custom made solution made around saving single frames and then calling
ffmpeg to save that files to a movie file. That function (called
anim_save had to be maintained accross different libraries to reflect new needs (going to WEBM and MP4 formats for instance). That made the code longer than necessary and had not its place in a scientific library.
Here, I show how to use the
animation library from matplotlib to replace that
For a master's project in computational neuroscience, we adopted a quite novel workflow to go all the steps from the learning of the small steps to the wrtiting of the final thesis. Though we were flexible in our method during the 6 months of this work, a simple workflow emerged that I describe here.
Gizeh (that is, Cairo for tourists) is a great interface to the Cairo drawing library.
I recently wished to make a small animation of a bar moving in the visual field and crossing a simple receptive field to illustrate some simple motions that could be captured in the primary visual cortex ansd experiments that could be done there.