Refactoring continued (week 9)

Until now I have been following the schedule pretty strictly, however it now came out that the performance of kCSD framework depends maily on Python underlying data structures, so there is not much room for algorithm/data structure optimization. Other than that, the double and triple integrals used in kCSD variants may take up to 97% of overall computation time assuming reconstruction of only 1 frame.

I believe this is essential to maintaining general purpose of the library. There is another, analytical way to calculate the potential in 3D, which Daniel pointed out. This will be added as an option to use.

Also this week Daniel told me to write a set of functions to compare model data and reconstructions.

Refactoring

The library is already very modular, however there is still an obvious near-duplicacy of code in 1D, 2D and 3D KCSD. I intentionally made the classes as similar as possible, to make the merging easier. My idea now is to split KCSD execution into two steps:

  • initializing model
  • calculating CSD and LFP with the use of the model and measured LFP data

Actually each model will stay a separate class. This is because merging all three variants into one model would create unnecesary cascades of conditional statements and will assign to much responsibility to a single class.

Adding more appropriate tests

To make the process of refactoring go smoothly, I’m filling any gaps in the set of unit and functional tests I’ve prepared over the course of the last weeks.

Dropping tests that compare pykCSD against Matlab kCSD2D version

During the tests of creating sources in the 2D case I found out an inconsistency. So that old (matlab based) 2d source distribution always returns sources instead of . This will be dealt with by switching to the new source distribution based on hypervolume. Also the old approach did not manage cases, where coordinations of sources were negative. I’ve also corrected this.

The package is almost ready to drop the tests of comparison against the existing Matlab scripts and switch to comparison to model only.

Documentation

The documentation has been improved. I decided to follow the docstring conventions from Numpy for the functions that are directly available to the user.

I used sphinx-napoleon extension to Sphinx to parse the Numpy style docstrings to rst.

The documentation is now hosted on readthedocs.org site: link