Skip to content

Commit

Permalink
Merge pull request #159 from neurodata/develop
Browse files Browse the repository at this point in the history
Version 0.2.0
  • Loading branch information
bvarjavand authored Nov 2, 2020
2 parents daf8a9f + a117ac5 commit 757f22a
Show file tree
Hide file tree
Showing 2,643 changed files with 43,737 additions and 38,020 deletions.
11 changes: 0 additions & 11 deletions .aws.sh

This file was deleted.

11 changes: 2 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
**/.DS_Store
data/test_*
data/data_octree/1/
data/data_octree/2/
data/data_octree/3/
data/data_octree/4/
data/data_octree/5/
data/data_octree/6/
data/data_octree/7/
data/data_octree/8/
docs/notebooks/pipelines/demo*
**-checkpoint.ipynb

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
46 changes: 18 additions & 28 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,29 @@ dist: xenial
sudo: true
language: python
python:
- '3.6'
- "3.8"
matrix:
include:
- python: 3.7
- python: 3.8
cache: pip
before_install:
- "./.aws.sh"
install:
- pip install -r requirements.txt
- pip install -U pytest pytest-cov pytest-doctestplus codecov
- pip install black
- pip install -r requirements.txt
- pip install -U pytest pytest-cov pytest-doctestplus codecov six
- pip install black
script:
- pytest --cov=brainlit tests/
- black --check --diff ./brainlit ./tests
- pytest --cov=brainlit tests/
- black --check --diff ./brainlit ./tests
after_success:
- codecov
env:
global:
secure: XXGsCs9mY4iCJG8KHF7OqCfh5tmZbPd6HGm3XIHYHSKWfEozG7ac+LPFfUgHOXy4SJXsEBZEs/0LAENfJS5BL9ToFxsH08QOoHt5cXx/vt/v8Al4uFJEhNvn3FSRfabYljdjDNAzcIqTpj7h0PIxLpKzQOXsaYPtKuvYlp3pwg4kdX2mw0gqcz8sF0QmeyTLsYnXb2cQ4FVUrl7y9sLLUKfsR+6kMnoQNWA9Blnm3aIKp20RPcrjlD+XLsfjA85kQEAWsryMefjPo+K4DHfHV/sTu8157Yz8/OJ3yYofR/bfhSAmHHw4LOM92UYggMSRVM0txiL1kLjxP2kBY63aNtwKrC1q7WJ2WtFTLXNUo1kMUm8QbcSOhmzErBEADKnFviYQogs9UrsWfgeW3hBTIzYwUmatXXy33drQywbHzp0PDrweaoYI9Zr606oPvpzJ8G5WZwDWbf2G785L5J21UzxSKkPMTO6RZ2Oni0cxdiT9DgPlao4Y+P7f756L4dy5YE29/mbExAfbKt8FTqnEl5JDwJBaCPJe/1uaSUy5rFF2noAHbylKrrpE3kgt+9o83gG69wQj6RFx3Z889FjvQYiMKS0Dn/TEXsaWMbX7HlEtXSq4U9r5N59cF4c/m6+/YlY8Hwz8XxeKIf/r31anI93sapuYwgb0V0jBMBGGkAk=
- codecov

deploy:
- provider: pypi
user: "__token__"
password:
secure: $PYPI
skip_existing: true
on:
branch: master
tags: true
repo: neurodata/brainlit
python: '3.6'





- provider: pypi
user: "__token__"
password:
secure: $PYPI
skip_existing: true
on:
branch: master
tags: true
repo: neurodata/brainlit
python: "3.8"
24 changes: 10 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,23 @@ to record your changes in Git, push the changes to your branch with:
```git pull origin master```
```git push origin my-feature```

