|
| 1 | +# Stage Motion Times |
| 2 | + |
| 3 | +This folder contains code related to timing stage motions. |
| 4 | +This can be used for debugging if you are concerned that your stages are moving too slowly, not enough time is being allocated to allowing them to settle, etc. |
| 5 | + |
| 6 | +## Before starting |
| 7 | + |
| 8 | +Before running any code related to stage timing you should quit and restart MATLAB. |
| 9 | +On a minority of rigs it has been observed that, over time, MATLAB/ScanImage/BakingTray, begins to slow down by factor of 2 or 3 and restarting MATLAB solves this. |
| 10 | + |
| 11 | +For more accurate values you should have the stages assembled as an X/Y pair and a water bath filled to the typical level placed on top. |
| 12 | + |
| 13 | +It is also a good idea with PI stages to first test how long it takes for a step and settle motion in PI MikroMove. |
| 14 | +You can generate graphs showing things like position over time, position error over time, etc. |
| 15 | +This provides a really solid baseline indicating what to expect. |
| 16 | + |
| 17 | +Once you are ready: start BakingTray at the MATLAB command line. |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +## Quick test of stage motion times |
| 22 | +Run `softwareTimedMotionTime.m` then make plots of the resulting output. |
| 23 | +Read through the code before running the function! |
| 24 | +You can edit variables in-line to change behavior. |
| 25 | +It is recommended to copy file to a new location to do this, otherwise you will have to revert changes before pulling the latest version of BakingTray when you want to update. |
| 26 | + |
| 27 | +## Checking motion times in a tile scan |
| 28 | +You can start a tile scan in BakingTray without having to turn on the laser, the PMTs, make a directory, etc. |
| 29 | +To do this: |
| 30 | + |
| 31 | +1. Open the Prepare Sample window |
| 32 | +2. Open the Preview window |
| 33 | +3. Hit "ROI" and draw a box in the area you want to tile scan |
| 34 | +4. Select "tiled: manual ROI" under "Scan Mode" in the main BakingTray window |
| 35 | +5. run `hBT.scanner.armScanner` to set up ScanImage for the tile scan |
| 36 | +6. run `hBT.runTileScan` to initiate and run the tile scan. You might need to press "Abort" in ScanImage to do more tile scans or disarm the scanner (below). |
| 37 | +7. run `hBT.scanner.disarmScanner` after the tile scan is finished and if you plan to do no more. |
| 38 | + |
| 39 | +You can, for example, acquire the Y galvo signal to see how long it takes for each stage motion to complete. |
| 40 | +You might want to set the number of Z planes to 1 for this. |
| 41 | +The easiest way to decrease the step size of the stages should you need to, is to increase the zoom number in ScanImage. |
| 42 | + |
| 43 | + |
| 44 | +## Acquiring data from a tile scan |
| 45 | +The `sitools.ai_recorder` class can be used to pull in data from an AI line while ScanImage runs. |
| 46 | +Clone from https://github.com/BaselLaserMouse/ScanImageTools and read the docs. |
| 47 | +It should be compatible with both the vDAQ and an NI DAQ. |
| 48 | +T the Y galvo waveform into an AI line that is free and set up the AI recorder to acquire this. |
| 49 | +You can either edit the class file, or instantiate the class and modify properties at the CLI. |
| 50 | +To save data, check the Save checkbox in ScanImage and choose a directory to which data are to be saved. |
| 51 | +Then run the tile scan as above. |
| 52 | +The recorder will keep saving data to disk until you hit Abort in ScanImage. |
| 53 | +You can use `readAIrecoderBinFile` to read data for analysis; |
| 54 | + |
| 55 | +You can find the interval between frames using MATLAB's findpeaks function: |
| 56 | +```matlab |
| 57 | +findpeaks(yData) % check visually if it looks right |
| 58 | +[pks,loc]=findpeaks(yData); |
| 59 | +plot(lok,pks,'.') |
| 60 | +%Then apply a threshold and get the times. e.g. |
| 61 | +timesOfPeaks = loc(pks>0); |
| 62 | +
|
| 63 | +% Divide by the sample rate to get time in seconds |
| 64 | +timesInSec = timesOfPeaks / 1000; % in this case data were acquired at 1kHz |
| 65 | +plot(diff(peakTimes)) |
| 66 | +
|
| 67 | +``` |
0 commit comments