ibllib.plots.snapshot
Classes
A class to register images in form of Notes, linked to an object on Alyx. |
- class ReportSnapshot(session_path, object_id, content_type='session', **kwargs)[source]
Bases:
Task
- class ReportSnapshotProbe(pid, session_path=None, one=None, brain_regions=None, brain_atlas=None, **kwargs)[source]
Bases:
ReportSnapshot
- signature = {'input_files': [], 'output_files': []}
- property pid_label
‘SWC_054_2020-10-05_001_probe01’
- Type:
returns a probe insertion stub to label titles, for example
- class Snapshot(object_id, content_type='session', one=None)[source]
Bases:
object
A class to register images in form of Notes, linked to an object on Alyx.
- Parameters:
object_id – The id of the object the image should be linked to
content_type – Which type of object to link to, e.g. ‘session’, ‘probeinsertion’, ‘subject’,
default is ‘session’ :param one: An ONE instance, if None is given it will be instantiated.
- generate_image(plt_func, plt_kwargs)[source]
Takes a plotting function and adds the output to the Snapshot.images list for registration
- Parameters:
plt_func – A plotting function that returns the path to an image.
plt_kwargs – Dictionary with keyword arguments for the plotting function
- register_image(image_file, text='', json_field=None, width=None)[source]
Registers an image as a Note, attached to the object specified by Snapshot.object_id
- Parameters:
image_file – Path to the image to to registered
text – str, text to describe the image, defaults ot empty string
json_field – dict, to be added to the json field of the Note
width – width to scale the image to, defaults to None (scale to UPLOADED_IMAGE_WIDTH in alyx.settings.py),
other options are ‘orig’ (don’t change size) or any integer (scale to width=int, aspect ratios won’t be changed)
- Returns:
dict, note as registered in database
- register_images(image_list=None, texts=None, widths=None, jsons=None)[source]
Registers a list of images as Notes, attached to the object specified by Snapshot.object_id. The images can be passed as image_list. If None are passed, will try to register the images in Snapshot.images.
- Parameters:
image_list – List of paths to the images to to registered. If None, will try to register any images in Snapshot.images
texts – List of text to describe the images. If len(texts)==1, the same text will be used for all images
widths – List of width to scale the figure to (see Snapshot.register_image). If len(widths)==1, the same width will be used for all images
jsons – List of dictionaries to populate the json field of the note in Alyx. If len(jsons)==1, the same dict will be used for all images
- Returns:
list of dicts, notes as registered in database