Code formatting
This commit is contained in:
parent
0234b20ce3
commit
2bfb988460
60 changed files with 392 additions and 396 deletions
|
|
@ -1,18 +1,16 @@
|
|||
from labthings import fields, find_component, current_action
|
||||
from labthings.extensions import BaseExtension
|
||||
from labthings.views import View, ActionView, PropertyView
|
||||
|
||||
from openflexure_microscope.devel import JsonResponse, request, abort
|
||||
from openflexure_microscope.utilities import set_properties
|
||||
|
||||
import time
|
||||
import numpy as np
|
||||
|
||||
import logging
|
||||
from scipy import ndimage
|
||||
import time
|
||||
from contextlib import contextmanager
|
||||
from threading import Event, Thread
|
||||
|
||||
from threading import Thread, Event
|
||||
import numpy as np
|
||||
from labthings import current_action, fields, find_component
|
||||
from labthings.extensions import BaseExtension
|
||||
from labthings.views import ActionView, PropertyView, View
|
||||
from scipy import ndimage
|
||||
|
||||
from openflexure_microscope.devel import JsonResponse, abort, request
|
||||
from openflexure_microscope.utilities import set_properties
|
||||
|
||||
### Autofocus utilities
|
||||
|
||||
|
|
@ -447,4 +445,3 @@ autofocus_extension_v2.add_view(
|
|||
autofocus_extension_v2.add_view(
|
||||
MoveAndMeasureAPI, "/move_and_measure", endpoint="move_and_measure"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,18 @@
|
|||
from labthings.extensions import BaseExtension
|
||||
from labthings.views import View, PropertyView
|
||||
from labthings import fields, find_component
|
||||
|
||||
from openflexure_microscope.paths import settings_file_path, check_rw
|
||||
from openflexure_microscope.config import OpenflexureSettingsFile
|
||||
from openflexure_microscope.captures.capture_manager import BASE_CAPTURE_PATH
|
||||
from openflexure_microscope.captures.capture import build_captures_from_exif
|
||||
|
||||
from openflexure_microscope.api.utilities.gui import build_gui
|
||||
|
||||
from flask import abort
|
||||
import logging
|
||||
import os
|
||||
import psutil
|
||||
|
||||
from sys import platform
|
||||
|
||||
import psutil
|
||||
from flask import abort
|
||||
from labthings import fields, find_component
|
||||
from labthings.extensions import BaseExtension
|
||||
from labthings.views import PropertyView, View
|
||||
|
||||
from openflexure_microscope.api.utilities.gui import build_gui
|
||||
from openflexure_microscope.captures.capture import build_captures_from_exif
|
||||
from openflexure_microscope.captures.capture_manager import BASE_CAPTURE_PATH
|
||||
from openflexure_microscope.config import OpenflexureSettingsFile
|
||||
from openflexure_microscope.paths import check_rw, settings_file_path
|
||||
|
||||
AS_SETTINGS_PATH = settings_file_path("autostorage_settings.json")
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
from labthings import find_component
|
||||
from labthings.views import View, ActionView
|
||||
from labthings.extensions import BaseExtension
|
||||
|
||||
from flask import abort
|
||||
|
||||
from contextlib import contextmanager
|
||||
import logging
|
||||
from contextlib import contextmanager
|
||||
|
||||
# Type hinting
|
||||
from typing import Tuple
|
||||
|
||||
from flask import abort
|
||||
from labthings import find_component
|
||||
from labthings.extensions import BaseExtension
|
||||
from labthings.views import ActionView, View
|
||||
|
||||
from .recalibrate_utils import (
|
||||
recalibrate_camera,
|
||||
auto_expose_and_freeze_settings,
|
||||
flat_lens_shading_table,
|
||||
recalibrate_camera,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -125,5 +124,9 @@ lst_extension_v2.add_method(
|
|||
)
|
||||
|
||||
lst_extension_v2.add_view(RecalibrateView, "/recalibrate", endpoint="recalibrate")
|
||||
lst_extension_v2.add_view(FlattenLSTView, "/flatten_lens_shading_table", endpoint="flatten_lens_shading_table")
|
||||
lst_extension_v2.add_view(DeleteLSTView, "/delete_lens_shading_table", endpoint="delete_lens_shading_table")
|
||||
lst_extension_v2.add_view(
|
||||
FlattenLSTView, "/flatten_lens_shading_table", endpoint="flatten_lens_shading_table"
|
||||
)
|
||||
lst_extension_v2.add_view(
|
||||
DeleteLSTView, "/delete_lens_shading_table", endpoint="delete_lens_shading_table"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import numpy as np
|
||||
import time
|
||||
import logging
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
from picamerax import PiCamera
|
||||
from picamerax.array import PiRGBArray, PiBayerArray
|
||||
from picamerax.array import PiBayerArray, PiRGBArray
|
||||
|
||||
|
||||
def rgb_image(camera, resize=None, **kwargs):
|
||||
|
|
|
|||
|
|
@ -1,21 +1,24 @@
|
|||
import datetime
|
||||
import itertools
|
||||
import logging
|
||||
import time
|
||||
import uuid
|
||||
import datetime
|
||||
from typing import Tuple
|
||||
from functools import reduce
|
||||
from typing import Tuple
|
||||
|
||||
from labthings import (
|
||||
current_action,
|
||||
fields,
|
||||
find_component,
|
||||
find_extension,
|
||||
update_action_progress,
|
||||
)
|
||||
from labthings.extensions import BaseExtension
|
||||
from labthings.views import ActionView, View
|
||||
|
||||
from openflexure_microscope.captures.capture_manager import generate_basename
|
||||
|
||||
from labthings import fields, find_component, find_extension, current_action, update_action_progress
|
||||
from labthings.views import View, ActionView
|
||||
from labthings.extensions import BaseExtension
|
||||
|
||||
from openflexure_microscope.devel import abort
|
||||
|
||||
import time
|
||||
|
||||
|
||||
### Grid construction
|
||||
|
||||
|
||||
|
|
@ -56,9 +59,6 @@ def flatten_grid(grid):
|
|||
### Capturing
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class ScanExtension(BaseExtension):
|
||||
def __init__(self):
|
||||
self._images_to_be_captured: int = 1
|
||||
|
|
@ -83,7 +83,12 @@ class ScanExtension(BaseExtension):
|
|||
if namemode == "coordinates":
|
||||
filename = "{}_{}_{}_{}".format(basename, *microscope.stage.position)
|
||||
else:
|
||||
filename = "{}_{}".format(basename, str(self._images_captured_so_far).zfill(len(str(self._images_to_be_captured))))
|
||||
filename = "{}_{}".format(
|
||||
basename,
|
||||
str(self._images_captured_so_far).zfill(
|
||||
len(str(self._images_to_be_captured))
|
||||
),
|
||||
)
|
||||
folder = "SCAN_{}".format(basename)
|
||||
|
||||
# Do capture
|
||||
|
|
@ -97,14 +102,14 @@ class ScanExtension(BaseExtension):
|
|||
annotations=annotations,
|
||||
tags=tags,
|
||||
metadata=metadata,
|
||||
cache_key=folder
|
||||
cache_key=folder,
|
||||
)
|
||||
|
||||
def progress(self):
|
||||
progress = (self._images_captured_so_far / self._images_to_be_captured) * 100
|
||||
logging.info(progress)
|
||||
return progress
|
||||
|
||||
|
||||
### Scanning
|
||||
def tile(
|
||||
self,
|
||||
|
|
@ -164,7 +169,9 @@ class ScanExtension(BaseExtension):
|
|||
autofocus_enabled = False
|
||||
|
||||
# Construct an x-y grid (worry about z later)
|
||||
x_y_grid = construct_grid(initial_position, stride_size[:2], grid[:2], style=style)
|
||||
x_y_grid = construct_grid(
|
||||
initial_position, stride_size[:2], grid[:2], style=style
|
||||
)
|
||||
|
||||
# Keep the initial Z position the same as our current position
|
||||
initial_z = initial_position[2]
|
||||
|
|
@ -245,7 +252,6 @@ class ScanExtension(BaseExtension):
|
|||
end = time.time()
|
||||
logging.info(f"Scan took {end - start} seconds")
|
||||
|
||||
|
||||
def stack(
|
||||
self,
|
||||
microscope,
|
||||
|
|
@ -304,6 +310,7 @@ class ScanExtension(BaseExtension):
|
|||
|
||||
scan_extension_v2 = ScanExtension()
|
||||
|
||||
|
||||
class TileScanAPI(ActionView):
|
||||
args = {
|
||||
"filename": fields.String(missing=None, example=None),
|
||||
|
|
@ -365,4 +372,5 @@ class TileScanAPI(ActionView):
|
|||
tags=args.get("tags"),
|
||||
)
|
||||
|
||||
|
||||
scan_extension_v2.add_view(TileScanAPI, "/tile", endpoint="tile")
|
||||
|
|
|
|||
|
|
@ -1,21 +1,17 @@
|
|||
from openflexure_microscope.devel import (
|
||||
JsonResponse,
|
||||
request,
|
||||
)
|
||||
|
||||
from flask import send_file, abort, url_for
|
||||
|
||||
import uuid
|
||||
import os
|
||||
import zipfile
|
||||
import tempfile
|
||||
import logging
|
||||
import os
|
||||
import tempfile
|
||||
import uuid
|
||||
import zipfile
|
||||
|
||||
from flask import abort, send_file, url_for
|
||||
from labthings import fields, find_component, update_action_progress
|
||||
from labthings.views import View, ActionView, PropertyView
|
||||
from labthings.schema import Schema, pre_dump
|
||||
from labthings.extensions import BaseExtension
|
||||
from labthings.schema import Schema, pre_dump
|
||||
from labthings.utilities import description_from_view
|
||||
from labthings.views import ActionView, PropertyView, View
|
||||
|
||||
from openflexure_microscope.devel import JsonResponse, request
|
||||
|
||||
|
||||
class ZipObjectSchema(Schema):
|
||||
|
|
@ -137,9 +133,7 @@ class ZipBuilderAPIView(ActionView):
|
|||
microscope = find_component("org.openflexure.microscope")
|
||||
|
||||
# Return a handle on the autofocus task
|
||||
return default_zip_manager.marshaled_build_zip_from_capture_ids(
|
||||
microscope, ids
|
||||
)
|
||||
return default_zip_manager.marshaled_build_zip_from_capture_ids(microscope, ids)
|
||||
|
||||
|
||||
class ZipListAPIView(PropertyView):
|
||||
|
|
@ -191,7 +185,9 @@ zip_extension_v2 = BaseExtension(
|
|||
description="Build and download capture collections as ZIP files",
|
||||
)
|
||||
|
||||
zip_extension_v2.add_view(ZipGetterAPIView, "/get/<string:session_id>", endpoint="get_id")
|
||||
zip_extension_v2.add_view(
|
||||
ZipGetterAPIView, "/get/<string:session_id>", endpoint="get_id"
|
||||
)
|
||||
zip_extension_v2.add_view(ZipListAPIView, "/get", endpoint="get")
|
||||
|
||||
zip_extension_v2.add_view(ZipBuilderAPIView, "/build", endpoint="build")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue