Profiling comes in three different flaviors. The first is emulation, where a processor behavior is emulated, the second is sampling, where at regular intervals, the profiler samples the status of a program, and fianlly instrulentation, where the profiler gets information when a subroutine is called and when it returns. As with the Heisenberg uncertainty, profiling changes the exact behavior of your program. This is something you have to remember when analyzing a profile.
Valgrind is an Open Source emulation profiler. It is freely available on standard Linux platforms. As it is an emulation, it is far slower than the actual program. This means that the I/O are underestimated. The advantage is that you can have every detail on the memory behavior (cache misses for instance). Valgrind does not emulate all processors, but you can tweak it to approach your own one.
Continue reading Profiling with Valgrind/Callgrind
For my research, I had to create a set of smooth deformation fields where I knew which points were moved and by which amount.
I tried to find a script, but I couldn’t find an appropriate one, not even talking about one in Python. So here I propose my own version, allowing to interpolate a 1D, 2D or 3D deformation field based on some points.
How does it work ? It is based on Bookstein’s algorithm. The first step is the computation of the coefficients of the smooth deformation field and then they are used to compute the values on the deformation field on a grid and this grid is returned.
The function to use is denseDeformationFieldFromSparse(), the arguments being size, the size of the desired grid, points, the locations where the deformation field is known, and displacements, the amount of displacement for each previously given point.
This code is given as is, but feel free to comment so that bugs can be ironed out (if there are bugs). It was tested with 1D, 2D and 3D test cases which can also be found on the gist.
Thanks to Bill Baxter for the distance function that was proposed on the numpy discussion list.