Skip to main content
. Author manuscript; available in PMC: 2025 Apr 27.
Published in final edited form as: Nat Protoc. 2023 May 29;18(7):2051–2083. doi: 10.1038/s41596-023-00829-4
lrImageSeq=zeros(3648,5472,length(usedLed),3,uint8);expTimeArray=[1,1,3.5];%the ratio used for setting different exposure timesgainArray=[0,26,26];%gain array for image acquisitionstriggerconfig(vid,manual);%set the trigger mode to manualset(vid,FramesPerTrigger,1);%set the number of frames captured in single triggervid.TriggerRepeat=length(usedLed)-1;%set to capturelength(usedLed)images in totalforcaptureLoop=1:3%loops for image acquisitionframeAvail=0;%flag to check the camerasstatusstart(vid);pause(0.1);src.Gain=gainArray(captureLoop);%set gainsrc.Exposure=basicExptimeexpTimeArray(captureLoop);%set the exposure timefprintf(lightSource,F);pause(0.1);%turn off all the LEDsfori=1:length(usedLed)j=usedLed(i);%the index of the LED to turn onfprintf(lightSource,controlLed(j,ledColour));%turn on the LEDtrigger(vid);%trigger the camera to capture imagenumAvail=vid.FramesAvailable;%check the feedback of the camera%Check if the current trigger has endedwhile(numAvail=frameAvail+1)numAvail=vid.FramesAvailable;%check the feedback of the cameraendframeAvail=numAvail;pause(0.07);%pause 0.07 seconds between each acquisitionendfprintf(lightSource,F);%turn off all the LEDsframes=vid.FramesAvailable;%Extract the captured images tolrImageSeqlrImageSeq(:,:,:,captureLoop)=squeeze(getdata(vid,frames));%Capture a background imagebackgroundImage(:,:,captureLoop)=getsnapshot(vid);stop(vid)end