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