Ads by Google
Christian Borgelt's Web Pages

PyCoCo - Continuous-time Closed Neuron Assembly Detection for Python

Download

standard MIS-based support
32 bit 64 bit (32/64 bit only for shared object/dynamic module)
coco.so (383 kb) coco.so (374 kb) GNU/Linux Python 2.7.x shared object
coco.so (383 kb) coco.so (374 kb) GNU/Linux Python 3.5.x shared object
coco.pyd (94 kb) coco.pyd (113 kb) Windows Python 2.7.x dynamic module
coco.pyd (94 kb) coco.pyd (113 kb) Windows Python 3.5.x dynamic module
 
influence map overlap based support
32 bit 64 bit (32/64 bit only for shared object/dynamic module)
ccnovl.so (359 kb) ccnovl.so (358 kb) GNU/Linux Python 2.7.x shared object
ccnovl.so (359 kb) ccnovl.so (358 kb) GNU/Linux Python 3.5.x shared object
ccnovl.pyd (94 kb) ccnovl.pyd (113 kb) Windows Python 2.7.x dynamic module
ccnovl.pyd (94 kb) ccnovl.pyd (113 kb) Windows Python 3.5.x dynamic module
 
pycoco.zip (408 kb) pycoco.tar.gz (389 kb) C sources, version 2.44 (2016.11.21)
psf+psr.zip (78 kb) psf+psr.tar.gz (71 kb) Python scripts for Pattern Spectrum Filtering
and Pattern Set Reduction

Description

PyCoCo is an extension module that makes the CoCoNAD implementation available as a function in Python 2.7.x & 3.5.x and also includes a function for generating a pattern spectrum with the help of surrogate data and CoCoNAD analysis.

This extension module was originally developed for Python 2.7. The shared objects made available above were compiled particularly for Python 2.7.11 and Python 3.5.1 on Ubuntu 16.04 LTS and the dynamic modules made available above were compiled for Python 2.7.10 and Python 3.5.1 on Windows 10.

How to use the function coconad can be seen in the script testcoco.py in the source package (directory pycoco/ex). For the function patspec see the script ccn+psf+psr.py in the psf+psr archives. Alternatively, from a Python command prompt interface, call help(coco), help(coconad) (or help(coco.coconad)) and help(patspec) (or help(coco.patspec)) or print coconad.__doc__ and patspec.__doc__ for a description of these functions and their arguments.

The Python scripts in the archives psf+psr implement the full analysis process of parallel (spike) trains/point processes as it is described (although for standard frequent item set mining) in [Picado-Muiño et al. 2013] and [Torre et al. 2013]. A full description of these scripts can be found here. Call the main script ccn+psf+psr.py without any arguments to obtain a help message that shows the invocation and the available options.

If instead of a command prompt interface as the psf+psr scripts provide it, a graphical user interface is desired, the Java-based CoCoGUI program is worth looking at.

Installation: precompiled version

If you have a GNU/Linux system (Ubuntu 12.04 or later preferred), you can simply use this extension module by downloading the shared object made available above (choose the version depending on your system and your installed Python version) and storing it in a directory that is on your PYTHONPATH (environment variable). This should also work on other GNU/Linux distributions, particularly Debian based ones. A typical (local) installation directory is $HOME/lib/; typical (global) installation directories are /usr/local/lib/python2.7/site-packages/ or /usr/local/lib/python3.5/site-packages/ (Note that you may need root rights to copy into the latter directories.) Typical (local) installation directories for the Anaconda Python distribution are $HOME/anaconda/lib/python27/site-packages/ or $HOME/anaconda/lib/python35/site-packages/.

If you have a Windows system, downloading the Python dynamic module made available above (choose the version depending on your system and your installed Python version) and placing it into the extension module directory of your Python installation should work. Consult the manual of your Python installation to find the correct directory. Typical directories for (global) installation are C:\Program Files\Python27\Lib\site-packages\ or C:\Program Files\Python35\Lib\site-packages\ (Note that you may need administrator rights to copy into this directory.) Typical installation directories for the Anaconda Python distribution are C:\Anaconda2\Lib\site-packages\ or C:\Anaconda3\Lib\site-packages\.

If you have trouble on Microsoft Windows, check whether you have the Microsoft Visual C++ Redistributable Packages for Visual Studio 2015 installed, as the library was compiled with Microsoft Visual Studio 2015.

Installation: using distutils

Another way to install the extension module for your system is to use the Python script setup_coco.py (in the source package), which uses Python's distutils package to build and install the module.

On a GNU/Linux system call the script with

./setup_coco.py install

in a terminal window to build and install the extension module. If you get a "Permission denied" error message, check whether the file setup_coco.py is marked as executable. If it is not, add the executable flag with the command

chmod +x setup_coco.py

Alternatively, call the script explicitly through Python:

python setup_coco.py install

On a Microsoft Windows system call the script with

python setup_coco.py install

in a command prompt window to build and install the extension module. Note, however, that this direct call to Python is possible on Microsoft Windows only if the directory, in which the program python.exe resides, is contained in your PATH variable (environment variable, check its contents at a command prompt with echo %PATH%). Otherwise you may have to specify the full path to the Python program. A typical form of the command for this case is

"C:\Program Files\Python-2.7.10\python.exe" setup_coco.py install

In addition, building the module requires a C compiler. On a GNU/Linux system Python uses the system C compiler, which for GNU/Linux is usually the GNU C compiler gcc. This compiler is essentially part of the system and thus basically always available. One only may have to install the Python development files (package python-dev or python3-dev for Debian based GNU/Linux distributions).

On a Windows system Python commonly uses Microsoft Visual Studio C/C++, which therefore needs to be installed. Note that the Community Edition of this C compiler can be obtained (perfectly legally) free of charge. Although Python's distutils package works directly with Microsoft Visual Studio 2008 (or 9.0), it is not recommended to use this compiler, because it lacks stdint.h, which is needed (and not much of a requirement as it is part of the C99 standard), but not included with this compiler. If you want to use Microsoft Visual Studio 2008 nevertheless, you can download the missing stdint.h here: stdint.h.

Rather it is recommended to use Microsoft Visual Studio 2010 (or 10.0), 2012 (or 11.0), 2013 (or 12.0) or 2015 (or 14.0). However, to make these work, an environment variable needs to be set/changed beforehand. Consult the files vs2010.bat, vs2012.bat, vs2013.bat and vs2015.bat (included in the source packages) for this. Executing vs2010.bat sets the environment variable for Microsoft Visual Studio 2010 (or 10.0), vs2012.bat for Microsoft Visual Studio 2012 (or 11.0), vs2013.bat for Microsoft Visual Studio 2013 (or 12.0) and vs2015.bat for Microsoft Visual Studio 2015 (or 14.0).

Note that on a 64 bit Microsoft Windows system some complications may arise. The reason is that on a 64 bit system the Microsoft Visual Studio Compiler (which is a 32 bit program, even on 64 bit systems, at least in the Community Editions up to Visual Studio 2015/14.0) comes in two version (both of which are usually installed): a so-called "native" version, which produces 32 bit programs ("native", because a 32 bit program creates a 32 bit program), and a so-called "cross" version, which produces 64 bit programs ("cross", because a 32 bit program creates a 64 bit program). As it seems, executing the above installation commands (that is, vs201[023].bat followed by python setup_coco.py install) in a standard command prompt window invokes the "native" version of the Visual Studio Compiler, which will fail if the installed Python version is 64 bit. The reason is simply that the compiler, being "native", searches for the 32 bit Python interface, which it cannot find if the installed Python version is 64 bit.

However, there may also be other problems that can arise if the installation commands are used in a standard command prompt window, because Python is configured to work with Visual Studio 2008 (or 9.0). To avoid such problems, it is advisable to use one of the command prompt windows that come with the installation of Microsoft Visual Studio (to be found under Programs > Microsoft VisualStudio). For example, the Community Edition of Microsoft Visual Studio 2015 (or 14.0) has the two command prompt windows "VS2015 x86 Native Tools Command Prompt", which refers to the "native" version of the compiler (producing 32 bit output), and "VS2015 x64 Cross Tools Command Prompt", which refers to the "cross" version of the compiler (producing 64 bit output). Use the former if you have a 32 bit Python installed (which is necessarily the case if you are on a 32 bit system), and the latter if you have a 64 bit Python installed. Open the command prompt window and change directory (using the cd command) to the directory where vs201[0235].bat and setup_coco.py reside. Then execute vs201[0235].bat first (using the batch file whose name matches the name of the command prompt window, which also contains the Microsoft Visual Studio year/version) and python setup_coco.py install afterward.

Note generally (for GNU/Linux as well as for Microsoft Windows) that installing this extension module for all users may require root/administrator rights in order to copy the shared object/Python dynamic module to the standard extension module directory. Local installations (for individual users) are also possible. Consult the help provided by Python's distutils package by calling the setup script with

python setup_coco.py --help install

to get information about the installation options.

Installation: recompilation with makefiles

On GNU/Linux (provided the Python development files are installed – package python-dev on Debian based distributions), you may also install the extension module (for Python 2.7) by simply calling

make all

in the source directory pycoco/src and copying the resulting shared object coco.so to a directory that is on your PYTHONPATH (environment variable).

For Python 3.5.x, simply call

make py3

in the source directory pycoco/src and copy the resulting shared object coco.so to a directory that is on your PYTHONPATH (environment variable).

On Windows you may also install the extension module (for Python 2.7.10) by simply calling

nmake /f pycoco.mak all

in a command prompt of Microsoft Visual Studio C/C++ in the source directory pycoco/src (make sure to chose the "native" or the "cross" command prompt depending on your Python version, see above, "Installation: using distutils") and copying the resulting dynamic module coco.pyd to the extension module directory of your Python installation.

For Python 3.5.x, simply call

nmake /f pycoco.mak py3

in a command prompt of Microsoft Visual Studio C/C++ in the source directory pycoco/src (make sure to chose the "native" or the "cross" command prompt depending on your Python version, see above, "Installation: using distutils") and copying the resulting dynamic module coco.pyd to the extension module directory of your Python installation.

Should the compilation fail, check the definition of the variables PY2DIR and/or PY3DIR in the makefile (Gnu/Linux) or pycoco.mak (Windows)

If you are using the Anaconda Python distribution, you may use the special makefile pycoco_conda.mak, which is configured for Anaconda 1.8.0 installed in the default path. If you have a different version or installed to a non-standard path, you may have to adapt the definitions of CONDAINC and CONDALIB in pycoco_conda.mak.

References

More information about the CoCoNAD algorithm can be found in the following papers:

The use of pattern spectra to evaluate the statistical significance of found frequent item sets is explained in these papers (although for standard frequent item set mining, but the idea can be transferred, with a few adaptations, to CoCoNAD):