Option to run scan without background detect in webapp and Thing

This commit is contained in:
jaknpper 2024-01-09 20:24:51 +00:00
parent 89dae7ba80
commit d219e32bc8
2 changed files with 21 additions and 15 deletions

View file

@ -330,6 +330,7 @@ class SmartScanThing(Thing):
csm: CSMDep,
background_detect: BackgroundDep,
recentre: RecentreStage,
sample_check
):
"""Move the stage to cover an area, taking images that can be tiled together.
@ -345,16 +346,23 @@ class SmartScanThing(Thing):
# Before anything else, check that we've got a background set
# It's annoying to have to wait to find out!
max_dist = self.max_range
d = background_detect.background_distributions
if not d:
raise RuntimeError("Background is not set: you need to calibrate background detection.")
if sample_check:
d = background_detect.background_distributions
if not d:
raise RuntimeError("Background is not set: you need to calibrate background detection.")
else:
logger.warning(
"This scan will run in a spiral from the starting point "
f"until you cancel it, or until it has moved by {max_dist} steps "
"in every direction. Make sure you watch it run to stop it leaving "
"the area of interest, or (worse) leading the microscope's range "
"of motion."
)
names = []
positions = []
max_dist = self.max_range
# Record the starting position so we can move back there afterwards
starting_position = stage.position
@ -422,11 +430,13 @@ class SmartScanThing(Thing):
)
# Check if the image is background
image_is_sample = background_detect.image_is_sample()
if sample_check:
image_is_sample = background_detect.image_is_sample()
else:
image_is_sample = True
# if more than 92% of the image is background, treat it as background and continue
if not image_is_sample:
category = "background"
logger.info(f"Skipping {stage.position} as it is {round(background_detect.background_fraction(),0)}% background.")
else:
# if not, it's sample. run an autofocus and use the updated height
@ -443,8 +453,6 @@ class SmartScanThing(Thing):
):
path.append(pos)
category = "sample"
attempts = 0
while True:
recentre.looping_autofocus(dz=self.autofocus_dz)

View file

@ -35,15 +35,16 @@
<div class="uk-margin">
<taskSubmitter
:submit-url="smartScanUri"
:submit-data="{ sample_check: true }"
submit-label="Start smart scan"
:can-terminate="true"
:modal-progress="true"
/>
</div>
<div class="uk-margin">
<taskSubmitter
:submit-url="standardScanUri"
:submit-url="smartScanUri"
:submit-data="{ sample_check: false }"
submit-label="Start manual scan"
:can-terminate="true"
:modal-progress="true"
@ -69,9 +70,6 @@ export default {
},
smartScanUri() {
return this.thingActionUrl("smart_scan", "sample_scan");
},
standardScanUri() {
return this.thingActionUrl("smart_scan", "standard_scan");
}
},