-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathpspm_update_channeltype.m
50 lines (49 loc) · 2.04 KB
/
pspm_update_channeltype.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
function [channeltype_new] = pspm_update_channeltype (channeltype_og, keyword)
% ● Description
% pspm_update_channeltype update the keywords of channel type
% ● Arguments
% channeltype_og: [string] the name of the original channel type
% keyword: the keyword to update to
% accepted values, 'c', 'pp', or {'c','pp'}
% 'c': update the lateral keyword 'l' or 'r' to 'c'
% 'pp': update the channel type to be preprocessed
% {'c','pp'}: update the channel type to be both bilateral
% and preprocessed.
% ● Output
% channeltype_new: the new channel type with the updated keyword
% ● History
% Introduced in PsPM 6.0.
% Written in 2022 by Teddy Chao (UCL)
%% Initialise
global settings
if isempty(settings)
pspm_init;
end
sts = -1;
channeltype_new = channeltype_og;
channeltype_og_struct = split(channeltype_og, '_');
channeltype_new_struct = split(channeltype_new, '_');
switch class(keyword)
case 'char'
switch keyword
case settings.lateral.char.c
loc = strcmp(channeltype_og_struct, settings.lateral.char.l) + strcmp(channeltype_og_struct,settings.lateral.char.r);
channeltype_new_struct{logical(loc)} = settings.lateral.char.c;
case 'pp'
if ~strcmp(channeltype_og_struct,'pp')
channeltype_new_struct = {channeltype_og_struct{1}, 'pp', channeltype_og_struct{2:end}};
end
end
otherwise
% if keyword is {'c','pp'}
if isempty(setdiff(keyword, {settings.lateral.char.c,'pp'})) || isempty(setdiff(keyword, {'pp',settings.lateral.char.c}))
loc = strcmp(channeltype_og_struct,settings.lateral.char.l) + strcmp(channeltype_og_struct,settings.lateral.char.r);
channeltype_new_struct{logical(loc)} = settings.lateral.char.c;
if ~strcmp(channeltype_og_struct,'pp')
channeltype_new_struct = {channeltype_new_struct{1}, 'pp', channeltype_new_struct{2:end}};
end
end
end
channeltype_new = join(channeltype_new_struct,'_');
channeltype_new = channeltype_new{1};
return