Exemplo n.º 1
0
"""Module responsible for storage of serializers used in Labels endpoints."""
from flask_restplus import fields

from medtagger.api import api
from medtagger.database.models import RectangularLabelElement, BrushLabelElement, PointLabelElement, ChainLabelElement
from medtagger.definitions import LabelVerificationStatus, LabelElementStatus, LabelTool


in__action_response = api.model("Response for Action", {})

in__label_status = api.model("Status for label", {
    'status': fields.String(description='New status for label',
                            enum=[status.name for status in LabelVerificationStatus],
                            required=True),
})

out__common_label_element = api.model('Common Label Element model', {
    'label_element_id': fields.String(description='Label Element\'s ID', attribute='id'),
    'slice_index': fields.Integer(description='Slice\'s order index', min=0),
    'tag': fields.String(description='Element\'s tag', attribute='tag.key'),
    'tool': fields.String(description='Element\'s tool', attribute='tool.value',
                          enum=[tool.name for tool in LabelTool]),
    'status': fields.String(description='Element\'s status', attribute='status.value',
                            enum=[status.name for status in LabelElementStatus]),
})

out__rectangular_label_element = api.inherit('Rectangular Label Element model', out__common_label_element, {
    'x': fields.Float(description='Element\'s X position', min=0.0, max=1.0),
    'y': fields.Float(description='Element\'s Y position', min=0.0, max=1.0),
    'width': fields.Float(description='Element\'s width', min=0.0, max=1.0),
    'height': fields.Float(description='Element\'s height', min=0.0, max=1.0),
Exemplo n.º 2
0
"""Module responsible for storage of serializers used in Labels endpoints."""
from flask_restplus import fields

from medtagger.api import api
from medtagger.database.models import RectangularLabelElement, BrushLabelElement
from medtagger.definitions import LabelVerificationStatus, LabelElementStatus, LabelTool

in__label_status = api.model("Status for label", {
    'status': fields.String(description='New status for label',
                            enum=[status.name for status in LabelVerificationStatus],
                            required=True),
})

out__common_label_element = api.model('Common Label Element model', {
    'label_element_id': fields.String(description='Label Element\'s ID', attribute='id'),
    'slice_index': fields.Integer(description='Slice\'s order index', min=0),
    'tag': fields.String(description='Element\'s tag', attribute='tag.key'),
    'tool': fields.String(description='Element\'s tool', attribute='tool.value',
                          enum=[tool.name for tool in LabelTool]),
    'status': fields.String(description='Element\'s status', attribute='status.value',
                            enum=[status.name for status in LabelElementStatus]),
})

out__rectangular_label_element = api.inherit('Rectangular Label Element model', out__common_label_element, {
    'x': fields.Float(description='Element\'s X position', min=0.0, max=1.0),
    'y': fields.Float(description='Element\'s Y position', min=0.0, max=1.0),
    'width': fields.Float(description='Element\'s width', min=0.0, max=1.0),
    'height': fields.Float(description='Element\'s height', min=0.0, max=1.0),
})

out__brush_label_element = api.inherit('Brush Label Element model', out__common_label_element, {
Exemplo n.º 3
0
"""Module responsible for storage of serializers used in Scans endpoints."""
from flask_restplus import reqparse, fields

from medtagger.api import api
from medtagger.definitions import ScanStatus, LabelVerificationStatus

in__new_scan = api.model('New Scan model', {
    'dataset': fields.String(description='Dataset', required=True),
    'number_of_slices': fields.Integer(description='Number of Slices that will be uploaded', required=True),
})

elements_schema = {
    'type': 'array',
    "items": {
        "type": "object",
        'oneOf': [
            {'$ref': '#/definitions/rectangular_label_element_schema'},
            {'$ref': '#/definitions/brush_label_element_schema'},
            {'$ref': '#/definitions/point_label_element_schema'},
            {'$ref': '#/definitions/chain_label_element_schema'},
        ],
    },
    'definitions': {
        'rectangular_label_element_schema': {
            'properties': {
                'x': {'type': 'number', 'minimum': 0.0, 'maximum': 1.0},
                'y': {'type': 'number', 'minimum': 0.0, 'maximum': 1.0},
                'width': {'type': 'number', 'minimum': 0.0, 'maximum': 1.0},
                'height': {'type': 'number', 'minimum': 0.0, 'maximum': 1.0},
                'slice_index': {'type': 'integer'},
                'tag': {'type': 'string'},
Exemplo n.º 4
0
"""Module responsible for storage of serializers used in Tasks endpoints."""
from flask_restplus import fields

from medtagger.api import api
from medtagger.definitions import LabelTool

out__label_tag = api.model(
    'Label Tag model', {
        'key':
        fields.String(),
        'name':
        fields.String(),
        'actions_ids':
        fields.List(fields.Integer(),
                    attribute=lambda label_tag:
                    [action.id for action in label_tag.actions]),
        'tools':
        fields.List(fields.String(),
                    description='Available tools for Label Tag',
                    enum=[tool.name for tool in LabelTool],
                    attribute=lambda label_tag:
                    [tool.name for tool in label_tag.tools]),
    })

in__label_tag = api.model(
    'Label Tag model', {
        'key':
        fields.String(),
        'name':
        fields.String(),
        'actions_ids':
Exemplo n.º 5
0
"""Module responsible for storage of serializers used in Auth endpoints."""
from flask_restplus import fields

from medtagger.api import api

new_user = api.model('New user model', {
    'email': fields.String(required=True, min_length=1),
    'password': fields.String(required=True, min_length=8),
    'firstName': fields.String(required=True, min_length=1),
    'lastName': fields.String(required=True, min_length=1),
})
sign_in = api.model('Sign in model', {
    'email': fields.String(required=True),
    'password': fields.String(required=True),
})
Exemplo n.º 6
0
"""Module containing serializers for users endpoints."""
from flask_restplus import fields

from medtagger.api import api

user_settings = api.model('User settings', {
    'skipTutorial': fields.Boolean(attribute='skip_tutorial', description='Should tutorial be skipped?'),
})
user = api.model('User model', {
    'id': fields.Integer(attribute='id', description='User\'s id'),
    'email': fields.String(attribute='email', description='Email address'),
    'firstName': fields.String(attribute='first_name', description='First name'),
    'lastName': fields.String(attribute='last_name', description='Last name'),
    'role': fields.String(attribute='role.name', description='User\'s role'),
    'settings': fields.Nested(user_settings, attribute='settings', description='User\'s settings'),
})
users_list = api.model('Users list', {
    'users': fields.List(fields.Nested(user)),
})
Exemplo n.º 7
0
"""Module that contains helpers related to pagination in the REST API."""
from flask_restplus import fields

from medtagger.api import api

PAGINATION = {
    'pagination':
    fields.Nested(
        api.model(
            'Pagination', {
                'page':
                fields.Integer(description='Page number'),
                'per_page':
                fields.Integer(description='Number of entries per page'),
                'total':
                fields.Integer(description='Total numer of entries'),
            })),
}
Exemplo n.º 8
0
"""Module responsible for storage of serializers used in Datasets endpoints."""
from flask_restplus import fields

from medtagger.api import api
from medtagger.api.tasks.serializers import out__task

in__dataset = api.model('New Dataset model', {
    'key': fields.String(),
    'name': fields.String(),
})

out__dataset = api.model(
    'Dataset model', {
        'key': fields.String(),
        'name': fields.String(),
        'tasks': fields.List(fields.Nested(out__task)),
    })
Exemplo n.º 9
0
"""Module responsible for storage of serializers used in Core endpoints."""
from flask_restplus import fields

from medtagger.api import api

out__status = api.model(
    'Status model', {
        'success':
        fields.Boolean(
            description='Should be True if everything is all right.'),
    })