Skip to content

Commit 36481f0

Browse files
ENH - numerous small changes as suggested by the MATLAB coder for compatibility reasons.
1 parent 2c5107d commit 36481f0

File tree

9 files changed

+38
-26
lines changed

9 files changed

+38
-26
lines changed

ft_appenddata.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@
8989

9090
% ensure consistent input data
9191
for i=2:Ndata
92-
if isfield(varargin{1}, 'topo'),
92+
if isfield(varargin{1}, 'topo')
9393
assert(isequaln(varargin{1}.topo, varargin{i}.topo), 'the input has inconsistent topo fields')
9494
end
95-
if isfield(varargin{1}, 'topolabel'),
95+
if isfield(varargin{1}, 'topolabel')
9696
assert(isequaln(varargin{1}.topolabel, varargin{i}.topolabel), 'the input has inconsistent topolabel fields')
9797
end
98-
if isfield(varargin{1}, 'unmixing'),
98+
if isfield(varargin{1}, 'unmixing')
9999
assert(isequaln(varargin{1}.unmixing, varargin{i}.unmixing), 'the input has inconsistent unmixing fields')
100100
end
101101
end
@@ -177,7 +177,7 @@
177177
if haselec, sens{j} = varargin{j}.elec; end
178178
if hasgrad, sens{j} = varargin{j}.grad; end
179179
if hasopto, sens{j} = varargin{j}.opto; end
180-
if j>1,
180+
if j>1
181181
if ~isequaln(sens{j}, sens{1})
182182
removesens = 1;
183183
warning('sensor information does not seem to be consistent across the input arguments');
@@ -222,9 +222,9 @@
222222
shuflabel = cattrial && ~all(all(order-repmat(order(:,1),[1 Ndata])==0));
223223
prunelabel = cattrial && sum(sum(order~=0,2)==Ndata)<length(alllabel);
224224

225-
if shuflabel,
225+
if shuflabel
226226
fprintf('the channel order in the input-structures is not consistent, reordering\n');
227-
if prunelabel,
227+
if prunelabel
228228
fprintf('not all input-structures contain the same channels, pruning the input prior to concatenating over trials\n');
229229
selall = find(sum(order~=0,2)==Ndata);
230230
alllabel = alllabel(selall);

plotting/ft_plot_slice.m

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,12 +409,14 @@
409409
v1 = loc + inplane(1,:);
410410
v2 = loc + inplane(2,:);
411411
v3 = loc + inplane(3,:);
412+
pr = nan(size(plotmarker,1), 3);
413+
d = nan(size(plotmarker,1), 1);
412414
for k = 1:size(plotmarker,1)
413-
[pr(k,:),d(k,:)] = ptriprojn(v1,v2,v3,plotmarker(k,:));
415+
[pr(k,:), d(k,:)] = ptriprojn(v1, v2, v3, plotmarker(k,:));
414416
end
415417
sel = d<eps*1e8;
416-
if sum(sel)>0,
417-
ft_plot_dipole(pr(sel,:),repmat([0;0;1],1,size(pr,1)),'length',0,'color',markercolor,'diameter',markersize);
418+
if sum(sel)>0
419+
ft_plot_dipole(pr(sel,:), repmat([0;0;1], 1, size(pr,1)), 'length', 0, 'color', markercolor, 'diameter', markersize);
418420
end
419421
end
420422

@@ -423,7 +425,7 @@
423425
axis(ax([1 4 2 5 3 6])); % reorder into [xmin xmax ymin ymaz zmin zmax]
424426

425427
st = dbstack;
426-
if numel(st)>1,
428+
if numel(st)>1
427429
% ft_plot_slice has been called from another function
428430
% assume the remainder of the axis settings to be handled there
429431
else

plotting/ft_plot_vol.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ function ft_plot_vol(headmodel, varargin)
7575
switch ft_voltype(headmodel)
7676
case {'singlesphere' 'concentricspheres'}
7777
headmodel.r = sort(headmodel.r);
78-
bnd = [];
79-
for i=1:length(headmodel.r)
78+
bnd = repmat(struct(), numel(headmodel.r));
79+
for i=1:numel(headmodel.r)
8080
bnd(i).pos(:,1) = pos(:,1)*headmodel.r(i) + headmodel.o(1);
8181
bnd(i).pos(:,2) = pos(:,2)*headmodel.r(i) + headmodel.o(2);
8282
bnd(i).pos(:,3) = pos(:,3)*headmodel.r(i) + headmodel.o(3);
@@ -87,8 +87,8 @@ function ft_plot_vol(headmodel, varargin)
8787
end
8888

