|
|
**Table of Contents**
|
|
|
|
|
|
[[_TOC_]]
|
|
|
# Creating Marks by Using Scripts
|
|
|
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.
|
... | ... | @@ -10,37 +12,37 @@ The example below calls the function *chan_neighbour_r* which creates an array b |
|
|
Preforming the calculation on the data and sorting it by the result criteria:
|
|
|
```matlab
|
|
|
%% IDENTIFY BRIDGED CHANNELS...
|
|
|
%Does a calculation based on the EEG.data
|
|
|
mr=mean(fisherz(EEG.m_neigbr_r_ch),2);
|
|
|
sr=std(fisherz(EEG.m_neigbr_r_ch),[],2);
|
|
|
msr=mr./sr;
|
|
|
% Does a calculation based on the EEG.data
|
|
|
mr = mean(fisherz(EEG.m_neigbr_r_ch), 2);
|
|
|
sr = std(fisherz(EEG.m_neigbr_r_ch), [], 2);
|
|
|
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]);
|
|
|
flag_b_chan_inds = find(msr > ve_trimmean(msr, [bridge_trim]) + ve_trimstd(msr, [bridge_trim]) * [bridge_z]);
|
|
|
```
|
|
|
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;
|
|
|
lnkflags = zeros(EEG.nbchan, 1);
|
|
|
lnkflags(chan_inds(flag_b_chan_inds)) = 1;
|
|
|
% 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});
|
|
|
EEG.marks = marks_add_label(EEG.marks, 'chan_info', {'bridge', [.7, 1, .7], [.2, 1, .2], -1, lnkflags});
|
|
|
|
|
|
%%COMBINE MARKS STRUCTURE INTO MANUAL FLAGS...
|
|
|
%% COMBINE MARKS STRUCTURE INTO MANUAL FLAGS...
|
|
|
% Adds the marks label into the *manual* labelled structure.
|
|
|
EEG=pop_marks_merge_labels(EEG,'chan_info',{'manual','low_r','bridge'},'target_label','manual');
|
|
|
EEG = pop_marks_merge_labels(EEG, 'chan_info', {'manual', 'low_r', 'bridge'}, 'target_label', 'manual');
|
|
|
|
|
|
%REMOVE FLAGGED channels...
|
|
|
%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');
|
|
|
% REMOVE FLAGGED channels...
|
|
|
% 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');
|
|
|
```
|
|
|
More information on the marks functions can be found on the [Functions](https://git.sharcnet.ca/bucanl_eeglab_extensions/vised_marks/wikis/functions) and [Marks Structure Design](https://git.sharcnet.ca/bucanl_eeglab_extensions/vised_marks/wikis/marks) wiki pages. In the *scalpart.htb* script there are many mark labels all merged into *manual*. Areas marked with *manual* are then hidden before the data is given to an ICA analysis. If you want to remove a single mark label you can simplify the code to the following, directly rejecting the marks.
|
|
|
More information on the marks functions can be found on the [Functions](functions) and [Marks Structure Design](marks) wiki pages. In the *scalpart.htb* script there are many mark labels all merged into *manual*. Areas marked with *manual* are then hidden before the data is given to an ICA analysis. If you want to remove a single mark label you can simplify the code to the following, directly rejecting the marks.
|
|
|
|
|
|
```matlab
|
|
|
%REMOVE FLAGGED channels...
|
|
|
%Direct removal, no merge to *manual* first.
|
|
|
EEG=pop_marks_select_data(EEG,'channel marks',[],'labels',{'lnkflags'},'remove','on');
|
|
|
% REMOVE FLAGGED channels...
|
|
|
% Direct removal, no merge to *manual* first.
|
|
|
EEG = pop_marks_select_data(EEG, 'channel marks', [], 'labels', {'lnkflags'}, 'remove', 'on');
|
|
|
```
|
|
|
|
|
|
Flagging is crucial to preparing data for further analysis such as ICA , as you can remove the bad channel and time data for the ICA, but then return the flags once ICA is complete and still retain the original data file.
|
... | ... | @@ -48,8 +50,4 @@ Flagging is crucial to preparing data for further analysis such as ICA , as you |
|
|
|
|
|
***
|
|
|
|
|
|
[ :house: **Return to Main Page**](https://git.sharcnet.ca/bucanl_eeglab_extensions/vised_marks/wikis/home)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ :house: **Return to Main Page**](home) |
|
|
\ No newline at end of file |