Showing posts with label MOOSE. Show all posts
Showing posts with label MOOSE. Show all posts

Thursday, August 14, 2014

Parameter fitting tool for MOOSE

During my last week in India, I contributed to the MOOSE project by providing an interface to a parameter fitting tool. Now parameters of MOOSE models can be searched by doing some tiny Python scripting.

When you have experimental data on a phenomenon, and you intend to create a computational model of it, usually you need to apply parameter fitting/searching techniques. These methods help you determine those parameters of your model that you have no reference on. Parameter fitting using MOOSE models are accomplished through utilizing Optimizer [1], a parameter fitting tool developed for neural simulations, which I came across by pure chance.

Results 'layer' from the Optimizer tutorial. Optimizer has a simple GUI to guide the user to a successive parameter fitting.

[1] P. Friedrich, M. Vella, A. I. Gulyás, T. F. Freund, and S. Káli, A flexible, interactive software tool for fitting the parameters of neuronal models, Front. Neuroinform, vol. 8, p. 63, 2014.

Friday, August 8, 2014

Profiling Python C extensions

During my collaboration with Upinder S. Bhalla's lab, I made possible to profile MOOSE C++ code through Python scripting, which means one can profile the native functions of MOOSE without writing any C++ code.

For profiling I used gperftools: I wrapped three of its functions, particularly ProfilerStart, ProfilerStop and ProfilerFlush in python functions using Cython. The recompilation of MOOSE is also needed with the -lprofiler flag. After that, one can just call the wrapper functions for ProfilerStart and ProfilerStop before and after the python code that calls the C extensions one is interested in to profile. Then pprof can be used to investigate the results of profiling.

Howto

To profile Python C extensions, first Cython, gperftools and libc6-prof packages need to be installed. If you'd like a visual representation of the results of your profiling, better install kcachegrind as well.

The simplest way to get the wrapper done is to write a cython script wrapping the gperftools functions and a python script that compiles the wrapped functions and link them to the gperftools library.

Let's call the Cython script gperftools_wrapped.pyx:

1:  cdef extern from "gperftools/profiler.h":  
2:      int ProfilerStart(char* fname)  
3:      void ProfilerStop()  
4:      void ProfilerFlush()  
5:    
6:  def ProfStart(fname):  
7:      return ProfilerStart(fname)  
8:    
9:  def ProfStop():  
10:      ProfilerStop()  
11:    
12:  def ProfFlush():  
13:      ProfilerFlush()  
14:    

Here we define a python function for each function of gperftools that we wrap. More functions can be wrapped for more custom profiling (see ProfilerStartWithOptions()).

Wednesday, April 16, 2014

From PDEs to Hines' solver

To understand and model electrical activity in neurons and neural networks, it is necessary to solve equations on current flows. When we take a single neuron into account, we should distribute that current flow over time and space which takes us to solve a PDE (Partial differential equation) instead of a more simple ODE. Such a cable equation allowing spatial variation looks like this:

Sunday, March 30, 2014

Numerical methods for solving ODEs in MOOSE

This post is about methods for solving ODEs (Ordinary Differential Equations) and about such methods used particularly in GENESIS, the ancestor of MOOSE (Multiscale Object-Oriented Simulation Environment), for neuronal modeling.

Before we discuss the methods themselves, there's a need for mentioning stiffness. We consider an ODE stiff if it has abrupt transitions in it, like an action potential. Basically stiffness measures the difficulty of solving an ODE numerically.

Stiff systems