<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Aptos;
        panose-1:2 11 0 4 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Aptos",sans-serif;
        mso-ligatures:standardcontextual;
        mso-fareast-language:EN-US;}
code
        {mso-style-priority:99;
        font-family:"Courier New";}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML - vooraf opgemaakt Char";
        margin:0cm;
        font-size:10.0pt;
        font-family:"Courier New";}
span.HTML-voorafopgemaaktChar
        {mso-style-name:"HTML - vooraf opgemaakt Char";
        mso-style-priority:99;
        mso-style-link:"HTML - vooraf opgemaakt";
        font-family:"Courier New";
        mso-ligatures:none;
        mso-fareast-language:NL;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:11.0pt;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="NL" link="#467886" vlink="#96607D" style="word-wrap:break-word">
<div class="WordSection1">
<p><span lang="EN-US" style="color:black">Dear FieldTrip Support Team,<o:p></o:p></span></p>
<p style="caret-color: rgb(0, 0, 0);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span lang="EN-US" style="color:black">Currently, I am working with sleep EEG data and facing an issue with visualizing artifact-rejected data after employing partial rejection methods.<o:p></o:p></span></p>
<p style="caret-color: rgb(0, 0, 0);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span lang="EN-US" style="color:black">I have developed a custom script to define trials, which reads PSG signals from an EDF file and event annotations from a CSV file. This script calculates trial segments (trl) by specifying start and end points relative
 to event times, ensuring that each trial fits within the dataset's limits. The trl matrix records the start and end samples of each trial, along with its offset and associated event value. This precise trial definition is crucial for subsequent data analysis
 steps, including artifact rejection and sleep stage classification.<o:p></o:p></span></p>
<p style="caret-color: rgb(0, 0, 0);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span lang="EN-US" style="color:black">For artifact detection, I utilize automatic methods within FieldTrip to partially reject artifacts based on segments, specifically targeting EOG and EMG artifacts.
</span><span lang="EN-US" style="color:black">The</span><span class="apple-converted-space"><span lang="EN-US" style="color:black"> </span></span><code><span lang="EN-US" style="font-family:"Aptos",sans-serif;color:black">eog_artifacts.EOG_eye</span></code><span class="apple-converted-space"><span lang="EN-US" style="color:black"> </span></span><span lang="EN-US" style="color:black">and</span><span class="apple-converted-space"><span lang="EN-US" style="color:black"> </span></span><code><span lang="EN-US" style="font-family:"Aptos",sans-serif;color:black">combined_muscle_artifacts
</span></code><span lang="EN-US" style="color:black">structures contain</span><span lang="EN-US" style="color:black"> pairs of sample indices indicating the start and end of detected artifact segments, highlighting where artifacts were identified during the
 detection process.<o:p></o:p></span></p>
<p style="caret-color: rgb(0, 0, 0);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span lang="EN-US" style="color:black">I am able to visualize marked artifacts using the following code snippet:<o:p></o:p></span></p>
<pre style="caret-color: rgb(0, 0, 0);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px"><code><span lang="EN-US" style="color:black">%% Visualization of the signal with marked artifacts <o:p></o:p></span></code></pre>
<pre><code><span lang="EN-US" style="color:black">cfg = [];<o:p></o:p></span></code></pre>
<pre><code><span lang="EN-US" style="color:black">cfg.channel = 'all'; % All channels<o:p></o:p></span></code></pre>
<pre><code><span lang="EN-US" style="color:black">cfg.viewmode = 'vertical'; % Or 'butterfly', depending on preference<o:p></o:p></span></code></pre>
<pre><code><span lang="EN-US" style="color:black">cfg.artfctdef.eog.artifact = eog_artifacts_high.EOG_eye;<o:p></o:p></span></code></pre>
<pre><code><span lang="EN-US" style="color:black">cfg.artfctdef.muscle.artifact = combined_muscle_artifacts;<o:p></o:p></span></code></pre>
<pre><code><span lang="EN-US" style="color:black">ft_databrowser(cfg, data_segmented);<o:p></o:p></span></code></pre>
<p style="caret-color: rgb(0, 0, 0);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span lang="EN-US" style="color:black">Here is a simplified version of the code snippet I use to reject artifact segments:<o:p></o:p></span></p>
<pre style="caret-color: rgb(0, 0, 0);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px"><code><span lang="EN-US" style="color:black">%% Reject artifacts partially within trials<o:p></o:p></span></code></pre>
<pre><code><span lang="EN-US" style="color:black">cfg = [];<o:p></o:p></span></code></pre>
<pre><code><span lang="EN-US" style="color:black">cfg.artfctdef.reject = 'partial'; % Partial rejection within trials<o:p></o:p></span></code></pre>
<pre><code><span lang="EN-US" style="color:black">cfg.artfctdef.eog.artifact = eog_artifacts.EOG_eye; % EOG artifacts<o:p></o:p></span></code></pre>
<pre><code><span lang="EN-US" style="color:black">cfg.artfctdef.muscle.artifact = combined_muscle_artifacts; % Combined muscle artifacts<o:p></o:p></span></code></pre>
<pre><code><span lang="EN-US" style="color:black"><o:p> </o:p></span></code></pre>
<pre><code><span lang="EN-US" style="color:black">data_clean_artifactfree = ft_rejectartifact(cfg, data_segmented);<o:p></o:p></span></code></pre>
<pre><code><span lang="EN-US" style="color:black"><o:p> </o:p></span></code></pre>
<pre><code><span lang="EN-US" style="color:black">cfg = [];<o:p></o:p></span></code></pre>
<pre><code><span lang="EN-US" style="color:black">cfg.channel = 'all'; % All channels<o:p></o:p></span></code></pre>
<pre><code><span lang="EN-US" style="color:black">cfg.viewmode = 'vertical'; % Visualization mode<o:p></o:p></span></code></pre>
<pre><code><span lang="EN-US" style="color:black">ft_databrowser(cfg, data_clean_artifactfree);<o:p></o:p></span></code></pre>
<p style="caret-color: rgb(0, 0, 0);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span lang="EN-US" style="color:black">During artifact rejection </span><span lang="EN-US" style="color:black">using</span><span class="apple-converted-space"><span lang="EN-US" style="color:black"> </span></span><code><span lang="EN-US" style="font-family:"Aptos",sans-serif;color:black">ft_rejectartifact</span></code><span lang="EN-US" style="color:black">,
 I encounter the following warning messages: "The input is raw data with 14 channels and 1 trial. Warning</span><span lang="EN-US" style="color:black">: Original data has trialinfo, using user-specified trialinfo instead. Warning: correcting numerical inaccuracy
 in the time axes". Despite these warnings, the artifact rejection process completes successfully. However, when attempting to visualize the cleaned data (second part of the code), I observe fragmented signals where rejected artifact segments are displayed
 as white spaces, indicating signal removal. This fragmentation makes it challenging to assess the artifact-free data as a continuous signal and to detect any discontinuities or abrupt transitions in the data.<o:p></o:p></span></p>
<p style="caret-color: rgb(0, 0, 0);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span lang="EN-US" style="color:black">Ultimately, </span><span lang="EN-US" style="color:black">my objective is to use</span><span class="apple-converted-space"><span lang="EN-US" style="color:black"> </span></span><code><span lang="EN-US" style="font-family:"Aptos",sans-serif;color:black">ft_redefinetrial</span></code><span class="apple-converted-space"><span lang="EN-US" style="color:black"> </span></span><span lang="EN-US" style="color:black">to
 concatenate</span><span lang="EN-US" style="color:black"> segments and visualize the entire continuous signal (while preserving the event markers – so that the information about the sleep stages is still accessible). Could you please provide guidance on how
 to seamlessly visualize the cleaned data after partial artifact rejection? Specifically, I would appreciate insights into any additional parameters or configurations that might be necessary to achieve a continuous visualization of the artifact-free EEG signal,
 ensuring proper data handling and analysis.<o:p></o:p></span></p>
<p style="caret-color: rgb(0, 0, 0);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span lang="EN-US" style="color:black">Thank you in advance for your assistance.<o:p></o:p></span></p>
<p style="caret-color: rgb(0, 0, 0);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="color:black">Best regards,<o:p></o:p></span></p>
<p style="caret-color: rgb(0, 0, 0);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="color:black">Sophie Schubert<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<!-- --><hr>

<p><font size="-2" face="arial" color="black"><i>
De informatie opgenomen in dit bericht kan vertrouwelijk zijn en is
uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onterecht
ontvangt, wordt u verzocht de inhoud niet te gebruiken en de afzender direct
te informeren door het bericht te retourneren. Het Universitair Medisch
Centrum Utrecht is een publiekrechtelijke rechtspersoon in de zin van de W.H.W.
(Wet Hoger Onderwijs en Wetenschappelijk Onderzoek) en staat geregistreerd bij
de Kamer van Koophandel voor Midden-Nederland onder nr. 30244197.
</i></font></p>

<p><font size="-2" face="arial"  color="green"><i>
Denk s.v.p aan het milieu voor u deze e-mail afdrukt.
</i></font></p>

<hr>

<p><font size="-2"  face="arial" color="black"><i>
This message may contain confidential information and is intended
exclusively for the addressee. If you receive this message
unintentionally, please do not use the contents but notify the sender
immediately by return e-mail. University Medical Center Utrecht is a legal
person by public law and is registered at the Chamber of Commerce for
Midden-Nederland under no. 30244197.
</i></font></p>

<p><font size="-2"  face="arial" color="green"><i>
Please consider the environment before printing this e-mail.
</i></font></p>
</body>
</html>