Skip to content

FastADT: Add an option to re-use previous tracking#159

Open
Baharis wants to merge 1 commit intoinstamatic-dev:mainfrom
Baharis:reuse-fastadt-tracking
Open

FastADT: Add an option to re-use previous tracking#159
Baharis wants to merge 1 commit intoinstamatic-dev:mainfrom
Baharis:reuse-fastadt-tracking

Conversation

@Baharis
Copy link
Member

@Baharis Baharis commented Feb 28, 2026

Introduction

Experimental protocol "FastADT" allows selection of an a priori tracking algorithm. The current version of Instamatic implements two: "none" - no tracking will be attempted or "manual" - requires recent beamshift calibration, after which the user clicks on the display to track the crystal. Following a suggestion by @pbklar, this PR implements a third option: "load".

To make this change possible, in the first place the previously tracked paths must be saved. This is now implemented via new FastADT Run methods .to_csv and from_csv. Since any Run is an annotated pandas table, the table is saved as an csv, while the metadata is put in the first line in the comment. The resulting file looks like this:

# exposure=0.5, continuous=False
alpha,beampixel_x,beampixel_y,beamshift_x,beamshift_y
-30.0,68.0,47.0,10847.79481536781,25305.489227894126
-25.0,474.0,30.0,10700.459974864512,25252.37755842664
-20.0,480.0,445.0,10631.694170818164,25365.779351145444
-15.0,53.0,455.0,10787.913281505274,25419.471505893274
-10.0,144.0,364.0,10768.871426748909,25383.59156361
-5.0,296.0,377.0,10710.606346716635,25369.032293268374
0.0,384.0,373.0,10678.722257385976,25357.433710426438
5.0,382.0,271.0,10695.817887722733,25329.624132527846
10.0,377.0,158.0,10715.786269517632,25299.147659169157
15.0,266.0,158.0,10756.81277433411,25312.39027964438
20.0,164.0,155.0,10794.993876788083,25323.734227556513
25.0,37.0,182.0,10837.604473019624,25346.310213433906
30.0,36.0,119.0,10848.076572191974,25329.105638170146

One path_#.csv file is created for each tracked path, as soon as it is defined, even if an experiment is never performed. Then, whenever a tracking option "load" is selected, the GUI immediately opens a tk-built-in multiple-file-selection dialogue, saves the paths as semicolon-separated string, and passes to the experiment alongside other variables. If the experiment receives param["tracking_algo"] == "load", it parses the details string as paths, tries to open every one of them, and runs an experiment for every path, without requesting any new manual process. This way once a tracked path is determined, it can be reused to perform multiple experiments, for example with different exposure or angle range:

image

This was successfully tested on a simulator and emulator. Because DiffractionRun beam shifts are determined by interpolating beam shifts of TrackingRun points, this works fine if the alpha range for tracking is different - even tighter than - the alpha range used for diffraction. The GUI by default wants csv files but accepts any others. In case these can not be parsed as valid path tables, the exceptions are gracefully handled at the level of an experiment.

What's new

  • FastADT experiments now save files with beamshift paths as soon as they are created;
  • FastADT experiment can accept tracking_algo = 'load, tracking_details = 'path1;path2;path3' to re-use previous beamshifts.

@Baharis Baharis requested a review from stefsmeets February 28, 2026 17:41
@Baharis Baharis self-assigned this Feb 28, 2026
@Baharis Baharis marked this pull request as ready for review March 2, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant