Giter VIP home page Giter VIP logo

johnson's Introduction

Neuron Segmentation

This repository contains various algorithms implemented on neurons images segmentation which are completed on CSCI 8360, Data Science Practicum at the University of Georgia, Spring 2018.

This project uses the time series image datasets of neurons from CodeNeuro. Each folder of training and testing images is a single plan, and the images are numbered according to their temporal ordering. The neurons in the images will flicker on and off as calcium is added. In this repository, we are offering three main algorithms as follows using different packages to locate the neurons and segment them out from the surrounding image.

  1. Non-negative Matrix Factorization by thunder-extraction
  2. Convolutional Neural Network by Unet
  3. Constrained Non-negative Matrix Factorization by CaImAn

Read more details about each algorithm and their applications in our WIKI tab.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

Environment Setting

  1. Clone this repository.
$ git clone https://github.com/dsp-uga/Johnson.git
$ cd Johnson
  1. Create conda environment based on environments.yml offered in this repository.
$ conda env create -f environments.yml -n neuron python=3.6
$ source activate neuron

Note that tf_unet works best in python 2.7, which is also the environment we used for it. (All other experiments are done in Python 3.6). So if you want to use tf_unet, create a conda environment as follows:

$ conda env create -f environments.yml -n neuron python=2.7
$ source activate neuron
  1. (for Unet) Clone the source repository by tf_unet, go into tf_unet repository, and set up tf_unet in the conda environment, then delete tf_unet repository.
$ git clone https://github.com/jakeret/tf_unet
$ cd tf_unet
$ python setup.py install
$ rm -rf tf_unet
  1. (for CNMF) Clone the sources repository by CaImAn, go into CaImAn repository, and set up caiman in the conda environment, then delete CaImAn repository.
$ git clone https://github.com/flatironinstitute/CaImAn
$ cd CaImAn
$ python setup.py install
$ rm -rf CaImAn

Add sudo before the command if you encounter the permission problems.

Running the tests

python -m [option-name] [args-for-the-option]
Options
  • ThunderNMF: Running NMF by thunder-extraction
  • UNET: Running CNN by unet
  • CNMF: Running CNMF by caiman

Each module provides their own arguments. Use help() to know more details when running the algorithms.

Evaluation

Based on the neurons coordinates, five related scores to determine the results will be generated as follows:

  • Recall: (number of matched regions)/(number of ground-truth regions)
  • Precision: (number of matched regions)/(number of our regions)
  • Inclusion: (number of intersecting pixels)/(number of total pixels in the ground-truth regions)
  • Exclusion: (number of intersecting pixels)/(number of total pixels in our regions)
  • Combined:

Test Results

Module arguments Total Score Avg Precision Avg Recall Avg Inclusion Avg Exclusion
ThunderNMF percentile=99, max_iter=50, overlap=0.1, chunk=32 2.94815 0.78606 0.84156 0.56725 0.75328
ThunderNMF percentile=99, max_iter=50, overlap=0.1, chunk=128, padding=15 2.852 0.663 0.93048 0.67249 0.58641
Unet (only running on 00 sets) train_iter=120, epoch=500, layer=4, features=64 2.93394 1.0 0.9446 0.41857 0.57077
CNMF k=1000, g=5, merge=0.8 2.60321 0.860 0.645 0.790 0.309

Tensorboard Records for Unet training

Accuracy

Loss

TODO

Training tf_unet with padded images, because tf_unet with shrink the image size. Our results from tf_unet is not as good as we expected. We used scaling, but that may not work so well here. See Issues #13 and #18.

We also tried implementing the image segmentation problem using the spectral clustering method. Due to lack of time, we were not able to test our results for this method. We used the scikit-learn package of spectral clustering in order to implement this.

Authors

(Ordered alphabetically)

See the CONTRIBUTORS file for details.

License

This project is licensed under the MIT License - see the LICENSE file for details

johnson's People

Contributors

ankitajoshi15 avatar melanieihuei avatar whusym avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

melanieihuei

johnson's Issues

Speeding up

Using vanilla NMF method provided from the handout, it takes a LONG time! I am currently testing the performance of different filters, and running a whole tiff folder takes around 45 minutes. So the whole 9 testing folder might take around 7-8 hours.....

It would be nice if we can speed up on this.

CNMF

We can use CNMF to improve the performance of NMF

Loading example.py

image

So I got this the error when loading data using the example.py. No idea why. Environment - py3.6. I don't think I need to install any extra libraries but I just can't get it work.

It works in my py2.7 environment though. I don't really want to use py2.7 ... /shrug

I/O, prototype

so I think we should build our program in such a way that it can call different algorithms to solve the issues, like nmf, cnmf, unet, etc. My team did something similar in the last project. I think I can do this for our project this time as well (given that I don't think I can progress further on nmf stuff.)

hopefully get this done before Tuesday.

Thursday....

Filtering?

Some people use Gaussian filtering, or other similar ones for noise reduction(?). Do we need to do similar things in this project? I am mainly talking about the stuff he covered in the lecture slides.

Anybody want to claim this? I know there are different techniques but I've no idea which one works better

PEP8 Standards

Per the project requirements, our Python code should accord with PEP8. I am a messy coder. So I will leave the issue here and for further improvement.

https://pep8.org/

cv2 thresholds/filters

  • median works better than mean values
    cv2.threshold(img,np.median(img),255,cv2.THRESH_BINARY) works better than cv2.threshold(img,np.mean(img),255,cv2.THRESH_BINARY)
  • mean threshold
    cv2.adaptiveThreshold(blurs[0],255,cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY,3,1)
  • gaussian threhold
    cv2.adaptiveThreshold(blurs[0],255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY,3,0)

Having trouble accessing files on Google Cloud

I can't do things like this:

wget https://storage.googleapis.com/uga-dsp/project3/neurofinder00.10/images/image00000.tiff

Any ideas? I tried to add --no-check-certificate and it doesn't work. Changing https to http doesn't work either.

import matplotlib running on terminal

Issue on importing matplotlib in terminal while using tf_unet
(for your information of tf_unet: github, installation, toy_problem)

The following problem only happens in using macosx + anaconda:

Even though we are able to run the script including matplotlib and the matplotlib is installed whether in root or conda environments, the default python provided in (Ana)Conda is not a framework build, which means we will not be able to run it in terminal. The following error happens when trying to import matplotlib in conda environment:

image

Conda developers have made it easy to install a framework build in both the main environment and in Conda envs: Install python.app by

$ conda install python.app 

and use pythonw rather than python (this solution is posted in matplotlib FAQ)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.