Skip to main content

Annotate frames of a multiTIFF video

Project description

FrAn: FRame ANnotation

Watch a video in multipage TIFF format and label frames where events start or end.

Written for python 3.7.

Installation

pip install fran

If you think you may already have a version of fran installed, add the --upgrade option.

Usage

fran

usage: fran [-h] [--write_config WRITE_CONFIG] [--outfile OUTFILE]
            [--config CONFIG] [--fps FPS] [--cache CACHE] [--threads THREADS]
            [--keys KEYS] [--flipx] [--flipy] [--rotate ROTATE] [--version]
            [--verbose] [--logfile LOGFILE]
            [infile]

Log video (multipage TIFF) frames in which an event starts or ends

positional arguments:
  infile                Path to multipage TIFF file to read. If no path is given, a file dialog will open.

optional arguments:
  -h, --help            show this help message and exit
  --write_config WRITE_CONFIG, -w WRITE_CONFIG
                        Write back the complete config to a file at this path, then exit
  --outfile OUTFILE, -o OUTFILE
                        Path to CSV for loading/saving. If no path is selected when you save, a file dialog will open.
  --config CONFIG, -c CONFIG
                        Path to TOML file for config
  --fps FPS, -f FPS     Maximum frames per second; default 30
  --cache CACHE, -n CACHE
                        Number of frames to cache (increase if reading over a network and you have lots of RAM); default 500
  --threads THREADS, -t THREADS
                        number of threads to use for reading file (increase if reading over a network); default 3
  --keys KEYS, -k KEYS  Optional mappings from event name to key, in the format "w=forward,a=left,s=back,d=right". These are additive with those defined in the config
  --flipx, -x           Flip image in x
  --flipy, -y           Flip image in y
  --rotate ROTATE, -r ROTATE
                        Rotate image (degrees counterclockwise; applied after flipping)
  --version             Print the version and then exit
  --verbose, -v         Increase verbosity of logging (can be repeated). One for DEBUG, two for FRAME.
  --logfile LOGFILE, -l LOGFILE
                        File to save log to

Playback
========
LEFT and RIGHT arrows play the video in that direction at the configured FPS.
Hold SHIFT + direction to play at 10x speed.
Press COMMA or PERIOD to step one frame left or right, respectively.

Contrast
========
Contrast is controlled by rescaling the pixel intensities between a min and max threshold.
Hold UP/DOWN to change the lower threshold (increasing it blacks out dim pixels).
Hold SHIFT + UP/DOWN to change the upper threshold (decreasing it whites out bright pixels).

Events
======
LETTER keys mark the start of an event associated with that letter.
SHIFT + LETTER marks the end of the event.
Events can overlap, but events of the same type cannot contain each other or start on the same frame.

Status
======
SPACE shows in-progress events.
RETURN shows the current result table in the console.
BACKSPACE shows the current frame number and contrast thresholds in the interval [0, 1].

Prompts
=======
DELETE shows a prompt asking which in-progress event to delete, then a confirmation.
SHIFT + delete shows a prompt asking which keypress on this frame to delete.
CTRL + n shows a prompt asking which in-progress event whose note to edit (if there is more than one), then the new value.

Prompts may appear in unexpected places on your screen.

Debug
=====
CTRL + d to dump the event log for debugging

Other
=====
CTRL + j to Jump to a frame
CTRL + s to Save
CTRL + z to undo
CTRL + r to Redo
CTRL + h to show this Help message

Examples

# run with default settings: a file dialog will ask where your TIFF file is and where to save the CSV
fran

# run with 5 image-reading threads (more than the default 3)
# and a 1000-frame cache (more than the default 500)
fran --threads 5 --cache 1000

# copy the default config to a file, which you can edit
fran --write_config my_config.toml

# run with a given config file
fran --config my_config.toml

# give the input and output files to avoid file dialogs
fran my_image_file.tif --outfile my_results.csv

# flip the image in x and then rotate counterclockwise by 45 degrees
fran my_image_file.tif --flipx --rotate 45

To add event names (with mappings from their associate keys) to your config, the [keys] section should look like

[keys]
w = "forward"
a = "left"
s = "back"
d = "right"

See the default config file for the defaults and other settings which can be configured.

Output

If --outfile is given, saving writes to the file in CSV format. Otherwise, it writes to stdout (all other messages are on stderr).

If given output file already exists, events will be loaded from it. This is not possible if the output file is selected in the GUI.

e.g.

start,stop,key,event,note
120,500,f,forward,"this event is a nice event"
505,530,b,backward,
650,None,r,right,"this doesn't finish in the video"

Example workflow

  1. Install fran (pip install fran)
  2. Write a basic config file to your working directory (fran --write_config my_project/project_config.toml)
  3. Edit that config file as you like, with the image transform, event names and so on
  4. Start annotating! fran my_project/my_video.tiff --config my_project/project_config.toml --outfile my_project/results.csv

fran-rename

A utility to rename events in an existing results file.

usage: fran-rename [-h] [--config CONFIG] [--keys KEYS] [--version] [--print]
                   results

Rename all of the events in a given results file, with a key mapping specified
in a config TOML and/or command line argument.

positional arguments:
  results               Path to CSV to update.

optional arguments:
  -h, --help            show this help message and exit
  --config CONFIG, -c CONFIG
                        Path to TOML file for config
  --keys KEYS, -k KEYS  Optional mappings from event name to key, in the
                        format "w=forward,a=left,s=back,d=right". These are
                        additive with those defined in the config
  --version             Print the version and then exit
  --print, -p           Print results to stdout, instead of saving file back

MacOS

MacOS disagrees with pygame if installed in a virtual environment: use the system python (if 3.7+ is available) or one installed with homebrew.

Contributing

# Install development dependencies
pip install -r requirements.txt
# Install package in editable mode
pip install -e .
# Install pre-commit hooks for lint/formatting
pre-commit install

Attributions

Test data JeffT1_le.tif from ImageJ image repository.

Thanks to Nadine Randel for feature requests and bug reports.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fran-0.9.1.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

fran-0.9.1-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file fran-0.9.1.tar.gz.

File metadata

  • Download URL: fran-0.9.1.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.1

File hashes

Hashes for fran-0.9.1.tar.gz
Algorithm Hash digest
SHA256 3c154eae8612bc200d14eb5cf6decab49d98c109d65f3ae674fe385c81b6bb9a
MD5 f24fae1e9fcb1114870af6ce5558428c
BLAKE2b-256 aa2d43d09c1de133d57368c816dc86d22619e46934c97ac84e7f175398a7ad99

See more details on using hashes here.

File details

Details for the file fran-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: fran-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.1

File hashes

Hashes for fran-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ec90ec41243560556f34becf9caded8c96c7a38b3907f6c1e82da607de6998b5
MD5 aebde0c31c3a9a6e72385dabae0b0663
BLAKE2b-256 dc00216f59515441aa00f63f474b422d5894cf06b255c58f8ed930c649904abe

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page