loopbio blog

Motif 4.0

Written on Monday November 27, 2017

Motif video recording software version 4.0 was released today. This version features many changes and improvements, as demonstrated in the following youtube video


Motif is a video recording sytem which supports single single camera or multiple camera recording, and video recordings can be from seconds to weeks in duration. The version 4.0 release has the following highlights:

Motif 4.0 screenshots

Sample screenshots of Motif 4.0 multi-camera and single-camera web user interface

I'd like to demonstrate a the last two of these features using the new Python API.

Starting and stopping recording is easy. The following snippet demonstrates starting recording on all cameras with the predefined compression settings named 'high' (see the Web UI for the names of your configured compression formats). The recording will run for 5 seconds and will have have the additional metadata 'experiment' and 'genotype' saved to the recorded file. The snipped works equally on single or simultaenous multiple-camera systems.

from motifapi import MotifApi

IP_ADDRESS = '10.11.12.13'
API_KEY = 'abcdef123456abcdef123456abcdef12'
api = MotifApi(IP_ADDRESS, API_KEY)

api.call('recording/start',
         codec='high',
         duration=5,
         metadata={'experiment': 'frobnicate', 'genotype': 'wt'})

Likewise, the API also supports defining scheduled tasks, this allows for example, to schedule recordings and their subsequent copy to storage to occur at specific times. Task scheduling re-uses Cron syntax with some extensions (monotonic tasks).

api.call('schedule/recording/start', task_name='record_video',
         cron_expression='0 06-16 * * *',
         codec='low', duration=30*60)

We are really excited about these new API feature as they allowa laboratory wide automation of single or multiple recording systems or experimental assays. We are looking forward to extending our API support in future releases.

Python Imgstore

Written on Tuesday May 30, 2017

Imgstore is a library that we built for efficient reading and writing of large video recordings. By splitting long recordings into chunks and implementing efficient indexing alongside, it allows frame accurate seeking and random frame access.

Imgstore supports videos recorded with loopbio’s Motif recording system.

If you need to store hundreds, to thousands to millions of frames, and metadata with each frame (including but not limited to framenumber and timestamp), then check out the project page.

example frame from imgstore

Sample frame from a 7-day, 120Gb, 9-million frame recording (more information)

ImgStore supports two different backends; DirectoryImgStore and VideoImgStore which are designed for lossless and lossy recordings respectively. DirectoryImgStore stores each frame as a single compressed file supporting raw numpy npy arrays, png images, compressed blosc arrays, raw pgm images, and many more. Files are grouped into directories ‘chunks’ to retain good filesystem performance.

In VideoImgStore, each ‘chunk’ is an individual movie file with a fixed number of frames. This chunking strategy limits the size of each file to make copying and archival easier (respecting FAT32 file size limits for USB sticks for example).

In both cases the Imgstore API allows continuous playback through all frames as though it were a single file on disk, and allows seeking to any frame within.

Reading files is easy:

from imgstore import new_for_filename

store = new_for_filename('mystore/metadata.yaml')

print('%d frames in store' % store.frame_count)

# read the best frame from the video
img, (frame_number, frame_timestamp) = store.get_image(42)
print('framenumber:', frame_number, 'timestamp:', frame_timestamp)

For more information check out the project page.