### Stack Configuration Example Source: https://docs.scanimage.org/Advanced%2BFeatures/ScanImage%2BAPI/Component%2BAPI/FastZ%2Band%2BStackManager%2BAPI.html Example MATLAB code configuring a fast volume stack with 50 slices, 2 micron step size, and 10 volumes, then starting acquisition. ```APIDOC ## Stack Configuration Example ### Description Example MATLAB code configuring a fast volume stack with 50 slices, 2 micron step size, and 10 volumes, then starting acquisition. ### Code ```matlab % a 100 um fast volume of 50 slices hSI.hStackManager.enable = true; hSI.hStackManager.stackMode = scanimage.types.StackMode.fast; hSI.hStackManager.stackActuator = scanimage.types.StackActuator.fastZ; hSI.hStackManager.stackDefinition = scanimage.types.StackDefinition.uniform; hSI.hStackManager.numSlices = 50; hSI.hStackManager.stackZStepSize = 2; hSI.hStackManager.numVolumes = 10; hSI.startGrab(); ``` ``` -------------------------------- ### CycleManager Usage Example Source: https://docs.scanimage.org/Advanced%2BFeatures/ScanImage%2BAPI/Component%2BAPI/TileManager%2Band%2BCycleManager%2BAPI.html Example code demonstrating how to append an iteration, set its delay, set total cycles, and start the cycle. ```APIDOC ``` hSI.hCycleManager.appendNewIteration(); hSI.hCycleManager.cycleDataGroup.getIterByIdx(1).iterDelay = 5; hSI.hCycleManager.totalCycles = 3; hSI.startCycle(); ``` ``` -------------------------------- ### Clone and set up lab repository from official releases Source: https://docs.scanimage.org/Appendix/Lab%2BUpstream%2BWorkflow.html Use this in an initial setup when starting fresh from the official 'scanimage-basic-releases' repo (Option A). It clones into 'scanimage-lab', renames the remote to 'upstream', creates a local bare repository as the private remote, pushes the main branch, and creates a 'lab//custom' branch. All commands are intended to be run in order. ```bash # 1. Clone the release repository locally git clone https://:@gitlab.com/vidriotech/scanimage-basic-releases.git scanimage-lab cd scanimage-lab # 2. Rename the remote so 'upstream' refers to the official releases repo git remote rename origin upstream # 3. Create a local bare repository to act as your lab's private remote # (Choose any path on your machine or shared network drive) git init --bare /path/to/your/lab-scanimage.git git remote add origin /path/to/your/lab-scanimage.git # 4. Push to your local bare repository git push -u origin main # 5. Create a branch for your lab's customizations git checkout -b lab//custom git push -u origin lab//custom ``` -------------------------------- ### Verify ScanImage installation with 'which scanimage' Source: https://docs.scanimage.org/Configuration/PC%2BConfig.html Run in MATLAB command window to verify ScanImage installation path. The output shows the installation directory. Then execute 'scanimage' to start ScanImage. ```matlab >> which scanimage C:\Program Files\Vidrio\SI2019bR0_2020-03-16-151209_4d721e971c >> scanimage ``` -------------------------------- ### Configure logging and start a GRAB acquisition Source: https://docs.scanimage.org/Advanced%2BFeatures/ScanImage%2BAPI/Component%2BAPI/Acquisition%2BControl.html Configure logging for a GRAB acquisition and start it. The start method returns as soon as the acquisition is armed, not when it finishes; use the acqModeDone user function event to run code on completion. ```matlab hSI.hChannels.loggingEnable = true; hSI.hScan2D.logFilePath = 'C:\data'; hSI.hScan2D.logFileStem = 'experiment_01'; hSI.hScan2D.logFileCounter = 1; hSI.startGrab(); ``` -------------------------------- ### Configure a fast uniform stack and start acquisition Source: https://docs.scanimage.org/Advanced%2BFeatures/ScanImage%2BAPI/Component%2BAPI/FastZ%2Band%2BStackManager%2BAPI.html Sets up a 100 um fast volume of 50 slices using the StackManager API, then starts acquisition with hSI.startGrab(). The example uses uniform stack definition, fastZ actuator, 2 um step size, and 10 volumes. ```matlab % a 100 um fast volume of 50 slices hSI.hStackManager.enable = true; hSI.hStackManager.stackMode = scanimage.types.StackMode.fast; hSI.hStackManager.stackActuator = scanimage.types.StackActuator.fastZ; hSI.hStackManager.stackDefinition = scanimage.types.StackDefinition.uniform; hSI.hStackManager.numSlices = 50; hSI.hStackManager.stackZStepSize = 2; hSI.hStackManager.numVolumes = 10; hSI.startGrab(); ``` -------------------------------- ### hSI.startCycle() Source: https://docs.scanimage.org/Advanced%2BFeatures/ScanImage%2BAPI/Component%2BAPI/Acquisition%2BControl.html Starts the acquisition through hSI.hCycleManager. ```APIDOC ## hSI.startCycle() ### Description Starts the acquisition through hSI.hCycleManager. ### Method `startCycle()` ### Parameters None. ### Returns None. ### Example ```matlab hSI.startCycle(); ``` ``` -------------------------------- ### hSI.hTileManager Example Source: https://docs.scanimage.org/Advanced%2BFeatures/ScanImage%2BAPI/Component%2BAPI/TileManager%2Band%2BCycleManager%2BAPI.html Example code showing how to configure and initialize a tile scan. ```APIDOC ## hSI.hTileManager Example ### Description Example code showing how to configure and initialize a tile scan. ### Code ```matlab hSI.hTileManager.scanFramesPerTile = 10; hSI.hTileManager.scanStageSettleTime = 0.2; hSI.hTileManager.initTileScanning(); ``` ``` -------------------------------- ### Create DAQ resource with ResourceStore Source: https://docs.scanimage.org/Advanced%2BFeatures/ScanImage%2BAPI/dabs%2BAPI/DAQs%2Band%2BIO.html Constructs a ResourceStore and retrieves a DAQ resource by name. The example shows how to get a vDAQ0 board and its AO0 channel. ```matlab hRS = dabs.resources.ResourceStore(); hDAQ = hRS.filterByName('vDAQ0'); hAO = hRS.filterByName('/vDAQ0/AO0'); ``` -------------------------------- ### Coordinate System API Usage Example Source: https://docs.scanimage.org/Advanced%2BFeatures/ScanImage%2BAPI/Coordinate%2BSystem%2BAPI/index.html Example demonstrating how to get the stage position in sample-relative coordinates, transform it to reference space, and plot the coordinate system tree. ```APIDOC ## Coordinate System API Usage Example ### Description This example shows how to retrieve the stage position in sample-relative coordinates, transform it to reference space, and display the coordinate system tree. ### Code Example ```matlab % where is the stage, expressed in sample-relative microns? hPt = hSI.hMotors.getPosition(hSI.hCoordinateSystems.hCSSampleRelative); disp(hPt.points); % ... and the same position in reference space (optical degrees / microns) hPtRef = hPt.transform(hSI.hCoordinateSystems.hCSReference); % show the whole tree hSI.hCoordinateSystems.plot(); ``` ``` -------------------------------- ### hSI.startLoop() Source: https://docs.scanimage.org/Advanced%2BFeatures/ScanImage%2BAPI/Component%2BAPI/Acquisition%2BControl.html Starts a LOOP acquisition: `hSI.acqsPerLoop` independently started acquisitions. ```APIDOC ## hSI.startLoop() ### Description Starts a LOOP acquisition: `hSI.acqsPerLoop` independently started acquisitions. ### Method `startLoop()` ### Parameters None. ### Returns None. ### Example ```matlab hSI.startLoop(); ``` ``` -------------------------------- ### Configure and start a cycle with hSI.hCycleManager Source: https://docs.scanimage.org/Advanced%2BFeatures/ScanImage%2BAPI/Component%2BAPI/TileManager%2Band%2BCycleManager%2BAPI.html Appends a new iteration, sets its delay to 5 seconds, sets the total cycle count to 3, and starts the cycle. This example demonstrates the basic workflow for defining and running a cycle. ```matlab hSI.hCycleManager.appendNewIteration(); hSI.hCycleManager.cycleDataGroup.getIterByIdx(1).iterDelay = 5; hSI.hCycleManager.totalCycles = 3; hSI.startCycle(); ``` -------------------------------- ### Progress Monitoring Example Source: https://docs.scanimage.org/Advanced%2BFeatures/ScanImage%2BAPI/Component%2BAPI/FastZ%2Band%2BStackManager%2BAPI.html Example MATLAB code adding a listener to the 'slicesDone' property to print progress during stack acquisition. ```APIDOC ## Progress Monitoring Example ### Description Example MATLAB code adding a listener to the 'slicesDone' property to print progress during stack acquisition. ### Code ```matlab % follow progress hL = most.ErrorHandler.addCatchingListener(hSI.hStackManager,'slicesDone','PostSet', ... @(varargin)fprintf('slice %d of %d\n', ... hSI.hStackManager.slicesDone,hSI.hStackManager.actualNumSlices)); ``` ``` -------------------------------- ### Set up a new lab member's clone Source: https://docs.scanimage.org/Appendix/Lab%2BUpstream%2BWorkflow.html Use these commands for a new lab member's first-time setup: clone the private repository, change into the scanimage directory, and check out the lab branch. After this, the member adds the folder to their MATLAB path. Each member maintains their own clone, so modifying source code does not affect other members' running instances. ```bash # First-time setup for a new lab member: git clone https://:@gitlab.com//.git scanimage cd scanimage git checkout lab//custom ``` -------------------------------- ### Initialize local bare repository with git init --bare Source: https://docs.scanimage.org/Appendix/Lab%2BUpstream%2BWorkflow%2BSourceTree.html Run this command in SourceTree's terminal to create a local bare repository that acts as your lab's private remote. Replace /path/to/your/lab-scanimage.git with the actual folder path, e.g., C:/Users/you/lab-repos/lab-scanimage.git. ```bash git init --bare /path/to/your/lab-scanimage.git ``` -------------------------------- ### hSI.startFocus() Source: https://docs.scanimage.org/Advanced%2BFeatures/ScanImage%2BAPI/ScanImage%2BScripting%2BAPI.html Starts a live view acquisition without logging data. Returns immediately once the acquisition is armed. ```APIDOC ## hSI.startFocus() ### Description Starts a live view acquisition without logging data. Returns immediately once the acquisition is armed. ### Method startFocus ### Syntax hSI.startFocus(); ### Parameters None. ### Return Value None. ``` -------------------------------- ### Start synchronized tasks (ao_task, do_task) in ScanImage Source: https://docs.scanimage.org/Advanced%2BFeatures/ScanImage%2BAPI/vDAQ%2BAPI.html Starts the ao_task first so it waits for the trigger on D0.0, then starts do_task to wait for the frame clock trigger. The ao_task.start() call automatically starts ai_task because it is synchronized. After ScanImage starts scanning, the frame clock triggers do_task, which then triggers ao_task and ai_task. ```matlab 1% start ao_task first. it will wait for the trigger on D0.0 2ao_task.start(); % automatically starts ai_task since it is synchronized 3 4% then start the do_task which will wait for the frame clock trigger 5do_task.start(); 6 7% after ScanImage starts scanning, the frame clock will trigger the do_task, 8% which will then trigger the ao_task and ai_task ``` -------------------------------- ### hSI.startGrab() Source: https://docs.scanimage.org/Advanced%2BFeatures/ScanImage%2BAPI/ScanImage%2BScripting%2BAPI.html Starts a single acquisition (grab). Returns immediately once the acquisition is armed. ```APIDOC ## hSI.startGrab() ### Description Starts a single acquisition (grab). Returns immediately once the acquisition is armed. ### Method startGrab ### Syntax hSI.startGrab(); ### Parameters None. ### Return Value None. ``` -------------------------------- ### Get scanner set from hSI.hScan2D Source: https://docs.scanimage.org/Advanced%2BFeatures/ScanImage%2BAPI/Component%2BAPI/ScannerSet%2Band%2BScanners.html Retrieves the currently configured scanner set from the Scan2D object. The first line gets the read-only set recomputed on configuration changes; the second gets the set used for photostimulation output. ```matlab ss = hSI.hScan2D.scannerset; % read-only, recomputed on configuration changes ss = hSI.hScan2D.stimScannerset; % the set used for photostimulation output ``` -------------------------------- ### hSI.startGrab() Source: https://docs.scanimage.org/Advanced%2BFeatures/ScanImage%2BAPI/Component%2BAPI/Acquisition%2BControl.html Starts a GRAB acquisition: one acquisition of the configured number of frames, volumes, or slices. Logged if `hSI.hChannels.loggingEnable` is set. ```APIDOC ## hSI.startGrab() ### Description Starts a GRAB acquisition: one acquisition of the configured number of frames, volumes, or slices. Logged if `hSI.hChannels.loggingEnable` is set. ### Method `startGrab()` ### Parameters None. ### Returns None. ### Example ```matlab hSI.hChannels.loggingEnable = true; hSI.hScan2D.logFilePath = 'C:\data'; hSI.hScan2D.logFileStem = 'experiment_01'; hSI.hScan2D.logFileCounter = 1; hSI.startGrab(); ``` ``` -------------------------------- ### hSI.hStackManager.setStackStart() / clearStackStart() Source: https://docs.scanimage.org/Advanced%2BFeatures/ScanImage%2BAPI/Component%2BAPI/FastZ%2Band%2BStackManager%2BAPI.html Sets the current z position as the start of a bounded stack, or clears the start position. ```APIDOC ## hSI.hStackManager.setStackStart() / clearStackStart() ### Description Sets the current z position as the start of a bounded stack, or clears the start position. ### Method setStackStart() / clearStackStart() ### Parameters None ### Returns None ``` -------------------------------- ### PowerFunction example Source: https://docs.scanimage.org/Windows%2BReference%2BGuide/Basic%2BWindows/Power%2BControls/index.html An example of a custom power function definition in MATLAB, which can be used for Power vs. Depth adjustments. ```matlab 1function powers = myPowerFunction( startPower,zPowerReference,z,lz) 2 powers = sqrt (z-zPowerReference).*startPower; 3end ``` -------------------------------- ### Create a RoiGroup and add Rois Source: https://docs.scanimage.org/Advanced%2BFeatures/ScanImage%2BAPI/RoiGroup%2Band%2BRoi%2BAPI.html Demonstrates initializing an empty RoiGroup, creating Roi objects, adding them to the group, and clearing the group. ```matlab hRoiGroup = scanimage.mroi.RoiGroup(); % create an empty RoiGroup object hRoi1 = scanimage.mroi.Roi(); % create an empty Roi hRoiGroup.add(hRoi1); % add hRoi1 to hRoiGroup hRoi2 = scanimage.mroi.Roi(); % create an empty Roi hRoiGroup.add(hRoi2); % add hRoi2 to hRoiGroup hRoiGroup.clear(); % removes all Rois from RoiGroup ``` -------------------------------- ### dabs.resources.ResourceStore.showConfig() Source: https://docs.scanimage.org/Advanced%2BFeatures/ScanImage%2BAPI/dabs%2BAPI/ResourceStore%2BAPI.html Opens the resource configuration editor. ```APIDOC ## [METHOD] dabs.resources.ResourceStore.showConfig() ### Description Opens the resource configuration editor. ### Method showConfig ### Endpoint `dabs.resources.ResourceStore.showConfig()` ### Parameters None. ### Request Example ```matlab dabs.resources.ResourceStore.showConfig(); ``` ### Response No return value. ``` -------------------------------- ### ScanImage Metadata Dot Syntax Example Source: https://docs.scanimage.org/Premium%2BFeatures/ALS.html Example of the dot syntax used for ScanImage parameters when the JSON metadata option is disabled. ```text SI.hScan2D.sampleRate = 1.2e+08 ```