[Eeglablist] visualization of rejmanual timepoints
Cedric Cannard
ccannard at protonmail.com
Mon Feb 20 14:58:00 PST 2023
Hi Agatha,
Sorry about that. This was the code for reconstructed data by ASR. The mask cannot be calculated here with different file lengths, indeed.
Here is the code for when data segments are removed (you'll need to run each section separated by %% one by one using ctrl+Enter, to wait for manual rejection to be done before trying to extract the latencies of the bad segments). The most ergonomic is probably to convert this into function.
% Make a copy of the dataset
EEG2 = EEG;
% Reject bad data manually
eegplot(EEG2.data,'winlength',15,'srate',EEG2.srate,'spacing',150, ...
'command','[TMPEEG, com] = eeg_eegrej(EEG2,eegplot2event(TMPREJ,-1));');
%% Get latency bounds of the removed segments
if ~isempty(com)
badData = extractBetween(com, ',',')');
badData = cellfun(@str2num, badData, 'UniformOutput', false);
badData = badData{:};
else
badData = [];
end
% Flatten removed segments on EEG2 (dataset copy)
for iSegment = 1:size(badData,1)
EEG2.data(:,badData(iSegment,1):badData(iSegment,2)) = 0;
end
% Visualize what you removed (in red)
vis_artifacts(EEG2,EEG);
%% If satisfied, remove the bad segments from the original dataset.
EEG = pop_select(EEG, 'nopoint', badData);pop_eegplot(EEG,1,1,1);
Note: you can adjust window length and scale of the eegplot with the inputs 'winlength' and 'spacing', respectively. For vis_artifacts, you can adjust the scale with +/- key, and scroll to the right with the arrow button at the bottom.
I hope this works for you.
Cedric
------- Original Message -------
On Monday, February 20th, 2023 at 11:39 AM, Agatha Lenartowicz <alenarto at g.ucla.edu> wrote:
> For documentation purposes - Cedric - the code you provided won’t work (at least with 2022 versions). The mask creation line assumes that EEG.data and EEG2.data are the same size and can be subtracted to uncover the removed timepoints but this is not true. The rejection step modifies the size of the data (by removing windows of data) and thus the operation you provide won’t work.
>
> al.
>
>> On Jan 24, 2023, at 1:01 PM, Cedric Cannard <ccannard at protonmail.com> wrote:
>>
>> Dear Agatha,
>>
>> While I don't know about this previous feature, here is how you can 1) make a copy of your EEG dataset, 2) remove bad portions from that copy, 3) visualize the differences, and 4) remove these segments from original dataset if satisfied.
>>
>> EEG2 = EEG; % copy
>> pop_eegplot(EEG2,1,1,1); % plot and remove bad segments manually
>> vis_artifacts(EEG2,EEG); % compare (removed segments are in red)
>> mask = sum(abs(EEG.data-EEG2.data),1) > 1e-10; % mask index of bad samples
>> badData = reshape(find(diff([false mask false])),2,[])'; % reshape for pop_select function
>> badData(:,2) = badData(:,2)-1; % fix latency
>> cleanEEG = pop_select(EEG,'nopoint',badData);
>>
>> Hope this helps,
>>
>> Cedric
>>
>> ------- Original Message -------
>> On Monday, January 23rd, 2023 at 10:07 AM, Agatha Lenartowicz <alenarto at g.ucla.edu> wrote:
>>
>>> Hi all.
>>>
>>> It used to be possible to select bad time windows via visual inspection (or otherwise) without actually REJECTing those time points. These would just be saved in EEG.reject.rejmanual. And they could later be viewed and modified.
>>>
>>> In 2022 it looks like this ability to visual inspect rejection-marked epochs has been removed.
>>>
>>> Is that correct? Is there a way to get this functionality back?
>>> Thanks!
>>> Agatha
>>>
>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>
>>> Agatha Lenartowicz, Ph.D.
>>> https://urldefense.com/v3/__http://www.agathalenartowicz.com__;!!Mih3wA!Hf_fuMWsUg6_m8hJuGFqzGcI7OQRWkvADSV8oUm78CTOUUlXIvsG5pobFmVgp88AQqfPg6jC1DxfGnktWs0Q8wz5_A$<https://urldefense.com/v3/__http://www.agathalenartowicz.com/__;!!Mih3wA!Hf_fuMWsUg6_m8hJuGFqzGcI7OQRWkvADSV8oUm78CTOUUlXIvsG5pobFmVgp88AQqfPg6jC1DxfGnktWs2-jg0X0w$>
>>>
>>> Associate Professor
>>> Semel Institute for Neuroscience and Human Behavior
>>> Department of Psychiatry and Biobehavioral Sciences
>>> Brain Research Institute
>>>
>>> Managing Director Neuroimaging Center for Cognitive Neuroscience
>>> https://urldefense.com/v3/__https://www.semel.ucla.edu/staglin__;!!Mih3wA!Hf_fuMWsUg6_m8hJuGFqzGcI7OQRWkvADSV8oUm78CTOUUlXIvsG5pobFmVgp88AQqfPg6jC1DxfGnktWs1vUnexgw$<https://urldefense.com/v3/__https://www.semel.ucla.edu/staglin__;!!Mih3wA!Hf_fuMWsUg6_m8hJuGFqzGcI7OQRWkvADSV8oUm78CTOUUlXIvsG5pobFmVgp88AQqfPg6jC1DxfGnktWs1vUnexgw$>
>>>
>>> University of California Los Angeles
>>> 760 Westwood Plaza, Suite 27-370B
>>> Los Angeles, CA 90095
>>> 310.794.5641 (x45641)
>>>
>>> _______________________________________________
>>> Eeglablist page:http://sccn.ucsd.edu/eeglab/eeglabmail.html
>>> To unsubscribe, send an empty email toeeglablist-unsubscribe at sccn.ucsd.edu
>>> For digest mode, send an email with the subject "set digest mime" toeeglablist-request at sccn.ucsd.edu
More information about the eeglablist
mailing list