nik-sm / trefide

Trend Filter Denoising

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TreFiDe - Trend Filter Denoising

TreFiDe is the software package accompanying the research publication "Penalized matrix decomposition for denoising, compression, and improved demixing of functional imaging data".

TreFiDe is an imporved appproach to compressing and denoising functional image data. The method is based on a spatially-localized penalized matrix decomposition (PMD) of the data to separate (low-dimensional) signal from (temporally-uncorrelated) noise. This approach can be applied in parallel on local spatial patches and is therefore highly scalable, does not impose non-negativity constraints or require stringent identifiability assumptions (leading to significantly more robust results compared to NMF), and estimates all parameters directly from the data, so no hand-tuning is required. We have applied the method to a wide range of functional imaging data (including one-photon, two-photon, three-photon, widefield, somatic, axonal, dendritic, calcium, and voltage imaging datasets): in all cases, we observe ~2-4x increases in SNR and compression rates of 20-300x with minimal visible loss of signal, with no adjustment of hyperparameters; this in turn facilitates the process of demixing the observed activity into contributions from individual neurons. We focus on two challenging applications: dendritic calcium imaging data and voltage imaging data in the context of optogenetic stimulation. In both cases, we show that our new approach leads to faster and much more robust extraction of activity from the video data.

Install using conda

This installation method is supported and tested only on Ubuntu 18.04.

It is recommended to use conda to manage the dependencies for TreFiDe in it's own Python environment. First, download and install conda. Verify conda installation by executing the following scripts. A list of base environment packages will be displayed.

conda list

Create a new environment for TreFiDe and install TreFiDe software and all of its dependencies.

conda create -n trefide python=3.6 trefide -c jw3132 -c intel -c menpo

Download Demo folder. Follow the notebook scripts in Demo folder to try out TreFiDe. To learn about TreFiDe functions, please check doc .

For user that doesn't have access to Ubuntu:18.04 but is familiar with Docker, please use Ubuntu docker image to access TreFiDe software.

Install from source

Dependencies:

  • A Linux OS, Ubuntu 16.04 recommended (Installation support for MacOS and Windows coming);
  • Python3;
  • Required Python Packages: numpy, scipy, cython;
  • Recommended Python Packages (To run demos, generate plots, and render videos): matplotlib, jupyter, opencv3;
  • Intel MKL (see below for instructions);
  • C compiler (installation currently requires icc, support for gcc coming);

This package contains C++ source code with Cython wrappers which need to be built on your system. The easiest way to ensure all the required libraries are installed is to follow the instructions for installing & setting up Intel MKL (which is a free product for both personal and commercial applications). Additionally, you will need a C++ compiler. For ease of implementation, the current installation scripts are setup for the Intel C Compiler icc (which is free for students and academics). Support to optionally use gcc (which is more commonly available by default) is coming.

Installing:

Ensure that the neccessary dependencies are installed and that your the python environment you wish to install trefide into (we highly recommend using conda contained in the Anaconda & Miniconda disctributions to manage your python environments) is active.

  1. Clone the repository by navigating to the location you wish to install the package and executinggit clone git@github.com:ikinsella/trefide.git. The absolute path to the location mentioned above will be refered to as /path/to/install/directory for the remainder of these instructions.
  2. Add the location of the C++ libraries to your shared library path by appending the lines
export TREFIDE="/path/to/install/directory/trefide"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$TREFIDE/src"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$TREFIDE/src/proxtv"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$TREFIDE/src/glmgen/lib"

to your .bashrc file. 3. Compile the C++ source code by running

cd /path/to/install/directory/trefide/src
make
  1. Build the Cython wrappers and use pip to create an "editable" installation in your active python environment by running
cd /path/to/install/directory/trefide
LDSHARED="icc -shared" CC=icc CXX=icpc pip install -e /path/to/trefide
  1. Execute PMD demo code using the sample data here to ensure that the installation worked correctly.

Rebuilding & Modification

If you modify or pull updates to any C++ &/or Cython code, the C++ &/or Cython code (respectively) will need to be rebuilt for changes to take effect. This can be done by running the following lines

  • C++:
    cd /path/to/install/directory/trefide/src
    make clean
    make
    
  • Cython:
    cd /path/to/install/directory/trefide
    LDSHARED="icpc -shared" CXX=icpc CC=icc python setup.py build_ext --inplace
    

Uninstalling

The project can be uninstalled from an active python environment at any time by running pip uninstall trefide. If you wish to remove the entire project (all of the files you cloned) from your system, you should also run rm -rf /path/to/install/directory/trefide.

References:

About

Trend Filter Denoising

License:Other


Languages

Language:C++ 40.4%Language:Python 31.5%Language:C 27.4%Language:Makefile 0.6%Language:Shell 0.1%Language:Dockerfile 0.1%Language:Batchfile 0.0%