Skip to content

Instantly share code, notes, and snippets.

@raacampbell
Created July 31, 2023 15:41
Show Gist options
  • Save raacampbell/fa8b772597e3e0fca271dc9d1ae70843 to your computer and use it in GitHub Desktop.
Save raacampbell/fa8b772597e3e0fca271dc9d1ae70843 to your computer and use it in GitHub Desktop.
Path of laser beam over a scanned area showing blanking
function scanBeamPathDiagram
% Generate a figure showing a scanned beam with scan and image field
%
% The path of a resonant-scanned focused beam over a sample. The beam moves
% sinusoidally along the fast axis whilst being scanned up/down with a galvo.
% The area over which the beam moves is known as the “scan field”. On the left and
% right edges the beam slows and turns around. In these areas the potential for
% photodamage is greatest, as the beam is travelling more slowly over the sample.
% Thus the beam is “blanked” or disabled during these epochs. In a resonant scanning
% microscope the beam is blanked about 30% of the time. The image field (red lines
% and gray region) is the area over which the beam is on and capable of exciting
% fluorescence. The dotted lines indicate the blanked turn-around regions.
%
%
nCycles = 20; % number of scan beam cycles to plot
% Generate the scan waveform
x = sin(0.5*pi : 0.01 : (nCycles*2*pi + 0.5*pi));
y = 1:length(x);
fillFraction = 0.7;
clf
set(gcf,'Color','w')
plot(x,y,':k')
hold on
axis tight square
set(gca,'XTick',[],'YTick',[])
f = find(x<-fillFraction | x>fillFraction);
x(f)=nan;
y(f)=nan;
plot(x,y,'-r')
% Patch showing the image field (i.e. the sub-region within the scan field that is
% being imaged).
yl = ylim;
Y = [yl,fliplr(yl)];
X = [-fillFraction,-fillFraction,fillFraction,fillFraction];
p = patch(X,Y,0, ...
'FaceColor',[1,1,1]*0.5, ...
'FaceAlpha',0.25, ...
'EdgeColor', 'none');
sideColor = [1,1,1]*0.5;
plot([-fillFraction,-fillFraction],yl,'-','color',sideColor)
plot([fillFraction,fillFraction],yl,'-','color',sideColor)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment