Thing properties for autofocus dz, overlap and range limit
This commit is contained in:
parent
9a3e870d21
commit
090f447d26
2 changed files with 82 additions and 12 deletions
|
|
@ -330,7 +330,6 @@ class SmartScanThing(Thing):
|
||||||
csm: CSMDep,
|
csm: CSMDep,
|
||||||
background_detect: BackgroundDep,
|
background_detect: BackgroundDep,
|
||||||
recentre: RecentreStage,
|
recentre: RecentreStage,
|
||||||
overlap: float = 0.4,
|
|
||||||
):
|
):
|
||||||
"""Move the stage to cover an area, taking images that can be tiled together.
|
"""Move the stage to cover an area, taking images that can be tiled together.
|
||||||
|
|
||||||
|
|
@ -354,6 +353,8 @@ class SmartScanThing(Thing):
|
||||||
names = []
|
names = []
|
||||||
positions = []
|
positions = []
|
||||||
|
|
||||||
|
max_dist = self.max_range
|
||||||
|
|
||||||
# Record the starting position so we can move back there afterwards
|
# Record the starting position so we can move back there afterwards
|
||||||
starting_position = stage.position
|
starting_position = stage.position
|
||||||
|
|
||||||
|
|
@ -375,13 +376,13 @@ class SmartScanThing(Thing):
|
||||||
# TODO: this downsampling by two is to deal with a camera issue
|
# TODO: this downsampling by two is to deal with a camera issue
|
||||||
img_width = int(arr.shape[1] / 2)
|
img_width = int(arr.shape[1] / 2)
|
||||||
|
|
||||||
|
overlap = self.overlap
|
||||||
|
|
||||||
dx = int(np.dot(np.array([0, arr.shape[1] * (1 - overlap)]), CSM)[0])
|
dx = int(np.dot(np.array([0, arr.shape[1] * (1 - overlap)]), CSM)[0])
|
||||||
dy = int(np.dot(np.array([arr.shape[0] * (1 - overlap), 0]), CSM)[1])
|
dy = int(np.dot(np.array([arr.shape[0] * (1 - overlap), 0]), CSM)[1])
|
||||||
|
|
||||||
logger.info(f"Based on an overlap of {overlap}, we will make steps of {dx}, {dy}")
|
logger.info(f"Based on an overlap of {overlap}, we will make steps of {dx}, {dy}")
|
||||||
|
|
||||||
dz = 3000 # This is used for autofocus - make configurable?
|
|
||||||
|
|
||||||
# construct a 2D scan path
|
# construct a 2D scan path
|
||||||
path = [[stage.position["x"], stage.position["y"]]]
|
path = [[stage.position["x"], stage.position["y"]]]
|
||||||
|
|
||||||
|
|
@ -446,7 +447,7 @@ class SmartScanThing(Thing):
|
||||||
|
|
||||||
attempts = 0
|
attempts = 0
|
||||||
while True:
|
while True:
|
||||||
recentre.looping_autofocus(dz=3000)
|
recentre.looping_autofocus(dz=self.autofocus_dz)
|
||||||
current_height = stage.position["z"]
|
current_height = stage.position["z"]
|
||||||
|
|
||||||
# if there have been successful autofocuses in this scan, find the closest one in x-y
|
# if there have been successful autofocuses in this scan, find the closest one in x-y
|
||||||
|
|
@ -508,6 +509,16 @@ class SmartScanThing(Thing):
|
||||||
if len(names) > 1:
|
if len(names) > 1:
|
||||||
generate_config(images_folder, positions, names, CSM, csm_calibration_width, img_width, logger)
|
generate_config(images_folder, positions, names, CSM, csm_calibration_width, img_width, logger)
|
||||||
|
|
||||||
|
temp_path = []
|
||||||
|
|
||||||
|
for i in path:
|
||||||
|
if distance_to_site(i, true_path[0][:2]) < max_dist:
|
||||||
|
temp_path.append(i)
|
||||||
|
else:
|
||||||
|
logger.info(f'Rejected moving to {i} as it is out of range')
|
||||||
|
|
||||||
|
path = temp_path.copy()
|
||||||
|
|
||||||
path = sorted(path, key=lambda x: (steps_from_centre(x, true_path[0][:2], dx, dy), distance_to_site(loc[:2], x)))
|
path = sorted(path, key=lambda x: (steps_from_centre(x, true_path[0][:2], dx, dy), distance_to_site(loc[:2], x)))
|
||||||
|
|
||||||
if len(true_path) > 750:
|
if len(true_path) > 750:
|
||||||
|
|
@ -526,6 +537,33 @@ class SmartScanThing(Thing):
|
||||||
logger.info("Returning to starting position.")
|
logger.info("Returning to starting position.")
|
||||||
stage.move_absolute(**starting_position, block_cancellation=True)
|
stage.move_absolute(**starting_position, block_cancellation=True)
|
||||||
|
|
||||||
|
@thing_property
|
||||||
|
def max_range(self) -> int:
|
||||||
|
"""The maximum distance from the centre of the scan before we break"""
|
||||||
|
return self.thing_settings.get("max_range", 400000)
|
||||||
|
|
||||||
|
@max_range.setter
|
||||||
|
def max_range(self, value: int) -> None:
|
||||||
|
self.thing_settings["max_range"] = value
|
||||||
|
|
||||||
|
@thing_property
|
||||||
|
def autofocus_dz(self) -> int:
|
||||||
|
"""The z distance to perform an autofocus"""
|
||||||
|
return self.thing_settings.get("autofocus_dz", 3000)
|
||||||
|
|
||||||
|
@autofocus_dz.setter
|
||||||
|
def autofocus_dz(self, value: int) -> None:
|
||||||
|
self.thing_settings["autofocus_dz"] = value
|
||||||
|
|
||||||
|
@thing_property
|
||||||
|
def overlap(self) -> float:
|
||||||
|
"""The z distance to perform an autofocus"""
|
||||||
|
return self.thing_settings.get("overlap", 0.4)
|
||||||
|
|
||||||
|
@overlap.setter
|
||||||
|
def overlap(self, value: float) -> None:
|
||||||
|
self.thing_settings["overlap"] = value
|
||||||
|
|
||||||
@thing_property
|
@thing_property
|
||||||
def scans(self) -> list[ScanInfo]:
|
def scans(self) -> list[ScanInfo]:
|
||||||
"""All the available scans
|
"""All the available scans
|
||||||
|
|
@ -614,4 +652,4 @@ class SmartScanThing(Thing):
|
||||||
Use with extreme caution.
|
Use with extreme caution.
|
||||||
"""
|
"""
|
||||||
for scan in self.scans:
|
for scan in self.scans:
|
||||||
self.delete_scan(scan.name)
|
self.delete_scan(scan.name)
|
||||||
|
|
@ -4,22 +4,54 @@
|
||||||
No scan back-end found.
|
No scan back-end found.
|
||||||
</div>
|
</div>
|
||||||
<div v-show="backendOK">
|
<div v-show="backendOK">
|
||||||
<taskSubmitter
|
<ul uk-accordion="multiple: true">
|
||||||
:submit-url="smartScanUri"
|
<li>
|
||||||
submit-label="Start tiled scan"
|
<a class="uk-accordion-title" href="#">Configure</a>
|
||||||
:can-terminate="true"
|
<div class="uk-accordion-content">
|
||||||
:modal-progress="true"
|
<div class="uk-margin">
|
||||||
/>
|
<propertyControl
|
||||||
|
thing-name="smart_scan"
|
||||||
|
property-name="max_range"
|
||||||
|
label="Maximum Distance (steps)"
|
||||||
|
/>
|
||||||
|
<div class="uk-margin">
|
||||||
|
<propertyControl
|
||||||
|
thing-name="smart_scan"
|
||||||
|
property-name="autofocus_dz"
|
||||||
|
label="Autofocus range (steps)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="uk-margin">
|
||||||
|
<propertyControl
|
||||||
|
thing-name="smart_scan"
|
||||||
|
property-name="overlap"
|
||||||
|
label="Image overlap (0-1)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="uk-margin">
|
||||||
|
<taskSubmitter
|
||||||
|
:submit-url="smartScanUri"
|
||||||
|
submit-label="Start tiled scan"
|
||||||
|
:can-terminate="true"
|
||||||
|
:modal-progress="true"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import taskSubmitter from "../../genericComponents/taskSubmitter";
|
import taskSubmitter from "../../genericComponents/taskSubmitter";
|
||||||
|
import propertyControl from "../../labThingsComponents/propertyControl.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
taskSubmitter
|
taskSubmitter,
|
||||||
|
propertyControl
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue