class SmartScanThing(lt.Thing): (source)
Constructor: SmartScanThing(thing_server_interface, scans_folder, default_workflow)
A Thing for scanning samples and interacting with past scans.
SmartScanThing exposes all functionality for automatically scanning samples, previewing live stitching, retrieving data from past scans, and for deleting past scans.
| Method | __enter__ |
Open hardware connection when the Thing context manager is opened. |
| Method | __exit__ |
Clean up after context manager is closed. |
| Method | __init__ |
Initialise a SmartScanThing saving to and loading from the input directory. |
| Method | delete |
Delete all the scans on the microscope. |
| Method | delete |
Delete the folder for the specified scan. |
| Method | download |
Return zip after including any files left until the end. |
| Method | get |
Retrieve the latest preview image. |
| Method | get |
Retrieve a file from a scan. |
| Method | get |
Return the stitched image corresponding to a given scan name, if it exists. |
| Method | purge |
Delete all scan folders containing no images at the top level. |
| Method | sample |
Move the stage to cover an area, taking images. |
| Method | stitch |
Check the list of scans, and stitch any that don't have a DZI associated with it. |
| Method | stitch |
Generate a stitched image based on stage position metadata. |
| Method | workflow |
The name of the scan workflow selector. |
| Method | workflow |
Validate and set workflow_name. |
| Class Variable | stitch |
Whether to run a final stitch at the end of a successful scan. |
| Class Variable | stitch |
Whether or not to also produce a pyramidal tiff at the end of a scan. |
| Property | all |
Return a list of all available Scan Workflows. |
| Property | latest |
The path of the latest preview stitched image, or None if not available. |
| Property | latest |
The modification time of the latest preview image, to allow live updating. |
| Property | latest |
The name of the last scan to be started. |
| Property | ongoing |
The ScanDirectory object of the ongoing scan. |
| Property | scan |
The ActiveScanData object holding information about the of the ongoing scan. |
| Property | scans |
All the available scans. |
| Property | thing |
Return a metadata dict for ongoing scan to populate. |
| Property | workflow |
Return a list of the display names of all available Scan Workflows. |
| Method | _collect |
Collect and return the data for this scan so it cannot be changed mid-scan. |
| Method | _delete |
Delete a scan. |
| Method | _get |
Return all the information from the scan directories. |
| Method | _main |
Run the main loop of the scan. |
| Method | _manage |
Manage the stitching threads, starting them if needed and not already running. |
| Method | _move |
Move the stage to the next position. |
| Method | _perform |
Update the scan zip and perform final stitch of the data. |
| Method | _return |
Return to the initial scan position, if set. |
| Method | _run |
Prepare and run the main scan, and perform final actions on completion. |
| Method | _save |
Update scan data JSON file with data only known at the end of the scan. |
| Class Variable | _all |
Undocumented |
| Class Variable | _cam |
Undocumented |
| Class Variable | _stage |
Undocumented |
| Instance Variable | _default |
Undocumented |
| Instance Variable | _latest |
Undocumented |
| Instance Variable | _ongoing |
Undocumented |
| Instance Variable | _preview |
Undocumented |
| Instance Variable | _scan |
Undocumented |
| Instance Variable | _scan |
Undocumented |
| Instance Variable | _scan |
Undocumented |
| Instance Variable | _workflow |
Undocumented |
| Property | _workflow |
The active scan workflow object. |
type[ BaseException], _exc_value: BaseException | None, _traceback: TracebackType | None):
(source)
¶
Clean up after context manager is closed.
In this case it doesn't need to do anything.
lt.ThingServerInterface, scans_folder: str, default_workflow: str):
(source)
¶
Initialise a SmartScanThing saving to and loading from the input directory.
| Parameters | |
thinglt.ThingServerInterface | Undocumented |
scansstr | This is the path to the directory where all scans will be saved. Any scans already in this directory will be accessible through the HTTP interface. |
defaultstr | Undocumented |
Delete all the scans on the microscope.
This will irreversibly remove all scanned data from the microscope! Use with extreme caution.
str):
(source)
¶
Delete the folder for the specified scan.
This endpoint allows scans to be deleted from disk.
| Parameters | |
scanstr | The name of the scan to delete |
FileResponse:
(source)
¶
Retrieve the latest preview image.
str) -> FileResponse:
(source)
¶
Retrieve a file from a scan.
This endpoint allows files to be downloaded from a scan.
str) -> FileResponse:
(source)
¶
Return the stitched image corresponding to a given scan name, if it exists.
Will only return a file ending in suffix STITCH_SUFFIX Note: when downloading this, the default filename will be scan_name.jpeg
Move the stage to cover an area, taking images.
The way the stage moves depends on the selected workflow. If images overlap for a scan workflow then the images can be stitched together into a larger composite image.
Check the list of scans, and stitch any that don't have a DZI associated with it.
| Raises | |
RuntimeError | if the microscope is currently running a scan |
The modification time of the latest preview image, to allow live updating.
This will return None (null to JS) if there is no preview image to return.
This is used for two reasons:
- If all caching was turned off this stitch would be sent over the network repeatedly
- If caching was is on, then the stitch will not update when needed.
The ScanDirectory object of the ongoing scan.
Only read this property is a scan is ongoing or it will raise an error.
The ActiveScanData object holding information about the of the ongoing scan.
Only read this property is a scan is ongoing or it will raise an error.
All the available scans.
Each scan has a name (which can be used to access it), along with its modified and created times (according to the filesystem) and the number of items in the images folder. Note that image count uses a regular expression, and changes to the naming scheme will break it.
Delete a scan.
This is a wrapper around scan manager's delete_scan that logs to the things logger if there is a problem.
Return all the information from the scan directories.
It is preferable to use the method rather than calling _scan_dir_manager.all_scans_info() directly as it will handle stopping the json in any ongoing scans being read.
Run the main loop of the scan.
This loop runs during a scan, until no more scan x,y positions are remaining.
tuple[ int, int], z_estimate: int | None = None) -> tuple[ int, int, int]:
(source)
¶
Move the stage to the next position.
If no z_estimate is given then the current stage position is used. Must move to the estimated focused position (although moving below would be marginally faster) because background detect is most reliable at the focused position.
| Returns | |
tuple[ | the (x,y,z) with the chosen z_estimate |
Prepare and run the main scan, and perform final actions on completion.
The result (or exception) from the main scan loop determines whether the scan should be stitched and whether the microscope should return to the starting x,y,z position.