Skip to content

Commit

Permalink
Bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
aojeda committed Oct 28, 2018
1 parent bff9663 commit 37e8af7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
3 changes: 3 additions & 0 deletions EEGSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
function g = get.g(obj)
g = obj.x(obj.indG,:,:);
end
function g = get_source_trial(obj,trial)
g = obj.x(obj.indG,:,trial);
end
function g_roi = get.g_roi(obj)
dim = size(obj.x);
if length(dim) < 3
Expand Down
2 changes: 1 addition & 1 deletion pop_inverseSolution.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
loc(loc>EEG.pnts) = [];
if isempty(loc), break;end
if length(loc) < windowSize
[X(:,loc(1):end,trial),~,~,gamma(:,c,trial), logE(c,trial)] = solver.update(EEG.data(:,loc(1):end,trial), [],[],options);
[X(:,loc(1):EEG.pnts,trial),~,~,gamma(:,c,trial), logE(c,trial)] = solver.update(EEG.data(:,loc(1):end,trial), [],[],options);
break;
end

Expand Down
23 changes: 11 additions & 12 deletions pop_inverseSolutionROI.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
loc(loc>EEG.pnts) = [];
if isempty(loc), break;end
if length(loc) < windowSize
[X(:,loc(1):end),~,~,gamma(:,c,trial), logE(c,trial)] = solver.update(EEG.data(:,loc(1):end,trial), [],[],options);
[X(:,loc(1):EEG.pnts),~,~,gamma(:,c,trial), logE(c,trial)] = solver.update(EEG.data(:,loc(1):end,trial), [],[],options);
break;
end

Expand Down Expand Up @@ -164,10 +164,10 @@
end

% Compute average ROI time series
X_roi(:,:,trial) = computeSourceROI(X, indG, trial, P, isVect);
X_roi(:,:,trial) = computeSourceROI(X, indG, P, isVect);

% Data cleaning
EEG.data(:,:,trial) = cleanData(H, X, indG, trial);
EEG.data(:,:,trial) = cleanData(H, X, indG);

fprintf('\n');
end
Expand All @@ -187,29 +187,28 @@
end

%%
function y = cleanData(H, X, indG, trial)
function y = cleanData(H, X, indG)
try
y = H(:, indG)*X(indG,:, trial);
y = H(:, indG)*X(indG,:);
catch
n = size(X,2);
y = zeros(size(H,1),n);
delta = min([1024 round(n/100)]);
for k=1:delta:n
ind = k:k+delta-1;
ind(ind>n) = [];
y(:,ind) = H(:, indG)*X(indG,ind, trial);
y(:,ind) = H(:, indG)*X(indG,ind);
end
end
end

%%
function x_roi = computeSourceROI(X, indG, trial, P, isVect)
function x_roi = computeSourceROI(X, indG, P, isVect)
try
x = X(indG,:, trial);
if isVect
x_roi = sqrt(P*(x.^2));
x_roi = sqrt(P*(X(indG,:).^2));
else
x_roi = P*x;
x_roi = P*X(indG,:);
end
catch
n = size(X,2);
Expand All @@ -219,9 +218,9 @@
ind = k:k+delta-1;
ind(ind>n) = [];
if isVect
x_roi(:,ind) = sqrt(P*(X(indG,ind, trial).^2));
x_roi(:,ind) = sqrt(P*(X(indG,ind).^2));
else
x_roi(:,ind) = P*X(indG,ind, trial);
x_roi(:,ind) = P*X(indG,ind);
end
end
end
Expand Down

0 comments on commit 37e8af7

Please sign in to comment.