Commit graph

56 commits

Author SHA1 Message Date
Richard Bowman
a965d04047 Move raw images folder inside images folder
This ensures images.zip contains everything - a neater solution
for this is TBD.
2024-01-11 13:56:24 +00:00
Richard Bowman
f4c4206a53 Return an empty scans list if the folder is missing 2024-01-11 13:40:47 +00:00
Richard Bowman
ba86c37292 Swap background detection from argument to property
For consistency, I've made background detection a property.
2024-01-11 03:21:50 +00:00
Richard Bowman
717cf7657c Combine stitcher and smart scan Things
I'm now running stitching in subprocesses during the scan.
This seems to be working well - I'm using multiple CPU
cores and getting images out. However, the only way to
avoid circular dependencies was to combine the Things.

I'm still getting not-infrequent memory allocation errors from the camera, which may or may not be related.
2024-01-11 01:49:24 +00:00
Richard Bowman
b5fbcc85b5 Succeed immediately if the stitched image is up to date
To save some CPU cycles, we will return immediately if the
images don't look newer than the stitch. NB this does mean
that the stitched image will be repeatedly transferred, as its
URL will change each time it's re-requested.

Alternatively, we could fail with an error, which may be more efficient, at the expense of being uglier.
2024-01-10 23:17:16 +00:00
Richard Bowman
00a4b38a83 Prevent scans from filling the SD card 2024-01-10 21:07:25 +00:00
Richard Bowman
8fb70bf43a Make latest_scan_name a property 2024-01-10 20:51:50 +00:00
Richard Bowman
9ce52c2845 Added a Thing to run stitching as Actions 2024-01-10 20:51:49 +00:00
Joe Knapper
1464d7d553 Restored old log path 2024-01-10 18:33:08 +00:00
jaknapper
6d622c1bf8 Avoid negative dx/dy and allow for float CSM image resolution 2024-01-10 15:38:34 +00:00
jaknpper
d219e32bc8 Option to run scan without background detect in webapp and Thing 2024-01-09 20:24:51 +00:00
Joe Knapper
090f447d26 Thing properties for autofocus dz, overlap and range limit 2024-01-08 19:33:24 +00:00
Richard Bowman
d615522712 Raw images and better cancellation
Cancelling a smart scan now resets position to the starting point.

a "raw images" folder now includes images without resampling.
2024-01-08 17:25:31 +00:00
Richard Bowman
26f5b1955e Reset position to starting point when CSM is cancelled
NB there's a confusing feature, where stage.move will
fail after the task has been cancelled, because it is cancellable.
For now, we can work around it by passing `block_cancellation` but
this may want to be solved more generally in LabThings
2024-01-08 17:24:18 +00:00
Richard Bowman
552fde45ed Improve logging commands
use logging.exception instead of setting exc_info.
2024-01-08 16:43:28 +00:00
jaknapper
4445990966 Check we have a background set before starting scan 2024-01-08 16:21:57 +00:00
jaknapper
ae68a1b319 Pseudo spiral scan path and fixed dx-dy inversion 2024-01-08 16:01:54 +00:00
jaknapper
a53062af83 Background detect fraction as a thing 2024-01-07 15:00:46 +00:00
jaknapper
9eb0b6a6b8 Log CSM result in a safe way 2024-01-05 18:41:57 +00:00
jaknapper
1ebf00ffb3 Fiji config file and low res capture to avoid exposure time drift 2024-01-05 17:23:44 +00:00
Richard Bowman
90a68ed4f1 Added endpoints to add and delete scans
This makes use of the new @fastapi_endpoint decorator
in labthings.
2024-01-05 00:42:24 +00:00
Richard Bowman
2ce143ff01 WIP: Exception handling and file management
It's now possible to see (via the HTTP API) scans and download
them as zip files. Zip files appear to be malformed at present.
2024-01-04 18:59:51 +00:00
Richard Bowman
1ca2c9ca0d Expand comments 2024-01-04 16:36:58 +00:00
Richard Bowman
bcc13475b6 Propagate logs from camera-stage-mapping 2024-01-04 13:19:00 +00:00
Richard Bowman
91cb514e08 Use blocking, non-cancellable moves in autofocus
Autofocus timing is pretty critical. I've introduced the ability
to abort moves, which introduces ~50ms timing jitter. This
commit reverts the tming-critical move in autofocus to the old behaviour.

I've only reverted the move that really matters - this means
that if you start a massive sweep by accident, you can still
abort it when it's moving down to the start of the sweep.
2024-01-04 10:46:27 +00:00
Richard Bowman
9f01a5ab29 WIP: logging and cancellability in smart_scan 2024-01-04 01:32:18 +00:00
Richard Bowman
09bec65b15 Add a Thing for API testing
This may not be in the codebase forever, but it's a very useful
sanity check to have during development.

The current implementation is clearly not a performance or
security risk.
2024-01-04 01:11:44 +00:00
Richard Bowman
d561ff4484 Update blocking portal syntax
spawn_task should be replaced with start_task_soon as per the
anyio API for v4.
2024-01-03 17:09:36 +00:00
Richard Bowman
25552215f9 Refactored background detection into a Thing
The new background detect Thing (currently in smart_scan.py)
manages its own settings and exposes a few more actions.
2024-01-03 16:56:20 +00:00
jaknapper
0e32fd1e1f Added position log 2023-12-29 15:58:51 +00:00
Richard Bowman
1b6e2686be Format and linting of recentre and smart scan 2023-12-14 16:06:05 +00:00
Richard Bowman
a54c972891 Merge branch 'new_things' into 'v3'
Scanning and recentring

See merge request openflexure/openflexure-microscope-server!162
2023-12-14 15:19:02 +00:00
jaknapper
1d50dcb3f8 Scanning and centring things 2023-12-14 15:08:43 +00:00
Richard Bowman
d0eb9fa2c1 Format/comment improvements 2023-12-13 16:35:13 +00:00
Richard Bowman
3b2fd29fb0 Log to a file and make it visible via the API 2023-12-13 01:54:42 +00:00
Richard Bowman
3059683186 Enable logging
`logging.basicConfig` doesn't work when run via `uvicorn`.
I now explicitly get the root logger and set its level to INFO,
which means we now see logs on the terminal.
2023-12-13 00:51:41 +00:00
Richard Bowman
94e1619056 Use safer metadata dependency
Retrieving metadata pre-action risks stale metadata being
returned if DirectThingClients are used. I've switched to
the safer callable dependency, which is guaranteed to be fresh.
2023-12-12 23:40:12 +00:00
Richard Bowman
d9711522d5 Detect static directories
Simplified code and removed hard-coded list of static dirs.
2023-12-12 22:55:50 +00:00
Richard Bowman
753514c24b Added v2 API routes and hard-coded static files to support Connect
Connect looks for /routes and /api/v2/streams/snapshot
These are now present and working.

I've also hard coded the static files directory - fixing this
properly is a work in progress.
2023-12-11 23:59:11 +00:00
Richard Bowman
60f854b7db Return None if calibration matrix is missing
Previously, we raised an exception (and thus HTTP error
code) if the CSM matrix was requested and not yet set.
Now, we just return None, and I've added a (not-network-exposed)
function that will raise an HTTPException if it's missing.
2023-12-01 21:29:14 +00:00
Richard Bowman
a6e8c7ab93 Return HTTP error properly if CSM is uncalibrated 2023-12-01 02:18:28 +00:00
Richard Bowman
e5e5be7369 Added settings manager to store arbitrary metadata 2023-11-29 23:38:28 +00:00
Richard Bowman
b6ed55caba Fixed module docstring 2023-11-29 23:38:12 +00:00
Richard Bowman
b9605fa2a0 Added module docstring 2023-11-29 23:37:54 +00:00
Richard Bowman
20a7fd52b1 Reinstate move_and_measure 2023-11-28 23:47:53 +00:00
Richard Bowman
291bbde9cf Don't raise an exception if thing_state called before calibration
It's helpful to raise an exception if we access the calibration
before it's been set - but thing state should not raise exceptions,
just return an empty dict if the data is not there yet.
2023-11-28 21:06:42 +00:00
Richard Bowman
27c74bff6e Add shutdown/restart actions 2023-11-02 21:18:59 +00:00
Richard Bowman
7bbc105fc6 Expose last calibration and thing_state 2023-11-02 20:29:22 +00:00
Richard Bowman
92ba79ef7a Improved docstrings 2023-11-02 10:27:27 +00:00
Richard Bowman
6eefa4f25b Add image resolution to CSM metadata
The camera stage mapper should now note the resolution
used when it was last calibrated - this is helpful for tiling,
because we may need to scale it if the images recorded are
a different resolution from the images used for calibration.

This addresses https://gitlab.com/openflexure/microscope-extensions/camera-stage-mapping/-/issues/11
2023-11-02 10:05:54 +00:00