Skip to content

Commit

Permalink
ic_temporalspatial - added icachansind to winv indices, proc_interp -…
Browse files Browse the repository at this point in the history
… now can handle interpolation and keeping non-scalp channels, proc_ica - updated for amica
  • Loading branch information
sjburwell committed May 21, 2019
1 parent b4fd56b commit 823f17d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
3 changes: 2 additions & 1 deletion functions/basefunc/ic_temporalspatial.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
return
elseif size(EEG.icawinv,2)<size(ICWINV.icwinv,1),
if V>0, disp(' Adjusting inverse weights from spatial input to match existing chanlocs...'); end
rdcidx = find(ismember(ICWINV.labels,{EEG.chanlocs.labels})); % assumes sorted the same, maybe change
% rdcidx = find(ismember(ICWINV.labels,{EEG.chanlocs.labels})); % assumes sorted the same, maybe change
rdcidx = find(ismember(ICWINV.labels,{EEG.chanlocs(find(EEG.icachansind)).labels})); % assumes sorted the same, maybe change %UPDATED 2019-5-20
icwinvtemp = ICWINV.icwinv; clear ICWINV
ICWINV = icwinvtemp(rdcidx); clear icwinvtemp
else,
Expand Down
8 changes: 5 additions & 3 deletions functions/procfunc/proc_ica.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
end
EEG = eeg_hist(EEG, ['EEG = ' mfilename '(EEG, ' arg2str(args) ');'] );



% specify input data matrix
if isfield(args,'datafilt') && EEG.trials>1 && args.datafilt>0,
EEG.reject.rejglobal = []; EEG.reject.rejglobalE = [];
Expand Down Expand Up @@ -83,11 +85,11 @@
end;

case 'amica',
if ~exist('runamica12'), disp(['Must have amica in path, see: https://sccn.ucsd.edu/~jason/amica_web.html']); return; end
if ~exist('runamica15'), disp(['Must have amica15 in path, see: https://sccn.ucsd.edu/~jason/amica_web.html']); return; end
if ~isempty(args.opts),
[EEG.icaweights, EEG.icasphere, mods] = runamica12(icadata, args.opts{:});
[EEG.icaweights, EEG.icasphere, mods] = runamica15(icadata, args.opts{:});
else,
[EEG.icaweights, EEG.icasphere, mods] = runamica12(icadata);
[EEG.icaweights, EEG.icasphere, mods] = runamica15(icadata);
end

otherwise,
Expand Down
18 changes: 18 additions & 0 deletions functions/procfunc/proc_interp.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@
args.rejreject = 0;
end

if args.rejthresh>50,
disp(' proc_interp; resetting rejthresh to 50, cannot interpolate >50% of channels');
args.rejthresh = 50;
end

% initiate interpE
EEG = eeg_rejsuperpose(EEG,1,1,1,1,1,1,1,1);
%EEG = eeg_hist(EEG, 'EEG = eeg_rejsuperpose(EEG,1,1,1,1,1,1,1,1);');
Expand Down Expand Up @@ -150,14 +155,27 @@
% interpolate
XSTCHANS = find( ismember({chanlocs.labels},{EEG.chanlocs.labels}));
ADDCHANS = find(~ismember({chanlocs.labels},{EEG.chanlocs.labels}));
MISCHANS = find(~ismember({EEG.chanlocs.labels},{chanlocs.labels})); % SJB 2019-05-13, in case of extra non-interpolated channels not in XSTCHANS
if ~isempty(find(interpE)) && ismember(args.type,{'full','artifact'}), % SJB 2019-01-22
EEG = eeg_interp3d_spl(EEG, interpE); %chan-epoch
end

if ~isempty(ADDCHANS),
EEG = eeg_interp(EEG, chanlocs); %whole-channel
newE = zeros(length(chanlocs), size(interpE,2));
if ~isempty(MISCHANS),
interpEmis = interpE(MISCHANS,:);
interpE(MISCHANS,:) = '';
end
newE(XSTCHANS,:) = interpE;
newE(ADDCHANS,:) = 1;
if ~isempty(MISCHANS),
newE = [newE; interpEmis];
EEG.data = [EEG.data; EEG.data(1:length(MISCHANS),:,:)];
EEG.data(1:length(MISCHANS),:,:) = '';
EEG.chanlocs = [EEG.chanlocs EEG.chanlocs(1:length(MISCHANS))];
EEG.chanlocs(1:length(MISCHANS)) = '';
end
interpE = newE;
end

Expand Down

0 comments on commit 823f17d

Please sign in to comment.