ethoscope.utils package

Module contents

ethoscope.utils.debug module

exception ethoscope.utils.debug.EthoscopeException(value, img=None)[source]

Bases: exceptions.Exception

A custom exception. It can store an image

Parameters:
  • value – A value passed to the exception, generally a text message
  • img (ndarray) – an image
Returns:

ethoscope.utils.debug.show(im, t=-1)[source]

A function to simply display an image and wait. This is for debugging purposes only. :param im: the image to show :type im: ndarray :param t: the time to wait, in ms. Lower than 1 means until user enter a key. :type t: int :return:

ethoscope.utils.description module

class ethoscope.utils.description.DescribedObject[source]

Bases: object

An object that contains a description attribute. This is used to parse user option for the web interface. This way, users can send option to the different objects used. description is a dictionary with the fields “overview” and “arguments”. “overview” is simply a string. “arguments” is a list of dictionaries. Each has the field:

  • name: The name of the argument as it is in “__init__”
  • description: “A user friendly description of the argument”
  • type: “number”, “datetime”, “daterange” and “string”.
  • min, max and step: only for type “number”, defines the accepted limits of the arguments as well as the increment in the user interface
  • default: the default value

Each argument must match a argument in __init__.

description

ethoscope.utils.img_proc module

ethoscope.utils.img_proc.merge_blobs(contours, prop=0.5)[source]

Merge together contour according to their position and size. If the distance between two blobs is smaller than the longest axis of, at least, one of them, then they get merged. This algorithm is aimed at merging together part of the same physical object without morphological operations.

Parameters:contours – list of contours
Returns:the convex hulls of the merged contours, list of contourss

ethoscope.utils.io module

class ethoscope.utils.io.AsyncMySQLWriter(db_credentials, queue, erase_old_db=True)[source]

Bases: multiprocessing.process.Process

run()[source]
class ethoscope.utils.io.AsyncSQLiteWriter(db_name, queue, erase_old_db=True)[source]

Bases: multiprocessing.process.Process

run()[source]
class ethoscope.utils.io.DAMFileHelper(period=60.0, n_rois=32)[source]

Bases: object

flush(t)[source]
input_roi_data(t, roi, data)[source]
make_dam_file_sql_fields()[source]
class ethoscope.utils.io.ImgToMySQLHelper(period=300.0)[source]

Bases: object

Parameters:period – how often snapshots are saved, in seconds
Returns:
flush(t, img)[source]
Parameters:
  • t – the time since start of the experiment, in ms
  • img (np.ndarray) – an array representing an image.
Returns:

class ethoscope.utils.io.Null[source]

Bases: object

class ethoscope.utils.io.ResultWriter(db_credentials, rois, metadata=None, make_dam_like_table=True, take_frame_shots=False, erase_old_db=True, *args, **kwargs)[source]

Bases: object

close()[source]
flush(t, img=None)[source]
metadata
write(t, roi, data_rows)[source]
class ethoscope.utils.io.SQLiteResultWriter(db_credentials, rois, metadata=None, make_dam_like_table=False, take_frame_shots=False, *args, **kwargs)[source]

Bases: ethoscope.utils.io.ResultWriter