|
|
[[_TOC_]]
|
|
|
# Creating Marks by Using Scripts
|
|
|
Marks can also be generated from a flag structure based on any criteria you would like. Creating functions that test the data for particular features is easily done by generating a script.
|
|
|
Marks can be generated from computing a flag structure based on any criteria you would like. Creating functions that test the data for particular features is easily done by generating a script.
|
|
|
|
|
|
:b: The following code snippets are from the BUCANL *eeglab_pipe_asr_amica* pipeline: *s01_scalpart.htb* script.
|
|
|
|
... | ... | @@ -17,30 +17,27 @@ msr=mr./sr; |
|
|
% If a channel fits the criteria specified its index is added to an array
|
|
|
flag_b_chan_inds=find(msr>ve_trimmean(msr,[bridge_trim])+ve_trimstd(msr,[bridge_trim])*[bridge_z]);
|
|
|
```
|
|
|
This code creates a new channel mark label called *lnkflags* and fill it with the data array gathered above. It then copies the mark locations into the *manual* label, as *manual* in the end will be the only label that is removed.
|
|
|
This next section of code creates a new channel mark label called *lnkflags* and fills it with the data in the array gathered above. It then copies the mark locations into the flags structure labelled *manual*. In the end *manual* will be the only label that is updated with all of the information from he other criteria structures.
|
|
|
|
|
|
```matlab
|
|
|
%% EDIT CHANFLAGINFO STRUCT...
|
|
|
% Create a new array to store the results
|
|
|
lnkflags=zeros(EEG.nbchan,1);
|
|
|
lnkflags(chan_inds(flag_b_chan_inds))=1;
|
|
|
% Creates a new marks label, sets its color, and list which array contains the marks it is using.
|
|
|
% Creates the new marks label, sets its color, and list which array contains the marks it is using.
|
|
|
EEG.marks=marks_add_label(EEG.marks,'chan_info', {'bridge',[.7,1,.7],[.2,1,.2],-1,lnkflags});
|
|
|
|
|
|
%%COMBINE MARKS STRUCTURE INTO MANUAL FLAGS...
|
|
|
% Adds the marks label into the *manual* label which will be rejected by default
|
|
|
% Adds the marks label into the *manual* labelled structure.
|
|
|
EEG=pop_marks_merge_labels(EEG,'chan_info',{'manual','low_r','bridge'},'target_label','manual');
|
|
|
|
|
|
%REMOVE FLAGGED channels...
|
|
|
%Removes the *manual* channel mark label
|
|
|
%Removes the *manual* channel mark label which deletes the channels stored in the *lnkflags* structure and any others that were merged into manual.
|
|
|
EEG=pop_marks_select_data(EEG,'channel marks',[],'labels',{'manual'},'remove','on');
|
|
|
```
|
|
|
In the *scalpart.htb* script there are many mark labels merged into *manual* before it is eventually removed. If you want to remove a single mark label you can simplify the code to the following, directly rejecting the marks.
|
|
|
```matlab
|
|
|
%% EDIT CHANFLAGINFO STRUCT...
|
|
|
lnkflags=zeros(EEG.nbchan,1);
|
|
|
lnkflags(chan_inds(flag_b_chan_inds))=1;
|
|
|
EEG.marks=marks_add_label(EEG.marks,'chan_info', {'bridge',[.7,1,.7],[.2,1,.2],-1,lnkflags});
|
|
|
|
|
|
```matlab
|
|
|
%REMOVE FLAGGED channels...
|
|
|
%Direct removal, no merge to *manual* first.
|
|
|
EEG=pop_marks_select_data(EEG,'channel marks',[],'labels',{'lnkflags'},'remove','on');
|
... | ... | |