-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateGplFile_v2.m
56 lines (49 loc) · 1.86 KB
/
createGplFile_v2.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
function [save_file] = createGplFile_v2(savePath, params, posx, posy, posz_scalar, r, num_pixels, zoom, varName)
%{
Function to create a gpl file to be uploaded to the prairie view
savePath --> path where to save the .gpl file
posx --> vector of x coordinates
poxy --> vector of y coordinates
r --> vector of roi size
%}
if nargin <9
varName = '';
end
%% Parameters
% UncagingLaserPower = 0.4;
% Duration = 100;
% SpiralSize = 0.3;
% SpiralRevolutions = 5;
if(zoom == 1.5)
conversionValue = 5.06666666666667;
elseif(zoom == 2)
conversionValue = 3.8;
disp('zoom2');
%512 > 3.8
%0 -> -3.8
else
print('please calibrate the zoom')
end
%% prepare file
% change from pixel space to motor space
posx = 2*conversionValue/num_pixels*posx - conversionValue;
posy = -2*conversionValue/num_pixels*posy + conversionValue;
% print the first part of the text
save_file = fullfile(savePath, [varName, 'holoMask.gpl']);
fileID = fopen(save_file,'wt');
fprintf(fileID,'<?xml version="1.0" encoding="utf-8"?>\n');
fprintf(fileID,'<PVGalvoPointList>\n');
% print for each point
formatSpec = [' <PVGalvoPoint X="%f" Y="%f" Name="Point %d" Index="%d"', ...
' ActivityType="MarkPoints" UncagingLaser="None" UncagingLaserPower="%d"', ...
' Duration="%d" IsSpiral="True" SpiralSize="%f" SpiralRevolutions="%d" Z="%.2f" />\n'];
num_roi = length(posx);
for ind = 1:num_roi
%TODO change from pixelspace to motorspace
content = [posx(ind), posy(ind), ind, ind-1, params(ind).UncagingLaserPower, params(ind).Duration, ...
params(ind).SpiralSize, params(ind).SpiralRevolutions, posz_scalar];
fprintf(fileID, formatSpec,content);
end
fprintf(fileID,'</PVGalvoPointList>\n');
fclose(fileID);
end