py4sci

Table Of Contents

Previous topic

pyLICORS Documentation

Next topic

TODO and feature requests

This Page

pyLICORS was built and is maintained in Python 2.7. As far as I am aware it does not use any particular 2.7 feature of Python so pyLICORS should also work with other versions (at least 2.5+ should not pose problems; but: Python 2 or 3 and What’s new in Python 3).

If you follow the instructions below and get all third-party extension/libraries (both Python and C/C++) to work properly, then chances are high it will work also on your Python version.

One-line installation

Open the command line and run

> pip install pyLICORS

or

> easy_install pyLICORS

Dependencies

Note

From experience during the devolopment the most difficult part was to get the Python wrappers for OpenCV to work properly.

OpenCV has a built in Python wrapper cv, which can be imported using import cv. However, the pyopencv wrapper using the Boost libraries which are 3-4 times faster on a Windows machine.

Although several third-party wrappers for OpenCV exist (e.g. ctypes-opencv or Swig Python Interface from OpenCV), I could only successfully use pyopencv in Windows.

If you can successfully call the OpenCV Kmeans++ from Python with another wrapper I would appreciate instructions (and a simple demo script) so I can include it another wrapper as an option in future relaeses.

Required

The most important non-Python software to install are:

  • OpenCV library (version 2.2 [1] ): collection of powerful and fast computer vision algorithms. Absolutely necessary to perform fast Kmeans++ (original paper on kmeans++).
  • FFmpeg: cross-platform solution to record, convert and stream audio and video. This library is used to write the results of the analysis back to a video file.
  • OpenGL: OpenGL for video writing/reading.
  • Boost: free peer-reviewed portable C++ source libraries. Necessary for pyopencv.

Before installing pyLICORS the following Python packages must be installed and run successfully (installing in this order will avoid dependency problems between libraries):

  • numpy and scipy: libraries for scientific computing.
  • matplotlib: plotting library
  • pyopengl: Python wrapper for OpenGL. Used for visvis.
  • pyopencv: Python wrapper for the OpenCV library
  • visvis: Video processing module for python. Necessary to read and access videos frame-by-frame. Requires pyopengl and OpenGL.
  • PyTables: Data storage in HDF5 files with a convenient Python wrapper.
  • psutil: interface for retrieving information on all running processes and system utilization (CPU, disk, memory, network).
  • PIL: another plotting library

Note

If you know another library for Kmeans that can be used from Python and is faster than OpenCV Kmeans, please let me know.

Optional

Recommended packages for better visualization/individual checks of the analysis are:

  • nibabel: read and write access to some common medical and neuroimaging file formats
  • ViTables: GUI for browsing and editing files in PyTables’ HDF5 and standard hdf5 formats.
  • sklearn: powerful machine learning library with a huge selection of methods. In particular, if you can’t get the OpenCV library to work, then you can use the Kmeans algorithm in sklearn. However, this will be much slower and can only be used for small data projects.
  • munkres: implementation of the Munkres algorithm (also called the Hungarian algorithm or the Kuhn-Munkres algorithm), useful for solving the Assignment Problem.
  • VirtualDub: An excellent program (at least on Windows) to view videos frame by frame (and do almost any other imaginable video processing).

Note

These packages are optional; they are not necessary for the core functionality of pyLICORS.

[1]I use version 2.2. As long as you successfully set up a Python wrapper with the OpenCV library the actual version should not matter (probably it should at least be 2.2+).
[2]If you are aware of a Python wrapper for ffmpeg that works nicely to read frames of videos and write video data from numpy.arrays please let me know.
[3]An excellent program (at least on Windows) to view videos frame by frame (and do almost any other imaginable video processing) is VirtualDub.
[4]In particular, it uses subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE), where cmd is a particular ffmpeg command to produce useful videos from a sequence of images.