-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathplsdefgrp.m
executable file
·146 lines (128 loc) · 4.61 KB
/
plsdefgrp.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
function plsdefgrp(grpdef, varargin)
% pldefsgrp(grpdef)
% ctrl: ctrl string for useful default options.
% Starts with group type, then switches:
% noloop
% notrig
% cat
% seq
% varargin{1}: if true, then do not display overwrite warnings
%
% nrep: rep counts, defaults to 1
% jump: overrides default jumps
% name: group (file) name
%
% chan: physical output channel list (or channels going into matrix)
% matrix: Compensation/linear combination matrix
% one col per input channel, one row per output channel.
% Default = Identity.
% markmap: optional map for marker channels, first row is input channel, second
% row the corresponding oputput channel.
% offset: added to pulse voltages before applying matrix. Default = 0;
% dict: optional name of pulse dictionary to apply to elem style pulses.
% varpar: length(pulses) x m matrix with parameters varying between pulses,
% nan entries are ignored, used for last m parameters.
% params: vector with default and start parameters, length determines number of parameters.
% pulsedind: Optional index array determining which pulses will be used in a
% sequence. Default all.
% xval: Optional xval to be prepended to pulse, varpar xvals.
% trafofn.func, trafofn.args ; called on each channel of data as
% func(wf,chan,args)
% type = 'grp'
% pulses: struct with fields
% groups: Cell array with group names
% chan: Matrix with target channels for each group, 0 = ignore.
% Row index is group index
% Indices refer to columns of matrix. Default chan for source group.
%
%
% type = 'pls'
% pulses: struct array with pulses in std format.
% Only 'elem' format (after database index substitution) implemented for parametrization.
% pardef: n x 2 matrix with pulsedef and data entry indices,
% -ve second indices refer to time, +ve ones val.
% trafofn (optional): transforms given parameters into pulse parameters. (Can be a function or matrix.)
%
% (c) 2010 Hendrik Bluhm. Please see LICENSE and COPYRIGHT information in plssetup.m.
if nargin > 1 && varargin{1}
disableOverwriteWarning = true;
else
disableOverwriteWarning = false;
end;
if length(grpdef) > 1
if iscell(grpdef)
for l=1:length(grpdef)
plsdefgrp(grpdef{l});
end
else
for l=1:length(grpdef)
plsdefgrp(grpdef(l));
end
end
return;
end
global plsdata;
file = [plsdata.grpdir, 'pg_', grpdef.name];
if exist(file, 'file') || exist([file, '.mat'], 'file') && ~disableOverwriteWarning
fprintf('File %s exists. Overwrite? (yes/no)', file);
while 1
str = input('', 's');
switch str
case 'yes'
break;
case 'no'
return;
end
end
end
% set defaults
if ~isfield(grpdef, 'ctrl')
grpdef.ctrl = [];
end
if isempty(grpdef.ctrl) || isempty(strmatch(grpdef.ctrl(1:min([end find(grpdef.ctrl == ' ', 1)-1])), {'pls', 'grp', 'grpcat'}))
% format not given
if ~isstruct(grpdef.pulses) || isfield(grpdef.pulses, 'data')
grpdef.ctrl = ['pls ' grpdef.ctrl];
elseif isfield(grpdef.pulses, 'groups')
grpdef.ctrl = ['grp ' grpdef.ctrl];
else
error('Invalid group format.');
end
end
if isempty(strfind(grpdef.ctrl, 'seq'))
if ~isfield(grpdef,'params')
grpdef.params=[];
end
if ~isfield(grpdef, 'matrix') || isempty(grpdef.matrix)
grpdef.matrix = eye(length(grpdef.chan));
else
if isfield(grpdef, 'chan')
grpdef.matrix = grpdef.matrix(:, grpdef.chan);
if ~isfield(grpdef, 'markmap')
grpdef.markmap = [1:length(grpdef.chan); grpdef.chan];
end
end
if isfield(grpdef, 'outchan')
grpdef.chan = grpdef.outchan;
else
grpdef.chan = 1:size(grpdef.matrix, 1);
end
end
if ~isfield(grpdef, 'offset') || isempty(grpdef.offset)
grpdef.offset = zeros(size(grpdef.matrix, 2), 1);
end
if ~isfield(grpdef, 'dict')
grpdef.dict=[];
end
else
if ~isfield(grpdef, 'pulseind')
error('Pulseind must be specified with ''seq'' option.');
end
if size(grpdef.pulseind, 1) == 1
grpdef.pulseind = repmat(grpdef.pulseind, length(grpdef.pulses.groups), 1);
end
end
plslog.time = 0; % not loaded yet
lastupdate = now;
save(file, 'grpdef', 'plslog', 'lastupdate');
logentry('Created group %s.', grpdef.name);