Fixed imports, and PEP8 styling
This commit is contained in:
parent
298bc2ba6a
commit
89ea6a69de
3 changed files with 30 additions and 33 deletions
|
|
@ -1 +1 @@
|
||||||
from .plugin import StackPlugin
|
from .plugin import ScanPlugin
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
from openflexure_microscope.api.v1.views import MicroscopeViewPlugin
|
from openflexure_microscope.api.v1.views import MicroscopeViewPlugin
|
||||||
from openflexure_microscope.api.utilities import JsonPayload
|
from openflexure_microscope.api.utilities import JsonPayload
|
||||||
|
|
||||||
|
|
@ -9,7 +7,7 @@ from flask import request, jsonify, abort
|
||||||
class TileScanAPI(MicroscopeViewPlugin):
|
class TileScanAPI(MicroscopeViewPlugin):
|
||||||
def post(self):
|
def post(self):
|
||||||
payload = JsonPayload(request)
|
payload = JsonPayload(request)
|
||||||
|
|
||||||
# Get params
|
# Get params
|
||||||
name = payload.param('name')
|
name = payload.param('name')
|
||||||
step_size = payload.param('step_size', default=[2000, 1500], convert=list)
|
step_size = payload.param('step_size', default=[2000, 1500], convert=list)
|
||||||
|
|
@ -31,29 +29,28 @@ class TileScanAPI(MicroscopeViewPlugin):
|
||||||
print("Running tile scan...")
|
print("Running tile scan...")
|
||||||
task = self.microscope.task.start(
|
task = self.microscope.task.start(
|
||||||
self.plugin.tile,
|
self.plugin.tile,
|
||||||
basename = name,
|
basename=name,
|
||||||
step_size = step_size,
|
step_size=step_size,
|
||||||
grid = grid,
|
grid=grid,
|
||||||
autofocus_dz = autofocus_dz,
|
autofocus_dz=autofocus_dz,
|
||||||
use_video_port = use_video_port,
|
use_video_port=use_video_port,
|
||||||
resize = resize,
|
resize=resize,
|
||||||
bayer = bayer,
|
bayer=bayer,
|
||||||
metadata = metadata,
|
metadata=metadata,
|
||||||
tags = tags
|
tags=tags
|
||||||
)
|
)
|
||||||
|
|
||||||
# return a handle on the autofocus task
|
# return a handle on the autofocus task
|
||||||
return jsonify(task.state, 202)
|
return jsonify(task.state, 202)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ZStackAPI(MicroscopeViewPlugin):
|
class ZStackAPI(MicroscopeViewPlugin):
|
||||||
def post(self):
|
def post(self):
|
||||||
payload = JsonPayload(request)
|
payload = JsonPayload(request)
|
||||||
|
|
||||||
# Get params
|
# Get params
|
||||||
name = payload.param('name')
|
name = payload.param('name')
|
||||||
step_size = payload.param('step_size', default=[2000, 1500], convert=list)
|
step_size = payload.param('step_size', default=100, convert=int)
|
||||||
steps = payload.param('steps', default=5, convert=int)
|
steps = payload.param('steps', default=5, convert=int)
|
||||||
center = payload.param('center', default=True, convert=bool)
|
center = payload.param('center', default=True, convert=bool)
|
||||||
|
|
||||||
|
|
@ -72,16 +69,16 @@ class ZStackAPI(MicroscopeViewPlugin):
|
||||||
print("Running tile scan...")
|
print("Running tile scan...")
|
||||||
task = self.microscope.task.start(
|
task = self.microscope.task.start(
|
||||||
self.plugin.stack,
|
self.plugin.stack,
|
||||||
basename = name,
|
basename=name,
|
||||||
step_size = step_size,
|
step_size=step_size,
|
||||||
steps = steps,
|
steps=steps,
|
||||||
center = center,
|
center=center,
|
||||||
use_video_port = use_video_port,
|
use_video_port=use_video_port,
|
||||||
resize = resize,
|
resize=resize,
|
||||||
bayer = bayer,
|
bayer=bayer,
|
||||||
metadata = metadata,
|
metadata=metadata,
|
||||||
tags = tags
|
tags=tags
|
||||||
)
|
)
|
||||||
|
|
||||||
# return a handle on the autofocus task
|
# return a handle on the autofocus task
|
||||||
return jsonify(task.state, 202)
|
return jsonify(task.state, 202)
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@ import uuid
|
||||||
|
|
||||||
from openflexure_microscope.camera.base import generate_basename
|
from openflexure_microscope.camera.base import generate_basename
|
||||||
from openflexure_microscope.plugins import MicroscopePlugin
|
from openflexure_microscope.plugins import MicroscopePlugin
|
||||||
from openflexure_microscope.utilities import set_properties
|
|
||||||
|
|
||||||
from .api import TileScanAPI, ZStackAPI
|
from .api import TileScanAPI, ZStackAPI
|
||||||
|
|
||||||
|
|
||||||
class ScanPlugin(MicroscopePlugin):
|
class ScanPlugin(MicroscopePlugin):
|
||||||
"""
|
"""
|
||||||
Stack and tile plugin
|
Stack and tile plugin
|
||||||
|
|
@ -19,7 +19,6 @@ class ScanPlugin(MicroscopePlugin):
|
||||||
'/stack': ZStackAPI,
|
'/stack': ZStackAPI,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def capture(self,
|
def capture(self,
|
||||||
basename,
|
basename,
|
||||||
scan_id,
|
scan_id,
|
||||||
|
|
@ -95,7 +94,8 @@ class ScanPlugin(MicroscopePlugin):
|
||||||
for j in range(grid[1]):
|
for j in range(grid[1]):
|
||||||
|
|
||||||
if autofocus_enabled:
|
if autofocus_enabled:
|
||||||
self.microscope.plugin.default_autofocus.autofocus(range(-2*autofocus_dz, 3*autofocus_dz, autofocus_dz))
|
self.microscope.plugin.default_autofocus.autofocus(
|
||||||
|
range(-2 * autofocus_dz, 3 * autofocus_dz, autofocus_dz))
|
||||||
|
|
||||||
self.capture(
|
self.capture(
|
||||||
basename,
|
basename,
|
||||||
|
|
@ -108,11 +108,11 @@ class ScanPlugin(MicroscopePlugin):
|
||||||
)
|
)
|
||||||
|
|
||||||
if j != grid[0] - 1:
|
if j != grid[0] - 1:
|
||||||
self.microscope.stage.move_rel([step_size[0]*xdirection, 0, 0])
|
self.microscope.stage.move_rel([step_size[0] * xdirection, 0, 0])
|
||||||
|
|
||||||
xdirection *= -1
|
xdirection *= -1
|
||||||
if i != grid[1] - 1:
|
if i != grid[1] - 1:
|
||||||
self.microscope.stage.move_rel([256*xdirection, step_size[1], 0])
|
self.microscope.stage.move_rel([256 * xdirection, step_size[1], 0])
|
||||||
|
|
||||||
self.microscope.stage.move_abs(initial_position)
|
self.microscope.stage.move_abs(initial_position)
|
||||||
|
|
||||||
|
|
@ -120,7 +120,7 @@ class ScanPlugin(MicroscopePlugin):
|
||||||
self,
|
self,
|
||||||
basename: str = None,
|
basename: str = None,
|
||||||
step_size: int = 100,
|
step_size: int = 100,
|
||||||
steps: list = 5,
|
steps: int = 5,
|
||||||
center: bool = True,
|
center: bool = True,
|
||||||
use_video_port: bool = False,
|
use_video_port: bool = False,
|
||||||
resize: Tuple[int, int] = None,
|
resize: Tuple[int, int] = None,
|
||||||
|
|
@ -140,7 +140,7 @@ class ScanPlugin(MicroscopePlugin):
|
||||||
|
|
||||||
# Move to center scan
|
# Move to center scan
|
||||||
if center:
|
if center:
|
||||||
self.microscope.stage.move_rel([0, 0, int((-step_size * steps)/2)])
|
self.microscope.stage.move_rel([0, 0, int((-step_size * steps) / 2)])
|
||||||
|
|
||||||
with self.microscope.lock:
|
with self.microscope.lock:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue