%reload_ext autoreload
%autoreload 2
%matplotlib inline
import warnings
warnings.filterwarnings('ignore')
from exact_sync.v1.api.annotations_api import AnnotationsApi
from exact_sync.v1.api.images_api import ImagesApi
from exact_sync.v1.api.image_sets_api import ImageSetsApi
from exact_sync.v1.api.annotation_types_api import AnnotationTypesApi
from exact_sync.v1.api.products_api import ProductsApi
from exact_sync.v1.api.teams_api import TeamsApi
from exact_sync.v1.models import ImageSet, Team, Product, AnnotationType, Image, Annotation, AnnotationMediaFile
from exact_sync.v1.rest import ApiException
from exact_sync.v1.configuration import Configuration
from exact_sync.v1.api_client import ApiClient
import pandas as pd
configuration = Configuration()
configuration.username = 'exact'
configuration.password = 'exact'
configuration.host = "http://127.0.0.1:1337"
client = ApiClient(configuration)
image_sets_api = ImageSetsApi(client)
annotations_api = AnnotationsApi(client)
annotation_types_api = AnnotationTypesApi(client)
images_api = ImagesApi(client)
product_api = ProductsApi(client)
team_api = TeamsApi(client)
help(image_sets_api.list_image_sets)
Help on method list_image_sets in module exact_sync.v1.api.image_sets_api: list_image_sets(pagination:bool=True, **kwargs) method of exact_sync.v1.api.image_sets_api.ImageSetsApi instance list_image_sets # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.list_image_sets(async_req=True) >>> result = thread.get() :param bool pagination: active or deactive :param async_req bool :param int limit: Number of results to return per page. :param int offset: The initial index from which to return the results. :param str id: id :param str path: path :param str path__contains: path__contains :param str name: name :param str name__contains: name__contains :param str location: location :param str location__contains: location__contains :param str description: description :param str description__contains: description__contains :param str time: time :param str time__range: time__range :param str team: team :param str creator: creator :param str public: public :param str main_annotation_type: main_annotation_type :param str set_tags: set_tags :param str product: product :param str collaboration_type: collaboration_type :param str priority: priority :param str zip_state: zip_state :param str images: images :return: ImageSets If the method is called asynchronously, returns the request thread.
image_set = image_sets_api.list_image_sets(name__contains="MICCAI Mitotic Figure Study")
image_set
{'count': 1, 'next': None, 'previous': None, 'results': [{'creator': 1, 'description': '', 'id': 161, 'images': [1436, 1437, 1438, 1439, 1440, 1441, 1442, 1443, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455], 'location': None, 'main_annotation_type': 266, 'name': 'MICCAI Mitotic Figure Study', 'path': 'exact_166_161', 'product_set': [130], 'set_tags': [], 'team': 166}]}
annos = []
for image_id in image_set.results[0].images:
for anno in annotations_api.list_annotations(image=image_id, deleted=False,pagination=False,expand="user,annotation_type",fields="id,user,time,unique_identifier,annotation_type,vector").results:
annos.append([anno.id, anno.user["username"], anno.time, anno.unique_identifier, anno.annotation_type["name"], anno.vector])
anno
{'annotation_type': {'area_hit_test': True, 'closed': True, 'color_code': '#0000FF', 'default_height': 50, 'default_width': 50, 'enable_blurred': True, 'enable_concealed': True, 'id': 266, 'name': 'mitotic figure', 'node_count': 0, 'product': 130, 'sort_order': 0, 'vector_type': 1}, 'annotationversion_set': [], 'blurred': None, 'concealed': None, 'deleted': None, 'description': None, 'id': 1310601, 'image': None, 'last_edit_time': None, 'last_editor': None, 'meta_data': None, 'time': datetime.datetime(2020, 10, 23, 18, 2, 12, 170203), 'unique_identifier': 'd4adb89f-f080-4287-9854-f75bc65faba1', 'uploaded_media_files': [], 'user': {'id': 55, 'is_active': True, 'is_staff': False, 'is_superuser': False, 'last_login': None, 'team_set': [166], 'username': 'Participant_9'}, 'vector': {'x1': 3690, 'x2': 3740, 'y1': 3801, 'y2': 3851}, 'verified_by_user': None}
annos = pd.DataFrame(annos, columns=["id", "user", "time", "unique_identifier", "type", "vector"])
annos
id | user | time | unique_identifier | type | vector | |
---|---|---|---|---|---|---|
0 | 1292457 | exact | 2020-10-20 16:29:55.210182 | 842fb8c3-0de7-40f4-ae56-b5248df9f60e | mitotic figure | {'x1': 4425, 'x2': 4475, 'y1': 3416, 'y2': 3466} |
1 | 1304465 | Participant_10 | 2020-10-23 17:49:07.294591 | 05345076-582f-4cc7-885e-1b81a0a8307e | mitotic figure | {'x1': 2213, 'x2': 2263, 'y1': 4335, 'y2': 4385} |
2 | 1304466 | Participant_10 | 2020-10-23 18:00:39.163809 | 56b1124e-7ba7-40dc-808c-64495fee9cf2 | mitotic figure | {'x1': 2213, 'x2': 2263, 'y1': 4335, 'y2': 4385} |
3 | 1304467 | Participant_10 | 2020-10-23 18:00:39.163809 | 5146dc65-7887-4994-9b4f-69b104cd643f | mitotic figure | {'x1': 4426, 'x2': 4476, 'y1': 3417, 'y2': 3467} |
4 | 1305447 | Participant_13 | 2020-10-23 18:01:09.986946 | 62632382-8a52-43aa-96c7-185b1e810390 | mitotic figure | {'x1': 4426, 'x2': 4476, 'y1': 3418, 'y2': 3468} |
... | ... | ... | ... | ... | ... | ... |
6877 | 1310597 | Participant_9 | 2020-10-23 18:02:12.168202 | db139eea-0c22-41a7-be28-034b9f030859 | mitotic figure | {'x1': 1112, 'x2': 1162, 'y1': 341, 'y2': 391} |
6878 | 1310598 | Participant_9 | 2020-10-23 18:02:12.169204 | eeba4467-55e2-40ad-b57e-a9d9017871b0 | mitotic figure | {'x1': 4499, 'x2': 4549, 'y1': 4028, 'y2': 4078} |
6879 | 1310599 | Participant_9 | 2020-10-23 18:02:12.169204 | 71c53fdf-4f44-40f6-ae94-611c5ada7650 | mitotic figure | {'x1': 4277, 'x2': 4327, 'y1': 3889, 'y2': 3939} |
6880 | 1310600 | Participant_9 | 2020-10-23 18:02:12.169204 | 40951d62-9f68-4ab1-948a-644e16de8273 | mitotic figure | {'x1': 3705, 'x2': 3755, 'y1': 3834, 'y2': 3884} |
6881 | 1310601 | Participant_9 | 2020-10-23 18:02:12.170203 | d4adb89f-f080-4287-9854-f75bc65faba1 | mitotic figure | {'x1': 3690, 'x2': 3740, 'y1': 3801, 'y2': 3851} |
6882 rows × 6 columns