Skip to content

Commit

Permalink
Merge c9563f0 into 56b09a8
Browse files Browse the repository at this point in the history
  • Loading branch information
tddough98 committed Nov 30, 2020
2 parents 56b09a8 + c9563f0 commit 10a7aea
Show file tree
Hide file tree
Showing 38 changed files with 7,232 additions and 1,744 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -112,3 +112,4 @@ venv.bak/
# mypy
.mypy_cache/

node_modules
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Expand Up @@ -15,7 +15,7 @@ Before sending your pull requests, make sure you have followed this list.

### Contributing code

If you have improvements to Caliban, please send us your pull requests! If you are new to the process, Github has a
If you have improvements to DeepCell Label, please send us your pull requests! If you are new to the process, Github has a
[how-to](https://help.github.com/articles/using-pull-requests/).

If you want to contribute, start working through the codebase. Navigate to the
Expand All @@ -40,8 +40,8 @@ DeepCell coding style.
changes to lower the maintenance cost.
* Bug fixes also generally require unit tests, because the presence of bugs
usually indicates insufficient test coverage.
* When you contribute a new feature to Caliban, the maintenance burden is
(by default) transferred to the Caliban team. This means that the benefit
* When you contribute a new feature to DeepCell Label, the maintenance burden is
(by default) transferred to the DeepCell Label team. This means that the benefit
of the contribution must be compared against the cost of maintaining the
feature.
* As every PR requires CI/CD testing, we discourage
Expand Down
26 changes: 13 additions & 13 deletions README.md
@@ -1,9 +1,9 @@
# Caliban: Data Curation Tools for DeepCell.
# DeepCell Label: Data Curation Tools for DeepCell.
[![Actions Status](https://github.com/vanvalenlab/caliban/workflows/browser/badge.svg)](https://github.com/vanvalenlab/caliban/actions)

Caliban is a segmentation and tracking tool used for human-in-the-loop data curation. It displays lineage data along with raw and annotated images. The output files prepare this information as training data for DeepCell.
DeepCell Label is a segmentation and tracking tool used for human-in-the-loop data curation. It displays lineage data along with raw and annotated images. The output files prepare this information as training data for DeepCell.

## Instructions for Running Caliban Locally on Desktop
## Instructions for Running DeepCell Label Locally on Desktop
```bash
git clone https://github.com/vanvalenlab/caliban.git
cd caliban
Expand All @@ -12,7 +12,7 @@ python3 caliban.py [input file location]
```

**Accepted file types:**
Caliban can open .trk files or .npz files. .npz files must contain two zipped files corresponding to raw images and annotated images. If the files are not named 'raw' and 'annotated' or 'X' and 'y', the first file in the .npz will be opened as the raw images. Raw and annotated images must both be in 4D arrays in the shape (frames, y, x, channels or features).
DeepCell Label can open .trk files or .npz files. .npz files must contain two zipped files corresponding to raw images and annotated images. If the files are not named 'raw' and 'annotated' or 'X' and 'y', the first file in the .npz will be opened as the raw images. Raw and annotated images must both be in 4D arrays in the shape (frames, y, x, channels or features).

## Tools Guide
Files can be edited using keyboard operations.
Expand All @@ -26,7 +26,7 @@ Files can be edited using keyboard operations.

### Edit Operations:

Caliban's default setting allows operations to be carried out quickly and easily on existing segmentations. The actions that can modify cell labels and/or lineage information are:
DeepCell Label's default setting allows operations to be carried out quickly and easily on existing segmentations. The actions that can modify cell labels and/or lineage information are:

*click* - click on a cell label to select it. Up to two labels can be selected at one time.

Expand Down Expand Up @@ -73,9 +73,9 @@ Annotation mode focuses on using an adjustable brush to modify annotations on a

*n* - change brush label to an unusued label, so that a new label can be created with a unique id. Can be used with conversion brush to overwrite existing label with unused label (follow conversion brush prompt).

*p* - color picker (click on a label to change the brush value to it)
*p* - color picker (click on a label to change the brush label to it)

*r* - turn on "conversion brush" setting, which changes brush behavior so that one label value is overwritten with another label value. No other labels are affected, and conversion brush will not draw on background. After turning on conversion brush, click on cell labels as prompted to set brush values.
*r* - turn on "conversion brush" setting, which changes brush behavior so that one label value is overwritten with another label value. No other labels are affected, and conversion brush will not draw on background. After turning on conversion brush, click on cell labels as prompted to set brush labels.

*t* - threshold to predict annotations based on brightness. After turning this on, click and drag to draw a bounding box around the cell you wish to threshold. Make sure to include some background in the bounding box for accurate threshold predictions. Whatever was thresholded as foreground within the bounding box will be added to the annotation as a new cell with unique label.

Expand All @@ -88,7 +88,7 @@ Annotation mode focuses on using an adjustable brush to modify annotations on a

**To pan in image:** Hold down the spacebar while clicking and dragging image to pan. Alternatively, the keys *home, page up, page down, and end* can be used to jump across the screen. Holding the shift key while using these pan buttons will result in a smaller jump; holding the control key will snap to the edge of the image.

*h* - switch between highlighted mode and non-highlighted mode (highlight exists in label- and pixel-editing modes but is displayed differently; label-editing highlighting recolors solid label with red, pixel-editing highlighting adds white or red outline around label in image). Once highlight mode is on, use *[ (left bracket) / ] (right bracket)* to decrement/increment selected cell label number.
*h* - switch between highlighted mode and non-highlighted mode (highlight exists in whole-label mode and paint mode but is displayed differently; label-editing highlighting recolors solid label with red, paint mode highlighting adds white or red outline around label in image). Once highlight mode is on, use *[ (left bracket) / ] (right bracket)* to decrement/increment selected cell label number.

*shift+h* - switch between showing and hiding annotation masks in the pixel editor

Expand All @@ -106,7 +106,7 @@ Annotation mode focuses on using an adjustable brush to modify annotations on a

*shift + ↓ / ↑* - cycle between colormaps for viewing raw images (does not apply to pixel editor)

*e* - toggle annotation mode between pixel-editing and whole-label-editing (when nothing else selected)
*e* - toggle annotation mode between paint mode and whole-label mode (when nothing else selected)

*scroll wheel* - change image or annotation maximum brightness

Expand All @@ -117,12 +117,12 @@ Annotation mode focuses on using an adjustable brush to modify annotations on a

Once done, use the following key to save the changed file.
The tool will also save the original file in the same folder.
In npz mode, a new npz file will be saved with a version number. An npz can be saved as a trk file (select "t" in response to save prompt). This will bundle together the current channel and feature of the npz along with a generated lineage file, which will contain label and frame information and empty parent/daughter entries for each cell. The new trk file can then be edited in Caliban's trk mode to add relationship information.
In npz mode, a new npz file will be saved with a version number. An npz can be saved as a trk file (select "t" in response to save prompt). This will bundle together the current channel and feature of the npz along with a generated lineage file, which will contain label and frame information and empty parent/daughter entries for each cell. The new trk file can then be edited in DeepCell Label's trk mode to add relationship information.

*s* - save


## Instructions for Running Caliban in a Docker Container
## Instructions for Running DeepCell Label in a Docker Container

In addition to having Docker, you will also need to have a VNC viewer to view the application inside the container.

Expand All @@ -147,12 +147,12 @@ caliban:latest
```
This will launch a new Docker container and run Xvfb, Fluxbox, and a VNC server. To access the container’s display, point a VNC client to 127.0.0.1.

Inside the VNC client, one can access Caliban through the terminal emulator. Start the terminal by right-clicking the desktop and selecting
Inside the VNC client, one can access DeepCell Label through the terminal emulator. Start the terminal by right-clicking the desktop and selecting

```bash
Applications > Terminal Emulators > XTerm
```
Next, enter the following into the terminal and Caliban will start:
Next, enter the following into the terminal and DeepCell Label will start:

```bash
cd desktop
Expand Down
18 changes: 9 additions & 9 deletions browser/README.md
@@ -1,10 +1,10 @@
# Browser-Based Application of Caliban for Data Curation
# Browser-Based Application of DeepCell Label for Data Curation

This is an version of Caliban that runs on a browser. The browser-based Caliban application can be run locally or deployed to AWS Elastic Beanstalk.
This is an version of DeepCell Label that runs on a browser. The browser-based DeepCell Label application can be run locally or deployed to AWS Elastic Beanstalk.

Many key and mouse operations are the same between desktop and browser versions, but these versions are not guaranteed to share the same features. See the "Controls" section for an up-to-date list of features.

# Caliban for Developers
# DeepCell Label for Developers

## Install Dependencies
Using a virtual environment to install dependencies is recommended.
Expand Down Expand Up @@ -49,13 +49,13 @@ sudo docker system prune --volumes

Flask is used as an HTTP server that serves the frames as pngs and metadata as JSON. The .js files in the `browser/template` folder are what makes the requests to the Flask server.

​Python Flask was used as a web application framework for constructing Caliban. The Flask framework helps serves as the router that maps the specific URL with the associated function that is intended to perform some task. Specifically, the application.route decorator binds the URL rule to the function below it. Thus, if user performs actions that cause a change in the underlying data, the side-serving .js file will request to visits a specific URL, and the output of the function below the decorator will be rendered in the browser.
​Python Flask was used as a web application framework for constructing DeepCell Label. The Flask framework helps serves as the router that maps the specific URL with the associated function that is intended to perform some task. Specifically, the application.route decorator binds the URL rule to the function below it. Thus, if user performs actions that cause a change in the underlying data, the side-serving .js file will request to visits a specific URL, and the output of the function below the decorator will be rendered in the browser.

Functions depend on Python libraries -- including NumPy, Matplotlib, and scikit-image – to change the data within files. After the desired change has been made to the lineage information or mask annotation, the Flask app routing will update the interface to reflect the alterations with support from side-serving JavaScript scripts.

The final Flask application has been deployed to an AWS Elastic Beanstalk environment as a RESTful web service. A stable demo of the browser application can be accessed at caliban.deepcell.org. To deploy this application to AWS EB, an AWS RDS MySQL database must be set up and configured to handle data storage for application use. (Add database credentials to the .env configuration file.) Once a database is appropriately configured, the application can easily be launched by using the AWS EB command line tool or web interface. The .ebextensions folder will configure the web service to use the appropriate Flask application (eb_application.py, which uses a MySQL database instead of SQLite).
The final Flask application has been deployed to an AWS Elastic Beanstalk environment as a RESTful web service. A stable demo of the browser application can be accessed at label.deepcell.org. To deploy this application to AWS EB, an AWS RDS MySQL database must be set up and configured to handle data storage for application use. (Add database credentials to the .env configuration file.) Once a database is appropriately configured, the application can easily be launched by using the AWS EB command line tool or web interface. The .ebextensions folder will configure the web service to use the appropriate Flask application (eb_application.py, which uses a MySQL database instead of SQLite).

Caliban can also be run locally using a SQLite database (this is the default behavior). When we start using Caliban, Caliban creates a TrackEdit (for .trk files) or ZStackEdit (for .npz files) object, gives it a unique ID, and stores it locally in caliban.db. Whenever we change an Edit object, Caliban updates the object in the database. After we submit the file and our changes to the S3 bucket, Caliban deletes the Edit object from the database, leaving behind the unique ID and session metadata. Running application.py creates the database if it does not already exist.
DeepCell Label can also be run locally using a SQLite database (this is the default behavior). When we start using DeepCell Label, DeepCell Label creates a TrackEdit (for .trk files) or ZStackEdit (for .npz files) object, gives it a unique ID, and stores it locally in deepcell_label.db. Whenever we change an Edit object, DeepCell Label updates the object in the database. After we submit the file and our changes to the S3 bucket, DeepCell Label deletes the Edit object from the database, leaving behind the unique ID and session metadata. Running application.py creates the database if it does not already exist.

## Controls

Expand All @@ -70,7 +70,7 @@ Caliban can also be run locally using a SQLite database (this is the default beh

### Edit Operations:

Caliban's default setting allows operations to be carried out quickly and easily on existing segmentations. The actions that can modify cell labels and/or lineage information are:
DeepCell Label's default setting allows operations to be carried out quickly and easily on existing segmentations. The actions that can modify cell labels and/or lineage information are:

*click* - click on a cell label to select it. Up to two cells can be selected at one time.

Expand Down Expand Up @@ -115,9 +115,9 @@ Annotation mode focuses on using an adjustable brush to modify annotations on a

*n* - change brush label to an unusued label, so that a new cell can be created with a unique id

*p* - color picker (click on a label to change the brush value to it)
*p* - color picker (click on a label to change the brush label to it)

*r* - turn on "conversion brush" setting, which changes brush behavior so that one label value is overwritten with another label value. No other labels are affected, and conversion brush will not draw on background. After turning on conversion brush, click on cell labels as prompted to set brush values. (Eraser mode is automatically turned off when the conversion brush is set.)
*r* - turn on "conversion brush" setting, which changes brush behavior so that one label value is overwritten with another label value. No other labels are affected, and conversion brush will not draw on background. After turning on conversion brush, click on cell labels as prompted to set brush labels. (Eraser mode is automatically turned off when the conversion brush is set.)

*t* - threshold to predict annotations based on brightness. After turning this on, click and drag to draw a bounding box around the cell you wish to threshold. Make sure to include some background in the bounding box for accurate threshold predictions. Whatever was thresholded as foreground within the bounding box will be added to the annotation as a new cell with unique label.

Expand Down
10 changes: 9 additions & 1 deletion browser/application.py
Expand Up @@ -10,13 +10,15 @@
from flask_cors import CORS
import flask_monitoringdashboard as dashboard
from flask_compress import Compress
from flask_dropzone import Dropzone

import config
from blueprints import bp
from models import db


compress = Compress() # pylint: disable=C0103
dropzone = Dropzone() # pylint: disable=C0103


class ReverseProxied(object):
Expand Down Expand Up @@ -79,6 +81,12 @@ def create_app(**config_overrides):
app.register_blueprint(bp)

compress.init_app(app)
dropzone.init_app(app)
app.config.update(
# Flask-Dropzone config:
DROPZONE_MAX_FILE_SIZE=128, # 128 MB max filesize
DROPZONE_TIMEOUT=60 * 1000 # 1 minute upload timeout
)

# For flask monitoring dashboard
if config.DASHBOARD_CONFIG:
Expand All @@ -87,7 +95,7 @@ def create_app(**config_overrides):
def group_action():
"""Apply custom grouping for action endpoint"""
from flask import request
if request.endpoint == 'caliban.action':
if request.endpoint == 'label.action':
return request.view_args['action_type']

dashboard.config.group_by = group_action
Expand Down

0 comments on commit 10a7aea

Please sign in to comment.