8989
case 'localspheres'
90-
bnd = [];
91-
for i=1:length(headmodel.label)
90+
bnd = repmat(struct(), numel(headmodel.label));
91+
for i=1:numel(headmodel.label)
9292
bnd(i).pos(:,1) = pos(:,1)*headmodel.r(i) + headmodel.o(i,1);
9393
bnd(i).pos(:,2) = pos(:,2)*headmodel.r(i) + headmodel.o(i,2);
9494
bnd(i).pos(:,3) = pos(:,3)*headmodel.r(i) + headmodel.o(i,3);

plotting/private/ptriprojn.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
end
2020

2121
[la, mu, dist, proj] = lmoutrn(v1, v2, v3, r);
22+
2223
switch flag
2324
case 0
2425
% finished

utilities/ft_checkdata.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,8 @@
13481348
% concatenate all trials
13491349
tmptrial = nan(ntrial, nchan, length(time));
13501350

1351+
begsmp = nan(ntrial, 1);
1352+
endsmp = nan(ntrial, 1);
13511353
for i=1:ntrial
13521354
begsmp(i) = nearest(time, data.time{i}(1));
13531355
endsmp(i) = nearest(time, data.time{i}(end));

utilities/nearest.m

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,17 @@
5454
if numel(val)==2
5555
% interpret this as a range specification like [minval maxval]
5656
% see also http://bugzilla.fcdonders.nl/show_bug.cgi?id=1431
57-
intervaltol=eps;
57+
intervaltol = eps;
5858
sel = find(array>=val(1) & array<=val(2));
5959
if isempty(sel)
6060
error('The limits you selected are outside the range available in the data');
6161
end
62-
indx(1) = sel(1);
63-
indx(2) = sel(end);
62+
indx = sel([1 end]);
6463
if indx(1)>1 && abs(array(indx(1)-1)-val(1))<=intervaltol
65-
indx(1)=indx(1)-1;
64+
indx(1) = indx(1)-1;
6665
end
6766
if indx(2)<length(array) && abs(array(indx(2)+1)-val(2))<=intervaltol
68-
indx(2)=indx(2)+1;
67+
indx(2) = indx(2)+1;
6968
end
7069
return
7170
end

utilities/private/channelposition.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,16 @@
165165
end
166166
chan = unique(chan);
167167
% find the matching channel-duplets
168-
ind = [];
169-
lab = {};
168+
ind = false(size(chan));
169+
lab = cell(length(chan),2);
170+
pnt = nan(length(chan),3);
171+
ori = nan(length(chan),3);
170172
for i=1:length(chan)
171173
ch1 = [chan{i} '_dH'];
172174
ch2 = [chan{i} '_dV'];
173175
sel = match_str(sens.label, {ch1, ch2});
174176
if length(sel)==2
175-
ind = [ind; i];
177+
ind(i) = true;
176178
lab(i,:) = {ch1, ch2};
177179
meanpnt1 = mean(sens.coilpos(abs(sens.tra(sel(1),:))>0.5, :), 1);
178180
meanpnt2 = mean(sens.coilpos(abs(sens.tra(sel(2),:))>0.5, :), 1);

utilities/private/fixinside.m

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,17 @@
6565
if ~isfield(source, 'outside')
6666
source.outside = [];
6767
end
68-
inside(source.inside) = (1==1); % true
69-
inside(source.outside) = (1==0); % false
70-
source.inside = inside(:);
68+
if isfield(source, 'pos')
69+
tmp = false(size(source.pos,1),1);
70+
elseif isfield(source, 'dim')
71+
tmp = false(prod(source.dim),1);
72+
end
73+
tmp(source.inside) = true;
7174
if isfield(source, 'outside')
75+
tmp(source.outside) = false;
7276
source = rmfield(source, 'outside');
7377
end
78+
source.inside = tmp(:);
7479
elseif logicalfmt && strcmp(opt, 'index')
7580
% convert to a vectors with indices
7681
tmp = source.inside;

utilities/private/pos2dim.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
% Copyright (C) 2009, Jan-Mathijs Schoffelen
1616

17-
if isstruct(pos),
17+
if isstruct(pos)
1818
pos = pos.pos;
1919
end
2020

@@ -24,6 +24,7 @@
2424
npos = size(pos,1);
2525
dpos = zscore(abs(diff(pos,[],1)));
2626

27+
dim = nan(1,3);
2728
[tmp, ind] = max(dpos,[],2);
2829
dim(1) = find(tmp>1.5,1,'first');
2930
dpos = dpos(dim:dim:npos-1,:);

0 commit comments

Comments
 (0)