The repository is structured according to
![this model](https://nvie.com/img/[email protected])
([source](https://nvie.com/posts/a-successful-git-branching-model/))

## Pull Request Checklist
We recommended that your contribution complies with the following rules before you submit a pull request:

Give your pull request a helpful title that summarises what your contribution does. In some cases Fix <ISSUE TITLE> is enough. Fix #<ISSUE NUMBER> is not enough.

All public methods should have informative docstrings with sample usage presented as doctests when appropriate.

At least one paragraph of narrative documentation with links to references in the literature (with PDF links when possible) and the example.

All functions and classes must have unit tests. These should include, at the very least, type checking and ensuring correct computation/outputs.

Ensure all tests are passing locally using pytest. Install the necessary packages by:

- [ ] Give your pull request a helpful title that summarises what your contribution does. In some cases Fix <ISSUE TITLE> is enough. Fix #<ISSUE NUMBER> is not enough.
- [ ] All public methods should have informative docstrings with sample usage presented as doctests when appropriate.
- [ ] At least one paragraph of narrative documentation with links to references in the literature (with PDF links when possible) and the example.
- [ ] All functions and classes must have unit tests. These should include, at the very least, type checking and ensuring correct computation/outputs.
- [ ] Ensure all tests are passing locally using pytest. Install the necessary packages by:
```pip install pytest pytest-cov```
then run

```pytest```
or you can run pytest on a single test file by

```pytest path/to/test.py```
Run an autoformatter. We use black and would like for you to format all files using black. You can run the following lines to format your files.

- [ ] Run an autoformatter. We use black and would like for you to format all files using black. You can run the following lines to format your files.
```pip install black```
```black path/to/module.py```
167 changes: 115 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Brainlit

[![Python](https://img.shields.io/badge/python-3.7-blue.svg)]()
[![Build Status](https://travis-ci.com/neurodata/brainlit.svg?branch=master)](https://travis-ci.com/neurodata/brainlit)
[![PyPI version](https://badge.fury.io/py/brainlit.svg)](https://badge.fury.io/py/brainlit)
Expand All @@ -7,77 +8,124 @@
![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/bvarjavand/brainlit)
![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/bvarjavand/brainlit)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
This repository is a container of methods that Neurodata usees to expose their open-source code while it is in the process of being merged with larger scientific libraries such as scipy, scikit-image, or scikit-learn. Additioanlly, methods for computational neuroscience on brains too specific for a general scientific library can be found here, such as image registration software tuned specifically for large brain volumes.

![Brainlight Features](https://raw.githubusercontent.com/neurodata/brainlight/diagram/Brainlight.png)

- [Motivation](#motivation)
- [Installation](#installation)
* [Environment](#environment)
* [Install from pypi](#install-from-pypi)
* [Install from source](#install-from-source)
- [How to Use Brainlit](#how-to-use-brainlit)
* [Data Setup](#data-setup)
* [Create a Session](#create-a-session)
- [Features](#features)
* [Registration](#registration)
- [Core](#core)
* [Push/Pull Data](#push-and-pull-data)
* [Visualize](#visualize)
* [Manually Segment](#manually-segment)
* [Automatically Segment](#automatically-and-semi-automatically-segment)
- [API reference](#api-reference)
- [Tests](#tests)
- [Contributing](#contributing)
- [Credits](#credits)

This repository is a container of methods that Neurodata uses to expose their open-source code while it is in the process of being merged with larger scientific libraries such as scipy, scikit-image, or scikit-learn. Additionally, methods for computational neuroscience on brains too specific for a general scientific library can be found here, such as image registration software tuned specifically for large brain volumes.

![Brainlight Features](https://github.com/neurodata/brainlit/blob/develop/docs/images/figure.png)

- [Brainlit](#brainlit)
- [Motivation](#motivation)
- [Installation](#installation)
- [Environment](#environment)
- [(optional, any python >= 3.7 environment will suffice)](#optional-any-python--38-environment-will-suffice)
- [Install from pypi](#install-from-pypi)
- [Install from source](#install-from-source)
- [How to use Brainlit](#how-to-use-brainlit)
- [Data setup](#data-setup)
- [Create a session](#create-a-session)
- [Features](#features)
- [Registration](#registration)
- [Core](#core)
- [(Push and Pull Data)](#push-and-pull-data)
- [Visualize](#visualize)
- [Manually Segment](#manually-segment)
- [Automatically and Semi-automatically Segment](#automatically-and-semi-automatically-segment)
- [API Reference](#api-reference)
- [Tests](#tests)
- [Common errors and troubleshooting](#common-errors-and-troubleshooting)
- [Contributing](#contributing)
- [Credits](#credits)

## Motivation
The repository originated as the project of a team in Joshua Vogelstein's class **Neurodata** at Johns Hopkins University. This project was focused on data science towards the [mouselight data](https://www.hhmi.org/news/mouselight-project-maps-1000-neurons-and-counting-in-the-mouse-brain). It becme apparent that the tools developed for the class would be useful for other groups doing data science on large data volumes.

The repository originated as the project of a team in Joshua Vogelstein's class **Neurodata** at Johns Hopkins University. This project was focused on data science towards the [mouselight data](https://www.hhmi.org/news/mouselight-project-maps-1000-neurons-and-counting-in-the-mouse-brain). It became apparent that the tools developed for the class would be useful for other groups doing data science on large data volumes.
The repository can now be considered a "holding bay" for code developed by Neurodata for collaborators and researchers to use.

## Installation

### Operating Systems
Brainlit is compatible with Mac, Windows, and Unix systems.

#### Windows Linux Subsystem 2
For Windows 10 users that prefer Linux functionality without the speed sacrifice of a Virtual Machine, Brainlit can be installed and run on WSL2. See installation walkthrough [here.](docs/WSL2-install-instructions.md)


### Environment
- [get conda](https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html)
- create a virtual environment with `python>=3.7` via `conda create --name brainlit python=3.7`
- activate the environment via `conda activate brainlit`


#### (optional, any python >= 3.8 environment will suffice)

- [get conda](https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html)
- create a virtual environment: `conda create --name brainlit python=3.8`
- activate the environment: `conda activate brainlit`

### Install from pypi
- install brainlit via `pip install brainlit`


- install brainlit: `pip install brainlit`

### Install from source
- clone the repo via `git clone https://github.com/neurodata/brainlit.git`
- cd into the repo via `cd brainlit`
- install brainlit via `pip install -e .`

- clone the repo: `git clone https://github.com/neurodata/brainlit.git`
- cd into the repo: `cd brainlit`
- install brainlit: `pip install -e .`

### For Windows Users setting up a Conda environment:

Users currently may run into an issue with installing dependencies on Python 3.8. There are a couple workarounds currently available:

#### Use Python 3.7 - RECOMMENDED

- Create a new environment using Python 3.7 instead: `conda create --name brainlit3.7 python=3.7`

- Run `pip install -e .` This should successfully install the brainlit module for Conda on Windows.

#### Other potential fixes

Potentially, `gcc` is missing, which is necessary for wheel installation from Python 3.6 onwards.

- Install [gcc for Windows](https://www.guru99.com/c-gcc-install.html) and run `pip install brainlit -e . --no-cache-dir`.

Post-Python 3.6, windows handles wheels through the Microsoft Manifest Tool, it might be missing.

- Add the [Microsoft Manifest Tool](https://docs.microsoft.com/en-us/windows/win32/sbscs/mt-exe) to the `PATH` variable.

## How to use Brainlit

### Data setup
The `source` data directory should look something like an octree data structure with optional swc folder

data/
- default.0.tif
- 1/
* default.0.tif
* 1/ ... 8/
- 2/ ... 8/
- transform.txt
- consensus-swcs (optional, for .swc files)

First, decide for your team where you'd like to store the data - whether it will be on a local machine or on the cloud. If on the cloud,
each collaborator will need to create a file at `~/.cloudvolume/secrets/x-secret.json`, where `x` is one of `[aws, gc, azure]` which contains your id and secret key for your cloud platform.

The `source` data directory should have an octree data structure

```
data/
├── default.0.tif
├── transform.txt
├── 1/
│ ├── 1/, ..., 8/
│ └── default.0.tif
├── 2/ ... 8/
└── consensus-swcs (optional)
├── G-001.swc
├── G-002.swc
└── default.0.tif
```

If your team wants to interact with cloud data, each member will need account credentials specified in `~/.cloudvolume/secrets/x-secret.json`, where `x` is one of `[aws, gc, azure]` which contains your id and secret key for your cloud platform.
We provide a template for `aws` in the repo for convenience.

### Create a session

Each user will start their scripts with approximately the same lines:

```
from brainlit.utils.ngl import NeuroglancerSession
session = NeuroglancerSession(url='file:///abc123xyz')
```

From here, any number of tools can be run such as the visualization or annotation tools. [Interactive demo](https://github.com/neurodata/brainlit/blob/master/docs/notebooks/visualization/visualization.ipynb).

## Features

### Registration

The registration subpackage is a facsimile of ARDENT, a pip-installable (pip install ardent) package for nonlinear image registration wrapped in an object-oriented framework for ease of use. This is an implementation of the LDDMM algorithm with modifications, written by Devin Crowley and based on "Diffeomorphic registration with intensity transformation and missing data: Application to 3D digital pathology of Alzheimer's disease." This paper extends on an older LDDMM paper, "Computing large deformation metric mappings via geodesic flows of diffeomorphisms."

This is the more recent paper:
Expand All @@ -95,15 +143,18 @@ https://doi.org/10.1023/B:VISI.0000043755.93987.aa
A tutorial is available in docs/notebooks/registration_demo.ipynb.

## Core
The core brain-lit package can be described by the diagram at the top of the readme:

The core brainlit package can be described by the diagram at the top of the readme:

### (Push and Pull Data)

Brainlit uses the Seung Lab's [Cloudvolume](https://github.com/seung-lab/cloud-volume) package to push and pull data through the cloud or a local machine in an efficient and parallelized fashion. [Interactive demo](https://github.com/neurodata/brainlit/blob/master/docs/notebooks/utils/uploading_brains.ipynb).
The only requirement is to have an account on a cloud service on s3, azure, or google cloud.
The only requirement is to have an account on a cloud service on s3, Azure, or Google Cloud.

Loading data via local filepath of an octree structure is also supported. [Interactive demo](https://github.com/neurodata/brainlit/blob/master/docs/notebooks/utils/upload_brains.ipynb).

### Visualize

Brainlit supports many methods to visualize large data. Visualizing the entire data can be done via Google's [Neuroglancer](https://github.com/google/neuroglancer), which provides a web link as shown below.

screenshot
Expand All @@ -113,22 +164,34 @@ Brainlit also has tools to visualize chunks of data as 2d slices or as a 3d mode
screenshot

### Manually Segment

Brainlit includes a lightweight manual segmentation pipeline. This allows collaborators of a projec to pull data from the cloud, create annotations, and push their annotations back up as a separate channel. [Interactive demo](https://github.com/neurodata/brainlit/blob/master/docs/notebooks/pipelines/manual_segementation.ipynb).

### Automatically and Semi-automatically Segment
Similar to the above pipeline, segmentations can be automatically or semi-automatically generated and pushed to a separate channel for viewing. [Interactive demo](https://github.com/neurodata/brainlit/blob/master/docs/notebooks/pipelines/seg_pipeline_demo.ipynb)

Similar to the above pipeline, segmentations can be automatically or semi-automatically generated and pushed to a separate channel for viewing. [Interactive demo](https://github.com/neurodata/brainlit/blob/master/docs/notebooks/pipelines/seg_pipeline_demo.ipynb).

## API Reference

[![Documentation Status](https://readthedocs.org/projects/brainlight/badge/?version=latest)](https://brainlight.readthedocs.io/en/latest/?badge=latest)
The documentation can be found at [https://brainlight.readthedocs.io/en/latest/](https://brainlight.readthedocs.io/en/latest/).

## Tests
Running tests can easily be done by moving to the root directory of the brainlit package ant typing `pytest tests` or `python -m pytest tests`.

Running tests can easily be done by moving to the root directory of the brainlit package and typing `pytest tests` or `python -m pytest tests`.
Running a specific test, such as `test_upload.py` can be done simply by `ptest tests/test_upload.py`.

## Common errors and troubleshooting

- [macOS Install/Run Issues](https://github.com/NeuroDataDesign/brainlit/blob/develop/docs/macOS_Install_%26_Run_Issues.md)

- [AWS Credentials Issues](https://github.com/NeuroDataDesign/brainlit/blob/develop/docs/AWS_Credentials_Issues.md)

## Contributing

Contribution guidelines can be found via [CONTRIBUTING.md](https://github.com/neurodata/brainlit/blob/master/CONTRIBUTING.md)

## Credits
Thanks to the neurodata team and the group in the neurodata class which started the project.

Thanks to the Neurodata team and the group in the Neurodata class which started the project.
This project is currently managed by Tommy Athey and Bijan Varjavand.
4 changes: 3 additions & 1 deletion brainlit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import warnings

# import brainlit.algorithms
import brainlit.algorithms
import brainlit.cloudreg
import brainlit.feature_extraction
import brainlit.preprocessing
import brainlit.registration
import brainlit.utils
Expand Down
2 changes: 0 additions & 2 deletions brainlit/algorithms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import brainlit.algorithms.connect_fragments
import brainlit.algorithms.generate_fragments

from brainlit.algorithms.connect_fragments import *
from brainlit.algorithms.generate_fragments import *
3 changes: 0 additions & 3 deletions brainlit/algorithms/connect_fragments/__init__.py

This file was deleted.

Loading

0 comments on commit 757f22a

Please sign in to comment.