diff --git a/requirements_server.txt b/requirements_server.txt index c5124bd..ac23c64 100644 --- a/requirements_server.txt +++ b/requirements_server.txt @@ -5,4 +5,4 @@ django-cors-headers==3.2.1 tiledb==0.10.3 zarr==2.8.3 palettable==3.3.0 -https://github.com/crs4/ome_seadragon_cache/archive/v0.2.2.zip +https://github.com/crs4/ome_seadragon_cache/archive/v0.2.3.zip diff --git a/slides_manager/ome_engine.py b/slides_manager/ome_engine.py index b051924..8d35c6a 100644 --- a/slides_manager/ome_engine.py +++ b/slides_manager/ome_engine.py @@ -200,6 +200,7 @@ def get_thumbnail(self, size, original_file_source=False, file_mimeype=None): def get_tile(self, level, column, row, original_file_source=False, file_mimetype=None, tile_size=None, limit_bounds=None): tile_size = tile_size if tile_size is not None else settings.DEEPZOOM_TILE_SIZE + limit_bounds = limit_bounds if limit_bounds is not None else settings.DEEPZOOM_LIMIT_BOUNDS self._check_source_type(original_file_source) if settings.IMAGES_CACHE_ENABLED: cache = CacheDriverFactory(settings.IMAGES_CACHE_DRIVER). \ @@ -211,7 +212,8 @@ def get_tile(self, level, column, row, original_file_source=False, file_mimetype 'row': row, 'tile_size': tile_size, 'image_format': settings.DEEPZOOM_FORMAT, - 'rendering_engine': 'omero' + 'rendering_engine': 'omero', + 'limit_bounds': limit_bounds } if cache_params['image_format'].lower() == 'jpeg': cache_params['image_quality'] = settings.DEEPZOOM_JPEG_QUALITY diff --git a/slides_manager/openslide_engine.py b/slides_manager/openslide_engine.py index 82959d9..bd4cc0b 100644 --- a/slides_manager/openslide_engine.py +++ b/slides_manager/openslide_engine.py @@ -142,6 +142,7 @@ def get_tile(self, level, column, row, original_file_source=False, file_mimetype cache = CacheDriverFactory(settings.IMAGES_CACHE_DRIVER).\ get_cache(settings.CACHE_HOST, settings.CACHE_PORT, settings.CACHE_DB, settings.CACHE_EXPIRE_TIME) tile_size = tile_size if tile_size is not None else settings.DEEPZOOM_TILE_SIZE + limit_bounds = limit_bounds if limit_bounds is not None else settings.DEEPZOOM_LIMIT_BOUNDS self.logger.debug('TILE SIZE IS: %s', tile_size) cache_params = { 'image_id': self.image_id, @@ -150,7 +151,8 @@ def get_tile(self, level, column, row, original_file_source=False, file_mimetype 'row': row, 'tile_size': tile_size, 'image_format': settings.DEEPZOOM_FORMAT, - 'rendering_engine': 'openslide' + 'rendering_engine': 'openslide', + 'limit_bounds': limit_bounds } if cache_params['image_format'].lower() == 'jpeg': cache_params['image_quality'] = settings.DEEPZOOM_JPEG_QUALITY diff --git a/urls.py b/urls.py index dcb30a7..cfab28d 100644 --- a/urls.py +++ b/urls.py @@ -102,6 +102,8 @@ url(r'mirax/register_slide/$', views.register_mirax_slide, name='ome_seadragon_register_mirax'), url(r'^mirax/delete_files/(?P[\w\-.]+)/$', views.delete_original_files, name='ome_seadragon_mrxs_delete_files'), + url(r'mirax/details/(?P[\w\-.]+).json$', views.get_mirax_slide_details, + name='ome_seadragon_mirax_details'), # 3DHISTECH FILES HANDLING --- DEEPZOOM url(r'^mirax/deepzoom/get/(?P[\w\-.]+).dzi$', views.get_image_dzi, name='ome_seadragon_image_dzi_metadata_mrxs', diff --git a/views.py b/views.py index 36845cc..0b54465 100644 --- a/views.py +++ b/views.py @@ -54,7 +54,7 @@ def check_repository(request): @login_required() def start_connection(request, conn=None, **kwargs): - public_user_allowed = strtobool(request.GET.get('allow_public_user', default='true')) + public_user_allowed = bool(strtobool(request.GET.get('allow_public_user', default='true'))) if not public_user_allowed: if settings.OME_PUBLIC_USER is None: return HttpResponseServerError('"omero.web.ome_seadragon.ome_public_user" property was not configured on the server') @@ -71,14 +71,14 @@ def check_image_path(request, image_id, conn=None, **kwargs): def get_example_viewer(request, image_id): base_url = '%s://%s' % (request.META['wsgi.url_scheme'], request.META['HTTP_HOST']) - mirax = strtobool(request.GET.get('mirax_image', default='false')) + mirax = bool(strtobool(request.GET.get('mirax_image', default='false'))) return render(request, 'ome_seadragon/test/test_viewer.html', {'image_id': image_id, 'host_name': base_url, 'mirax': mirax}) def get_example_viewer_json(request, image_id): base_url = '%s://%s' % (request.META['wsgi.url_scheme'], request.META['HTTP_HOST']) - mirax = strtobool(request.GET.get('mirax_image', default='false')) + mirax = bool(strtobool(request.GET.get('mirax_image', default='false'))) return render(request, 'ome_seadragon/test/test_viewer_json.html', {'image_id': image_id, 'host_name': base_url, 'mirax': mirax}) @@ -99,7 +99,7 @@ def get_example_double_viewer(request, image_a_id, image_b_id): def get_example_annotations(request, image_id): base_url = '%s://%s' % (request.META['wsgi.url_scheme'], request.META['HTTP_HOST']) - mirax = strtobool(request.GET.get('mirax_image', default='false')) + mirax = bool(strtobool(request.GET.get('mirax_image', default='false'))) return render(request, 'ome_seadragon/test/test_annotations.html', {'image_id': image_id, 'host_name': base_url, 'mirax': mirax}) @@ -112,28 +112,28 @@ def get_example_ome_rois(request, image_id): def get_example_interactive_markers(request, image_id): base_url = '%s://%s' % (request.META['wsgi.url_scheme'], request.META['HTTP_HOST']) - mirax = strtobool(request.GET.get('mirax_image', default='false')) + mirax = bool(strtobool(request.GET.get('mirax_image', default='false'))) return render(request, 'ome_seadragon/test/test_markers.html', {'image_id': image_id, 'host_name': base_url, 'mirax': mirax}) def get_example_interactive_polygons(request, image_id): base_url = '%s://%s' % (request.META['wsgi.url_scheme'], request.META['HTTP_HOST']) - mirax = strtobool(request.GET.get('mirax_image', default='false')) + mirax = bool(strtobool(request.GET.get('mirax_image', default='false'))) return render(request, 'ome_seadragon/test/test_polygons.html', {'image_id': image_id, 'host_name': base_url, 'mirax': mirax}) def get_example_interactive_rulers(request, image_id): base_url = '%s://%s' % (request.META['wsgi.url_scheme'], request.META['HTTP_HOST']) - mirax = strtobool(request.GET.get('mirax_image', default='false')) + mirax = bool(strtobool(request.GET.get('mirax_image', default='false'))) return render(request, 'ome_seadragon/test/test_rulers.html', {'image_id': image_id, 'host_name': base_url, 'mirax': mirax}) def get_example_interactive_freehand(request, image_id): base_url = '%s://%s' % (request.META['wsgi.url_scheme'], request.META['HTTP_HOST']) - mirax = strtobool(request.GET.get('mirax_image', default='false')) + mirax = bool(strtobool(request.GET.get('mirax_image', default='false'))) return render(request, 'ome_seadragon/test/test_freehand_drawing.html', {'image_id': image_id, 'host_name': base_url, 'mirax': mirax}) @@ -146,7 +146,7 @@ def get_example_array_viewer(request, dataset_label): def get_example_overlay_viewer(request, image_id, dataset_label): base_url = '%s://%s' % (request.META['wsgi.url_scheme'], request.META['HTTP_HOST']) - mirax = strtobool(request.GET.get('mirax_image', default='false')) + mirax = bool(strtobool(request.GET.get('mirax_image', default='false'))) return render(request, 'ome_seadragon/test/test_overlay_viewer.html', {'image_id': image_id, 'dataset_label': dataset_label, 'host_name': base_url , 'mirax': mirax}) @@ -155,7 +155,7 @@ def get_example_overlay_viewer(request, image_id, dataset_label): @login_required() def get_projects(request, conn=None, **kwargs): try: - fetch_datasets = strtobool(request.GET.get('datasets')) + fetch_datasets = bool(strtobool(request.GET.get('datasets'))) except (ValueError, AttributeError): fetch_datasets = False projects = projects_datasets.get_projects(conn, fetch_datasets) @@ -165,15 +165,15 @@ def get_projects(request, conn=None, **kwargs): @login_required() def get_project(request, project_id, conn=None, **kwargs): try: - fetch_datasets = strtobool(request.GET.get('datasets')) + fetch_datasets = bool(strtobool(request.GET.get('datasets'))) except (ValueError, AttributeError): fetch_datasets = False try: - fetch_images = strtobool(request.GET.get('images')) + fetch_images = bool(strtobool(request.GET.get('images'))) except (ValueError, AttributeError): fetch_images = False try: - expand_series = strtobool(request.GET.get('full_series')) + expand_series = bool(strtobool(request.GET.get('full_series'))) except (ValueError, AttributeError): expand_series = False project = projects_datasets.get_project(conn, project_id, fetch_datasets, fetch_images, @@ -184,11 +184,11 @@ def get_project(request, project_id, conn=None, **kwargs): @login_required() def get_dataset(request, dataset_id, conn=None, **kwargs): try: - fetch_images = strtobool(request.GET.get('images')) + fetch_images = bool(strtobool(request.GET.get('images'))) except (ValueError, AttributeError): fetch_images = False try: - expand_series = strtobool(request.GET.get('full_series')) + expand_series = bool(strtobool(request.GET.get('full_series'))) except (ValueError, AttributeError): expand_series = False dataset = projects_datasets.get_dataset(conn, dataset_id, fetch_images, @@ -199,7 +199,7 @@ def get_dataset(request, dataset_id, conn=None, **kwargs): @login_required() def get_image(request, image_id, conn=None, **kwargs): try: - fetch_rois = strtobool(request.GET.get('rois')) + fetch_rois = bool(strtobool(request.GET.get('rois'))) except (ValueError, AttributeError): fetch_rois = False image = projects_datasets.get_image(conn, image_id, fetch_rois) @@ -209,7 +209,7 @@ def get_image(request, image_id, conn=None, **kwargs): @login_required() def get_images_quick_list(request, conn=None, **kwargs): try: - expand_series = strtobool(request.GET.get('full_series')) + expand_series = bool(strtobool(request.GET.get('full_series'))) except (ValueError, AttributeError): expand_series = False images_list = projects_datasets.get_images_quick_list(conn, expand_series) @@ -219,7 +219,7 @@ def get_images_quick_list(request, conn=None, **kwargs): @login_required() def get_annotations(request, conn=None, **kwargs): try: - fetch_images = strtobool(request.GET.get('fetch_imgs')) + fetch_images = bool(strtobool(request.GET.get('fetch_imgs'))) except (ValueError, AttributeError): fetch_images = False annotations = tags_data.get_annotations_list(conn, fetch_images) @@ -229,11 +229,11 @@ def get_annotations(request, conn=None, **kwargs): @login_required() def get_tagset(request, tagset_id, conn=None, **kwargs): try: - fetch_tags = strtobool(request.GET.get('tags')) + fetch_tags = bool(strtobool(request.GET.get('tags'))) except (ValueError, AttributeError): fetch_tags = False try: - fetch_images = strtobool(request.GET.get('images')) + fetch_images = bool(strtobool(request.GET.get('images'))) except (ValueError, AttributeError): fetch_images = False tagset = tags_data.get_tagset(conn, tagset_id, fetch_tags, fetch_images) @@ -243,7 +243,7 @@ def get_tagset(request, tagset_id, conn=None, **kwargs): @login_required() def get_tag(request, tag_id, conn=None, **kwargs): try: - fetch_images = strtobool(request.GET.get('images')) + fetch_images = bool(strtobool(request.GET.get('images'))) except (ValueError, AttributeError): fetch_images = False tag = tags_data.get_tag(conn, tag_id, fetch_images) @@ -254,7 +254,7 @@ def get_tag(request, tag_id, conn=None, **kwargs): def find_annotations(request, conn=None, **kwargs): search_pattern = request.GET.get('query') try: - fetch_images = strtobool(request.GET.get('fetch_imgs')) + fetch_images = bool(strtobool(request.GET.get('fetch_imgs'))) except (ValueError, AttributeError): fetch_images = False logger.debug('"fetch_imgs" value %r', fetch_images) @@ -269,7 +269,7 @@ def get_image_dzi(request, image_id, fetch_original_file=False, file_mimetype=No except TypeError: tile_size = None try: - limit_bounds = strtobool(request.GET.get('limit_bounds')) + limit_bounds = bool(strtobool(request.GET.get('limit_bounds'))) except AttributeError: limit_bounds = None rf = RenderingEngineFactory() @@ -371,7 +371,7 @@ def get_tile(request, image_id, level, column, row, tile_format, except TypeError: tile_size = None try: - limit_bounds = strtobool(request.GET.get('limit_bounds')) + limit_bounds = bool(strtobool(request.GET.get('limit_bounds'))) except AttributeError: limit_bounds = None if tile_format != settings.DEEPZOOM_FORMAT: @@ -481,6 +481,28 @@ def register_mirax_slide(request, conn=None, **kwargs): return HttpResponseServerError('{0}'.format(sce)) +@login_required() +def get_mirax_slide_details(request, slide_id, conn=None, **kwargs): + mirax_data_folder = get_original_file(conn, slide_id, 'mirax/datafolder') + mirax_index_file = get_original_file(conn, slide_id, 'mirax/index') + slide_details = { + 'slide_label': slide_id, + 'index_file': { + 'omero_id': mirax_index_file.getId(), + 'label': mirax_index_file.getName(), + 'mimetype': mirax_index_file.getMimetype(), + 'hash': mirax_index_file.getHash() + }, + 'data_folder': { + 'omero_id': mirax_data_folder.getId(), + 'label': mirax_data_folder.getName(), + 'mimetype': mirax_data_folder.getMimetype(), + 'hash': mirax_data_folder.getHash() + } + } + return HttpResponse(json.dumps(slide_details), content_type='application/json') + + @login_required() def list_array_datasets(request, conn=None, **kwargs): datasets = datasets_files.get_datasets(conn) @@ -495,11 +517,11 @@ def register_array_dataset(request, conn=None, **kwargs): try: dataset_path, is_dir = datasets_files.get_dataset_file_path(dataset_label) if not is_dir: - if strtobool(request.GET.get('extract_archive', default='true')) == False: + if bool(strtobool(request.GET.get('extract_archive', default='true'))) == False: dataset_label, dataset_path = datasets_files.rename_archive(dataset_path) else: try: - keep_archive = strtobool(request.GET.get('keep_archive', default='false')) + keep_archive = bool(strtobool(request.GET.get('keep_archive', default='false'))) dataset_label, dataset_path = datasets_files.extract_archive(dataset_path, keep_archive=keep_archive) is_dir = True