Giter VIP home page Giter VIP logo

brainstem's Introduction

Brainstem project

Some useful code for the brainstem project. Parts of this project will be incorporated into this project.

Right now there are three main modules. The first reads images, thresholds them, and clusters objects found by thresholding. It also optionally caches files as TIFs, which take up more space than JPEG2000 but are faster to read. Here is an example of how to use it:

import brainstem as b
from sklearn.decomposition import PCA
from sklearn.cluster import MiniBatchKMeans
from matplotlib import pyplot as pp

# get a list of all available image files
filenames = b.get_filenames()

# get a cropped version of the first few files
samples = b.sample_many(filenames[:5])

# segment the cells in each image
segmented, n_objects = zip(*list(b.segment_cells(i) for i in samples))

# cluster the resulting objects
X = b.all_object_features(segmented)
model = MiniBatchKMeans()
model.fit(X)

# visualize results, projecting onto first two principal components
pca = PCA(2)
Xp = pca.fit_transform(X)
pp.figure()
pp.scatter(Xp[:, 0], Xp[:, 1], c=model.labels_, s=30)

# visualize clusters in the first image
label_vecs = b.split_labels(segmented, model.labels_, n_objects=n_objects)
clustered_img = b.assign_clusters(segmented[0], label_vecs[0], rgb=True)
pp.figure()
pp.imshow(clustered_img)

You will have to modify brainstem.DATADIR to point to a directory containing jp2 files. If you do not want the caching functionality, set brainstem.USE_CACHE = False.

The second module implements shape context descriptors, shape distance metrics via dynamic programming, and context-sensitive shape similarity via graph transduction. Before using it, it is necessary to build the Cython modules in place:

python setup.py build_ext --inplace

Here is an example of how to use it:

import skimage.data
import shape_context as sc

# get a binary horse shape
img = skimage.data.horse()
img = skimage.color.rgb2gray(img)
t = skimage.filter.threshold_otsu(img)
binary_img = img < t

# make a copy and cut off its legs
legless = binary_img.copy()
legless[200:, 200:] = 0

# compute the distance between them
sc.full_shape_distance(binary_img, legless)

Finally, the third module, "texture.py", implementes filtering with Gabor filters, filter visualization, and texture segmentation.

brainstem's People

Contributors

kemaleren avatar

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.