Skip to content

LabelSlide is a slide annotation tool and label object bounding boxes in virtual slides (generally used in pathology)

License

Notifications You must be signed in to change notification settings

steven22tom/LabelSlide

Repository files navigation

LabelSlide

LabelSlide is a slide annotation tool and label object bounding boxes in virtual slides (generally used in pathology)

example

Feature

LabelSlide is based on B/S structure and written in Python.
Using OpenSlide to read the virtual slides and create DeepZoom Image.
Then view the zoomable image in browser by OpenSeadragon.
Adding Fabric.js canvas to draw label box overlaying the OpenSeadragon viewer.
The webpage build with Bootstrap

Installation

Build from source

Python

pip install -r requirements.txt
python label_slide.py

access 127.0.0.1:5000 (as default)

If show error "Could not find module 'libopenslide-0.dll'". Please download libvips and unzip to bin folder

Usage

Config

There's two config file.

app_config.py
Including HOST, PORT for the app and the SLIDE_CONFIG for slide config(the file path of config.yaml).
ps: parameter name must be uppercase

config.yaml
Containing the following parameters
slide_dir: the directory where slides are kept. label_dir: the directory where the annotation will be saved to.
class: pre-defined classes including id, name and color.

For example:

slide_dir: D:\Dataset\slides
label_dir: D:\Dataset\labels
class:
- id: 0
  name: A
  color: '#2196f3'
- id: 1
  name: B
  color: '#0014a8'

ps: the class id must be integer and the color must be hex format.
All content in config.yaml could be modified from webpage

Slide

In theory, the tool can read virtual slides in several formats because using OpenSlide:

But only try MIRAX(.mrxs) under development.
If you want to read slide in other formats, you should modify code in label_tool.py by yourself.

Annotation

Support rectangle box and polygon box currently.

Hotkeys

Key Function
q View Mode
e Create new rectangle box
r Create new polygon box
del Delete the selected rect box

Annotation file
One slide corresponds to one annotation file.
Take annotation for MIRAX (.mrxs) as an example

slide: C20200174
boxes:
- class: 0
  type:rect
  x: 30749
  y: 70121
  w: 468
  h: 434
- class: 1
  type: poly
  points:
  - x: 33813
    y: 62176
  - x: 33931
    y: 62571
  - x: 34099
    y: 62308

x,y is the top left pixel and w,h is the region size in the level 0 reference frame(highest resolution)

Related

License

LGPL-2.1 License