123
2017 UNIVERSIDADE DE LISBOA FACULDADE DE CIÊNCIAS DEPARTAMENTO DE FÍSICA Development of an Algorithm for the Automatic Detection of Artifacts in Neonatal Electroencephalography Filipe Gervásio Gonçalves Costa Mestrado Integrado em Engenharia Biomédica e Biofísica Perfil em Sinais e Imagens Médicas Dissertação orientada por: Prof. Alexandre Andrade Prof. Dr. Linda S. de Vries

Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

Embed Size (px)

Citation preview

Page 1: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

2017

UNIVERSIDADE DE LISBOA

FACULDADE DE CIÊNCIAS

DEPARTAMENTO DE FÍSI CA

Development of an Algorithm for the

Automatic Detection of Artifacts in

Neonatal Electroencephalography

Fi l ipe Gervásio Gonçalves Costa

Mestrado Integrado em Engenharia Biomédica e Biofís ica

Perf i l em Sina is e Imagens Méd icas

Disser tação or ientada por :

Pro f. Alexandre Andrade

Pro f . Dr. L inda S. de Vr ies

Page 2: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através
Page 3: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

3

“We may feel i l l prepared to face the feared changes ahead, yet each of

us can look back at our own lives and see count less t imes that

something felt scary, hard and imposs ible . We were sure we wouldn’ t

make it , and then we did . This is res il ience - the wil l ingness to pers is t ,

to learn from the exper ience, and to try again.”

Sarina Behar Natkin

Page 4: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através
Page 5: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

i

Acknowledgements – Pt. 1

This f i r s t sect ion of the acknowledgements i s dedica ted to Suzanne Ol ivei ra -

Mar tens and Leona rd van Schelven , medica l phys icis t s in the Depa rtment Medische

Technologie en Kl inische Fys ica of the UMC Utrecht .

As an engineer ing s tudent worki ng in a hospi t a l , I cannot thank you enough for

your technica l input and for your open mi nd whenever I showed you my ideas .

Thank you for t he suppor t you gave me in my project , a lways backing up my

ideas and hel ping me taking them even fur ther . Fo r ques t ioning the methods and

helpi ng me see wha t could be i mproved and wha t the nex t s tep should be.

As for supervis ion in the more technica l and engi neer -y par ts of my project , I

wi l l a lways r emember your par t ic ipa t ion as a very i mpor tant and sol id founda t ion

in the cha l lenge I ca me across a t the UMCU. Thank you.

Page 6: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

i i

Page 7: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

i i i

Acknowledgements – Pt. 2

There comes a t ime when r ecogni t ion i s not only necessary, but due.

This sect ion i s dedica ted to every per son tha t ha s helped me throughout this

project .

So, f i r s t of a l l , thank you a l l .

Thank you, Professor Alexandre Andrade, for helping me and suppor t ing me

ever s ince day one. When I f i r s t approached you wi th this project you showed an

i mmedia te inter es t tha t meant a lot to me, and tha t inter es t ha s never fad ed

throughout the la s t year .

Thank you, Dr . Linda de V r ies, for br inging me to Utrecht and for introduci ng

me to one of the bes t projects I’ve ever worked on. Thank you for being ab le to

see my engineer ing ski l l s and al lowing me to apply them i n the cl inic a l wor ld.

Obr igado Inês , por seres quem és . Por me compreenderes , mes mo quando não é

preciso dizer as coisa s . Por seres igua l a mi m.

Obr igado Mãe, pelo coração .

Obr igado Pa i, pela mente de engenhei ro.

Obr igado Mar ta , pelas r edes , pela s conver sa s e pelos ca fé s. Especia lmente pelos

ca fés .

Obr igado ao CV pela companhia , pela paciência , e pela vi leza.

Obr igado à Rodr igues pela mel hor equipa , em tudo.

Obr igado à Pinto e à Sousa pelos f ins de sema na em que me sent i em casa.

Obr igado ao Pessoa l Fixola s, porque um “ Bom dia !” diár io é sempre a mel hor

ma neir a de começa r o dia a sor r i r .

Obr igado à Anica , por ser a Anica que todos devia m ter .

Thank you, Bi l t s traa t Family, fo r maki ng Utrecht my second home, a nd for

ma king every day an adventure . Should we meet tonight for ice cr eam a t Rober to’ s?

Thank you, everybody in the WKZ off ices : Lauren, for the amaz ing help

throughout my project ; Kris t in, for the coffees and for the cha ts ; N ienke, Na tha l ie,

Lisa , Raymond, Kim, Nino, Mehmet , for being a grea t off ice company!

Las t ly, I would l ike to t hank t he Erasmus+ ins t i tut ion, a s wel l a s the Depa r tment

of Neona tology a t the UMCU for the suppor t throughout my s tay in The

Nether lands .

Page 8: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

iv

Page 9: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

v

Resumo

Todos os dia s , bebés r ecém-nascidos são admit idos em inú meras Unidades de

Cuidados Intens ivos Neona ta is (UCIN). As causas para es tas admissões passam

pr incipa l mente por na scimentos prema turos ou out ros t ipos de compl icações

durante o pa r to, como é o ca so da a s f ix ia .

Vis to que qua isquer compl icações durante o pa r to podem leva r a Acidentes

Vasculares Cerebra is (AVC’s) ou out ro t ipo de danos no cé rebro, os r ecém -

na scidos são admit idos por per íodos de tempo que podem chega r à s 72 hora s . Nes te

per íodo de admissã o, os bebés do hospi ta l pedi á tr ico de Utrecht , nos Pa íses Ba ixos,

são acompanhados por uma equipa de médicos e enfermeiros sempre presente , ao

mes mo tempo que são a ltamente moni tor i zados , tanto em ter mos da sua a tividade

cerebral – a través de e le t roencefa logra fia (EEG) – como de out ros pa râmetros

f i s iológicos , como o r i tmo ca rdíaco - e le t rocardiogra fia (ECG) - , função

r espi ra tó ria ou mes mo oxigenação cerebra l a t ravés de espetroscopia do

infr avermelho próx imo ( Near Infra- red Spectroscopy – NIRS) .

Dadas a s longas aquis ições dos vá r ios parâmetros f i s iológicos , dos qua is a

a t ividade cerebral medi da a través de EEG é t ida em especia l foco nes ta disser tação,

é norma l que ocor ram per turbações nas le itura s, sejam essa s per turbações de

or igem fis iológica ou não. Ass im sendo, os ar tefactos, i . e . , os per íodos de

infor mação de EEG que não r epresentam cor retamente a a t ividade cerebra l do

indiví duo, cor rompem a integr idade da aquis ição de dados , podendo mes mo leva r

a decisões erradas no que diz r espei to ao diagnós t ico do paciente ou a opções

terapêut icas . Um dos grandes obs táculos nes te camp o é o facto de mui t os ar tefactos

ter em um ca rácter per iódico e a l tamente r í tmico e serem comummente ident i f icados

como convulsões pelos a lgor i tmos de deteção de convulsões , levando mui ta s vezes

à admi nis t ração de medicação excess iva e/ou er rada n os pacientes na UCIN.

Atua l mente já ex istem a lgor i t mos de deteção de a r tefactos em EEG, os qua is se

baseiam pr inci pa l mente em ca racter í s t ica s espacia is dos s ina is de EEG – à s qua is

não é poss ível r ecor rer nes te ca so, vis to que se usam apenas dois cana is bipola res

– ou na Aná l ise de Componentes Independent es ( ICA), a qua l sepa ra os s ina is de

EEG nos di ferentes componentes presentes no s ina l . Como já foi r efer ido, com

apenas dois cana is de EEG não se torna viável apl icar es ta aná l i se porque o

r esul tado ser ia demasiado r eduz ido pa ra ser poss ível a lcançar uma decisão de

confiança . Estes a lgor i tmos já desenvolvi dos foca m-se pr incipa lmente nos

ar tefactos ma is comummente presentes nos dados , como os da a t ividade ocula r ,

muscula r e cardíaca.

Pos to i s to, o projet o desenvolvi do na presente disser tação propõe um novo

mé todo de deteção de a r tefactos em s ina is de EEG neona ta l . Atua lmente podem ser

encontr ados no EEG da UCIN sete tipos di fer entes de a r tefactos :

- Ondas Sinusoida is – ondas que se a ssemelham em tudo à função ma temá t ic a

s inusoida l e que têm uma fr equência caracter ís t ica ent r e os 1 .5 Hz e os 3 Hz;

Page 10: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

vi

- Ondas t ipo PED ( Periodic Epi lept i form Discharges ) – es ta s ondas

a ssemelha m-se a ondas caracter í s ticas de episódios epi lé t icos , mas devido ao facto

de possuí r em uma for ma di fe rente e não terem causa f i s iológica conhecida são

cons ideradas como a r tefactos ;

- Ondas Zeta – ondas del ta ( com fr equência infer ior a 4 Hz) com uma for ma de

serra e que se encontr am no EEG durante per íodos de tempo r eduz idos ;

- Osci lações de Al ta Frequência – embora não tenham uma fr equência

pa r t icula rmente a l ta para os va lores que o EEG pode a tingi r , es tes ar tefactos são

ca racter izados por uma onda s inusoida l cons t ante com uma fr equência ent r e os 8

Hz e os 11 Hz ;

- At ividade Muscula r – como o nome indica , a a t ividade muscula r na cabeça dos

r ecém-nascidos pode in f luencia r a le i tura dos elé trodos , int roduz indo uma

aquis ição com ma ior fr equência e de menor ampl i tude;

- At ividade Cardíaca – o campo elé tr ico do bat iment o cardíaco é c onduz ido a té

ao esca lpe, onde se encontr am os elé t rod os agulha , inf luenciando a le i tu ra dos

mes mos e levando a um s ina l de EEG que se assemelha bas tante à de um ECG;

- Movi mento/Des locação dos Elé t rodos – Quando os bebés são movi dos ou

quando se admi nis t ra a lgum t ipo de medicação pode haver des locament o dos

elé trodos col ocados no esca lpe e a lei tura pode a t ingi r va lores demasiado elevados ,

que não têm jus t i f icação f i siológica .

Des ta forma , o a lgor i tmo pa ra deteção de ar tefactos desenvolvi do focou- se

pr i meir amente na cr iação de sete a lgor i tmos individua is , cada um especia l izado

nas caracter ís t ica s de cada um dos a r tefactos menci onados acima . P ara cada

a lgor i tmo i ndi vidua l foi cr iada uma base de dados de EEG de cinco sujei tos , que

serviu pa ra o t r e ino e pa ra o tes te de cada a lgor i tmo. O EEG de cada sujei to t inha

aprox imada mente 30 minutos e er am per íodos com uma for te presença de

ar tefactos . Es tes períodos foram selecionados especia lmente pa ra es te projeto e

todos os ar tefactos presentes nos dados foram marcado s manua l mente por uma

mé dica especial izada , de forma a que os a lgor i tmos t ivessem um golden s tandard

pa ra que fosse poss ível comparar os seus r esul tados e ot i mizar cada a lgor i tmo.

Des ta forma , foram cons i derados nes te projet o aquis ições de EEG de 28 sujei t os

di fer entes : c inco pa ra cada algor i tmo, à exceção do a lgor i t mo pa ra a A t ividade

Muscula r que teve apenas tr ês sujei tos e o do Movi ment o, que não necess i tou de

nenhum.

Durante o desenvol vi mento de cada a lgor i tmo foram sempre cons i derados os

r esul tados de Sens ib i l idade e Especi f ic idade a t ravés da comparação com as

marcações manua is do golden s tandard da base de dados de t r e ino e tes te, de forma

a ot imizar cada a lgor i tmo e ob ter sempre os melhores r esul tados poss íveis .

Para os trê s pr imeiros a r tefactos (Ondas Sinus oida is , t ipo PED e Zeta ) os

a lgor i tmos baseiam-se no cá lculo da corr elação do s inal com uma onda subs t ituta

que tem uma for ma igua l à do a r tefacto em ques tão. Qua ndo a cor r elação for

super ior a um deter mi nado va lor limi te de finido pelo ut i l iz ador , o a lgor i tmo

cons idera a presença desse ar tefacto, indicando -o no r esul tado f ina l . Es tes va lores

Page 11: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

vi i

l imi tes são di ferentes para cada a lgor i tmo devido à s caracter í s ticas de ca da

ar tefacto e à forma como cada a lgor i tmo foi desenvolvi do. O a lgor i tmo pa ra a s

Osci lações de Al ta Frequência tem como base a compressão no tempo do s ina l de

EEG, de forma a ob ter um s ina l semel hante ao de aEEG (EEG de ampl i tude

integrada) , o qua l permi te uma ident i f icação ma is fáci l do a r tefacto, mé todo es te

que é ut i l izado de for ma s emelhante pa ra o ar tefacto da A t ividade Cardíaca . O

a lgor i tmo pa ra a At ividade Muscula r baseia -se numa função que ca lcula a dis tância

ent r e pontos consecut ivos , vis to que es t e cons is te num s ina l com menor ampl i tude,

mas com va r iações de va lores ma is abrupta s ent r e pontos consecut ivos , permi t indo

ident i f ica r os per íodos de s ina l a r tefactua l. Por f i m, o a lgor i t mo pa ra o ar tefacto

de Movi ment o e/ou Des locação dos E lé trodos baseia - se no va lor máximo absoluto

que o EEG pode tomar . Des ta forma , no iní cio do a lgor i tmo o ut i l izador deve

int roduz i r a idade do sujei to em ques tão e para cada va lor ( ent r e 23 e 42 semanas

ges taciona is) haverá va lores máxi mos e míni mos acei tes na li tera tura como

f i s iologica mente nor ma l . Se o EEG est iver acima ou aba ixo (r espet ivamente)

desses l imi te s , é cons iderado como a r tefactual .

Após o desenvolvi ment o de todos os a lgor i tmos indivi dua is , es tes foram

combi nados num só algor i tmo de deteção de a r tefactos em E GG neona ta l. Es te

a lgor i tmo f i na l r equer apenas que o ut i l izador indique a idade do sujei to em que o

EEG foi adquir ido e que a r tefacto é que pretende deteta r . Des ta forma , o a lgor i t mo

a inda não é tota lmente independente do ut i l izador , pois confia que o mes mo fa rá

uma rápida ava l iação visua l do s ina l a anal i sar e que consegue ident i f ica r qua l o

ar tefacto presente no EEG, permi t indo ao a lgor i tmo ident i f ica r com ma ior exa tidão

os per íodos em que os a r tefactos se iniciam e termina m.

De forma a anal i sar os r esul tados f ina is do a lgor i t mo de deteção de a r tefactos ,

foram ca lculadas as taxas de Verdadeiros Pos i t ivos , Fa lsos Pos i tivos e Fa lsos

Nega t ivos . O algor i tmo f i na l , englobando t odos os a lgor i tmos individua is , ob teve

uma taxa de Verdadei ros Pos i t ivos de 92 ,4% ± 7,5%, uma taxa de Fa lsos Pos i t ivos

de 34 ,9% ± 19 ,8% e uma taxa de Fa lsos Negativos de 7 ,7% ± 7 ,5%.

Como se pode observar pela s percentagens ob t ida s, o a lgor i tmo consegui u

ident i f ica r corr etamente ma is de 90% dos ar tefactos presentes nos dados , o que se

t ra duz numa deteção cor r eta e de confiança . A taxa dos Fa lsos Pos i t ivos a inda

poderá ser foco de ot i mização, uma vez que é pa ssível de ser r eduz ida a través de

ma is dados pa ra tr e inar e tes tar os a lgor i tmos , conduz indo então a uma ma ior

precisão dos va lores limi te que sepa ram os per íodos a r tefactua i s daqueles que

cor r espondem a a t ividade cerebra l verdadei ra . Já a percentagem dos Fa lsos

Nega t ivos , ou seja , a s vezes que o a lgor i tmo não detetou um a rtefacto quando es te

es tava de facto presente no s ina l , não é exce ss ivamente a l ta e foi cons iderada

r eduz ida o sufic iente pelo pessoa l médico quando es tes r esul tados lhes foram

apresentados .

O projeto apresentado nes ta disser tação propõe então um pr i meiro passo no

desenvol vi ment o do pr i meiro a lgor i tmo que cons idera sete a r tefactos dis t intos ,

pelo que a inda há tópicos que merecem ot i mização – como os va lores l i mi te

defini dos - , havendo ta mbé m a necess idade da inclusão de ma is dados de sujei tos

di fer entes pa ra poder t r e inar e tes ta r os a lgori tmos indi vidua is , de forma a ev i tar

o sobre-a jus te dos mé todos aos dados disponí veis .

Page 12: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

vi i i

Pa lavra s-chave: Deteção de Ar tefactos ; EEG Neona ta l

Page 13: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

ix

Abstract

Ar t i facts - erroneous infor ma t ion in the acquis i t ion of the b ra in act ivi ty – in

the EEG reading of newborns tha t a r e admit ted in the NICU is a ma jor prob lem

tha t can have ser ious consequences , both in diagnos t ic and therapeut ic - r ela ted

decis ions , a s some a r t i facts can ea s i ly be mis taken for seizures , leading to

wrongful adminis t r a t ion of medica t ion . These a r ti facts can have var ious or igins

and i t s manua l ident i f ica t ion in the EEG trace i s highl y t i me -consuming, r ea son

why there i s the need to devel op an a lgor i thm tha t can automa t ica l ly detect the

ar t i facts in the EEG acquis it ions .

The a lgor i thm developed in this disser ta t ion proposes to detect seven dis t inct

types of a r t i facts commonly found i n neona ta l EEG: Sinus waves , PED-Like waves ,

Zeta waves , H igh Frequency Osci l la t ions , ECG, EMG and Movement /E lect rode

Displacement a r t i facts. Each one of these a r ti facts ha s i t s own speci f ic fea t ures

tha t a l low i t to be ident i f ied , usua l ly through a visua l assessment of the r aw EEG

s igna l , so the overa l l a lgor i thm is based on seven individua l a lgor i thms , each

focus ing on one a r t i fact, highl ight ing those cha racter i s t ics and select ing the

per iods of da ta tha t corr espond to a r ti factua l EEG. Each individua l a lgor i thm had

a tra ining/ tes t ing set of da ta tha t was selected by an exper ienced doctor who

ma nua l ly annota ted al l the a r t i facts present in the EEG s igna l , so that the

a lgor i thms could have a golden s tandard to compare i t s r esul t s to. Per iods of 30 -

minute EEG were cons idered from 28 di ffer en t sub jects a s a t ra ining/ tes t ing set of

da ta – f ive for each sub ject , minus EMG that only had three and Movement had

none. These per iods were selected due to a s t rong present of a r t i facts in i t .

The f ina l detect ion a lgor i thm had a True Pos i t ive ra te of 92 .4% (±7.5%) and a

Fa lse Nega tive ra te of 7 .7% (±7.5%). The a lgor i thm s t i l l r equi r es user input in the

select ion of which ar t i fact i s to be detected in the da ta , bu t this a lgor i thm is the

f i r s t s tep in a method tha t compr ises this many di ffer ent ar t i facts into one detect ion

tool , r eason why there i s st i l l r oom for i mprovement in the methods devel oped.

Keywords : Art i fact Detect ion, Neona tal EEG;

Page 14: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

x

Page 15: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

xi

Table of Contents

Acknowledgements – Pt. 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i

Acknowledgements – Pt. 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i i i

Resumo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v

Abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x i

Lis t of Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x i i i

Lis t of Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv

Lis t of Abbrevia t ions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi i

1 Int roduct ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

2 Theoret ica l Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 .1 Neona ta l Neuro-care in the NICU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 .2 Neona ta l E lectroencepha lography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 .3 Ampli tude- integra ted EEG in the NICU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 .4 EEG Art i facts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

3 Sta te of the Ar t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

3 .1 Ar t i fact Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

3 .2 Seizure Detect ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

3 .3 Ar t i fact Remova l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

4 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

4 .1 EEG Acquis i t ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

4 .2 Manua l marking of the a r t i facts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

4 .3 Detect ion Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

4 .4 Threshol d Select ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

4 .5 Assembl ing the Al gor i thms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

5 Resul ts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

5 .1 Sinus Wave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

5 .2 The ot her a lgor i thms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

5 .3 Assembl ing the Al gor i thms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

6 Discuss ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

7 Concl us ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

8 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

9 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

10 Appendices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i

Page 16: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

xi i

Page 17: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

xi i i

List of Figures

Figure 2 .1 – Signa l process ing from the r aw EEG to the aEEG. The sca le on the

hor izonta l ax is r ema ins cons tant in a l l plots . Source: [14] . . . . . . . . . . . . . . . . . . . . . . . . . 5

Figure 2.2 - D ifferent traces of the neona ta l aEEG: A –Cont inuous Nor ma l Vol tage,

B/C – D iscont inuous Nor ma l Vol tage, D - Bur s t suppress ion, E – Cont inuous

Low Vol tage, F – Flat Trace. Source : pa t ient da ta . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Figure 2.3 - Seizure pa t tern detected in the neona ta l aEEG (above) , wi th a rhythmic

act ivi ty vis ib le in the EEG (below) . Source: [14] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Figure 2 .4 – ECG a rt i facts vis ib le on both lef t and r ight raw EEG traces . Source:

pa t ient da ta . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Figure 2.5 – Art i facts due to muscle act ivi ty on the lef t r aw EEG (above) and HFO

ar t i facts on the r ight raw EEG (below) . Source: pa t ient da ta . . . . . . . . . . . . . . . . . . . . . . . 9

Figure 2 .6 – Art i facts due to movement wi th large increa se of the ampl i tude.

Source: pa t ient da ta . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Figure 2 .7 – Sinusoida l ar t i facts in the r ight raw EEG. Source: pa tient da ta . . . . 10

Figure 2.8 – Per iodic Epi lept ic Discha rges in both raw EEG t races, wi th a c lea r er

shape in the r ight s igna l . Source: pa t ient da ta . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Figure 2 .9 – PED-Like Ar t i fact in both raw EEG t races. Source: pa tient da ta . . . 11

Figure 2 .10 – Zeta waves ar t i facts vis ible on both raw EEG tr aces . Source: pa tient

da ta . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Figure 4 .1 - Examples of cor r ela t ion va lues for di ffer ent over lapping s inus s igna ls

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Figure 5 .1 - Raw EEG s igna l wi th annota ted ar t i facts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

Figure 5 .2 - Correla t ion ma tr ix wi th the s in funct i on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

Figure 5 .3 - Correla t ion ma tr ix wi t h the cos funct i on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

Figure 5 .4 - Correla t ion ma tr ix a f ter the combina t ion of the s in and cos ma t r ices

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

Figure 5 .5 - Norma l ized a rray wi th the cor r ela t ion va lues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

Figure 5 .6 - ROC curve wi th the Sens i t ivi ty and Speci f ic i ty va lues for a l l

thr esholds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

Figure 5 .7 –Detect ions array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Figure 5 .8 - Detect ions arr ay a f ter the funct ion jo in t_peaks . . . . . . . . . . . . . . . . . . . . . . . . . . 36

Figure 5 .9 - Raw EEG s igna l wi th two PED -Like a r t i facts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

Page 18: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

xiv

Figure 5 .10 - Ar ray wi th the detect ion of bot h PED -Like ar t i facts . . . . . . . . . . . . . . . . . . 37

Figure 5 .11 - Raw EEG s igna l wi th two Zeta ar t i facts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

Figure 5 .12 - Ar ray wi th the detect ion of bot h Zeta a r ti facts . . . . . . . . . . . . . . . . . . . . . . . . . 38

Figure 5 .13 - Raw EEG s igna l wi th one HFO ar t i fact . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

Figure 5 .14 - Ar ray wi th the detect ion of t he one HFO a r ti fact . . . . . . . . . . . . . . . . . . . . . . 39

Figure 5 .15 - Raw EEG s igna l wi th two ECG ar t i facts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

Figure 5 .16 - Ar ray wi th the detect ion of bot h ECG ar t i facts . . . . . . . . . . . . . . . . . . . . . . . . . 40

Figure 5 .17 - Raw EEG s igna l wi th one EMG ar t i fact . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

Figure 5 .18 - Ar ray wi th the detect ion of the one EMG ar t i fact . . . . . . . . . . . . . . . . . . . . . . 41

Figure 5 .19 - Raw EEG s igna l wi th two dis t inct per iods of ar t i facts due to

Movement or E lectrode Displacement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

Figure 5 .20 - Array wi th the detect ion of both per iods of a r t i facts due to Movement

or E lectrode Displacement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

Page 19: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

xv

List of Tables

Table 4.1 – Number of ar t i factua l per iods in each set of da ta . . . . . . . . . . . . . . . . . . . . . . . . . 18

Table 5.1 - Threshold va lues for the di ffer ent ar t i facts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

Table 5.2 - Types of a r t i facts tha t each a lgor ithm detected . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

Table 5.3 - Resul t s of a l l a lgor i thms, for a ll sub jects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

Table 5.4 - Mean of the r esul t s from a l l a lgori thms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

Page 20: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

xvi

Page 21: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

xvi i

List of Abbreviations

aEEG | Ampl i tude- Integra ted E lectroencepha logram

BCI | Bra in-Computer Inter face

B SS | Bl ind Source Sepa ra tion

DWI | D i ffus ion-Weighted Imaging

CFM | Cerebra l Funct ion Moni tor

ECG | E lectrocardiography

EEG | E lectroencepha lography

EMG | E lectromyography

EOG | E lectrooculography

FN | False Nega t ive

GA | Ges ta t iona l Age

HF | H igh Frequency

HFO | H igh Frequency Osci l la t ions

HIE | Hypoxic- Ischemic Encepha lopa thy

ICA | Independent Component Ana lys is

LF | Low Frequency

MRI | Magnet ic Resonance Imaging

NaN | Not a Number

NICU | Neona ta l Intens ive Care Uni t

NIRS | Near- Infr aRed Spect roscopy

PCA | Pr incipa l Component Ana lys is

PED | Per iodic Epi lept ic Discharges

ROC | Receiver Opera t ing Cha racter i s tic

aEEG | Ampl i tude- Integra ted EEG

STFT | Shor t -Ti me Four ier Transform

TN | True Nega t ive

TP | True Pos i t ive

US | Ul tra sound

WGA | Weeks of Ges ta t iona l Age

Page 22: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

xvi i i

Page 23: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

1

1 Introduction

The huma n bra in i s cons tant ly t rying to explain i t sel f .

Neuroscience i s one of the most s tudied f ie lds of science and yet there is

so much tha t i s s ti l l undiscovered. In an effor t to under s tand the human bra in,

one must take into account every a spect of i t s ma tura t ion and a l l the processes

tha t lead to the deve lopment of such a compl ex organ. This i s why i t i s very

i mpor tant to under s tand not only the adul t , ma tured brain, but a lso the

newborn one - term and preterm.

I f somet i mes i t i s compl ica ted enough to expla in the mechanis ms

under lying the adul t b rain, one can only expect to encounter jus t a s many

obs tacles wi th a newborn bra in, and then some more due t o the cons tant

devel opmenta l processes occur r ing. In the infants admit ted to the Neona ta l

Intens i ve Care Uni t (NICU), bra in act ivi ty i s moni tored over per iod s of

severa l hour s - even days - through e lect roencepha lographic (EEG)

acquis i tions , which a l low for a bet ter under s tanding of a l l the processes tha t

happen in tha t t ime.

Unfor tuna tely, and l ike any ot her phys iologi ca l parameter ’ s acquis i t ion,

i t is very ha rd to ob ta in only the intended in for ma t ion wi thout ar t i facts . In

this disser ta t ion, ar t i facts ar e defined a s phys iologica l or non-phys iol ogica l

fea tures [1] tha t dis rupt the da ta and inf luence the overa l l t ra ce on the

acquis i tion, poss ib ly leading to mis interpretat ions or la ck of under s tand ing

on the r ea l and cor r ect infor ma t ion of the hea l th sta te of the pa t ient . As the

NICU is no except ion, neona ta l EEG acquis itions a lso include a r t i facts tha t

somet i mes may prevent proper conclus ions on d iagnos is or therapeut ic

opt ions . This i s the r ea son why there i s the need to devel op a met hod tha t

automa t ica l ly detects these a r t i facts from the da ta and avoids the need for the

cl inica l sta ff or r esea rchers to have to run through a l l the da ta and annota te

them ma nua l ly, which i s very t i r esome and highl y t i me-cons umi ng.

As ar t i facts can very often mask the t rue EEG reading of the b rain’ s

act ivi ty and lead to mis interpretat ions , harming the diagnos t ic process , one

must be very ca reful when ana lys ing the raw EEG. Only exper ienced

cl inicians can infer conclus ions based on the EEG and/or the ampl i t ude-

integra ted EEG (aEEG) traces , a s i t r equi r es a grea t discerning capaci ty to be

ab le to separa te ar t i facts from nor ma l b ra in act ivi ty.

In the nor ma l bra in act ivi ty ca tegory, one must a lso include seizures , as

they a re present in 4% to 48% of the newb orn popula t ion in the NICU [2] .

The seizure detect ion a lgor i thms nowadays r ely most ly on the rhythmici ty o f

the s igna l in order to ident i fy an epi lept ic ep isode, and unfor tuna tely, some

ar t i facts have a s imi la r morphology a s seizures and are character ized by a

high degree of r epet i t iveness . When one cons ider s this fact , i t becomes ea sy

to under s tand the r ea son why these seizure detect ion a lgor i thms may have a

high r ate of fa lse pos i t ives [1] .

Page 24: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

2

This i s the mot iva t ion for this d isser ta t ion project : to be able to ident i fy

ar t i facts in EEG data wi thout r e lying solely on i t s rhythmici ty or i t s r epet i t ive

pa t tern, but a lso on some more a r t i fact -speci f ic known fea tures , indivi dua l to

each di ffer ent type of a r t i fact cons idered. With th is in mind, the a lgor i th m

devel oped here focused on each ar t i fact separa tely, making the most out o f

the cha racter is t ics tha t were previous ly s tudied and ident i f ied .

Automa t ic detect ion of di ffer ent a spects of the neona ta l b ra in’ s act ivi ty i s

a lr eady bui l t in some devices , but mos t of them focus on detect ing seizure

episodes or per iods of high elect rode i mpedance, both very di ffer ent , a s the

for mer a llows the cl inicians to adjus t medica t ion and make therapeut ic

decis ions , and the la t ter infor ms wha t per iods may not have the bes t da ta

qua l i ty , r ega rdless of being actual brain act ivi ty or ar t i factua l per iods of da ta .

The development of a method t ha t automa t ical ly detects a r t i facts in neona ta l

EEG would avoid t ime -consumi ng visua l assessment of a l l the da ta , wh ich

can cover a few days , whi le a lso being an addi t ion t o the s igna l process ing

tools tha t a lr eady ex is t.

As this i s the f i r s t approach on the project , the a lgor i thm was developed

in a ba s is of t r ia l - and-er ror , cr ea ting novel methods of ana lys is and a r t i fa ct

detect ion, compar ing those r esul t s wi th manua l annota t ions and ca lcula t ing

bas ic r esul t s of Sens i t ivi ty and Speci f ic i t y, and these methods a re a l l

descr ibed wi th a higher level of deta i l in the fo l lowing chapter – see Methods .

Once each a t tempt was developed and i t s r esul t s were ana lysed, the goa l was

to under s tand wha t was being done r ight and which a spects of the met hod

coul d be improved, a lways compar ing r esul t s wi thin the same a r t i fact’ s

methods , in order to opt i mize the detect ion a lgor i thm.

As one can under s tand, not a l l a t tempts for each a r ti fact’ s method coul d

be deta i led in this r epor t , so onl y the successful a t tempts a r e deta i led and

onl y those r esul t s ar e included in the Resul ts chapter . Fol lowing tha t , a

discuss ion of t he a lgor i thm’s r esul t s i s a l so included, a s wel l as a Conclus ion

for this disser ta t ion and some topics to r ef lect upon when cons i der ing the

Future Work tha t can s t i l l be done in this projec t .

Page 25: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

3

2 Theoretical Background

2.1 Neonatal Neuro-care in the NICU

In order to bes t moni tor the changes in the hea l thcare of neona tes , a s wel l

a s improve the r esources for bet ter therapeut ic opt ions and r esearch

inves t iga t ions a ssocia ted wi th b i r th asphyxia , b ra in hemor rhage and hypoxic -

ischemic bra in injury [3 ] , a va r ie ty of measur ing techniques ca be used. As

an example , a newborn admit ted to the NICU can be submit ted to EEG

acquis i tions , as wel l as cerebra l b lood oxygena t ion moni tor ing through Nea r

Infr a -Red Spect roscopy (NIRS). Other cr i t ical phys iol ogica l pa rameter s a r e

a lso measured in the NICU, such a s hear t ra te an d b lood pressure [4] . Given

the neurol ogica l s t r ess a t b ir th, the br ain’ s elect r ica l a ct ivi ty i s very ca reful ly

moni tored through aEEG, which a l lows for – but not exclus ively - seizure

detect ion through a moni t or ing sys tem [3] . Two-channel EEG suff ices in the

condi t ions of the NICU, a l lowing for an ear ly diagnos is tha t could ot herwise

be made la ter on, when the chi ld s tar ted to display learning di ff icul t ies . Whi le

the aEEG displayed in the Cerebral Funct ion Moni tor (CFM) only has two

channels , provi ding less infor ma t ion than a convent iona l EEG wi th 16

channels or more , one must cons ider the benefi t of placing only f ive

elect rodes at any t ime and leaving them for long - t ime acquis i t ions . This i s

especia l ly true in the ca se of prema ture newborns or bab ies wi th suppressed

bra in activi ty, where indica tor s of bra in injury may ar ise dur ing several hour s

or even days a f ter bi r th or an hypoxic - ischemic event , a l lowing for a bet ter

moni tor ing of the b ra in’ s r ecovery of the background act ivi ty and r esponse

to medica t ion in the presence of seizures [4] .

When i t comes to b ra in imaging, neona ta l cerebral ul t ra sound (US) i s

usua l ly cons idered in order to rule out any kind of antena ta l injury or some

sor t of int r acranial hemor rhage, whi le Magnet ic Resonance Imagi ng (MRI) i s

used to diagnose more sub t le whi te ma t ter les ions in the preterm infant and

hypoxic i schemic injury i n the ful l - term i nfant fol lowing per ina ta l asphyxia

or other disorder s such a s metabol ic disorde r s or s trokes [5] . At the same

t ime, Diffus ion Weighted Ima ging (DWI) can a lso be useful in the detect ion

of cytotox ic edema , when t he MRI i f prefor med wi thi n the f i r s t week a f ter

del ivery and pr esumed t i me of insul t .

When cons ider ing t o moni tor the newborn’ s b rain act ivi ty for longer

per iods of t i me, e lect roencepha lographic da ta becomes the bes t approach. In

this , one must take into account the hemispher ic a symmetry, r eason why most

acquis i tions take into account b i la teral f ronto -pa r ie ta l e lectrodes [6] .

Especia l ly in infants wi th suppressed bra in act ivi ty the ampl i tude may be

increa sed due to ar tefacts and r esul t in a dr i f t of the ba seline act ivi ty, which

must a lso be taken into cons idera t ion, especia l ly in infants wi th suppressed

bra in act ivi ty, so both the pa t tern and the a mpl i tude va lues must be cons idered

ca reful ly in order to avoid an incor rect diagnos is .

Page 26: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

4

The most i mpor tant r ea son for the use of cont inuous EEG in the NICU is

the detect ion of seizures, which can have cl inica l manifes ta t ions

( cl inica l/convuls ive seizures) or not (non -cl inica l /non-convuls ive seizures) ,

the la t ter being the hardes t to ident i fy wi thout EEG. These seizures may be

the r esul t of a cute cerebral edema or so me ot her kind of i njury, which can be

exacerba ted by the seizures [7] .

2.2 Neonatal Electroencephalography

In the NICU or in any other hea l th -care faci l ity, EEG is usua l ly the best

approach to moni t or the b ra in’ s activi ty, given tha t i t i s a power ful and non -

invas ive tool for diagnos is , r esearch and prognos is on poss ib le injur ies to the

b ra in. Most of the t imes , in the NICU, EEG recordings begin a s soon a f ter

b i r th as poss ib le a f ter b ir th , a l lowing for a bet ter discernment between nor ma l

and abnorma l act ivi ty throug hout the admis s ion and poss ib le r eactions to

t r ea tment [9] .

G iven the di ffer ent s ta tes of neura l ma turat ion and development , the

neona ta l nervous sys tem is di ffer ent f rom t he pedia t r ic one, a s wel l a s the

adul t , wi th most o f the seizures being subcl inica l , an impor tant r ea son why

cont i nuous EEG is of great va lue [10] . When i t comes to a nor ma l preter m

EEG, one must take into account tha t the thi rd t r imes ter of pregnancy i s the

one wi th the b igges t devel opmenta l changes in the b ra in [9] , which a re a lso

vis ib le in the baby’s EEG. In preterms of under 30 weeks of ges ta t iona l age

(WGA) the di ffer ent pa t terns of sleep/wake cycl ing a re not yet c lear ly vis ib le,

given tha t they spend most of thei r t ime in a s ta te of quiet sleep. In these

pa t ients one can see in the EEG trace var ious discont inuous pa t terns , di ffer ent

rhythmic del ta , a lpha a nd beta act ivi ty, as well a s energy bur s ts and interva ls

between bur s ts wi th var iab le durat ions [9] .

2.3 Amplitude-integrated EEG in the NICU

Every day ex t r emely prema ture infants a r e born, and even i n term i nfants ,

some compl ica t ions may ar ise dur ing b i r th, such a s per ina ta l a sphyxia . In a l l

of these ca ses , the ex is tence of proper moni to r in g of t he newborn’ s cerebral

funct ion i s cr i t ica l , hence the increa s ing interes t in the development o f the

NICU’s equipment .

When i t comes to measur ing the b ra in act ivi ty of infants tha t ar e admit ted

to the NICU for severa l days, one can’ t expect to analyze approx ima tely 72

hour s of da ta to check the EEG trace and only then be ab le to run a corr ect

diagnos is . In order to faci l i ta te the observa t ion and make the decis ion- maki ng

process fa s ter , the NICU’s nowadays a lso cons ider aEEG as par t of beds ide

moni tor ing.

Page 27: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

5

This s igna l i s ob ta ined from a nor ma l EEG, but goes through a process of

f i l ter ing and t ime compress ion ( Figure 2 .1 ) , displaying the di ffer ence

between the maxi mum and mi ni mum a mpl i tude in the nor ma l EEG, a l lowing

for an ea s ier and quicker eva lua t ion of t he act ivi ty in t he neona ta l b ra in [11] .

This moda l i ty of displaying elect roencepha lographic da ta is widely used

in neona ta l cases of hypoxic - ischemic encepha lopa thies (HIE) , seizures,

infect ions , amongs t other s , and uses only f ive e lect rodes (preferab ly needle

because of lower impedance) [7] , unl ike the Amer ican Elect rophys iol ogy

Guidel ine [12] , tha t favor s the use of 16 channels . The elect rodes ar e placed

in b i -par ie ta l pos i t ions - P3 /F3 and P4/F4 according to the 10 /20 sys tem [13] .

The dis play of the infor ma t ion i s usua l ly made in a semi - loga r i thmic sca le

– l inear from 1 to 10 V and l oga r i thmic from 10 to 100 V – maxi miz ing the

ab il i ty to detect changes in the lower fr equencies . The s igna l in the aEEG is

ampl i f ied and band-pass f i l ter ed, which suppresses activi ty wi th a fr equency

lower than 2 Hz and higher than 15 Hz, in order to mini mize a r ti facts

or igina ted f rom swea t ing, movement , muscle act ivi ty and elect r ica l

inter ference [14] . The s igna l can be further processed, which includes

r ect i f ica t ion, s moothi ng and cons iderab le t ime compress ion, in order to see

the overa l l evolut ion of the t race and bet ter ident i fy speci f ic pa t terns , such

a s s leep-wake cycles and seizures , the la tter being r ecognized by a shi f t of

both the lower and upper margins in the aEEG.

The s igna l displayed on the beds ide moni tor can then be visua l ly eva lua ted

and di ffer ent pa t terns can be r ecognized and cla ss i f ied, a ccording to [14]

(Figure 2.2) :

A - Cont inuous Nor ma l Vol tage (CNV) – cont inuous act ivi ty wi t h a lower

margin between 7 V and 10 V and upper margin between 25 V and 50 V;

F ig ur e 2 . 1 – S ig na l p r o c e ss ing f r o m t he r a w EE G t o th e a E E G.

Th e s ca le o n t he ho r iz o nt a l a x is r e ma ins c o ns t a nt i n a l l p lo t s .

S o ur c e : [ 1 4]

Page 28: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

6

B /C - D iscont inuous Nor ma l Vol tage (DNV) – discont inuous background

wi th va r ious r anges of a mpl i tude, but wi th a lower margin under 5 V and

upper margin over 10 V;

D - Bur st Suppress ion (BS) – discont inuous background act ivi ty wi th a

mini mum act ivi ty a round 0 V and bur s ts that ar e grea ter than 25 V;

E - Cont inuous Low Vol tage (CLV) – cont inuous background act ivi ty but

wi th an upper margin a round 5 V;

F - Fla t Trace (FT) – isoelect r ic ( inact ive) background act ivi ty.

With this long-dura t ion da ta visua l iza t i on, aEEG is a very power f ul tool

for the diagnos is of HIE , but it s assessment r equi r es tra ining in detect ing

actua l brain act ivi ty, given tha t a r t i facts may a r ise and conta mi na te the actua l

da ta [15] . Movement , which has a much hi gher ampl i tude, may conta mina te

the da ta and be seen in the aEEG, a s wel l a s muscula r shiver ing, somet i mes

caused dur ing hypot her mia . Anot her thing t ha t the cl inica l s ta ff mus t be ab le

to r ecognize ar e seizures, which a re ident i f ied by an increa se in ampl i tude,

vis ib le in the aEEG, and a progress ive change in fr equency, vis ib le in the

EEG ( Figure 2 .3) . These seizures ar e caused by excessive and spontaneous

elect r ica l a ct ivi ty of c lus ter s of neurons tha t ar e r esponding to i ns tab i l it ies

in the nor ma l b ra in funct ion [1] .

The aEEG a l lows the t ime - locked s ynchronized visua l iza t ion wi th the r aw

EEG, the former having a window of approxima tely three hour s of r ecording

and the la t ter one of only 10 seconds . Thi s for m of dis play enab les the

ident i f ica t ion of a r t i facts tha t were not descr ibed in the newborn popula t ion

[16] , which could lead to mis interpreta t ions on the development of the

infants , a s wel l a s their outcomes [17] [18] .

F ig ur e 2 . 2 - D i f f e r e nt t ra c es o f t he ne o na t a l a E E G: A – Co nt i nuo us N o r ma l Vo l t a ge ,

B / C – D is c o nt i nuo us N o r ma l Vo l t a ge , D - B urs t s up p re s s io n, E – Co nt i nuo us L o w

V o l t a ge , F – F la t Tr ac e . So ur ce : p a t ie nt d a t a .

Page 29: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

7

Unfor tuna tely, and despi te a l l effor ts to mi ni mize the presen ce of a r ti facts

in the da ta , the NICU i t sel f i s a subopt i ma l envi ronment , as the r esearcher s

have less cont rol over the condi t ions of the acquis i t ion, cr ea t ing a higher r i sk

of r ecording a r t i factua l s igna ls [19] .

2.4 EEG Artifacts

As the aEEG is t ime -compressed, i t i s ma inly used to eva lua te the

background pa t tern, s leep -wake cycles and the presence of seizure episodes ,

given thei r ampl i tude s hi f t in the aEEG, a s shown in Figure 2 .3 . In the raw

EEG however , ar t i facts ar e more ea si ly seen, especia l ly in bab ies wi th

suppressed bra in act ivi ty, where ar t i factua l phys iologica l or non -

phys iologica l infor ma t ion can have a higher inf luence and j ux tapos i t ion i n

the b ra in’ s act ivi ty .

In order to fur ther under s tand ar t i facts and how to ident i fy t hem, a br ief

explana t ion on each type i s fol lowed.

2 .4.1 Electrocardiogram

An elect roca rdiogram (ECG) is the measurement of t he hea r t’ s e lectr ica l

act ivi ty and i s one of the pa rameter s acqui r ed in the NICU.

In infants wi th hi ghl y suppressed bra in act ivi ty, ECG ar ti facts occur when

the high elect r ica l ca rdiac f ie ld a ffects the sur face potent ia ls on the sca lp,

nea r the electrodes , inter fer ing wi th the EEG reading [20] [21] . As one ca n

expect , the more suppressed the b ra in activi ty, the ea s ier i t is to see the

F ig ur e 2 . 3 - S e iz ur e p a t te r n d e t ec te d in t h e ne o na t a l a E E G (a bo ve ) , w i t h

a rh yt h mic a c t iv i t y v is i b le i n t h e E E G ( be lo w) . S o ur ce : [ 1 4]

Page 30: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

8

infant ’ s ECG on the EEG. The t ime gr id on the screen a l lows the visua l

assessment of a highly per iodic s igna l of sma l ler ampl i tude tha t a seizure

(which i s a lso per iodic but wi th an evol ut ion i n fr equency and/or ampl i tude ) ,

a s one can see in Figure 2.4 .

2 .4.2 Electromyogram

The EEG act ivi ty can often detect e lect romyographic (EMG) act ivi ty,

picked up because of the muscles ’ e lectr ical a ct ivi ty [22] . This act ivi ty can

a lso occur due to the eyes’ muscle movement , but those a r ti facts a r e not seen

in the NICU because of two r ea sons : f i r s t , the infants spend most of thei r t i me

wi th thei r eyes c losed, in a s ta te of quiet s leep, and second because the

elect rodes used a re usua lly pa r ieta l ly placed, fa r away from the in f luence of

the eye’ s movement .

These a r t i facts ar e usua lly cha racter iz ed by a sma l l ampl i tude in

suppressed infants , as wel l a s a s igna l wi th a shape tha t appea r s to be much

more l ike a s tochas tic signa l and wi thout a speci f ic fr equency , a s i t can be

seen by the upper ha l f of Figure 2 .5 ( in the lef t raw EEG).

F ig ur e 2 . 4 – E C G ar t i f ac ts v i s ib le o n bo t h le f t a nd r ig h t r aw E E G t r ac e s .

S o ur c e : p a t ie nt d a t a .

Page 31: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

9

2 .4.3 Movement and Electrode Displacement

When the infant i s moved or the elect rodes ar e displaced, the ar t i facts tha t

ar e ma inly present in the r aw EEG are character ized by a higher ampl i tude

than any than any bra in activi ty measured, and i s usua lly over 10 0 V (Figure

2 .6) , somet i mes r eaching 400 V. These a r t i facts can a lso be detected by a

very i rr egula r shape and by some t i me poi nts tha t don’ t have an actua l value

(due to t he a mpl i f ier ’ s sa tura t ion) , a s the elect rodes couldn’ t r ead infor ma t ion

from the bra in’ s act ivi ty due to the move ment a t tha t t ime .

2 .4.4 High Frequency Osc i llat ions

High Frequency Osci l la t ions (HFO) are sma ll ampl i tude waves tha t can

occur in the s uppressed EEG. They have a wel l defined shape and do not

t rans la te into any speci f ic brain process or kind of act ivi ty, l ike in the lower

F ig ur e 2 . 5 – Ar t i fa c ts d ue to mus c le ac t iv i t y o n t h e le f t r aw E E G (a bo ve ) a nd H FO

a r t i f ac ts o n t h e r igh t r aw EE G ( be lo w ) . S o ur ce : p a t ie nt d a t a .

F ig ur e 2 . 6 – Ar t i fa c ts d ue to mo ve me nt w i t h la r ge inc r ea s e of t h e a mp l i t ud e .

S o ur c e : p a t ie nt d a t a .

Page 32: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

10

ha l f of Fig ure 2 .5 , on the r ight r aw EEG. This type of a r t i fact usua l ly ha s a

fr equency r ange of 8 – 11 Hz , which i s higher than the nor ma l vent i la t ion

fr equency, hence i t s na me . Within this range, the fr equency can a lso depend

on the sub ject .

2 .4.5 Sinusoidal Waves

Sinusoi da l Waves are sine - shaped waves in the EEG recordings [2] tha t do

not have a wel l -defined source but ar e cha racter i s t ic to the head ’ s pos i t ion in

the incuba tor and mi ght be r ela ted to r espi ra t ion , in infants who a re on a

vent i la tor . These waves can have va r iable fr equency (between 1 .5 and 3 Hz)

and ampl i tude, but ar e usua l ly smooth and ea s i ly ident i f iab le ( Figure 2 .7–

r ight raw EEG).

2 .4.6 Per iodic Epilept i form Discharges

Per iodic Epi lept i for m Discha rges (PED) are speci f ic per iodic EEG

pa t terns defined a s a b isynchronous sha rp wave complex occur r ing in per iodi c

interva ls between 0 .5 and 4 seconds [23] (Figure 2.8) . They can be

la tera l ized, b i la tera l or general ized and in adul ts typica l ly occur in the set ting

of some sor t of neurologica l injury [24] , such a s s troke or HIE. PED s are not

cons idered a r t i facts, a s thei r or igin i s wel l known and s tudied [23] [24] [25] ,

but nonet heless , these phys iol ogica l fea tures a r e included in this chapter

because there i s a type of ar t i fact – PED-Like ( Figure 2 .9) – that is bel ieved

to be r ela ted to PED due to a s imi la r shape but wi thout the peak a t the end of

every cycle [2] . This wavefor m’s or igin i s unknown, and therefore cons idered

a s an ar t i fact on the neona ta l EEG.

F ig ur e 2 . 7 – S i nus o id a l a r t i f ac t s i n t h e r ig h t ra w E EG. S o ur ce : p a t ie nt d a t a .

Page 33: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

11

2 .4.7 Zeta Waves

Zeta waves ar e character ized by sharp spikes wi th va r iab le phase fol lowed

by s imi la r waves ( Figure 2 .10) [26] . These waves ar e dis tinct , sha rply

cont oured del ta waves [27] tha t have been r epor ted to have a high cor r ela t ion

wi th s t ructura l b rain les ions in adul ts [26][28] , but unfor tuna tely there i s s t i l l

very l i t t le tha t i s known about these waves , r ea son why they a re cons idered

ar t i facts . These waves can have a higher ampl i tude, a s they are cons idered

“s low” del ta waves , and they don’ t usua l ly la s t for long per iods of t i me,

r eason why i t i s only poss ib le to see a few per iods a t a t ime [2] .

F ig ur e 2 . 8 – P e r iod ic Ep i le p t ic D isc h ar ge s in bo t h r aw EE G t ra ce s , w i t h a c le ar e r

s h ap e in t h e r ig h t s ig na l . S o ur c e : p a t ie nt d a t a .

F ig ur e 2 . 9 – P E D -L ik e Ar t i f ac t i n bo t h ra w E E G t r ace s .

S o ur c e : p a t ie nt d a t a .

Page 34: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

12

F ig ur e 2 . 1 0 – Ze t a wa ve s a r t i fa c ts v i s ib le o n bo t h r aw EE G t ra ce s .

S o ur c e : p a t ie nt d a t a .

Page 35: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

13

3 State of the Art

3.1 Artifact Detection

Automa t ic a r ti fact detect ion a lgor i thms for e lect roencepha lographic da ta

must be highly speci f ic to the di ffer ent types of da ta i t a ims at , and for the

same r ea son, di ffer ent ana lys is met hods must be employed according t o each

ar t i fact ’s fea tures . This type of ana lys is can be divided int o two ca tego r ies :

one where the a r t i facts ar e r emoved from t he or igina l da ta , a l lowing for pos t -

process ing and ana lys is , and the other where the a lgor i thms onl y detect the

ar t i factua l da ta wi thout actua lly r emoving i t , keeping the or igina l s igna l

intact .

The interes t in per forming this detect ion automa t ica l ly i s cons tant ly

increa s ing, especia l ly in the las t two decades , as EEG has more and more

appl ica t ions , such a s the f ie ld of Bra in -Computer Inter faces (BCI) , or a s a

diagnos t ic tool for va rious neurologica l condi t ion s . Another r ea son for this

rapid interes t is the fact tha t wi th more appl ica t ions to the EEG, longer

acquis i tion t i mes a re set in order , and i t i s t ime cons umi ng for a c l inician or

a r esearcher to go through large amounts of EEG data to select the per iods

tha t do not present the da ta qua l i ty tha t i s r equi r ed. Unfor tuna tely, nowadays ,

tha t i s the scenar io in most ca ses, but several a lgor i thms a re being developed

in order to avoid this t ir esome ordea l .

Unfor tuna tely, given tha t the needle e lect rodes capture a mix ture of

s igna ls from di f ferent b ra in r egions , a s wel l a s other non -cerebra l sources

( through volume conduct i on) , the EEG s igna l can never be expected to have

onl y the t rue r aw s igna l , and thus i t s fea ture cannot be s i mpl y averaged out

or f i l ter ed, in most ca ses [1 ] .

D ifferent a lgor i thms are proposed to detect di ffer ent a r t i facts, such as

ocula r muscle movement [29]–[31] , muscula r act ivi ty [28] [29] , ECG/pulse

act ivi ty [1] or even elect r ic inter ference, known a s power l ine [34] . Not a l l

of these a r t i facts a r e common t o neona ta l EEG, a s ment i oned in t he previ ous

chapter , but these a lgor i thms a re pointed out to r e inforce the i dea tha t each

ar t i fact ha s i t s very speci f ic cha racter i s t ics and tha t one a lgor i thm can’ t

cons ider a l l ar t i facts a s only one ki nd. Most a lgor i thms use adapt ive f i l ter s,

r eference s igna ls ( such as the case of the ocula r movement or the ECG),

wavelet transfor ms or Bl ind -Source Sepa ra tion (BSS) techniques , such a s

Independent Component A na lys is ( ICA), which i s a lso used for the r emova l

of the a r t i facts [35] .

An example of tha t i s the ADJ UST (Automa t ic EEG ar ti fact Detect ion

based on t he J oint Use of Spa t ia l and Tempora l fea tures ) a lgor i thm [36] ,

which combines spa t ia l and tempora l features to detect the ar t i facts

automa t ica l ly. Especial ly in s tudies wi th chi ldren tha t can move fr eely ,

ar t i facts a r e a very common occur rence, increa s ing the ampl i t ude of the EEG

t race and making the acquis i t ion unusab le for r esea rch. For that purpose, ICA

Page 36: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

14

i s used to detect the independent components ( IC’ s) on the EEG, but i t s use

i s l imi ted: the select ion of the IC’ s i s a lmost jus t as t ime - cons umi ng and has

a sub jective factor tha t comes a long wi th the decider [36] . With this in mind,

this a lgor i thm cha racter izes the a r t i fact -r e la ted IC’s by previous ly known

s ter eotyped f ea tures ( tempora l and spa t ia lly) and then combi nes them i n order

to ident i fy the ar t i facts . The ar t i factua l fea tures cons idered in this a lgor i thm

are ocula r movements (b l inks , ver tical and hor izonta l) and a gener ic ar t i fact

c la ss – discont inui ty – for captur ing anoma l ous act ivi ty, which i s

cha racter ized by empt y (NaN) da ta points . This a lgor i thm was then tes ted

through the compar ison of i t s r esul t s and manua l ly c la ss i f ied ar t i facts , where

the ana lys is r evea led that ADJ UST’s per formance was equiva lent to the

ma nua l c la ss i f icat ion by exper ts , poss ib ly saving t i me in t he ana lys is and

giving an oppor tuni ty for fur ther i mprovements and addi t ion of ex t r a

ar t i factua l fea tures in fut ure detect ion models .

Whi le this was tes ted in adul t EEG, the same did not occur for neona ta l

a cquis i tions , where the t r aces can be qui te diver se , given the di ffer en t

pa t terns tha t one can f ind when going through the da ta : norma l background,

seizure, s low waves , sharp waves , rhythmic sp ikes or even discont inui ty [35] .

The bra in ma tura t ion and devel opment i s suppor ted by a process tha t i s ma inly

dr iven by energy bur s ts , which are ea s i ly seen i n the neona ta l EEG t race given

thei r sudden increa ses in ampl i tude from the background act ivi ty. However ,

high energy a r t i facts can mi mic these bur s ts , making i t di ff icul t for the

cl inician to di ffer ent ia te bur s t f rom a r ti factua l a ct ivi ty. A s tudy on the

detect ion of bur s ts , which had a s groundwork previous models [34] [35] ,

a l lowed for the i dent i f ica t ion of bur s ts in s ingle channel acquis i t ions [35] ,

where the segments of da ta were class i f ie d according to a model tha t

ident i f ies ar t i factua l da ta . This model r esorted to wavelet decomposi t ion and

ICA to tes t the da ta set previous ly ava ilab le and was ab le to ob ta in a grea ter

a ccuracy in the r esul t s in the detect ion of bur s ts and ar t i facts , when

compar ing to the previous model .

O ther met hods of detect ion have been set in order , such a s l ine length [39] .

Whi le most a lgor i thms a re ba sed on a mpl i tude changes t o detect a r ti factual

da ta , l ine length cons is ts on t he running sum of the ab solute di ffer ences

between the da ta samples wi thin a defined t ime window, thus increa s ing the

va lue of the l ine length i f the var iance of the s igna l increa ses . This met hod

a l lows for the detect ion of hi gh fr equency fea tures , such a s the energy bur s ts

wi th the same accuracy a s the manua l detect ion per for med by cl inicians .

Another advantage of this a lgor i thm is the poss ib i li ty to adapt the threshold

every 150 seconds , given tha t mul t iple factor s , but specia l ly medica t ion, can

have an a lmost immedia te inf luence on the EEG pa t tern. This a lgor i thm a lso

proved to be jus t a s accura te wi th only two channels a s wi th a ful l - head EEG,

a l lowing for the method to be appl ied not onl y in r esearch but a lso in every

hos pi ta l a s a method for analys is on the background EEG.

A Genera l Ar t i fact Detect ion Sys tem (GADS) , based on two s teps and

r egardless of the pa t ient , i s proposed in [40] . The f i r s t s tep cons is ts in

di ffer ent ia t ing ar t i factua l data wi th large ampl i tude from tha t caused by

Page 37: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

15

elect rode displacement ( r esul t ing in a la ck of acqui r ed va lues) or higher

i mpedance. The second and f ina l s tep a ims a t detect ing s ma l ler ar t i factual

ma nifes ta t ions , such a s muscula r act ivi ty, movement or per iodic fea tures .

These two s tages were proposed in a ma chine lea rning process , which means

tha t a ser ies of fea tures from neona ta l epochs were submit ted through a

c la ssi f ier and tha t c lass i f ier r e turned a s imple output s ta t ing i f the epoch was

ar t i factua l or not , based on a threshold. Pre -process ing techniques were a lso

used, such a s high-pass f i l ter ing, notch f i l ter ing and segmenta t ion of t he

or igina l s igna l into severa l epochs [40] . The f ea tures used in this sys tem were

the mean, median and va r ia t ion of ampl i tude, mean fr equ ency, bandwidth,

three fr equency-bands energies and a ra t io of maximum energy to mean

energy. For ECG and pulse ar t i fact two other fea tures were included in the

ana lys is, given i t s r epet i t ive na ture: peak fr equency and spect r a l dis tor t ion

[40] .

The cor r ela t ion coeff ic ient ha s been used previous ly a s a method to

quant i fy the changes in the f i l ter ed adul t EEG s igna l a f ter ICA was appl ied

to r emove cer ta in a r t i factua l components [41] , providing a measure of the

dis tor t ion by the suppress ion of the a r t i facts . ICA was preferr ed for this

method, over digi ta l f i l ter ing, given tha t digi ta l f i l ter s may a lter the

morphol ogy of the or igina l s igna l , meaning tha t the f i l ter ed r esul t may no t

a lways be t rue to the actual b ra in act ivi ty one wishes to measure. The

compar ison between t he eff icacy of IC A and of f i l ter ing was demonst r a ted by

the use of cor r ela t ion coeff ic ients a s an ob ject ive quant i f ier of r esul t s .

3.2 Seizure Detection

Seizures, c l inica l or non-cl inica l , ar e very common in preterm newborns

admit ted in the NICU wi th HIE [6] , and they a re character ized by an increa se

in the lower and upper margin of the aEEG trace [1] [14] .

In [42] autocor rela t ion was used to cha racter ize activi ty wi th a cer ta in

per iodici ty a s e lect rographic seizure in the EEG. This per iodici ty was then

scored according t o spect r a l analys is , a l l owing for a beds ide tool for the

onl ine detect ion of seizures a s they occur in the neona te .

A di ffer ent a lgor i thm was developed i n [43] , which had the ob ject ive of

a lso detect ing ar ti factual a ct ivi ty tha t cou ld be mis taken for seizures ,

a ssis t ing for the onl ine detect ion of epi lept ic act ivi ty in the beds ide aEEG

moni tor . In this s tudy, the author s only cons i dered seizures wi th 60 seconds

or more, even though most seizures la s t for f ive to ten seconds , given tha t in

the aEEG the act ivi ty i s t ime -compressed and the episodes woul d not be

r ecognizab le . In this a lgor i thm, the detect i on method was based on the sudden

increa se of the lower bounda ry of the s igna l , as a new lower bounda ry was

defined every ten seconds of the s igna l . Changes in this margin were detected

a s of inter es t through a determi ned threshold higher than the r eference

Page 38: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

16

bounda ry in those 60 seconds . The algor i thm was then eva luated by compar ing

i t s r esul t s wi th the manua l compar ison by two observers and ob tained r esul t s

wi th high sens i t ivi ty ( ra te of true pos i t ives) .

3.3 Artifact Removal

The i ssue wi th the r emova l of ar t i facts i s tha t one can never know the t rue

or igina l form of the EEG s igna l wi thout any sor t of ar t i facts or noise [44] .

This means tha t wi thout a “ t rue” example o f the da ta , i t i s not poss ib le to

know for sure the accuracy of the a r t i fact r emova l technique.

Dependi ng on the purpose of the ana lys is, somet i mes i t ’s eas ier to r emove

the ar t i facts from the EEG da ta ra ther than to si mpl y detect them, l ike in ca ses

where there i s no need to r ecover the or igina l EEG and the acquis i t ion can

s imply be deleted [45] .

In ca ses of ocular movement or pulse , the a r t ifactua l da ta can be detected

through a r eference signa l – e lectrooculography (EOG) or ECG, r espect ively

– through di ffer ent met hods , and then r emoved from the or igi na l s igna l.

Most a lgor i thms use BSS techniques to detec t the speci f ic pa t tern of the

ar t i fact to r emove i t , l ike ICA [1] [41] [46] [47] , Pr incipa l Component

Ana lys is ( PCA) [45] or cons t r ained ICA [ 48] (which can b e spa t ia l or

tempora l and impl ies pr ior knowledge on the s ource s igna l , making i t a semi -

b l ind source sepa ra tion) , but other methods can be appl ied, such a s f i l ter ing

speci f ic fr equencies [49] or wavelet ana lys is [50] .

A s tudy on the r emova l of neona ta l a r t i facts [51] uses wavelet - enhanced

ICA, where wavelet decomposi t ion i s used on t he IC’ s wi th the advantage tha t

i t a l lows for the r eta ining of a r es idua l neura l s igna l in the components

marked a s ar t i factua l, min i miz ing the loss of infor ma t ion on actua l bra in

act ivi ty. Unfor tuna tely, in this method, the a r t i facts were ident i f ied only

based on thei r high ampl i tude and shor t dura t ion in t ime, which compr ises

onl y a sma l l por t ion of a l l ar t i facts tha t c an be found on the neona ta l EEG.

Page 39: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

17

4 Methods

The cur r ent chapter focuses on the desc r ipt ion of the a lgor i thms

devel oped throughout this project .

As decided in the beginning of t he projec t , the development of the

detect ion a lgor i thm wi l l cons is t of the assembl ing of seven di ffer ent detect ion

a lgor i thms, each focus ing on a speci f ic ar t i fact .

Al l a lgor i thms were developed on MATLAB 2016b (The Ma thWorks , Inc. ,

Nat ick, Massachuset t s , USA ) .

As previous ly int roduced, the a r t i facts to be cons idered i n this project a r e:

- Sinus Waves with Low Frequency (LF): 1.5 – 2.5 Hz;

- High frequency Oscillations (HFO): 8 – 11 Hz;

- PED-Like;

- Zeta Waves;

- ECG activity;

- EMG activity;

- Movement/Electrode displacement.

This chapter wi l l cons is t of an int roduct i on t o the manua l markings of the

ar t i facts in the raw da ta , fol lowed by an explana t ion of each a lgor i thm’s

method and thei r a ssembly.

Al though the a lgor i thms have di ffer ent methods for the detect ion of the

ar t i facts (see Appendices I to V) , there a r e some pa r ts tha t share the same

logic . For tha t ma t ter , the gener a l backbone of the a lgor i thms i s :

- Detection Method

- Threshold Selection

The f i r s t topic , the core o f each a lgor i thm, wi l l be expla ine d for each

di ffer ent a lgor i thm, and the defini t ion and select ion of the threshold sha res

the same r ea soning for a l l the ar t i facts as wel l . Whi ls t not a pa rt of the

a lgor i thms i t sel f , the a r t i facts mus t be marked on the da ta before tra ining

and/or tes ting the algor i thm, r ea son why there i s a sub -chapter dedica ted to

expla ining how this procedure i s done ( even though i t ’ s outs ide the

a lgor i thm) .

4.1 EEG Acquisition

The EEG s igna ls tha t were used a s tra ining and tes t ing set were no t

acqui r ed a s a par t of this project , and therefore the author took no pa r t in the

process . Never theless , for the sake of c la r ifying, i t becomes r elevant to

expla in how the da ta were acqui r ed.

Page 40: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

18

All EEG s igna ls were acquir ed in the NICU of the Wilhel mina Chi ldren’ s

Hospi ta l, Univer s i ty Medica l Center Utrecht , The Nether lands . A tota l of 28

sub jects were cons idered for this project ( f ive sub jects for each of the f i r s t

f ive a r t i facts pointed out before , except the EMG one tha t only cons idered

thr ee sub jects) . Subjects ’ age and gender were not discr i mina ted .

The EEG montage in t he NICU cons is ts of f i ve needle e lect rodes placed

on the newborns’ sca lps , in the F3 /P3 and F4/P4 pos i t ions ( fol lowing the

10 /20 EEG sys tem adapted for neona tes [13]) and one for r eference on the

forehead, r esul t ing in two b ipola r channels . The s igna ls cons idered for the

a lgor i thms were raw, only wi th the pre-process ing for the b ipola r channels ’

s igna l , and the sampl ing fr equency was 64 Hz , meaning t ha t one second of

acquis i tion cons is ted of 64 da ta points .

4.2 Manual marking of the artifacts

G iven tha t the a lgor i thm needs a golden s tandard to eva lua te i ts r esul t s,

a l l the da ta cons idered in this project was f ir s t selected by an exper ienced

aEEG reader , in order to have t r a ining and te s t ing da ta wi th both a r t i factua l

and non-a rt i factua l EEG trac es . This assessment cons is ted of t he select ion of

da ta wi th approxima tely 30 mi nutes where there was a la rge amount of

ar t i factua l periods mixed wi th nor ma l b ra in act ivi ty. The aEEG reader cr ea ted

a da tabase where for each type of ar t i fact there was data from five di ffer ent

sub jects and for each sub jec t the a r t i facts were marked wi th the begi nni ng

and end t i me of each a r t i factua l per iod in those 30 minutes of da ta . These

per iods of a r t i factua l da ta could have a varying dura t ion, las t ing for a t lea s t

a few seconds , dependi ng on the type of a r t ifact . Also, the number of each

type of a r t i fact in each set of da ta ( from a l l f ive sub jects ) can vary, as can be

seen in Table 4 .1 .

T a b le 4 .1 – N umbe r o f a r t i f ac t ua l pe r io ds in e a c h s e t o f d a ta

Artifact Number of art ifacts in data

Sinus 167

PED-Like 104

Zeta 145

HFO 221

ECG 84

EMG 16

As one can see, t he Movement /E lect rode Displacement a r t i fact i s not

included in this table . Due to the fact tha t the a lgor i thm for this type of

ar t i fact depends onl y on the absolute va lue of the EEG s igna l, r egardless of

the sub ject ’ s condi t ion or any other features , i t was not necessary to ga ther

t ra ining and tes t ing da ta .

Page 41: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

19

The da ta i s then expor ted from Bra inZ and loaded int o MATLAB, where

the t i me poi nts for the beginning and end of each a r t i factua l per iod were saved

a s an independent va r iab le , so tha t they coul d be used throughout the

a lgor i thms. This a l lowed for a compara t ive ana lys is between the manua l

markings of the a r t i facts and the algor i thms’ r esul t s .

4.3 Detection Method

4 .3.1 Sinus , PED-Like and Zeta Waves

These three a r t i facts ar e included i n the same sub -chapter due to the fact

tha t thei r a lgor i thms fol low t he same l ine of t hought in i t s met hods .

The diagram in Appendix I summar izes the met hod in this type of

a lgor i thm, which wi l l now be fur ther explained.

For every a lgor i thm, the f i r s t s tep i s a lways the defi ni t ion of t he mos t

i mpor tant var iables . In this ca se, tha t includes loading the EEG s igna l ,

def ini ng t he sampl ing fr equency ( fs = 64 Hz) , s igna l length and begi nni ng

and end t i mes of the a r ti facts in th e da ta from the golden s tandard .

For a l l thr ee a lgor i thms included in this sub -chapter , the overal l idea i s to

f ind the a r t i facts based on the cor r ela t ion coeff ic ient between the s igna l and

a surroga te wave for m wi th a funda menta l f r equency and wi th a shape very

much l ike the a r t i facts ’ . For tha t r ea son, i t i s i mpor tant to shed a l ight on the

cor r ela t ion defi ni t ion. The MATLAB funct ion corrcoe f cons is t s on the

computa t ion of t he Pea r son cor r ela t ion coef f ic ient ( 4 .1 ) , measur ing the

l inea r dependence of two di f fer ent va r iab les . This va lue of dependence can

va ry between -1 and 1 , where -1 means a total nega t ive l inear cor r elat ion, 0

means an absence of cor r ela t ion and 1 a pos i t ive l inear corr ela t ion.

Cons ider ing tha t A and B are di ffer ent var iables , l ike the EEG s igna l and the

sur roga te , the coeff ic ient for a speci f ic surroga te’ s fr equency a t a speci f ic

t ime poi nt i i s given by:

(𝐴, 𝐵) =

1

𝑁 − 1∑ (

𝐴𝑖 − 𝜇𝐴̅̅ ̅̅ ̅̅ ̅̅ ̅̅

𝜎𝐴 𝐵𝑖 − 𝜇𝐵

𝜎𝐵)

𝑁

𝑖=1

( 4 . 1 )

where 𝜇 and 𝜎 r epresent the mean va lue and s tandard devia t ion of each

va r iable ( in index) . The r esul t of this funct ion ca l l i s a square ma tr ix ( 4 .2 )

where:

𝑟 = [

𝜌(𝐴, 𝐴) 𝜌(𝐴, 𝐵)

𝜌(𝐵, 𝐴) 𝜌(𝐵, 𝐵)].

( 4 . 2 )

Page 42: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

20

Given tha t both 𝜌(𝐴, 𝐴) and 𝜌(𝐵, 𝐵) r epresent the cor rela t ion of the

va r iables wi th themselves , the ma in diagona l of the ma tr ix i s a lways 1 . The

other two va lues a r e equa l to each other because the Pea rson cor r ela tion

coeff ic ient i s symmetr ica l , so 𝜌(𝐴, 𝐵) = 𝜌(𝐵, 𝐴). For this r ea son, onl y the

second va lue from the f i r s t row is cons idered for the ana lys is .

With this in mind, i t becomes r elevant to c lar i fy the method behind the

cor r ela t ion analys is for these three a lgor i thms.

4 .3.1 .1 Sinus (LF)

As previous ly int roduced, this type of a r ti fact cons is ts on a s inusoida l -

shaped wave wi t h a var iab le fr equency , but s t i l l wi thin the r ange of 1 .5 – 2 .5

Hz. Cons ider ing this specia l fea ture, the sur roga te wave for this ar t i fact was

created wi th the s in and cos funct ions from MATLAB (Appendix VI ) , given

tha t between the two funct ions there i s a phase di ffer ence of 90º and therefore

they a re ab le to cover more of the va r iab il i ty of the a r t i fact wi thin the same

fr equency va lue . This method cons is ted on the cr ea tion of severa l surroga te

waves wi th a length of f ive seconds , a l l wi th di ffer ent f r equencies from 0 .02

Hz up to 3 Hz , wi th a fr equency s tep of 0 .02 Hz, meaning tha t there a r e 150

di ffer ent sur roga tes for the sin funct ion, and anot her 150 for the cos funct ion,

in an a t tempt to cover as much of t he va r iab ili ty of the a r ti fact as poss ib le.

Each surroga te i s now a s l iding window tha t runs across the whole lengt h

of the raw signa l , calcula t ing the corr ela tion coef f ic ients between the

sur roga te and every per iod of f i ve seconds of s igna l , wi th a t ime s tep of 10

poi nts (or 10 /64 of a second) , meaning tha t there i s an over lap of fs*5 – 10 =

310 t ime poi nt s (approxima tely 97% of the window lengt h) . Hence, for each

s tep, the cor r ela t ion between the sur roga te and a por t ion of 5 seconds fro m

the s igna l wi l l be ca lcula ted and saved.

In order to save a ll the cor r ela tion va lues , a new ma tr ix i s cr ea ted for the

s in surroga te and another for the cos , in which the rows cor respond to a l l the

150 fr equencies cons idered and the col umns to each t ime point cons idered for

the cor r ela t ion.

Fol lowi ng this method, t he nex t s tep i s to combine the two ma tr ices in

order to get t he bes t r esul t s poss ib le . After cons ider ing several ways of

combi ning both ma tr ices , the method tha t provided the bes t r esul t s was found

to be the one tha t cons ider s a va rying shi f t ( f rom 1 to 10 points ) between each

row of the ma tr ices . From, Figure 4 .1 which shows a s imple example of this

method, one can see tha t wi th a s l ight shi f t of the two di f fer ent sur roga tes

( s in and cos) the absolute va lue of the cor r ela t ion can be opt imized ( i . e . ,

higher ) , and the shi f t i s never over 10 points because otherwise that could

change the t i me ident i f ica t ion of the a r ti facts in the EEG s igna l.

Page 43: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

21

G iven this method, wi th i n each di ffer ent shi f t , i t ca lcula tes the square of

the sum of t he absolute va lue from each row from both ma tr ices , i . e . , only

rows corresponding to the same fr equency are added . This s tep cons idered the

absolute va lues because a nega t ive cor r ela ted sur roga te and raw s igna l can

a lso indica te the presence of a s inus ar t i fact, but wi th a phase di ffer ence.

After this , the a lgor i thm cons ider s the sh i f t tha t produc ed t he hi ghes t

( therefore , the bes t ) va lues and s tores tha t r esul t into the cor r esponding row

of the f ina l ma tr ix. This way, di ffer ent rows may have been combined wi th

di ffer ent shi f t s becaus e of the maxi mum va lues tha t were poss ib le to achieve.

Once the ma tr ices ar e combined, the r esul t is one s ingle ma tr ix wi th al l

the va lues for every fr equency and t i me s tep. As a f i rs t visua l a ssessment , the

ma tr ix can be plot ted according to a color scheme where high va l ues can be

ea s i ly dis t inguished bot h in the t i me and the f r equency doma in.

The nex t s tep in the select ion of the a r ti factual per iods cons is ts on saving

the maximum va lue for each t ime poi nt , i . e . , for each column the maxi mu m

va lue i s cons idered from a l l fr equencies , correspondi ng to the fr equency tha t

wa s the most cor r ela ted to the s inus a r t i fact present in the da ta .

This r esul t s of this process i s a s ingle array cor r esponding to the max i mu m

va lues of the whole ma tr ix , and those va lues ar e then divided by the maxi ma l

va lue from tha t ar ray, in order to nor ma l ize the whole cor r ela t ion ar ray and

having a l l va lues between 0 and 1 , which wi l l make fut ure analys is ea sier to

compare.

4 .3.1 .2 PED-Like

The detect ion met hod for this ar t i fact (Appendix VII ) is s light ly di ff er ent

than the previous , given tha t Per iodic Epi lept i for m Discharges don’ t have a

wel l -defined or s imple shape.

F ig ur e 4 . 1 - E x a mp le s of c o r r e la t io n va lue s f o r d i f f e re nt o ve r la p p ing s i nus s ig na ls

Page 44: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

22

For this r eason, the bes t surroga te was crea ted by select ing examples o f

this ar t i fact in r ea l EEG da ta . G iven tha t one surroga te couldn’ t expla in the

whole va riab i l ity of the ar t i fact , which i s a phys iologica l character i s t ic, four

di ffer ent sur roga tes from four di ffer ent sub jects were cons idered.

After this , the detect ion method i s very s imi lar to the one discussed for

the Sinus (LF) ar ti fact. Every surroga te ha s a lengt h of two seconds and then

tha t surroga te is “ st r e tched” up to 33%, 67% and 100% more of i t s own lengt h,

meaning tha t for every surroga te there ar e three other copies but wi th

di ffer ent f r equencies , in ca se the ar t i fact had a di ffer ent f r equency t han the

segments cons idered a s surr oga te . This way, there a r e 16 (4*4) di ffer ent

sur roga tes for the corr elat ion ma tr ix in this a lgor i thm, in which a l l of them

work a s sl iding windows tha t go through the s igna l wi th a t ime s tep of 5 t ime

poi nts , a lways ca lcula t ing the cor r ela t ion coeff ic ient between the sur roga te

and the s igna l .

The f i na l r esul t , l ike in the previous a r t i fact , ar e four di ffer ent ma tr ices ,

one for each surroga te . For this a lgor i thm, the combina t ion of the ma tr ices i s

di ffer ent : in this ca se the a lgor i thm ana lyses which of the ma tr ices ha s the

most va lues above 0.8 ( a va lue that decided a s indica t ing of high cor r ela t ion)

and cons ider s tha t ma tr ix a s the one tha t best detected the a r t i fact , given tha t

more high cor r elat ion va lues indica te a s tronger presence of a r ti facts wi th the

sur roga te’ s shape in the raw da ta . After that , the a lgor i thm mul t ipl ies a l l

va lues of tha t ma tr ix by 2 and adds tha t to the sum of the squa re of the other

three ma tr ices , because those ma tr ices st i l l store impor tant infor ma t ion about

ar t i facts tha t may ha ve s l ight dis t inct fea tures and are therefore covered by

the ot her sur roga tes . The r esul t of this process i s a ma tr ix wi th the same

di mens ions , where the maxi ma l va lues for each t i me poi nt a r e saved into a

s ingle a rray tha t i s la ter norma l ized, l ike in the previous a lgor i thm.

4 .3.1 .3 Zeta Waves

The met hod for this type of ar t i fact (Appendix VIII ) is mos t ly s imi la r to

the one for the PED -Like. The only funct ion tha t coul d r esemble the Zeta

Waves i s the sawtooth but that does not take into account a l l the var iabi l i ty

i f the a r t i fact because the funct ion woul d s t i ll need to be adjus ted to ma tch

the ar t i fact . For tha t r ea son, in this a lgor ithm the sur roga tes were a lso

expor ted from the r aw s igna l of severa l sub jects , a l lowing the ana lys is to take

into account four di ffer ent surroga tes , a ll with a length of two seconds . In

this case, the fr equency of the sur roga tes was not a l ter ed because that

va r iabi l i ty was a lr eady taken into account in t he sur roga tes selected from the

da ta . Once the sur roga tes ar e l oaded, the corr ela t ion coeff ic ients wi th the raw

s igna l a r e calcula ted and saved.

For the ca se of this type of a r t i fact, the r esult of the cor r ela t ion between

each s l iding sur roga te and the s igna l i s only one a rr ay and not a corr ela t ion

ma tr ix , because the re was no va r ia t ion of the fr equency. The combi na t ion of

Page 45: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

23

the r esul t s was s imply t he sum of t he four a rrays , r esul t ing in one s ingle a r ray

tha t was also norma l ized, meaning tha t a l l i ts va lues ar e between zero and

one.

4 .3.2 HFO

The f i r s t approach on t he a lgor i thm (Appendix IX ) for this type of a r t i fact

was in a ll ways s imi la r to the one for the Sinus (LF), but unfor tuna tely tha t

method coul d not detect a r ti facts where they were present . This i s probably

due to the fact that the fr equency r ange in this ar t i fact i s broader and there

might be fr equency shi f t s wi thin the same a r ti factua l per iod, which does no t

a l low for a proper detect ion wi th the met hod descr ibed previous ly.

With tha t in mind, and a f ter a discuss ion wi th the medica l s ta ff , i t was

discussed tha t the HFO ar t i facts ar e visua lly ident i f ied not onl y in the r aw

EEG, but a lso in the aEEG, by a shi f t in both the upper and lower margins .

Fol lowi ng this l ine of though, and given tha t the aEEG a lgor i thms a re not

open- source, the a lgor i thm for this ar ti fact includes a n aEEG- like a lgor i thm,

but wi th less speci f ics and less computa t iona l load. This par t of the a lgor i thm

ca lcula tes the di ffer ence between the maxima l and the m i ni ma l va lue of the

raw EEG in a 1- second window, thus yielding a s igna l tha t r esembled the

t ime-compressed aEEG. This way, and given t ha t the HFO ar t i fact has a sma l l

ampl i tude, the r esul t ing a rray has lower values whenever the a r t i fact is

present . After tha t the signa l is norma l ized (by div idi ng a l l the va lues by i t s

maxi mum) and i nver ted between zero and one , meaning t ha t the end a r ray i s

the r esul t of 1 – aEEG. This i s done because for future ana lys is and threshold

select ion i t i s preferable i f the per i ods of the r esul t ing ar ray corr espondi ng

to ar t i factua l EEG have higher va lues than the per iods of nor ma l bra in

act ivi ty.

4 .3.3 EMG

This ar t i fact is character ized by a trace wi th a sma l l ampl i tude and a

fr equency higher than nor ma l for a neona ta l EEG. Knowing t ha t the high

fr equency i s one of the ma jor fea tures of muscula r activi ty, one would

cons ider fr equency ana lys is as a f ir st a t tempt . Unfor tuna tely, the fr equency

band of the nor ma l EEG can somet i mes over lap wi th the a r t i fact’s f r equency,

r eason why cla ss i ca l f i l ter ing cannot be appl ied in this ar t i fact , because tha t

coul d mean the loss of i mpor tant infor ma t ion r ega rding the nor ma l EEG

act ivi ty.

With this in mi nd , anot her approach was set in place (Appendix XI ) . G iven

the ma in cha racter is t ics of EMG ar ti fac t, this a lgor i thm takes into account

tha t more ampl i tude shi f t s in the da ta (due to the high fr equency) t rans la tes

into a higher dis tance between consecut ive po ints , so i t cons ider s a funct ion

Page 46: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

24

tha t ca lcula tes the di ffer ence between the va lues of consecut iv e points . After

this , the r esul t ing dis tance funct i on i s averaged in a window of seven seconds

because this a r t i fact can la s t for long per iods of t i me. This way, whenever the

EMG ar t i fact i s present the r esul t ing nor ma l ized array wi l l have higher

va lues , t hus dis t inguishi ng t he a r t i factua l periods from the ones wi th nor ma l

b ra in act ivi ty.

4 .3.4 ECG

The method in the a lgor i thm for this ar t i fact (Appendix X ) i s ba sed on the

a lgor i thm for the EMG act ivi ty, meaning tha t i t a l so takes into account the

dis tance between consecut ive points and an averaging wi thin a window of f i ve

seconds . The di ffer ence in this a lgor i thm comes in two par ts : the f ir s t i s that

this i s an ar t i fact wi th a very sma l l ampl i tude, where the QRS complex i s

r epresented by a shor t peak, hence the dis tance between poi nts i s a ctua lly

s ma l ler than average whenever the a r t i fact is present . The second a spect i s

tha t the averaging window in this case is only of f ive seconds , because a f ter

fur ther ana lys is this was the window lengt h tha t provided the bes t r esul t s .

Due to the f ir st di ffer ence, a f ter the f ina l a rray is nor ma l ized, i t is

sub t racted from 1 , l ike in the HFO ar t i fact , resul t ing in a norma l ized ar ray

where the higher va lues r epresent the per iods of s igna l wi th ar t i factua l da ta .

4 .3.5 Movement and Electrode displacement

This ar t i fact i s sepa ra te from the other s since i t does not need any

cor rela t ion method and, therefore , the thresho ld used does not depend on t he

s igna l process ing methods in the a lgor i thm.

As s ta ted in the li tera ture [52] , the maxima l act ivi ty for the norma l

neona ta l EEG takes di ffer ent va lues depending on the in fant ’ s ges ta t iona l age

(GA) , in weeks . With this in mi nd, this a lgor i thm (Appendix XII ) onl y

r equi r es that the user inserts the GA of the signa l ’ s sub ject a s an in put and

then for each di ffer ent age from 23 up to 42 weeks GA the a lgor i thm

associa tes that wi th a speci f ic va lue for the maxi ma l ( and mini ma l) a ct ivi ty

tha t ’s phys iologica l ly accepted. I f the act ivi ty in the EEG is above this

maxi ma l va lue (or below the mini ma l) or i f i t i s not a number (NaN) due to

e lect rode displacement , the a lgor i thm wi l l cons ider i t an a r ti fact.

Page 47: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

25

4.4 Threshold Selection

As s ta ted in the met hods descr ibed above, the r esul t of every a lgor i thm is

a single nor ma l ized arr ay, wi th a length r ela tively the sa me s ize a s the raw

s igna l and wi th a l l i t s values between zero and one.

The met hods in each a lgor i thm a l l a imed a t a r ti factua l periods wi th hi gher

va lues than the average norma l EEG, so the prob lem tha t poses now is how to

sepa ra te the ar t i factua l per iods from the ones wi th actual bra in act ivi ty. This

sepa ra t ion wi l l r e ly on the defi ni t ion of a threshold, a number between zero

and one tha t indica tes tha t any va lues above tha t threshold ( in the norma l ized

ar ray) r epresent ar t i factua l per iods in the EEG, and any va lues below

represent r ea l non-a rt i factua l b ra in act ivi ty.

To f i nd the bes t threshold for each di ffer ent s ub ject (because each sample

of s igna l f rom each pa t ient ha s i t s own cha racter i s t ics ) , a l l thr esholds between

zero and one, wi th a s tep of 0 .01 are tes ted. This tes t ing i s done r esor t ing t o

an ROC (Receiver Opera t ing Character i s t ic) Curve, which i s a plot of two

di ffer ent va r iab les:

• Sensitivity ( 4.3 ) – or true positive rate, calculated by:

𝑆𝑒𝑛𝑠𝑖𝑡𝑖𝑣𝑖𝑡𝑦 =

𝑇𝑃

(𝑇𝑃 + 𝐹𝑁)

( 4 . 3 )

where the True Pos i t ives (TP) a r e defined a s a l l the per iods of s igna l tha t the

a lgor i thm detects a s a r t i factua l (meaning, above the cons idered threshol d)

and Fa lse Nega t ives (FN) a s a l l the per iods of a r t i factua l da ta tha t the

a lgor i thm did not cons ider a r t i factua l but , in fact , cor r espond to a r t i facts in

the da ta .

• Specificity ( 4.4 ) – or true negative rate, calculated by:

𝑆𝑝𝑒𝑐𝑖𝑓𝑖𝑐𝑖𝑡𝑦 =

𝑇𝑁

(𝑇𝑁 + 𝐹𝑃)

( 4 . 4 )

where the True Nega t ives (TN) are a l l the per iods o f s igna l tha t the a lgor i thm

did not c la ss i fy a s a r t i fact, i . e. , the a lgor i thm cla ssi f ies them as actua l bra in

act ivi ty and are below the cons idered threshol d, and the Fa lse Pos i t ives (FP)

a ss a l l the per iods of actua l b r a in act ivi ty tha t the a lgor i thm cons idered a s

ar t i fact but ar e in fact periods of non -a r t i factua l bra in act ivi ty.

This met hod of ana lys is takes into account the b inary cla ss i f ica t ion of the

da ta . In this par t of the a lgor i thm, i f the r esul t ing a rray i s above the cur r ent

thr eshold, i t ’ ll be conver ted into a 1 , meaning tha t the a lgor i thm is class i fying

tha t a s par t of an ar t i fact , and i f i t i s below the threshol d i t ’ l l be conver ted

into a 0, i . e . , not an a r t i fact.

Page 48: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

26

Consider ing this method, for each threshold o ut of t he 100 di ffer en t

between 0 .01 and 1 , r esul t s one sens i t ivi ty and one speci f ic i ty va lues ,

meaning tha t the f ina l r esul t i s two di ffer ent ar rays wi th 100 va lues each: one

for the sens i t ivi ty va lues and another for the speci f ic i ty. The ROC Curve i s ,

a s previous ly s ta ted, the plot of t hese two a rrays . On the ver t ica l ax is i s the

sens i t ivi ty and on the hor izonta l one i s 1 – speci f ic i ty. The purpose of this

plot i s to f ind which threshold does the bes t sepa ra t ion between ar t i facts and

bra in activi ty, i . e . , which threshold opt i mizes both sens i t ivi ty and speci f ic i t y

s imul taneous ly . The chosen cr i ter ia for the threshold select ion was the

dis tance to the upper lef t corner of the plot , where sens i t ivi ty = 1 and 1 –

speci f ic i ty = 0 , or speci f ic i ty = 1 as wel l. Th e threshold tha t was plot ted the

closes t to this corner , was the one selected a s the bes t threshold to sepa ra te

the a r t i facts in tha t sub ject’ s detect ion a lgor i thm.

4.5 Assembling the Algorithms

After a ll the a lgor i thms a re developed, i t ’ s ti me to move on to t he nex t

s tep and a ssemble a ll the sma l ler a lgor i thms into one la rger detect ion

a lgor i thm.

The f i r s t a t tempt on the a ssembl ing of the a lgor i thms cons is ted on the

loading of the s igna l and then a l l the sma l l a lgor i thms would run, one a t a

t ime, and have i ts own detect ion r esul t . After this , the logic behind i t was

based on the fact tha t the a lgor i thm wi th the most detect ions ( length of overa l l

ar t i factua l per iods over s igna l length) woul d indica te tha t i t s ar ti fact was the

one present on the da ta , and the refore the ove ra l l a lgor i thm would be ab le to

not only detect the a r t i facts , but a lso cla ssi fy them.

The second a t tempt was decided a f ter a discuss ion wi th t he cl inica l s ta ff .

G iven tha t a doctor usua l ly does a quick preview of the r aw f i le before

per for ming any ana lys is , this method of combi ning a l l the algor i thms

cons ider s the decis ion of the user as an input : before running the detect ion

a lgor i thm, the user decides which a r ti fact he/she wants to detect and inser ts

tha t a s an input on the a lgor i thm. This way the user ha s the fr eedom to choos e

which a r t i fact i s to be detected and the overal l a lgor i thm only runs one ou t

of the seven s ma l ler a lgor i thms wi thi n. Once the a lgor i thm is f inished, the

r esul t i s a plot of t he r aw s igna l wi th col oured ba r s that r epresent the

beginni ng (green) and the end ( r ed) of each ar t i factua l per iod in the da ta .

Once a ll the c la ssi f icat ions were done, the method had to be compared to

the manua l annota t ions – the golden s tandard tha t was ava ilab le – in order to

a ssess i f the a lgor i thm was detect ing the ar t i facts a s i t should be. This

eva lua t ion of the a lgor i thm’s per formance cons idered three di ffer ent

cla ssi f ica tions :

Page 49: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

27

. True Pos it ive ( 4 .5 ) – when t he a lgor i thm de tects an ar ti fact where there

i s indeed an a r t i fact. This ra te i s calcula ted when dividi ng the number of

ar t i facts cor r ect ly detected by the a lgor i thm by the overa l l number of a r t i facts

in the da ta ( through the man ua l markings) :

𝑇𝑟𝑢𝑒 𝑃𝑜𝑠𝑖𝑡𝑖𝑣𝑒 =

# 𝑎𝑟𝑡𝑖𝑓𝑎𝑐𝑡𝑠 𝑑𝑒𝑡𝑒𝑐𝑡𝑒𝑑

# 𝑎𝑟𝑡𝑖𝑓𝑎𝑐𝑡𝑠 𝑖𝑛 𝑑𝑎𝑡𝑎

( 4 . 5 )

. Fa lse Pos it ive ( 4 .6 ) – when the a lgor i thm detects an ar t i fact in a per iod

of s igna l tha t is a ctual ly non -a rt i factua l bra in act ivi ty. This i s the quot ient

between the number of wrong detect ions of a r t i facts and th e tota l number o f

detect ions made by the a lgor i thm:

𝐹𝑎𝑙𝑠𝑒 𝑃𝑜𝑠𝑖𝑡𝑖𝑣𝑒 =

# 𝑤𝑟𝑜𝑛𝑔 𝑎𝑟𝑡𝑖𝑓𝑎𝑐𝑡𝑠 𝑑𝑒𝑡𝑒𝑐𝑡𝑒𝑑

# 𝑑𝑒𝑡𝑒𝑐𝑡𝑖𝑜𝑛𝑠

( 4 . 6 )

. Fa lse Negative ( 4 .7 ) – this indica tes the ra te of a r t i facts that the

a lgor i thm di dn’ t detect , i . e . , the a r t i facts tha t the a lgor i thm cons idered a s

nor ma l brain activi ty. This r a te is giv en by div iding the numb er of undetected

ar t i facts by the tota l number of a r t i facts in data (by the manua l markings) :

𝐹𝑎𝑙𝑠𝑒 𝑁𝑒𝑔𝑎𝑡𝑖𝑣𝑒 =

# 𝑎𝑟𝑡𝑖𝑓𝑎𝑐𝑡𝑠 𝑢𝑛𝑑𝑒𝑡𝑒𝑐𝑡𝑒𝑑

# 𝑎𝑟𝑡𝑖𝑓𝑎𝑐𝑡𝑠

( 4 . 7 )

These three di f fer ent types of c la ss i f icat ion eva lua te of the a lgor i thm’s

per for mance, a llowing for i t s opt i miza t ion upon t r a ining and tes t ing wi th the

da ta ava i lable .

In cons idera t ion of fur ther implementa t ion of t he developed a lgor i thm int o

di ffer ent sys tems t ha t a r e curr ent ly used in the NICU, Appendix XV focuses

on a b r ief explana t ion of Use Cases , which were approached in t he begi nni ng

but not ful ly devel oped throug hout the project .

Page 50: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

28

Page 51: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

29

5 Results

In this chapter the r esul t s ob ta ined from the methods previous ly descr ibed

are presented . To ea se the interpreta t ion process , the r esul t s for every s tep of

onl y one a lgor i thm wi l l be presented, given tha t mos t met hods fol l ow t he

same logic . After tha t, an example of eve ry a lgor i thm’s r esul t wi ll be

presented. The r esul t s for both approaches in a ssembl ing the s ma l ler

a lgor i thms a re a lso included, which demonst ra te why the f i r s t approach

( running a l l individua l a lgor i thms a t once ) was not opt i ma l for the purpose

of this project . The r esul t s for the three cla ss if ica t ion cr iter ia (True Pos i t ive,

Fa lse Pos i t ive and Fa lse Negat ive) ar e a lso presented, as a way of

demonst r a ting the overa l l r esul t s of the f ina l a lgor i thm.

5.1 Sinus Wave

5 .1.1 Detect ion Method

When cons i der ing a l l the di ffer ent a lgor i thms deta i led before , one can

under s tand tha t the a lgor i thm for the Sinus Wave ar t i fact i s the most complex

one, gi ven t he di ff er ent ma tr ices cr ea ted and thei r combina t ion method. With

this in mind, this chapter wi l l go through a deta i led explana t ion of the r esul t s

for each s tep of this a lgor i thm, clar i fying the output of every process wi thin

the a lgor i thm. The r esul t s for the other ar t ifacts’ a lgor i thms wi l l a lso be

cons idered a f terwards, given tha t a l l methods must be accounted for , but wi th

less deta il , due to the s imi la r i t ies between the methods .

In order to s i mpl i fy the wa lkthrough of t he logic for the Sinus Wave

a lgor i thm, this chapter wi l l focus on a sma l l por t ion of s igna l f rom the 30

minutes long sa mple of da ta from one s ub ject . This way, i t i s poss ib le to see

a plot of the r aw s igna l wi th three ar t i factua l per iods wi thin j us t a few

seconds , l ike in Figure 5 .1 .

In this sa mple of s igna l i t i s poss ib le to observe three per iods of non -

random act ivi ty, di ffer ent f rom nor ma l s igna l a cqui r ed wi th the EEG. These

ar t i factua l periods ar e character ized by a per iodic and rhyt hmi c act ivi ty, l ike

descr ibed in a previous chapter , and a lso by a sma l ler ampl i tude when

compared to the r es t of the s igna l , a s one can see by the compar ing these wi t h

the per iods not marked a s ar t i facts. These a r t i factua l periods ar e

approxima tely 15 seconds long, wi th interva ls between them of a round 5

seconds .

Page 52: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

30

The green and r ed bar s , marking the beginni ng and end of each a r t i fact

r espect ively, a id the visua l interpreta t ion and ident i f ica t ion of the a r ti facts

in the EEG s igna l.

Rega rding the cor r ela t ion method, i t i s r e levant to cons ider the i mpor tance

of the s in and cos corr ela tions , given the phase di ffer ence between the two

funct ions , a ccount ing for a larger va riab i l ity of the s igna l in ques t ion. For

tha t r ea son, in this chapter i t i s presented the ma tr ix r esul t ing from the

cor r ela t ion wi th both funct ions , in Figure 5 .2 and Figure 5 .3 .

1740 1750 1760 1770 1780 1790 1800 1810

Time (s)

-50

-40

-30

-20

-10

0

10

20

30

40E

EG

(V

)Raw EEG

Beginning of Artifact

End of Artifact

F ig ur e 5 . 1 - R a w EE G s ig na l w i t h a nno t a t e d a r t i f a c t s

1740 1750 1760 1770 1780 1790 1800 1810

Time (s)

0.5

1

1.5

2

2.5

3

Fre

qu

en

cy (

Hz)

Beginning of Artifact

End of Artifact

F ig ur e 5 . 2 - C o rr e la t io n ma t r ix w i th th e s in f u nc t io n

Page 53: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

31

In both f igures one can see the same ba rs that were marking the a r t i factua l

per iods in the r aw s igna l , for the same sample of EEG t race. These f igures

indica te the r esul t ing ma tr ices a f ter the cor rela t ion coeff i c ients wi th each

funct ion a re ca lcula ted, and a re then plot ted according a colour map, which

goes from -1 (dark blue) to 1 (br ight yel low) - the poss ib le ex tr eme va lues

tha t one can ob tain from the cor r ela tion funct ion. On the ver t ica l ax is of the

ma tr ices , one can f ind the di ffer ent f r equencies cons idered for the

cor r ela t ion: 0.02 Hz up to 3 Hz, wi th a fr equency s tep of 0 .02 Hz . This way

of displaying the r esul t s a llows the observer to ident i fy the fr equencies tha t

r esul ted in higher cor r ela t ions wi th the raw signa l . For the purposes of this

ana lys is, both ex tr emely hi gh and ex t r emel y low cor rela t ion va lues were

cons idered a s indica tors of the presence of an ar t i fact given due to the r eason

expla ined in the Methods . According to this , i t is poss ible to observe yel low

(high) and da rk b lue ( low) colour s in most o f the a r t i factua l per iods (between

the green and r ed ba rs ) , specia l ly in the ar ea cor r espondi ng to 1 .4 – 1 .5 Hz ,

a l lowing the user to a lso ex tr apola te the approxima te fr equency of the a r t i fact

in ques t ion.

I t i s a l so poss ib le to observe high and low va lues of cor r ela t ion

coeff ic ients for other fr equencies - around 0 .5 Hz outs ide ar t i factua l per iods

and 2 .7 Hz wi thi n the same per iods – but those poss ib le ar t i factua l va lues ar e

e l i mina ted once the combi na t ion method i s appl ied to both ma tr ices , r esul t ing

in the ma tr ix in Figure 5.4 .

In this Fig ure 5.4 , cons ider ing t he col our sca le changes from 0 (da rk b lue)

to 1 (br ight yel low) , i t i s poss ib le to under s tand tha t the cor r ela t ion va lues

wi thin the a r t i factua l per iods ar e indeed the ones wi th the highes t va lues

wi thin the ma tr ix , highl ighted by the b r ight co lour s wi t hin these per iods . This

1740 1750 1760 1770 1780 1790 1800 1810

Time (s)

0

0.5

1

1.5

2

2.5

3

Fre

qu

en

cy (

Hz)

Beginning of Artifact

End of Artifact

F ig ur e 5 . 3 - C o rr e la t io n ma t r ix w i th th e c os f u nc t io n

Page 54: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

32

sca le ha s a mini mum of zero because in the combi na t ion process a ll va lues

ar e conver ted in to thei r absolute va lues .

Another factor tha t should be cons idered i s tha t outs ide the a r t i factua l

per iods there a r e st i l l some r ela t ively high va lues , but these a r e much more

sca t ter ed in the fr equency doma i n, indica t ing tha t these va lues do not r e la te

to this ar t i fact , which has a speci f ic and somewha t cons tant f r equency.

Once this ma tr ix i s ob ta ined, and fol lowi ng the methods descr ibed before ,

the a lgor i thm selects the maxi mu m va lue of every t ime point , i . e . , the highes t

va lue from a l l f r equencies in tha t po int . This i s done because i f we a re in the

presence of an a r t i fact , i t indica tes the fr equency tha t corr ela ted the bes t wi th

tha t ar t i fact , and i f not , the value wi l l be lo w for a l l the fr equencies

cons idered anyway. This way the r esul t i s an ar ray jus t a s long a s the ma tr ix

and the or igina l signa l i t sel f tha t is then norma l ised, meaning tha t a l l the

va lues of the a rray are compr ised between zero and one, a s i t can be observ ed

in Figure 5 .5 .

In this nor ma l ised a rray ( from the sa me segment of s igna l and from t he

same cor rela t ion ma tr ices) is evident ly shown tha t the ar t i factua l per iods ar e

indeed cha racter ized by higher cor r ela tion va lues than nor ma l bra in act ivi ty

per iods . With this type of analys is , i t becomes clea r that the ar t i factua l

per iods have cer ta in character is t ics tha t di ffer f rom non -ar t i factua l s igna l ,

and those fea tures can b e evidenced thanks to this corr ela t ion method.

1740 1750 1760 1770 1780 1790 1800 1810

Time (s)

0

0.5

1

1.5

2

2.5

Fre

qu

en

cy (

Hz)

Beginning of Artifact

End of Artifact

F ig ur e 5 . 4 - C o rr e la t io n ma t r ix a f te r t he co mbi na t io n o f t he s i n a nd c os ma t r ic e s

Page 55: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

33

5 .1.2 Threshold Se lec t ion

The prob lem tha t ar ises now, i s how to sepa rate these two cla ss i f ica t ions :

ar t i factua l and non-ar t i factua l . Thanks to the di ffer ence i n va lues in this

nor ma l ised a rray, one can define a threshold tha t separa tes the two di ffer ent

per iods of s igna l . G iven tha t higher va lues ar e found in the por t ions of s igna l

wi th ar t i facts , everything above tha t sa id threshold sha l l be cons idered a s

ar t i fact , and everything below a s norma l bra in act ivi ty. Tha t can la ter be

t rans la ted into the raw s igna l and help in iden t i fyi ng the ar t i facts in the da ta .

With this in mind, i t i s now necessa ry to define the threshold tha t bes t

prefor ms the sepa ra t ion between a r t i factua l and non -a rt i factua l s igna l. This

was done wi th the a id of a ROC (Receiver Operat ing Cha racter i s t ic) curve.

As previous l y expla ined in deta i l , this curve a l lows the ana lys is of every

threshold between zero and one (because the a rray i s norma l ised) wi th a

threshold s tep of 0 .01 ( thus cons ider ing 100 di ffer ent thresholds) and

ca lcula ting the sens i t ivi ty ( t rue pos i t i ve r a te) and the speci f ic i t y ( t rue

nega t ive r a te) ob tained wi th every threshold . In the speci f ic ca se for the

sub ject cons idered i n this chapter , the ROC curve ob ta ined can be found i n

Figure 5 .6 .

Once the curve was ob ta ined, the select ion of the bes t threshold was

needed, and the cr i ter ia for this select ion was discussed wi th the cl inica l s ta ff .

The f i na l decis ion on t his ma t ter r e l ied on the fact tha t the bes t threshold i s

the one tha t maximizes both sens i t ivi ty and speci f ic i ty a t the same t i me,

meaning tha t i t is the one tha t ’ s c loses t to the upper lef t corner ( sens i t ivi ty =

speci f ic i ty) o f the ROC plot . Cons ider ing these cr i ter ia , the a lgor i thm a lso

ca lcula ted the dis tance between every poi nt in the curve and t he upper lef t

corner , and in the end, the sma l les t dis tance was the one tha t indica ted the

bes t threshold.

1740 1750 1760 1770 1780 1790 1800 1810

Time (s)

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

No

rmalis

ed

co

rre

latio

n v

alu

es

Array

Beginning of Artifact

End of Artifact

F ig ur e 5 . 5 - N o r ma l iz e d ar r a y w i t h t h e co r re la t io n va lue s

Page 56: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

34

For the ca se of this par t icular sub ject presented here in this chapter , the

bes t threshold was found to be 0 .54, but each di ffer ent sub ject has a di ffer ent

threshold, because of va r ious fea tures unique to each s igna l , l ike the exact

f r equency, the r esul t a f ter the combi na t ion of the cor r ela tion ma tr ices , or

even the threshol d s tep for the ROC curve. Despi te of a l l of these factor s, the

thresholds for each di ffer ent type of a r t i fact are a lways wi thin a cer ta in range,

a l lowing the user to have some guidance a s to which va lue to choose for the

threshold, a s it can be seen in Table 5 .1 .

T a b le 5 .1 - Th r es ho ld va lue s f or t he d i f f e re nt a r t i f ac ts

ARTIFACT THRESHOLDS’ RANGE [0 - 1 ]

WAVE 0 .49 - 0 .55

PED-LIKE 0 .68 - 0 .78

ZETA 0 .76 - 0 .80

HFO 0 .81 - 0 .94

ECG 0 .52 - 0 .81

EMG 0 .09 - 0 .30

After ana lys ing the va lues in the tab le , one can see tha t for the f i r s t four

a lgor i thms the thresholds a r e a l l wi thin a cer ta in and shor t - l imi ted r ange: for

the wave’ s a lgor i thm, the thresholds are around 0 .5 , for the PED-Like’ s i t s

around 0 .7 , same a s for the Zeta a lgor i thm, and t he HFO is around 0 .9 . The

la s t two a lgor i thms have wider ranges , and therefore in these ca ses the

select ion of t he threshold shoul d be per for med wi th caut ion. One must keep

in mind tha t a l l a lgor i thms were t ra ined and tes ted on 5 sub jects each, except

the EMG one, tha t only had 3 sub jects , so these ranges ar e r efer r ing to those

sub jects ’ thresholds wi thout any s ta t i s t ica l ca lculat ions , i . e . mean, median,

mini mum or maximum. Once every sub ject ’ s threshold i s deter mi ned, i t i s

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

1 - Specificity

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

Se

nsitiv

ity

ROC Curve

F ig ur e 5 . 6 - R O C c ur ve w i t h t he Se ns i t i v i t y a nd

S p ec i f ic i t y va l ue s f or a l l t h re s ho ld s

Page 57: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

35

t ime to per form the actua l separa t ion between bra in activi ty and ar t i facts .

This pa r t of the a lgor i thm takes the newly - found threshol d int o account int o

the nor ma l ised a rray and per for ms a b inary oper a t ion. Any t i me poi nt va lue

equa l or below the threshold i s turned into a zero (0) and any va lue above i s

turned int o a one (1) , r esul t ing into a b inary ar ray l ike the one in Fig ure 5 .7 .

This f igure r efer s to the por t ion of s igna l f rom t he same sample a s before ,

wi th the sa me markings , but this t i me t he plot i s b inary, as one can see fro m

the va lues and the sca le on the ver t ica l ax is . The a r t i factua l periods in the

ar ray have a comb- l ike, very spiky shape because the high va lues in the ar ray

from Figure 5.5 were a lso sharp- l ike and even in the high -va lues ar ea s , some

pa r ts were below the threshold, r esul t ing in this shape. Because of this fea ture

tha t was present in many di ffer ent a r rays , even for di ffer ent a r t i facts and

di ffer ent sub jects , a funct ion was created in order to join peaks (Appendix

XIII) tha t were too close together . This way, i t becomes poss ib le to ob tain a

s moother r esul t l ike the one in Figure 5.8 .

1740 1750 1760 1770 1780 1790 1800 1810

Time (s)

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

De

tectio

ns

Detections

Beginning of Artifact

End of Artifact

F ig ur e 5 . 7 – De t ec t io ns a r r a y

Page 58: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

36

Error ! Reference source not found.

As one can see, a f ter joining of the peaks , separate ar t i factua l periods tha t

ar e too close apa r t were merged and cons idered a s only one per iod of

ar t i factua l da ta , but a f ter convening wi th t he medica l s ta ff this was not posed

a s an obs tacle , given tha t a l l thr ee manua l ly marked per iods in this example

ar e contempla ted in the detect ion r esul t f rom the a lgor i thm.

This f ina l b ina ry array i s then cons idered the f ina l detect ion r esul t .

Rega rding the a lgor i thm’s r esul t s presenta t ion, i t is s ti l l lef t to be decided,

given tha t tha t decis ion i s up to the medica l sta ff’s preferences : i t can ei ther

be done by a plot of the raw s igna l wi th bar s marking the beginni ng and the

end of the detect ion per iods ( much l ike the manua l markings) or some sor t of

a r epor t tha t i s wr i t ten a f ter the a lgor i thm has run, s ta t ing in tex t the

beginni ng and end t i mes of the a r t i factua l per iods , in ‘hh: mm:ss’ for ma t ,

according to the t i me of the acquis i t ion of the s igna l .

1740 1750 1760 1770 1780 1790 1800

Time (s)

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1D

ete

ctio

ns

Detections

Beginning of Artifact

End of Artifact

F ig ur e 5 . 8 - D e te c t io ns a r r a y a f te r t he f u nc t io n jo i n t_ p ea k s

Page 59: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

37

5.2 The other algorithms

In r ega rds to the other ar t i facts, the met hods may di ffer , a s deta i led before ,

but the r esul t fol lows the same logic . Because of tha t , the r esul t s for every

s tep of the other a lgor i thms wi l l not be included in this chapter , a s the logic

behind i t ha s a lr eady been expla ined, but a sample of each a r ti fact and i t s

a lgor i thm’s r esul t wi l l be included here , a s to show the r eader that a l l the

different a lgor i thms are indeed detect ing the a r t i facts . Such r esul t s can be

found from Fig ure 5 .9 up to Figure 5 .20 .

140 145 150 155 160 165 170 175 180 185

Time (s)

-300

-200

-100

0

100

200

EE

G (

V)

Raw EEG

Beginning of Artifact

End of Artifact

F ig ur e 5 . 9 - R a w EE G s ig na l w i t h t w o PE D -L ik e a r t i fa c ts

140 145 150 155 160 165 170 175 180 185

Time (s)

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

De

tectio

ns

Detections

Beginning of Artifact

End of Artifact

F ig ur e 5 . 1 0 - Ar r a y w i th th e de t ec t io n o f bo th PE D -Lik e a r t i f ac t s

Page 60: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

38

In this set of examples , i t i s poss ib le to see tha t the di ffer ent a lgor i thms

can indeed detect the a r ti factua l per iods , even though the begi nni ng and end

t imes of the ma nua l markings and of the detect ions don’ t a lways ma tch.

Despi te tha t, the samples here included can t rans late the a lgor i thms’ r esul t s

as an ar t i fact detect ion met hod. This provides a new ins ight into the ana lys is

tha t can be per formed in t his type of neona tal a cquis it ions , poss ib ly helpi ng

the cl inica l s ta ff and r educing the t ime -cons umi ng t a sk of manua l ly

ident i fying the a r ti facts.

70 75 80 85 90

Time (s)

-200

-150

-100

-50

0

50

100

150

200

EE

G (

V)

Raw EEG

Beginning of Artifact

End of Artifact

F ig ur e 5 . 1 1 - R aw E E G s ig na l w i t h t wo Zet a a r t i f a c t s

70 75 80 85 90 95

Time (s)

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

De

tectio

ns

Detections

Beginning of Artifact

End of Artifact

F ig ur e 5 . 1 2 - Ar r a y w i th th e de t ec t io n o f bo th Ze ta a r t i f a c t s

Page 61: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

39

0 1 2 3 4 5 6 7 8 9 10

Time (s)

-150

-100

-50

0

50

100

150

EE

G (

V)

Raw EEG

Beginning of Artifact

End of Artifact

F ig ur e 5 . 1 3 - R aw E E G s ig na l w i t h o ne H FO ar t i f ac t

0 2 4 6 8 10

Time (s)

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

De

tectio

ns

Detections

Beginning of Artifact

End of Artifact

F ig ur e 5 . 1 4 - Ar r a y w i th th e de t ec t io n o f th e o ne H FO ar t i f ac t

Page 62: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

40

225 230 235 240 245 250 255 260

Time (s)

-60

-40

-20

0

20

40

60

EE

G (

V)

Raw EEG

Beginning of Artifact

End of Artifact

F ig ur e 5 . 1 5 - R aw E E G s ig na l w i t h t wo E C G ar t i f ac ts

225 230 235 240 245 250 255 260 265

Time (s)

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

De

tectio

ns

Detections

Beginning of Artifact

End of Artifact

F ig ur e 5 . 1 6 - Ar r a y w i th th e de t ec t io n o f bo th EC G ar t i f a c t s

Page 63: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

41

127 128 129 130 131 132 133 134 135 136 137

Time (s)

-100

-50

0

50

100

EE

G (

V)

Raw EEG

Beginning of Artifact

End of Artifact

F ig ur e 5 . 1 7 - R aw E E G s ig na l w i t h o ne E M G ar t i f ac t

127 128 129 130 131 132 133 134 135 136 137

Time (s)

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

De

tectio

ns

Detections

Beginning of Artifact

End of Artifact

F ig ur e 5 . 1 8 - Ar r a y w i th th e de t ec t io n o f th e o ne E MG a r t i f ac t

Page 64: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

42

0 200 400 600 800 1000 1200 1400 1600 1800

Time (s)

-500

-400

-300

-200

-100

0

100

200

300

400

500E

EG

(V

)Raw EEG

F ig ur e 5 . 1 9 - R aw E E G s ig na l w i t h t wo d is t inc t p e r iod s o f a r t i f a c t s d ue t o M o ve me nt o r

E le c t ro de D isp la c e me nt

0 200 400 600 800 1000 1200 1400 1600 1800

Time (s)

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

De

tectio

ns

Detections

F ig ur e 5 . 2 0 - Ar r a y w i th th e de t ec t io n o f bo th pe r io ds of a r t i f ac ts d ue to Mo ve me nt o r

E le c t ro de D isp la c e me nt

Page 65: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

43

5.3 Assembling the Algorithms

With the a forement ioned proof tha t the sepa ra te a lgor i thms are in fact detect ing

the ar t i facts , i t i s t ime to a ssemble them and wi th tha t cr ea te the overal l detect ion

a lgor i thm.

This a ssembl ing process went through two di ffer ent approaches : the f i r s t one,

where a l l a lgor i thms run and there i s a selective cr i ter ia to determi ne the a r t i fact

present , and a second one where only one ( ins tead of a l l seven) a lgor i thm runs . In

order to jus t i fy the r eason why the second a ttempt was necessa ry, i t wi ll be f i r st

demonst r a ted the r esul t s of the f ir s t a t tempt , and then the r es ul t s from the second.

As i t was descr ibed in the Methods chapter , the cr i ter ia for the f i r s t approach

on the overa l l a lgor i thm’s devel opment was to run a l l separate a lgor i thms and then

the one wi th the most detect ions was the one refer r ing to the ar ti fact present in the

s igna l . Fol lowing tha t logic , Table 5 .2 shows the a r t i facts present in the r espect ive

s igna ls in the rows and the sepa ra te a lgor i thms i n the columns .

The tab le ea s ily shows tha t each speci f ic ar t i fact i s not being ent i r e ly detected

by i t s own a lgor i thm, when a l l the a lgor i thms run a t the same t i me. As one can see,

the s igna ls wi th a Wave ar t i fact where being most ly detected by t he a lgor i t hm for

the HFO ar ti fact, meani ng t ha t the user can’ t even be sure tha t the ar t i facts that

were “ detected” by this a lgor i thm are indeed ar t i facts and not r ea l bra in act ivi ty.

This prob lem can be found for most of the ar t i fact , except the HFO and the EMG

ar t i facts , as i t can be seen in the tab le that these a r e the only ones wi th a check

mark solely on the same a r t i fact and a lgor i thm.

T a b le 5 .2 - Typ e s o f a r t i f a c t s t ha t e ac h a lg or i t h m d e te c te d

A L G O R IT H M S

WAVE PED-LIKE ZETA HFO ECG EMG A R T IF A C TS

WAVE

PED-LIKE

√ √

ZETA

HFO

ECG √

EMG

Bear ing this prob lem in mind, another approach on the overa l l a lgor i thm had to

be thought . After discuss ing the i ssue wi th the medica l sta ff , i t was poss ib le to

r each the conclus i on tha t the phys ician tha t i s ana lys ing the da ta a lways has an

overview of the overa l l signa l , in order to make sure tha t everything i s in order ,

Page 66: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

44

a l lowing the user to ident i fy the a r t i fact tha t i s present in the da ta . As such, the

second – and f ina l – approach on t he devel opi ng of t he f ina l a lgor i thm is ba sed on

the fact that only one out o f the seven speci f i c a lgor i thms runs .

This new approach means tha t the user i s the one t ha t selects which a r t i fact

he/she wants to detect in the s igna l , given tha t usual ly, per sub ject , there’ s only

one t ype of a r t i fact. Alongs ide wi th t he select i on of the a r t i fact to detect , the user

a lso has the fr eedom to choose the threshol d tha t sha l l separa te a r t i factua l da ta

from actua l bra in act ivi ty, thanks to the threshol ds from Table 5 .1 , which r ema in

the same for this f ina l a lgor i thm.

Fina l ly, wi th the f ina l detect ion a lgor i thm developed, i t i s t ime to demonst r a te

the overa l l r esul t s f rom every a lgor i thm for every sub ject , given tha t the plots

previous ly presented onl y display a sma l l sample of the eff icacy of the independent

a lgor i thms. Table 5 .3 gives us the r esul t s for every tes t per for med on th e s ub jects ,

for the opt i ma l thresholds taken from the ROC curves for each sub ject.

Page 67: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

45

T a b le 5 .3 - Re s ul t s of a l l a lg o r i t h ms , f or a l l s ub je c t s

WAVE ARTIFACT

SUBJECT TRUE

POSITIVE

FALSE

POSITIVE

FALSE

NEGATIVE

#1 92 .0 45 .2 8 .0

#2 91 .2 24 .4 8 .8

#3 81 .8 40 .0 18 .2

#4 78 .1 41 .9 21 .9

#5 90 .7 9 .3 9 .3

PED-LIKE ARTIFACT

SUBJECT TRUE

POSITIVE

FALSE

POSITIVE

FALSE

NEGATIVE

#1 100.0 25 .0 0 .0

#2 100.0 31 .8 0 .0 #3 81 .3 51 .9 18 .8

#4 88 .2 66 .7 11 .8

#5 100.0 40 .6 0 .0

ZETA ARTIFACT

SUBJECT TRUE

POSITIVE

FALSE

POSITIVE

FALSE

NEGATIVE

#1 87 .5 36 .4 12 .5

#2 94 .7 59 .1 5 .3

#3 95 .2 45 .9 4 .8

#4 95 .7 64 .5 4 .3

#5 94 .6 50 .0 5 .4

HFO ARTIFACT

SUBJECT TRUE

POSITIVE

FALSE

POSITIVE

FALSE

NEGATIVE

#1 96 .7 32 .6 3 .3

#2 97 .6 16 .7 2 .3

#3 100.0 9 .3 0 .0

#4 92 .3 37 .9 7 .7

#5 96 .4 8 .5 3 .6

ECG ARTIFACT

SUBJECT TRUE

POSITIVE

FALSE

POSITIVE

FALSE

NEGATIVE

#1 100.0 52 .9 0 .0

#2 81 .3 33 .3 18 .7

#3 92 .6 16 .7 7 .4

#4 80 .0 20 .0 20 .0 #5 100.0 25 .0 0 .0

EMG ARTIFACT

SUBJECT TRUE

POSITIVE

FALSE

POSITIVE

FALSE

NEGATIVE

#1 100.0 80 .0 0 .0

#2 77 .8 12 .5 22 .2

#3 100.0 0 .0 0 .0

Page 68: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

46

By observing Table 5 .3 one can see tha t the True Pos i t ive (TP) ra te ha s the

highes t va lues , a lways above 80% wi th a few except ions . Fol l owing t his ra te i s the

Fa lse Pos i t ive (FP) r a te , wi th lower va lues than the TP but s t i l l higher than the

Fa lse Nega tive (FN) ra te , which t r ans la tes the percentage of a r t i facts tha t were not

detected by the a lgor i thms. As one can see, the la s t column in the tab le ha s a few

va lues of 0 .0%, which means tha t in those cases the a lgor i thm s in ques t ion detected

a l l the ar t i facts present in the da ta .

In order to get an eas ier overview of the r esul t s presented above, Table 5 .4

pr esents the mean and s tandard devia t ion of a l l the three cr i ter ia .

T a b le 5 .4 - Me a n o f th e re s u l t s f r o m a l l a lg or i t h ms

CRITERIA MEAN ± STANDA RD DEVIATION (%)

TRUE POSITIVE 92 .4 ± 7 .5

FALSE POSITIVE 34 .9 ± 19.8

FALSE NEGATIVE 7 .7 ± 7 .5

This tab le cons ider s the overa ll per formance of the a lgor i thm, r egardless of the

ar t i fact i t ’s detect ing. As such, the ar t i fact due to movement or elect rode

displacement i s not included here because tha t ar t i fact, as i t was previous ly

expla ined, does not need any t r a ining or tes t ing, r e lying onl y on an absolute

threshold s ta ted in the l i tera ture [52] .

Page 69: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

47

6 Discussion

In this chapter , a cr i t ica l overview of the r esul t s i t wi l l be included, wi th a

discuss ion of wha t they mean and how they can be interpreted a s par ts of the whole

tha t i s this project . The logic of this chapter sha l l be the same a s the previous one

– Resul t s – in order to keep the same l ine of thought and e a se the process of

discuss ing the a lgor i thm’s s teps .

After cons ider ing the Sta te of the Ar t and a l l the met hods previous ly a t tempted

by other r esearch groups , three methodologica l conclus ions were r eached:

- Independent Component Ana lys is ( ICA) should not be per formed in this

set of da ta because one onl y has access to two di ffer ent channels in the EEG, which

would mean tha t this ana lys is could only have an output o f two di ffer ent

components , which was not r e l iab le enough to disc ern ar ti facts from nor ma l da ta ;

- Even though some a r t i facts have a speci f ic fr equency r ange, c la ss ica l

f i l ter ing i s a lso not the bes t approach due to the fact tha t these fr equency r anges

coul d be over lapping wi th the nor ma l EEG’s fr equency r ange, and one does not

want to r emove i mpor tant da ta from the EEG trace;

- Basic sub tract ion of the EEG trace wi th ECG, EMG or

r espi ra t ion/vent i la t ion s igna ls could not be done due to the fact tha t these

acquis i tions were not ava i lab le for every sub ject , and therefore the a lgor i thm coul d

not r e ly on addi t i ona l phys iologica l s igna ls in order to detect these types of

ar t i facts .

Therefore , t he f i r s t topic to ment ion in this chapter i s the sample of r aw EEG

chosen to i l lus t ra te the s teps of the a lgor i thm for the Sinus (LF) ar t i fact . As seen

in Figure 5 .1 one can see tha t the sample t r ans la tes the prob lem i n ques t ion: very

often t he r aw EEG s igna l conta ins ar ti factua l per iods tha t mask the r e a l bra in

act ivi ty and may lead to er roneous conclus ions r egarding diagnos is and t r ea tment

of seizures . In this por t ion of s igna l one can see three a r t i factua l episodes in the

da ta , c lear ly separa ted, but c lose enough to p rovide an ins ight on how accura tely

the a lgor i thm is ab le to ident i fy sepa ra te episodes o f a r t i factua l da ta . Another

fea ture tha t can be ident i f ied i s tha t this speci f ic ar t i fact usua l ly ha s a sma l ler

ampl i tude when compar ing to the b ra in act ivi ty on the EEG, whi ls t being less

s tochas t ic and therefore more per iodic .

When this por t ion of s igna l goes through t he cor r ela t ion process , the f i r s t r esul t

r esembles Figure 5.2 and Figure 5.3 , showing the ma tr ices of cor r ela t ion between

the r aw per iods of s igna l (per iods of 5 seconds) and the s l iding wi ndow t ha t i s the

sur roga te ( cr eated from the s in and cos funct ions in MATLAB) . Each column of

these ma tr ices corr espond to a t ime poi nt , f rom t he beginning to the end of the

acquis i tion, and each row cor responds to a di ffer ent f r equency cons idered to t he

sur roga tes, f rom 0 .02 to 3 H z , wi th a fr equency s tep of 0 .02 Hz .

One might a rgue tha t this met hod i s very s imi la r to the Shor t -Ti me Four ier

Transform (STFT) that can be per formed a lso in MATLAB wi th the a id of the

funct ion spectrogram . There ar e two di ffer ent r ea sons why this funct io n was not

Page 70: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

48

used i n this a lgor i thm: f i r s t , because this funct i on, wi th the sa me pa rameter s

( s l iding window of 5 seconds – 5x64 t ime poi nts – , over lap of 5x64-10 = 310 time

poi nts ) did not provide r esul t s a s good a s the ones presented previ ous ly, a s the

ar t i facts could not be ident i f ied i n the r esul t ing ma tr ix , whether in the t i me doma in

and the fr equency doma i n. The second r eason i s because spec trogram i s an in-bui l t

funct ion from MATLAB, and a s i t was discussed previous ly, the end -goa l of this

a lgor i thm is t o be i mplemented in Signa lBase and event ua l ly in the beds ide

moni tor s in the NICU. As none of these s ys tems have MATLAB wi thi n or even

have the chance to do so, one cannot r esort to such complex funct ions when

thinki ng about the future of the project . When the met hod for this ar t i fact’ s

a lgor i thm was devel oped the STFT was not cons idered, but once the or igina l

method proved effect ive the s i mi la r it ies between both processes were not iced and

therefore the r esul t s were compared, in order to see i f STFT s hould be cons i dered

in the ana lys is . As ment ioned before , the STFT did not per for m a separa t ion

between a r t i factua l and non -a r ti factua l per iods of EEG as effect ively a s the method

devel oped, r ea son why the funct ion spectrogram f rom MATLAB was not

cons idered for this a lgor i thm.

Focus i ng aga in on Fig ure 5 .2 and Figure 5 .3 , i t i s poss ib le to observe tha t there

ar e in fact di ffer ent pa t terns in the ma tr ices wi thin the a r ea s marked a s ar t i factua l .

For most of the length of t hese per iods and between t he fr equencie s 1 .2 Hz and 1 .5

Hz there ar e pa t terns composed by r ea l ly high and r ea l ly low cor rela tion va lues ,

a s one can see in the colour bar on the r ight s ide of t he ma tr ices . Somet hing wor th

not ic ing in these colour ba rs i s tha t the ex t r eme va lues of -1 and 1 ar e never r eached

or even cons idered in t he bar s , given tha t the computa t iona l process of cor r ela t ion

never r ea l ly r eaches a per fect r esul t , which i s expected because there i s a lso a

cer ta in var iab il i ty a ssocia ted wi th the ar t i fact, given tha t i t i s s t i l l pa r t of an EEG

measurement . For tha t r eason, the maxi ma l va lues in these ma tr ices ar e a lways

around ±0 .9 , which a re cons idered va lues h igh/ low enough to i ndica te a high

cor r ela t ion. Outs ide these ar ea s in the ma tr ices , mos t of the va lues a r e around 0 ,

indica ted by a green- ish colour in the overa l l plot , except ing some other r andom

high/ low va lues tha t a r e la ter e l imina ted when these ma tr ices ar e combined, a s one

can see in Figure 5 .4 .

In this f igure i t i s presented the r esul t of the combina t ion of the s in and cos

cor r ela t ion ma tr ices . The per iods of higher and lower cor r elat ion va lues ar e now

cons is tent ly hi gher than the r es t of t he ma tr ix , an ana lys is tha t’ s a ided by the

colour bar on the r ight of the plot . The va lues in this ma tr ix ar e not norma l ized,

but i t i s st i l l poss ib le to under s tand tha t the per iods of ar t i factua l da ta do indeed

possess higher va lues between the green and the r ed bar s and also a lways wi thin

the same fr equency r ange, another fea ture tha t indica tes tha t we’re in the presence

of an a r t i fact of Sinus (LF) and not jus t some random and per iodic act ivi ty from

the bra in. A character i s t ic tha t can be seen in this example i s tha t the s ta r t of th e

high va lues in the ma tr ix don’ t ma tch exact ly wi th the begi nni ng of t he a r t i factua l

per iod, i . e . , there’ s a lways a sma l l lag between bot h fea tures . This can be

under s tood when cons i der ing the fact that the surroga te window has a length of

f ive seconds , s o the hi gher cor r ela t ion va lues cannot commence when onl y a

por t ion of the r aw signa l ma tches the sur roga te , thus the delay.

Page 71: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

49

In this same ma tr ix , i t i s a lso poss ib le to observe s l ight ly higher va lues a lso

around 2 .8 Hz , but s t i l l not a s high a s the ones ment i oned before . As one can see,

this f r equency va lue i s approx ima tely the double of the fr equency r ange for the

highes t va lues , meaning tha t the sur roga te wi th a higher fr equency mi ght be havi ng

a cor r ela tion higher than usua l even though i t i s not the s ame fr equency of the

ar t i fact , given tha t one cycle of a sur roga te with 3 Hz can cover exact ly two cycles

of an a r ti fact wi th 1.5 Hz , having a r ea lly high cor r ela t ion both in i t s beginning

and end, and a r eal ly low cor rela t ion in the exact middle of the co r r ela t ion.

Once the ma tr ix combina t ion process i s done, i t i s t ime to nor ma l ize and conver t

the ma tr ix into an array, much l ike the one in Figure 5 .5 . This plot shows tha t the

ar eas wi th higher cor r ela t ion per iods can in fact be separa ted from the r es t of the

s igna l based only on i t s va lues . This poses the nex t b ig prob lem of this a lgor i thm,

tha t i s: how to sepa ra te ar t i factua l detect ions from nor ma l bra in activi ty per iods?

Given tha t the answer focused on the de f ini t i on of an opt i ma l threshol d tha t bes t

per for ms this separa t ion, one must cons ider the thresholds in Table 5 .1 . These

ranges take into account the thresholds for each sub ject f rom each di ffer ent

ar t i fact , and i t i s eas i ly seen tha t for the f i r st four a lgor i thms the t hresholds a r e

a lways wi thin a cer ta in range, which i s a good thi ng because there i s a lways a

cer ta in amount of va r iabi l i ty a ssocia ted wi th each di ffer ent sub ject , which can

inf luence the threshold va lue, but in these ca ses that does not pose as a ma jor

prob lem and a l l va lues a r e r e la t ively close to each other , wi thin the same a r t i fact.

For the l a s t two a lgor i thms, the ECG and EMG ones , the same does not occur .

Unfor tuna tely, the threshold ranges for thes e two a lgor i thms a re broader tha n the

r es t , and tha t mi ght pose a s a cha llenge when the a lgor i thm is not on a tra ining or

tes t ing phase but a lr ea dy in da i ly use. For tha t ma t ter , this i s a weak spot for the

overa l l a lgor i thm given tha t the user s t i l l does not have a shor t scope of va lues to

choose from. With tha t in mi nd, future s teps on this a lgor i thm must be cons idered:

given tha t these two ar t i facts ar e , from the seven proposed, the most commonly

found ar t i facts in the l i tera ture for infant and adul t EEG, compar ison wi th other

detect ion met hods must be set in place and tes t which approaches ar e bes t on the

detect ion of i t s r espect ive a r ti facts . S ta ti s t ica l analys is on these thresholds - in

order to f ind the bes t opt ima l va lue - was not per formed due to the fact tha t there

ar e only f ive va lues per a r t i fact, and that did not cons is t on a popula t ion large

enough to per for m tes ts . The fact that this a lgor i thm is s t i l l in a prel imi na ry phase

can a lso cons t i tute an argument a s to why this kind of ana lys is was not per for med

on this da ta .

Assumi ng tha t a l l bes t thresholds a r e now found for every sub ject on t his

t ra ining/ tes t ing set , the sepa ra t ion between non-a r ti fact and ar t i fact i s per formed

in the nor ma l ized arr ay and we ob ta in a plot l ike Figure 5 .7 . In this plot i t i s

poss ib le to see tha t wi thin the a r ti factua l per iods there ar e a lot of sma l l detect ions ,

due t o the fact tha t the array from the cor r ela t ion ma tr ix had a very i rr egula r sh ape

and in the per iods wi th high va lues , one can f ind di f fer ences of va lues up to 0 .2 .

This means tha t i f the threshol d i s e .g. , 0 .54 , an a rray in an ar t i factua l periods tha t

a lways has va lues between 0.5 and 0 .6 wi ll have a lot of shor ter detect ions and not

a single , cons is tent detect i on. With this prob lem in mi nd, a funct ion was crea ted –

jo in t_peaks – tha t a l lows for the joining of det ect ion peaks tha t a r e too close apa rt ,

turning the r esul t f rom Figure 5.7 into Figure 5 .8 , and the t ime tha t separates the

Page 72: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

50

s ma l ler detect ions can be chosen by the user as wel l. In concordance to this

prob lem, somet i mes random detect ions a lso a r ise from the methods descr ibed

before , even in por t ions of s igna l where there ar e no ar t i facts wha tsoever . These

random detect i ons a r e spur ious in the detect ion a rrays and do not t rans la te any

ar t i factua l presence a t a l l , being the r esul t of random bra in act ivi ty in the EEG

tha t could ma ybe r esemble the a r t i fact in ques t ion for a shor t per iod of t i me. With

this in mi nd, a di ffer ent funct i on was created – end_peaks – tha t e l imina tes

detect ions tha t ar e shor ter than a cer ta in dura tion t ha t i s a l so selected by the user .

I f one cons ider s tha t mos t a r t i facts occur for per iods longer than 5 -10 seconds , i t

becomes useful t o e l i mi na te detect ions tha t las t less than this amount of t i me. This

funct ion a l lows for the f ine - tuning of the algor i thm’s r esul t s and for a bet ter

under s tanding of where the r ea l a r ti facts ar e in the da ta .

With r ega rds to the other a lgor i thms’ r esul t s from Fig ure 5 .9 up to Fig ure 5.20

i t i s poss ib le to see s ix di ffer ent samples of raw EEG from s ix di ffer ent sub jects

conta ining the other types of a r ti facts ment ioned before . J us t a s the example

deta i led in the previous chapter s , the green a nd r ed ba r s a id the visua l

ident i f ica t ion of the a r t i facts in the raw da ta , marked by an exper ienced doctor .

When the a r t i facts’ ampl i tudes a r e very low (around 10 to 20 V) i t i s poss ib le to

see tha t the overa l l va r ia t ion of the EEG’s ampl i tude i s s t i l l pr esent and the ar t i fact

i s only an addi t ion to the s igna l , l ike in the ca ses of the HFO, ECG and EMG. For

the ca ses of the PED -Like and Zeta ar t i facts , i t’ s a s though the ar t i fact i s

super i mpos ing i t sel f on any bra in act ivi ty that coul d be present and the a r t i fact i s

a l l tha t the user can see in the acquis i tion, much l ike in the Sinus (LF) ca se.

For the ca se of the PED -Like a r t i fact, the detect ions can be found exact ly wi thin

the a r ti factua l per iod, as i t is a l so the ca se for the Zeta and fo r the HFO ar t i facts .

For the ECG and EMG ar t i fact , the detect ion of the a r t i facts la s ts a b i t longer than

the a r t i fact i t sel f , but a s one can see in the r aw EEG plots , the EEG s igna l does

not r e turn to a s moother shape r ight a f ter the ar t i fact , so this ir r egula r shape –

even though not being cons idered a r t i fact – is pa ssing the a lgor i thm’s cr i ter ia for

ar t i fact and therefore i t ’ s being cla ss i f ied as such. Focus ing on t hese two examples ,

the user must take one thing into account : the manua l markings of the a r ti facts in

the r aw EEG were per formed by onl y one exper ienced doct or and there was no

oppor tuni ty for other c la ss i f ica t ions by di fferent observer s. This means tha t there

was no poss ib i l i ty for inter -observer r e l iab i l i ty ca lcula t ions or any sor t of ana lys i s

such a s this , in order to make sure tha t the golden s tanda rd cons idered here i f in

fact agreed upon by more than one memb er of the cl inica l s ta ff . With this in mi nd,

the a lgor i thm onl y has one measure to cons ide r a s the r ea l truth between a r t i factual

and non-a rt i factua l da ta and the r esul t s a r e therefore prone to be di ff er ent should

more cla ss i f ier s be included in the project .

For the Movement a r t i fact, the s igna l cons idered in the example belonged t o a

sub ject wi th 40 ges ta t iona l weeks of age, and theref ore the maxima l and mi ni ma l

va lues for a nor ma l EEG are cons idered to be in the r ange of ±100 V. This way,

the a lgor i thm takes the age va lue and a ssociates i t wi th an agreed upon va lue for

both l imi ts in the EEG s igna l . The a lgor i thm t hen cons ider s the ra w s igna l and

every t ime the s igna l i f over (or under ) these va lues , an ar t i fact is detected. The

advantage of this speci f ic a lgor i thm is tha t i t does not need a gol den s tanda rd to

Page 73: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

51

compare i t’ s r esul t s because the met hod i s very binary: the EEG s igna l i s e i ther

wi thin the nor ma l va lues or not . The only dependence of this a lgor i thm is the

sub ject ’ s age, a character i s t ic that the cl inica l s ta ff can a lways access whenever

they need to, and tha t can even be found in the Bra inZ f i le when opened.

The s ma l l delay i n the detect ion of the a r t i fact s when compar ing them t o the

actua l beginni ng of the a r t i fact in the r aw EEG is not yet cons idered an obs tacle

to the a lgor i thm because this project focuses on a f i rs t approach for the a lgor i thm,

and a lso due to the fact tha t when the cl inica l s ta ff uses the a lgor i thm, a visua l

check of the r esul t s is s t i l l r ecommended given tha t there a r e s t il l fea tures to be

opt i mized in the a lgor i thm. Cons ider ing this , i t suff ices tha t the algor i thm

ident i f ies the a r t i facts where they a re p r esent , but i t’ s not yet essent ia l tha t the

detect ions have a per fect ma tch wi th the beginni ng and end of the a r t i fact in the

raw s igna l, given tha t for now this i s a detect ion tool and as long a s the a lgor i thm

a ler t s for the presence of an ar t i fact in the acquis i tion, the user can check the

r esul t s in the end and deter mine wi th more accuracy the exact s tar t and f inish of

the a r t i facts .

Cons ider ing now the a ssembl ing methods tha t were set in place, i t i s ea sy to

under s tand the need for a second approach, gi ven tha t Table 5 .2 e lucida tes tha t

when a l l a lgor i thms run a t the sa me t i me, the r esul t s ar e sub -opt i ma l . When

observing this tab le, one can see tha t in the f i rs t a t tempt to bui ld the overal l

a lgor i thm - wi th a l l a lgor i thms runni ng – some a lgor i thms could never r ea l ly detect

thei r own a r ti facts because other methods were super impos ing themsel ves and

over shadowing the r esul t s . I t i s c lear tha t the method for the HFO was ab le to

detect more than i t shoul d, a s it i s vis ib le tha t this a lgor i thm had the highes t

percentage of detect i ons for a l l ar t i facts, except for Zeta waves and EMG act ivi ty.

Alongs ide wi th this , even i f the other a lgor i thms had high detect ion percentages

but a b i t sma l ler than the ones from t he HFO, the r esul t s didn’ t ma t ter because the

r ight a lgor i thm would not be the chosen one . Taking the case of the Sinus (LF)

ar t i fact : when runni ng a l l a lgor i thms on an EEG s igna l wi th this ar t i fact, the

detect ion percentage mi ght even be the cor r ect one, but the HFO met hod was

detect ing more ar t i facts tha t could not even be so, in r ea l i ty. The r ea son some

ar t i facts have a checkmark on two di ffer ent a lgor i thms i s because for a ll f ive

sub jects from each a r t i fact, some met hods had di ffer ent percentages : in the ca se of

the f ive sub jects wi th PED -Like ar t i facts , two sub jects had the ECG met hod a s the

one wi t h highes t detect ion percentages and the other three had the HFO one wi th

the highes t detect i ons . Even though the HFO and the EMG ar t i facts were corr ect ly

ident i f ied by the cor r esponding a lgor i thms, this approach was not devel oped any

fur ther because the other a r ti facts were being er roneous l y r ecognized and the

overa l l a lgor i thm coul d not be trus ted wi th i t s f ina l r esul t s .

This method was clear ly not the bes t one and fur ther cons idera tion was taken

into this par t of the project . After a careful ana lys is on the prob lem a t hand , the

second approach was decided wi th the cl inica l s ta ff : given tha t the user a lways

overviews the raw s igna l before ana lys ing i t and can know beforehand wha t type

of a r t i fact he/she i s looking for , the overa ll detect ion a lgor i thm wi l l ask the user

for two di ffer ent inputs before runni ng any detect ion met hods : the sub ject ’ s age

and wha t type of a r t i fact i s to be detected. This solut i on comes wi th t wo ma in

Page 74: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

52

advantages : the f i r st one i s tha t the computa t iona l t ime of t he detect i on a lgor i thm

is cut shor t because ins tead of running seven di ff er ent a lgor i thms, onl y one i s

running. The second one i s tha t this gives the user fr eedom t o select the goa l of

the detect ion, being ab le to ident i fy more accura tely and wi th more confidence the

ar t i fact in ques t ion, especia l ly when cons ider ing the one EEG acquis i tion usua l ly

onl y has one type of a r t i fact , out of the seven descr ibed. This second and chosen

approach on the detect ion a lgor i thm does not need fur ther t ra ining or tes t ing

because the r esul t s ar e in every way l ike the ones from the sepa ra te a lgor i thms

presented in the pl ots before .

In any ca se, the r esul t s for every a lgor i thm and every sub ject mus t be

scrut inized, in order to demonst r a te the eff icacy of the overa l l detect ion a lgor i thm.

For tha t , one must take into cons idera t ion Table 5 .3 . In this tab le i t i s poss ib le to

see a l l the r esul t s for the three eva lua t ion cr i ter ia cons idered: True Pos i t ives (TP) ,

Fa lse Pos i t ives (FP) and Fa lse Nega tives (FN). True Nega t ives were not cons idered

due to the fact tha t these cr i ter ia would take most of the s igna l , i . e. , this cr i ter ia

would jus t indica te when the a lgor i thm purpos ely does not detect anything and the

ma in focus of t his ana lys is is the oppos i te : when the a lgor i thm in fact detects

somet hing, and how cor rect those detect ions ar e . This way, one can see the values

for a ll thr ee cr i ter ia , for every a lgor i thm and for every sub ject .

From a more careful analys is on the tab le , one can see tha t the TP rate is a lways

the one wi th the highes t va lues , which t rans lates a s a good outcome of the detect ion

a lgor i thm because tha t means tha t th e met hods are preforming a s they should and

tha t mos t a r t i fact s ar e being proper ly ident i f i ed. In fact , out of a l l the 23 sub jects

for a l l a lgor i thms, 6 had TP va lues below 90%, proving the a lgor i thm’s eff icacy in

detect ing a r t i facts. Fol lowing t his ra te i s the FP va lues , which demonst ra tes lower

va lues , but s t i l l higher than des i r ed. Even though s ome a r t i facts have low va lues

for this cr i ter ion, one of the weak spots of t he detect ion a lgor i thm is the Fa lse

Pos i t ives i t or iginates , meaning tha t the a lgor i th m is detect ing more ar t i facts than

actua lly ex is t in the da ta . This can be due to two di f fer ent r ea sons : f i rs t , i t can

happen because of the doct or ’ s c lass i f ica t ion and the need of more than one golden

s tandard, because wha t one doctor sees as ar t i fact mig ht be b ra in act ivi ty for

another , and vice -ver sa . The second r ea son i s due to t he threshol d select ion. With

a higher threshold, more t i me points woul d be below the threshold and t herefore

not c la ssi f ied as ar ti fact ; this would mean tha t the detect ions tha t a r e corr ect ly

ident i f ied would be ei ther shor ter in dura t ion or not ex is t ing a t a l l – this proves

tha t the threshold select ion i s a topic tha t should be focused on in future work and

tha t can s t i ll be opt i mized. Once the t hresho lds a r e improved and i t s r a nges ar e

na rrowed, the FP ra te wi l l cer ta inly r each lower va lues .

When cons ider ing the FN rate , as one would des i r e , this is the lowes t ra te out

of a l l thr ee. This i s a very opt i mis t ic fea ture from the detect ion a lgor i thm, for i t

proves tha t the methods a r e not le t t ing ar ti facts undetected, a s this cr i ter ion

eva lua tes the ar t i facts tha t ar e present in the da ta but were not ident i f ied by t he

a lgor i thm. The fact tha t for some sub jects ( in di ffer ent a r t i facts) this ra te i s 0 .0%

is a t ruly pos i t ive discuss ion p oint , because i t means tha t the a lgor i thm is not

miss ing any a r t i facts in the raw s igna l . Fol lowing the discuss ion from t he previ ous

pa ragraph where threshold select ion needs to be improved, i f the threshold i s

Page 75: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

53

lowered than one must take into account tha t the FP ra te wi l l be lower (and

therefore , bet ter) but this FN ra te might increase, so opt imiza t ion of the thresholds

must be per for med very ca reful ly and in discuss ion wi th the cl i nica l s ta ff , a s thei r

preferences must be a lways put f i r s t .

At this point , i t i s impor tant to c lar i fy one t hing about these cr i ter ia : a t rue

pos i t ive cla ss i f ica t ion does not necessa r i ly impl y tha t the a lgor i thm’s detect ion

and the manua l marking ma tch per fect ly. As i t was not iced before , these two are

not a lways in per fect synch, so a t rue pos i t ive i s c lass i f ied a s a detect ion from t he

a lgor i thm tha t i s wi thin the green and the r ed ba r in the manua l markings ,

independent ly on which one s ta r t s or ends f i r st . As long a s the a lgor i thm ident i f ies

an ar t i fact where an a r t i fact i s indeed present , tha t i s enough to cons ider a s a

r ight ful detect ion, because a t this s tage of the project one must a lways r ely on the

user ’ s f ina l assessment in confi r mi ng the a lgor i thm’s r esul t s .

Page 76: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

54

Page 77: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

55

7 Conclusion

The acquis i t ions of newborns’ brain act ivi ty tha t a r e per formed in the

environment of the NICU i n severa l hospi ta ls ar e very often f i l led wi t h di f fer ent

types of a r t i facts tha t may mask the t rue EEG s igna l tha t should be acquir ed. This

ma y lead to mis inter preta t ions of the EEG and therefore to er roneous conclus ions

when i t comes to diagnos t ic and/or therapeut ic procedures .

G iven the wide va r ie ty of di ff er ent a r ti facts tha t can be found, the methods

previous ly devel oped by other groups usua l ly focus on a pa r t icular ar t i fact , due to

i t s predomi nance in a speci f ic set of da ta or to the speci f ic needs of a cer ta in s tudy.

The project a t hands here i s, to the bes t of the author ’s knowledge up to da te , the

f i r s t approach on the s i mul taneous detect i on of seven (Sinu s LF and HF, PED-Like,

Zeta , EMG, ECG and Movement /E lect rode d isplacement) di ffer ent a r t i facts tha t

were previous ly ident i f ied by the cl inica l s ta ff .

The a lgor i thm devel oped focused on each a r t ifact ’s speci f ic fea tures and tr ied

to ident i fy those fea tures in EEG da ta wi th severa l sets of da ta , intermixed wi t h

ar t i factua l and non-a r t i factual per iods of t ime .

When cons ider ing t he methods descr ibed and i t s r esul t s, the overa l l conclus ion

i s tha t the a lgor i thm is indeed detect ing t he ar t i facts and, therefore , serves the

purpose i t was developed for .

There ar e c lear - yet minor - discrepancies when compar ing the manua l

annota t ions and the r esul t s from the a lgor i thm, but th a t does not present as an

obs tacle , given t ha t the a lgor i thm is in a s tage where i t s t i l l r e l ies on the user ’ s

f ina l a ssessment .

There i s s t i l l work to be done i n this project , which i s devel oped in t he chapter

Future Work, but the project descr ibed here a l r eady compr ises a f ir s t approach on

the detect ion of a r t i facts in neona ta l EEG, cont r ibut ing to a bet ter under s tanding

of the b ra in’ s true activi ty and hope ful ly, to a more eff ic ient and advantageous

tool in s igna l process ing in neurosciences , a f ie ld wi th so much tha t i s a l r eady

known, and yet so much to be discovered.

Page 78: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

56

Page 79: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

57

8 Future Work

As ment ioned before , this project r epor ts a f ir s t approach on an a lgor i thm tha t

a ims a t detect ing seven di ff er ent types of a r t ifacts tha t can be fr equent ly found in

neona ta l EEG acquis i t ions . As any f i r s t s tep a t a chieving somet hing, there i s

a lways room for i mprovement , especia l ly when t he ma t ter concerns diagnos t ic -

r ela ted decis ions .

With this in mi nd, ther e ar e a spects in this a lgor i thm tha t can benefi t f rom

opt i miza t ion. The ma in l i mi ta t ion of this project i s the sma l l amount of da ta that

was used to tr a in a nd tes t the individua l sma l ler a lgor i thms. Unfor tuna tely, due to

the t ime-consumi ng ta sk of manua l ly annota t ing the a r t i facts in the da ta , i t was

onl y poss ib le to ob ta in f ive di ffer ent sub jects for each type of a r t i fact ( except ing

the EMG ar ti fact , which only had three sub jects ) . Another l imi ta t ion tha t

under mines this i s the fact tha t a l l a cquisi t ions were used a s t ra ining and tes t ing

da ta , meaning tha t the way the a lgor i thm was bui l t might be the r esul t of over f i t t ing

the met hods into the speci f i c set of da ta tha t was ava ilab le . Cons ider ing this

l iab i l i ty , the f i r st s tep on opt i miz ing the a lgor i thm must be to cons ider more da ta

for every type of a r t i fact and divide i t into t wo dis t inct sets : one for t ra ining and

another one for tes t ing, a ssur ing t he bet ter qua l i ty of the methods devel oped. This

wi l l not only i mprove the methods overa l l , but more da ta ava i lab le can a lso be

t rans la ted into a bet ter cer ta inty as to what is the best threshold for each ar t i fact ,

thus r educi ng the r anges presented in Table 5 .1 and a l lowing for s ta t i st ical ana lys is

to be set in place and therefore provi ding wi th more cer ta inty a s ingle va lue for

each di ffer ent ar t i fact , r egardless of the sub ject .

Once the f ina l detect ion a lgor i thm is opt i mi zed and the cl inica l s ta ff agrees

wi th i t s outcomes , i mplementa t ion i n Si gna lBase can be set in mot ion. This

r equi r es a set of programmi ng ski l l s tha t include MATLAB (where the a lgor i thm

was develope d) and Embarcadero Delphi , the language in which Signa lBase was

devel oped. This implementa t ion wi l l a l low for the synchroniza tion of the EEG

s igna ls wi th other types of acquis i t ions ( e .g. NIRS, ECG) and the poss ib le

ident i f ica t ion of other a r ti facts that a r e not EEG -speci f ic , but can be found in ot her

phys iologica l parameter s .

When i t comes to i mplementa t ion, one must a lso ment ion the beds ide softwa re

tha t i s cur r ent ly used in the NICU moni tor s – Bra inZ – which per for ms r ea l- t ime

seizure detect ion. One of t he downsi des of this software i s tha t i t s seizure detect ion

a lgor i thm rel ies too much on rhythmici ty – a fea ture tha t i s inherent to ar t i facts a s

wel l – so miscla ss i f ica t ions of seizures tha t ar e indeed a r t i facts can a lso occur

from t i me to t i me. Once the a lgor i thm is a lr eady f inished, i t s implementa t ion on

Bra inZ is a lso somethi ng t o cons ider , hopefu l ly i mproving the t rue cla ss i f icat ion

of seizures and r educing the admi nis t ra t ion of ant iconvulsant drugs to tr ea t wha t

i s , in fact , an ar t i fact .

The f ina l opt i miza tion point i s not ful ly r e la ted to this a lgor i thm, but an

i mprovement in the overa l l s igna l analys is tool : ar t i fact detect ion i s the f ir s t s tep

in ar t i fact ident i f ica t ion, of cour se, but tha t does not change the qua l i ty of the

s igna l , because the er roneous in for ma t ion i s s t i l l there . With that in mind, a r t i fact

Page 80: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

58

r emova l shoul d a lso be a topic to discuss and to set in mot ion in the fut ure . This

might be a di ff icul t ta sk due to the fact tha t the acquis i tions in the NICU from the

WKZ rely on 2 channels onl y, but there i s a lways room for improvement of the

s igna l qual i ty and for the opt i miza tion of the tools tha t a r e wi thin our r each.

Page 81: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

59

9 References

[ 1] M. De Vos e t a l . , “Automa ted a r ti fact r emova l a s preprocess ing r ef ines

neona ta l seizure detect ion,” Clin . Neurophys io l . , vol . 122, no. 12, pp. 2345 –

2354 , 2011 .

[2] L. Weeke e t a l. , “Rhythmic EEG pa t terns in ex t r emel y preterm infants :

cla ssi f ica tion and a ssocia t ion wi th b r a in injury and outcome.”

[ 3] P. Rolfe , “Neona ta l cr i t ica l care moni tor ing. , ” J. Med . Eng. Technol . , vol .

10 , no. 3 , pp. 115–20, 1986 .

[4] G. Macdona ld, “ Long - term EEG moni t or ing in the Neona tal Intens ive Care

Unit . , ” Conf. Proc. IEEE Eng. Med. Bio l . Soc . , vol . 3 , pp. 2483 –5 , 2005.

[5] S. L. Merhar and V. Chau, “Neuroi maging and Other Neurodiagnos t ic Tes ts

in Neona ta l Encepha lopa thy,” Clin . Per ina to l. , vol . 43 , no. 3 , pp. 511 –527,

2016 .

[6] L. S . de Vr ies and L. Hel ls t rom-Westa s , “ Role of cerebra l funct ion

moni tor ing in the newborn,” Arch Dis Chi ld Fe ta l Neonatal Ed , vol . 90 , no.

3 , pp. F201-7 , 2005.

[7] T. Chang and T. N . Tsuchida , “ Convent iona l ( cont inuous) EEG moni tor ing

in the NICU. ,” Curr . Ped ia tr . Rev . , vol . 10, no. 1 , pp. 2–10 , 2014 .

[8] G . G. Lin and J . G . Scot t , “ Impact of NICU des ign on envi ronmenta l noise ,”

vol . 100 , no. 2 , pp. 130–134 , 2012.

[9] K. Watanabe, F. Hayakawa , and A. Okumura, “Neona ta l EEG: A power ful

tool in the assessment of b ra in damage in preterm infants ,” Brain Dev . , vol .

21 , no. 6 , pp. 361–372 , 1999.

[10] L. Hyl l ienmark and P. Åmark, “Cont inuous EEG moni tor ing in a paedia tr ic

intens ive ca re uni t , ” Eur. J . Paedia tr. Neuro l . , vol . 11 , no. 2 , pp. 70 –75 ,

2007 .

[11] A. M. Graça, I . Sampa io, C. Moniz , and M. do C. Machado,

“Elect roencefa l ograma de ampl i tude integrada (aEEG) no r ecém-nascido com

pa tologia neurológica – uma técnica a general izar ,” Ac ta Pedia tr Port , vol .

43 , no. 5 , pp. 202–9 , 2012.

[12] Amer ican E lectroencepha lographic Society . , “Guidel ine 2 : Mini mum

Technica l Standa rds for Pedia tr ic e lectroencepha lography. ,” J. Cl in.

Neurophys io l . , vol . 6 , pp. 1 –5 , 2006 .

[13] H. H. Jasper , “Repor t of the commit tee on methods of c l inica l examina t ion

in e lect roencepha lography. ,” Elec troencephalogr . Cl in. Neurophysio l.

Suppl . , vol . 10 , no. 2, pp. 370–375 , 1958 .

[14] M. C. Toet , L. G . M. van Rooi j , and L. S. de Vr ies , “ The Use of Ampl i tude

Integra ted E lectroencepha lography for Assess ing Neona ta l Neurologic

Injury,” Clin. Per ina tol . , vol . 35, no. 4, pp. 665 –678, 2008 .

[15] G. Mar ics , A. Csekő, B. Vásárhelyi , D . Zaka riá s, G . Schus ter , and M. Szabó ,

“Preva lence and et iology of fa lse nor ma l aEEG recordings in neona tal

hypoxic- i schaemic encepha lopa thy. , ” BMC Pedia tr. , vol . 13, no. 1 , p. 194,

2013 .

Page 82: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

60

[16] D. Suk, A. N. Krauss , M. Engel , and J . M. Per lman, “ Ampl i tude - integra ted

elect roencepha lography in the NICU: fr equent a r t i facts in prema ture infants

ma y l imi t i t s ut i l i ty as a moni tor ing device. , ” Pediatr ic s , vol . 123 , no. 2, pp.

e328-32 , 2009 .

[17] H . Niemarkt , P . Andr iessen, and F. J . Ha lber tsma , “ Ar tefacts in the

ampl i tude- integra ted EEG background pa t tern of a ful l - term a sphyxia ted

neona te caused by diaphragm spas ms. ,” BMJ Case Rep . , vol . 2012 , pp. 2011 –

2013 , 2012 .

[18] J . Shibasaki , K. Toyoshi ma , and M . K ishigami , “ Blood pressure and aEEG in

the 96h a f ter b ir th and cor r ela tions wi th neurodevelopmenta l outcome in

ex t r emely preterm infants . , ” Early Hum. Dev . , vol . 101, pp. 79 –84 , 2016.

[19] J . Ga le , T. L. Signa l, A. L. Garden, and P. H . Gander ,

“Elect roencepha lography ar t i facts in workplace a ler tness moni t or ing,”

Scand. J . Work. Env iron . Heal . , vol . 33 , no. 2, pp. 148 –152, 2007 .

[20] S. Devuys t , T. Dutoi t , P . Stenui t , M. Kerkhof s , and E . Stanus , “Remova l of

ECG ar t i facts from EEG us ing a modif ied i ndepende nt component ana lys is

approach. ,” Annu. In t . Conf . IEEE Eng . Med. Bio l . Soc . , vol . 30 , no. 1, pp.

5204–5207 , 2008 .

[21] D. Chakrabar ti and S. Bansal , “ECG contami na t ion of EEG s igna ls : effect on

ent ropy,” J . Cl in . Moni t. Comput. , vol . 30 , no . 1, pp. 119 –122, 2016 .

[22] J . F . Gao, C. X . Zheng, and P. Wang, “Onl ine Remova l of Muscle Ar t i fact

from Elect roencepha logram Signa ls Based on Canonica l Correla t ion

Ana lys is ,” Clin . Eeg Neurosc i . , vol . 41 , no. 1, pp. 53–59, 2010 .

[23] C. I . Akman, K . J . Abou Kha led, E . Sega l, V. Micic , and J . J . Riviel lo,

“Genera lized periodic epi lept i for m discha rges in cr i t ica l ly il l chi ldren:

Cl inica l fea tures, and outcome,” Epi lepsy Res . , vol . 106, no. 3, pp. 378–385 ,

2013 .

[24] S. Lahi r i , A. D. Boro, A. L. Shi loh, M. J . Mi ls te in, and R. H. Savel , “ Per iodic

Epi lept i for m Discha rges Clar i f ied for the Nonneurologis t Intens ivis t :

Clinica l Impl ica t ions and Cur rent Management . , ” J. In tens ive Care Med. ,

vol . 30 , no. 7, pp. 385 –391 , 2015 .

[25] N . Isobe e t a l. , “Per iodic Epi lept i for m Discharges in Chi ldren With

Advanced Stages o f Progress ive Myoclonic Epi lepsy,” Clin . EEG Neurosc i . ,

pp. 1–7 , 2015.

[26] O. Magnus and M. Van der Hols t , “ Zeta waves : a specia l type of s low del ta

waves ,” Electroencephalogr . Cl in . Neurophys io l . , vol . 67, no. 2 , pp. 14 0–

146, 1987 .

[27] T. A. Siepman, P. J . Cher ian, and G. H. Visser , “ Zeta waves , an unusua l EEG

findi ng in s t ructural b ra in les ions : r epor t of two pa t ients ,” Am J

E lectroneurodiagnos t ic Technol , vol . 44, no. 1 , pp. 24 –29 , 2004.

[28] B. F. Westmoreland and D. W. Klass , “ Unusua l EEG Pa t terns .” J ourna l of

CLinica l Neurophys iol ogy, New York.

[29] Y. Zou, V. Na than, and R. Ja far i , “ Automa t ic ident i f ica t ion of a r t i fact -

Rela ted independent components for ar t i fact r emova l in EEG recordings ,”

IEEE J . B iomed. Heal. In format ics , vol . 20 , no. 1 , pp. 73 –81 , 2016.

[30] J . F. Gao, Y . Yang, P. Lin, P . Wang, and C. X . Zheng, “ Automa t ic r emova l

Page 83: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

61

of eye- movement and b l ink a r t i facts from eeg s igna ls ,” Brain Topogr . , vol .

23 , no. 1 , pp. 105–114 , 2010.

[31] P. Senthi l Kumar , R. Arumugana than, and C. Vi ma l , “Wavelet based Ocular

Ar t i fact r emova l rom EEG Signa ls us ing ARMA met hod and Adapt ive

Fi l ter ing,” 2009.

[ 32] J . Ma , P. Tao, S. Bayram, and V. Svet nik, “Muscle a r ti facts in mul t ichannel

EEG: Character i s t ics and r educt ion,” Clin. Neurophys iol . , vol . 123 , no. 8 ,

pp. 1676–1686, 2012 .

[33] M. Crespo-Garcia , M. At ienza, and J . L. Cantero, “Muscle a r ti fact r emova l

from huma n s leep EEG by us ing independent component ana lys is ,” Ann.

B iomed. Eng. , vol . 36 , no. 3 , pp. 467–475 , 2008 .

[34] a G . Correa, E . Laciar , H . D. Pa t iño, and M. E . Valent inuzz i , “ Ar ti fact r emova l from EEG s igna ls us ing adapt ive f i l ter s in ca scade,” J . Phys . Conf .

Ser . , vol . 90, p. 12081, 2007 .

[35] S. Bhat tacharyya e t a l. , “Detection of ar t i facts from high energy bur s ts in

neona ta l EEG,” Comput . B io l . Med . , vol . 43 , no. 11 , pp. 1804–1814, 2013 .

[36] A. Mognon, J . J ovicich, L. Bruzzone, and M. Buia t ti , “ADJ UST: An

automa t ic EEG ar t i fact detector ba sed on the joint use of spa t ia l and tempora l

fea tures ,” Psychophys io logy , vol . 48 , no. 2 , pp. 229–240 , 2011.

[37] S. Bha t tacharyya e t a l. , “Fea ture selection for automa t ic bur s t detect ion in

neona ta l e lectroencepha logram,” IEEE J . Emerg . Sel . Top . Circu it s Sy st . ,

vol . 1 , no. 4 , pp. 469 –479, 2011 .

[38] S. Bha t tacharyya , J . Mukhopadhyay, and A. K. Ma jumdar , “ Automa ted Burs t

Detect ion in Neona ta l Eeg,” Proc. In t. Conf . B io- inspired Sys t. S ignal

Process. , pp. 15–21, 2011 .

[39] N . Koolen e t a l. , “Line length a s a robus t method to detect hi gh - act ivi ty

events : Aut oma ted bur s t detect ion in prema ture EEG recordings ,” Clin .

Neurophys io l . , vol . 125 , no. 10 , pp. 1985 –1994 , 2014 .

[40] N. J . Stevenson, J . M. O’Toole, I . Korotchikova , and G. B. Boylan, “Ar tefact

detect ion in neona ta l EEG,” 2014 36th Annu. In t . Conf . IE EE Eng. Med. B io l .

Soc . EMBC 2014 , no. Augus t , pp. 926 –929, 2014.

[41] J . Ir ia r te e t a l. , “ Independent component ana lys is a s a tool to e l imina te

ar t i facts in EEG: a quant i ta t ive s tudy. , ” J . Clin . Neurophys io l . , vol . 20 , no.

4 , pp. 249–257 , 2003 .

[42] A. Liu, J . S . Hahn, G. P. Heldt , and R. W. Coen, “Detect ion of neona ta l

seizures through computer ized EEG ana lys is ,” Elec troencephalogr. Cl in.

Neurophys io l . , vol . 82, no. 1, pp. 30–37 , 1992.

[43] C. M. L. Lommen e t a l . , “ An a lgor i thm for the automa t ic detect ion of seizures

in neona ta l ampl i tude - integra ted EEG,” Ac ta Paedia tr. In t . J . Paedia tr . , vol .

96 , no. 5 , pp. 674–680 , 2007.

[44] K. T. Sweeney, S. Member , H . Ayaz , E. Ward, and S. Member , “ A

Methodology for Va l ida t ing Ar t i fact Remova l Techniques for Phys iol og ica l

Signa ls ,” vol . 16, no. 5, pp. 918 –926, 2012 .

[45] S. P. Fi tzgibbon, D. M. W. Powers , K . J . Pope, and C. R. Clark, “Remova l of

EEG noise and ar t i fact us ing b l ind source separa t ion. , ” J . Cl in .

Page 84: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

62

Neurophys io l . , vol . 24, no. 3, pp. 232 –243, 2007 .

[46] H . No lan, R. Whelan, and R. B. Rei l ly, “ FASTER: Ful ly Automa ted

Sta t is t ica l Thresholdi ng for EEG ar t i fact Reject ion,” J . Neurosc i. Me thods ,

vol . 192 , no. 1 , pp. 152–162 , 2010.

[47] K . Hermans e t al . , “Effect iveness of r eference s igna l ba sed methods for

r emova l of EEG a rt i facts due to sub t le movements dur ing fMRI scanning,”

IEEE Trans . Biomed. Eng . , vol . 9294 , no. c , pp. 1 –1, 2016 .

[48] C. J . James and C. W. Hesse, “ Independent component analys is for

b iomedica l s igna ls,” Phys io l . Meas . , vol . 26 , no. 1 , pp. R15-39 , 2005.

[49] S. Boudet , L. Peyrodie , P. Ga l lois, and C. Vasseur , “ A global approach for

automa t ic ar ti fact r emova l for standa rd EEG record,” Annu. In t . Conf . IEEE

Eng. Med. Bio l. - Proc. , pp. 5719–5722 , 2006.

[50] J . A. Ur igüen and B. Ga rcia -Zapira in, “EEG ar t i fact r emova l - sta te -of- the-ar t

and gui del ines . , ” J. Neura l Eng . , vol . 12 , no. 3 , p. 31001, 2015 .

[51] M. Zima , P. Tichavský , K . Paul , and V. Kra jča , “Robus t r emova l of shor t -

dura t ion ar t i facts in long neona ta l EEG recordings us ing wavelet - enhanced

ICA and adapt ive combini ng of tenta t ive r econs t ruct ions ,” Phys io l. Meas . ,

vol . 33 , pp. N39–N49, 2012 .

[52] M. André e t a l. , “É lectroencépha lographie du nouveau -né préma turé et à

terme. Aspects ma tura t i fs e t glossa ir e ,” Neurophysio l. Cl in . , vol . 40 , no. 2,

pp. 59–124 , 2010.

Page 85: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

i

10 Appendices

The cur r ent sect ion compr ises the appendices r efer r ing to the project tha t was

devel oped.

The f i r s t sub - sect ions include diagrams of t he indivi dua l a lgor i thms for the

ar t i facts developed, which took a b ig pa rt in the devel opment of the ini t ia l logic

and method behind each a lgor i thm, whi ls t a l so eas ing the interpreta t ion of the

overa l l process .

Fol lowi ng t he diagrams, the or igina l MATLAB code wr i t ten throughout this

project i s a l so included in this sect ion, in order to demonst r ate the computa t iona l

logic wi thi n each method.

APPENDIX I – D iagram refer r ing to the a lgor i thms for the Sinus , PED -Like

and Zeta Waves ar ti facts ;

APPENDIX II – Diagram referr ing to the a lgor i t hm for the HFO a rt i fact;

APPENDIX III – D iagram refer r ing to the a lgor i thm for the EMG and ECG

ar t i facts ;

APPENDIX IV – Diagram refer r ing to the algor i thm for the

Movement /E lect rode Displacement a r t i fact ;

APPENDIX V – Body of the overa l l detect ion a lgor i th m;

APPENDIX VI – Auxi l iary funct ion for the Sinus Wave ar t i fact’ s detect ion

a lgor i thm;

APPENDIX VII – Auxi l iary funct i on for the PED -Like Wave ar t i fact ’s detect ion

a lgor i thm;

APPENDIX VIII – Auxi l iary funct i on for the Zeta Wave ar ti fact’ s detect ion

a lgor i thm;

APPENDIX IX – Auxi l iary funct ion for the HFO ar t i fact’ s detect ion a lgor i thm;

APPENDIX X – Auxi l ia ry funct ion for the ECG ar t i fact ’s detect ion a lgor i thm;

APPENDIX XI – Auxi l iary funct ion for the EMG ar t i fact’ s detect ion a lgor i thm;

APPENDIX XII – Auxi l ia ry funct ion for the Movement /E lect rode Displacement

ar t i fact ’s detect ion a lgor i thm;

APPENDIX XIII – Auxi l iary funct ion;

APPENDIX XIV – Auxi l iary funct ion;

APPENDIX XV – Use Cases ;

Page 86: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

APPENDIX I

Page 87: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

0 50 100 150 200 250 300 350-2

-1.5

-1

-0.5

0

0.5

1

1.5

2

575.5 576 576.5 577 577.5 578 578.5

-4

-3

-2

-1

0

1

2

3

4

5

time points

frequ

enci

es

Result: correlation matrix

high correlation

low correlation

maximal values for each time point

(sliding window)

manual marking of artefacts

beginning of the algorithm

Creating a surrogate signal

Correlation between signal and surrogate

combination of the matrices from every surrogate

time

normalised and combined

correlation values

Page 88: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

selection of the best threshold

beginning of artifact

end of artifact

optimal threshold

best separation between artifactual and non-artifactual data

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

The best threshold is the one with the highest

Sensitivity and Specificity in the ROC Curve

1 - specificity

sensitivity

end of the algorithm

Page 89: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

APPENDIX II

Page 90: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

the periods of signal with HFO artifacts have a lower amplitude in the aEEG because of the smaller differences in amplitude during this artifact

manual marking of artefacts

beginning of the algorithm

calculate the difference between the maximal and the minimal value of the EEG in a 1 second window

aEEG-like signal

(1 - aEEG) = artifactual periods with higher values

selection of the best threshold

end of the algorithm

Page 91: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

APPENDIX III

Page 92: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

manual marking of artefacts

Beginning of the algorithm

distance between two consecutive points

dhigher muscle activity

= higher distance between consecutive points (d)

d becomes a function of distance between points

Averaging the d function with a window of: 7 seconds for EMG artifacts 5 seconds for ECG artifacts

selection of the best threshold

end of the algorithm

Page 93: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

APPENDIX IV

Page 94: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

because when there’s movement of the infant or the electrodes, the values in the EEG signal are

much higher than normal or NaN (not a number)

beginning of the algorithm

user input: patient’s age in Gestational Weeks (GA)

each GA means different values for the maximal value for brain activity in the EG

different GA = different thresholds

acquisitions above this threshold or equal to NaN are considered artifact

end of the algorithm

Page 95: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

APPENDIX V

Page 96: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

% Filipe Costa _ May 11th 2017 % @ WKZ - UMC Utrecht

clear all close all

% LOAD SIGNAL signal = load('filename.mat'); fs = 64; % Hz L = length(signal); T = 1/fs; t = (0:L-1)*T; % time array %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % THRESHOLDS FOR EACH ARTIFACT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% thresh_muscle = 0.3; thresh_ecg = 0.52; thresh_hfo = 0.94; thresh_zeta = 0.76; thresh_pedlike = 0.75; thresh_wave = 0.49;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% artif = input('Which artifact do you want to detect? (wave, pedlike, zeta, hfo, muscle, ecg, movement) ', 's'); switch artif case 'wave' col = 'g'; [artifact_1, time] = semi_full_wave(signal, thresh_wave); case 'pedlike' col = 'g'; [artifact_1, time] = semi_full_pedlike(signal, thresh_pedlike); case 'zeta' col = 'g'; [artifact_1, time] = semi_full_zeta(signal, thresh_zeta); case 'hfo' col = 'g'; [artifact_1, time] = semi_full_hfo(signal, thresh_hfo); case 'muscle' col = 'g'; [artifact_1, time] = semi_full_muscle(signal, thresh_muscle); case 'ecg' [artifact_1, time] = semi_full_ecg(signal, thresh_ecg); col = 'g'; case 'movement' col = 'g'; ga = input('Insert the gestational age (in weeks): '); [artifact_1, time] = semi_full_movement(signal, ga) end if exist('time') == 0 % if there are no detections sprintf('There are no artifacts!') else if isempty(find(time~=0)) == 0 all_time = time; figure(2) plot(t, signal) for g = 1:length(all_time) line(([all_time(g,1) all_time(g,1)]),[-200 200], 'Color', char(col), 'LineWidth', 3) line(([all_time(g,2) all_time(g,2)]),[-100 100], 'Color', 'r') hold on end else figure(2) plot(t, signal) end end

Page 97: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

APPENDIX VI

Page 98: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

function [ artifact_1, time ] = semi_full_wave( signal, thresh ) fs = 64; % Hz L = length(signal); T = 1/fs; t = (0:L-1)*T; e = 1; h = 1; cycle = 1; wind = fs*60*10; tot_cycle = round(L/wind); for a = 1:wind:L if L-a < wind sig = signal(a:L); else sig = signal(a:a+wind-1); end % if length(sig) < 60*fs % break % end w = 5; % Time window t_small = t(1:fs*w)'; step = 10; m = 1; freq = 0.02:0.02:3; sin1_matrix = zeros(length(freq), length(t_small)); cos1_matrix = zeros(length(freq), length(t_small)); for i = 1:length(freq) sin1_matrix(i,:) = sin(2*pi*t_small.*freq(i)); cos1_matrix(i,:) = cos(2*pi*t_small.*freq(i)); end for i = 1:length(sig) if sig(i) > 50 || sig(i) < -50 sig(i) = 0; end end for s = 1:length(freq) n = 1; surrogate_sin1 = sin1_matrix(s,:); surrogate_cos1 = cos1_matrix(s,:); for i = 1:step:(length(sig)-fs*w) new_wave = sig((i:(i+fs*w)-1)); coef_1_sin1(m,n) = diag(corrcoef(new_wave, surrogate_sin1),1); coef_1_cos1(m,n) = diag(corrcoef(new_wave, surrogate_cos1),1); n = n+1; end m = m+1; end d = 10; lixo = zeros(d, size(coef_1_sin1,2)+d); coef_wave_1 = zeros(size(coef_1_sin1,1), size(coef_1_sin1,2)+d); for r = 1:size(coef_1_sin1, 1) for dt = 1:d for c = 1:(size(coef_1_sin1,2)+(2*dt)) if (1<=c) && (c<=dt) lixo(dt,c) = 2.*(coef_1_cos1(r,c).^2); end if (size(coef_1_sin1,2)+1 <= c) && (c <= (size(coef_1_sin1,2)+dt)) lixo(dt,c) = 2.*(coef_1_sin1(r,c-dt).^2); end if (dt+1<=c) && (c<= size(coef_1_sin1,2)) lixo(dt,c) = (abs(coef_1_sin1(r,c-dt)) + abs(coef_1_cos1(r,c))).^2; end end end index = find(max(mean(lixo,2))); coef_wave_1(r,:) = abs(lixo(index,:)); end coef_wave = max(coef_wave_1)./max(max(coef_wave_1)); % WAVE for k = 1:length(coef_wave) if coef_wave(k) >= thresh artifact_wave_1(k) = 1; else artifact_wave_1(k) = 0; end end q = 1; for p = 1:length(artifact_wave_1) artifact_wave(q:q+9) = artifact_wave_1(p); q = q + 10;

Page 99: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

end artifact_2 = joint_peaks(artifact_wave,fs,10); artifact = end_peaks(artifact_2, fs, 2); if artifact(1) == 1 time(e,1) = t(1 + (cycle-1)*length(sig)); e = e + 1; end for c = 2:length(artifact) if artifact(c-1) == 0 && artifact(c) == 1 time(e,1) = t(c + (cycle-1)*length(sig)); e = e + 1; end end for c = 1:length(artifact)-1 if artifact(c) == 1 && artifact(c+1) == 0 time(h,2) = t(c + (cycle-1)*length(sig)); h = h + 1; end end if artifact(end) == 1 time(h,2) = t(cycle*length(sig)); h = h + 1; end if cycle == 1 artifact_1 = artifact; else artifact_1 = [artifact_1 artifact]; end cycle = cycle + 1; end end

Page 100: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

APPENDIX VII

Page 101: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

function [ artifact_1, time ] = semi_full_pedlike( signal, thresh ) fs = 64; % Hz L = length(signal); T = 1/fs; t = (0:L-1)*T; e = 1; h = 1; cycle = 1; wind = fs*60*5; tot_cycle = round(L/wind); for a = 1:wind:L if L-a < wind sig = signal(a:L); else sig = signal(a:a+wind-1); end % if length(sig) < 60*fs % break % end load('pedlike_surr_1.mat') pedlike_surrogate1 = pedlike_surr_1(25:280); clear pedlike_surr_1 load('pedlike_surr_2.mat') pedlike_surrogate2 = pedlike_surr_2(75:330); clear pedlike_surr_2 load('pedlike_surr_3.mat') pedlike_surrogate3 = pedlike_surr_3(2:end); clear pedlike_surr_3 load('pedlike_surr_4.mat') pedlike_surrogate4 = pedlike_surrogate_4; clear pedlike_surrogate_4 w = length(pedlike_surrogate1); step = 2:3; surrogate1 = nan(length(step), L); for i = step k = 1; for j = 2:i:w surrogate1_1(i-1, k) = (pedlike_surrogate1(j-1) + pedlike_surrogate1(j))/2; surrogate1_2(i-1, k) = (pedlike_surrogate2(j-1) + pedlike_surrogate2(j))/2; surrogate1_3(i-1, k) = (pedlike_surrogate3(j-1) + pedlike_surrogate3(j))/2; surrogate1_4(i-1, k) = (pedlike_surrogate4(j-1) + pedlike_surrogate4(j))/2; k = k + 1; end end clear surrogate5 k = 1; for j = 1:3:w-2 surrogate5_1(1,k) = pedlike_surrogate1(j); surrogate5_1(1,k+1) = pedlike_surrogate1(j+1)*0.5 + pedlike_surrogate1(j+2)*0.5; surrogate5_2(1,k) = pedlike_surrogate2(j); surrogate5_2(1,k+1) = pedlike_surrogate2(j+1)*0.5 + pedlike_surrogate2(j+2)*0.5; surrogate5_3(1,k) = pedlike_surrogate3(j); surrogate5_3(1,k+1) = pedlike_surrogate3(j+1)*0.5 + pedlike_surrogate3(j+2)*0.5; surrogate5_4(1,k) = pedlike_surrogate4(j); surrogate5_4(1,k+1) = pedlike_surrogate4(j+1)*0.5 + pedlike_surrogate4(j+2)*0.5; k = k + 2; end clear surrogate6 k = 1; for j = 1:6:w-5 surrogate6_1(1,k) = pedlike_surrogate1(j); surrogate6_1(1,k+1) = pedlike_surrogate1(j+1)*0.8 + pedlike_surrogate1(j+2)*0.2; surrogate6_1(1,k+2) = pedlike_surrogate1(j+2)*0.6 + pedlike_surrogate1(j+3)*0.4; surrogate6_1(1,k+3) = pedlike_surrogate1(j+3)*0.4 + pedlike_surrogate1(j+4)*0.6; surrogate6_1(1,k+4) = pedlike_surrogate1(j+4)*0.2 + pedlike_surrogate1(j+5)*0.8; surrogate6_2(1,k) = pedlike_surrogate2(j); surrogate6_2(1,k+1) = pedlike_surrogate2(j+1)*0.8 + pedlike_surrogate2(j+2)*0.2; surrogate6_2(1,k+2) = pedlike_surrogate2(j+2)*0.6 + pedlike_surrogate2(j+3)*0.4; surrogate6_2(1,k+3) = pedlike_surrogate2(j+3)*0.4 + pedlike_surrogate2(j+4)*0.6; surrogate6_2(1,k+4) = pedlike_surrogate2(j+4)*0.2 + pedlike_surrogate2(j+5)*0.8; surrogate6_3(1,k) = pedlike_surrogate3(j); surrogate6_3(1,k+1) = pedlike_surrogate3(j+1)*0.8 + pedlike_surrogate3(j+2)*0.2; surrogate6_3(1,k+2) = pedlike_surrogate3(j+2)*0.6 + pedlike_surrogate3(j+3)*0.4; surrogate6_3(1,k+3) = pedlike_surrogate3(j+3)*0.4 + pedlike_surrogate3(j+4)*0.6; surrogate6_3(1,k+4) = pedlike_surrogate3(j+4)*0.2 + pedlike_surrogate3(j+5)*0.8; surrogate6_4(1,k) = pedlike_surrogate4(j); surrogate6_4(1,k+1) = pedlike_surrogate4(j+1)*0.8 + pedlike_surrogate4(j+2)*0.2; surrogate6_4(1,k+2) = pedlike_surrogate4(j+2)*0.6 + pedlike_surrogate4(j+3)*0.4; surrogate6_4(1,k+3) = pedlike_surrogate4(j+3)*0.4 + pedlike_surrogate4(j+4)*0.6; surrogate6_4(1,k+4) = pedlike_surrogate4(j+4)*0.2 + pedlike_surrogate4(j+5)*0.8;

Page 102: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

k = k + 5; end k = 1; for j = 1:1:w-1 surrogate2_1(1,k) = pedlike_surrogate1(j); surrogate2_1(1,k+1) = (pedlike_surrogate1(j) + pedlike_surrogate1(j+1))/2; surrogate2_2(1,k) = pedlike_surrogate2(j); surrogate2_2(1,k+1) = (pedlike_surrogate2(j) + pedlike_surrogate2(j+1))/2; surrogate2_3(1,k) = pedlike_surrogate3(j); surrogate2_3(1,k+1) = (pedlike_surrogate3(j) + pedlike_surrogate3(j+1))/2; surrogate2_4(1,k) = pedlike_surrogate4(j); surrogate2_4(1,k+1) = (pedlike_surrogate4(j) + pedlike_surrogate4(j+1))/2; k = k + 2; end k = 1; for j = 1:3:w-3 surrogate3_1(1,k) = pedlike_surrogate1(j); surrogate3_1(1,k+1) = pedlike_surrogate1(j)*0.4 + pedlike_surrogate1(j+1)*0.6; surrogate3_1(1,k+2) = pedlike_surrogate1(j+1)*0.8 + pedlike_surrogate1(j+2)*0.2; surrogate3_1(1,k+3) = pedlike_surrogate1(j+1)*0.2 + pedlike_surrogate1(j+2)*0.8; surrogate3_1(1,k+4) = pedlike_surrogate1(j+2)*0.6 + pedlike_surrogate1(j+3)*0.4; surrogate3_2(1,k) = pedlike_surrogate2(j); surrogate3_2(1,k+1) = pedlike_surrogate2(j)*0.4 + pedlike_surrogate2(j+1)*0.6; surrogate3_2(1,k+2) = pedlike_surrogate2(j+1)*0.8 + pedlike_surrogate2(j+2)*0.2; surrogate3_2(1,k+3) = pedlike_surrogate2(j+1)*0.2 + pedlike_surrogate2(j+2)*0.8; surrogate3_2(1,k+4) = pedlike_surrogate2(j+2)*0.6 + pedlike_surrogate2(j+3)*0.4; surrogate3_3(1,k) = pedlike_surrogate3(j); surrogate3_3(1,k+1) = pedlike_surrogate3(j)*0.4 + pedlike_surrogate3(j+1)*0.6; surrogate3_3(1,k+2) = pedlike_surrogate3(j+1)*0.8 + pedlike_surrogate3(j+2)*0.2; surrogate3_3(1,k+3) = pedlike_surrogate3(j+1)*0.2 + pedlike_surrogate3(j+2)*0.8; surrogate3_3(1,k+4) = pedlike_surrogate3(j+2)*0.6 + pedlike_surrogate3(j+3)*0.4; surrogate3_4(1,k) = pedlike_surrogate4(j); surrogate3_4(1,k+1) = pedlike_surrogate4(j)*0.4 + pedlike_surrogate4(j+1)*0.6; surrogate3_4(1,k+2) = pedlike_surrogate4(j+1)*0.8 + pedlike_surrogate4(j+2)*0.2; surrogate3_4(1,k+3) = pedlike_surrogate4(j+1)*0.2 + pedlike_surrogate4(j+2)*0.8; surrogate3_4(1,k+4) = pedlike_surrogate4(j+2)*0.6 + pedlike_surrogate4(j+3)*0.4; k = k + 5; end k = 1; for j = 1:3:w-3 surrogate4_1(1,k) = pedlike_surrogate1(j); surrogate4_1(1,k+1) = pedlike_surrogate1(j)*(2/3) + pedlike_surrogate1(j+1)*(1/3); surrogate4_1(1,k+2) = pedlike_surrogate1(j+1)*(1/3) + pedlike_surrogate1(j+2)*(2/3); surrogate4_1(1,k+3) = pedlike_surrogate1(j+3); surrogate4_2(1,k) = pedlike_surrogate2(j); surrogate4_2(1,k+1) = pedlike_surrogate2(j)*(2/3) + pedlike_surrogate2(j+1)*(1/3); surrogate4_2(1,k+2) = pedlike_surrogate2(j+1)*(1/3) + pedlike_surrogate2(j+2)*(2/3); surrogate4_2(1,k+3) = pedlike_surrogate2(j+3); surrogate4_3(1,k) = pedlike_surrogate3(j); surrogate4_3(1,k+1) = pedlike_surrogate3(j)*(2/3) + pedlike_surrogate3(j+1)*(1/3); surrogate4_3(1,k+2) = pedlike_surrogate3(j+1)*(1/3) + pedlike_surrogate3(j+2)*(2/3); surrogate4_3(1,k+3) = pedlike_surrogate3(j+3); surrogate4_4(1,k) = pedlike_surrogate4(j); surrogate4_4(1,k+1) = pedlike_surrogate4(j)*(2/3) + pedlike_surrogate4(j+1)*(1/3); surrogate4_4(1,k+2) = pedlike_surrogate4(j+1)*(1/3) + pedlike_surrogate4(j+2)*(2/3); surrogate4_4(1,k+3) = pedlike_surrogate4(j+3); k = k + 4; end surrogate_1{1} = surrogate2_1(1,~isnan(surrogate2_1(1,:))); surrogate_1{2} = surrogate3_1(1,~isnan(surrogate3_1(1,:))); surrogate_1{3} = surrogate4_1(1,~isnan(surrogate4_1(1,:))); surrogate_1{4} = pedlike_surrogate1; surrogate_1{5} = surrogate6_1(1,~isnan(surrogate6_1(1,:))); surrogate_2{1} = surrogate2_2(1,~isnan(surrogate2_2(1,:))); surrogate_2{2} = surrogate3_2(1,~isnan(surrogate3_2(1,:))); surrogate_2{3} = surrogate4_2(1,~isnan(surrogate4_2(1,:))); surrogate_2{4} = pedlike_surrogate2; surrogate_2{5} = surrogate6_2(1,~isnan(surrogate6_2(1,:))); surrogate_3{1} = surrogate2_3(1,~isnan(surrogate2_3(1,:))); surrogate_3{2} = surrogate3_3(1,~isnan(surrogate3_3(1,:))); surrogate_3{3} = surrogate4_3(1,~isnan(surrogate4_3(1,:))); surrogate_3{4} = pedlike_surrogate3; surrogate_3{5} = surrogate6_3(1,~isnan(surrogate6_3(1,:))); surrogate_4{1} = surrogate2_4(1,~isnan(surrogate2_4(1,:))); surrogate_4{2} = surrogate3_4(1,~isnan(surrogate3_4(1,:))); surrogate_4{3} = surrogate4_4(1,~isnan(surrogate4_4(1,:))); surrogate_4{4} = pedlike_surrogate4; surrogate_4{5} = surrogate6_4(1,~isnan(surrogate6_4(1,:))); step = 5; m = 1; for i = 1:length(sig) if sig(i) > 50 || sig(i) < -50 sig(i) = 0; end

Page 103: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

end for j = 1:length(surrogate_1) % number of surrogates n = 1; for i = 1:step:(length(sig)-length(surrogate_1{j})) new_wave = sig((i:(i+length(surrogate_1{j}))-1)); coef_pedlike_1(m,n) = diag(corrcoef(new_wave, surrogate_1{j}),1); coef_pedlike_2(m,n) = diag(corrcoef(new_wave, surrogate_2{j}),1); coef_pedlike_3(m,n) = diag(corrcoef(new_wave, surrogate_3{j}),1); coef_pedlike_4(m,n) = diag(corrcoef(new_wave, surrogate_4{j}),1); n = n + 1; end m = m + 1; end m1 = length(find(coef_pedlike_1>0.8)); m2 = length(find(coef_pedlike_2>0.8)); m3 = length(find(coef_pedlike_3>0.8)); m4 = length(find(coef_pedlike_4>0.8)); coef_max = [m1 m2 m3 m4]; if max(coef_max) == m1 coef_pedlike1 = abs(coef_pedlike_1)*2 + abs(coef_pedlike_2).^2 ... + abs(coef_pedlike_3).^2 + abs(coef_pedlike_4).^2; elseif max(coef_max) == m2 coef_pedlike1 = abs(coef_pedlike_1).^2 + abs(coef_pedlike_2)*2 ... + abs(coef_pedlike_3).^2 + abs(coef_pedlike_4).^2; elseif max(coef_max) == m3 coef_pedlike1 = abs(coef_pedlike_1).^2 + abs(coef_pedlike_2).^2 ... + abs(coef_pedlike_3)*2 + abs(coef_pedlike_4).^2; else coef_pedlike1 = abs(coef_pedlike_1).^2 + abs(coef_pedlike_2).^2 ... + abs(coef_pedlike_3).^2 + abs(coef_pedlike_4)*2; end coef_pedlike = max(coef_pedlike1)./max(max(coef_pedlike1)); % PEDLIKE clear artifact_pedlike for k = 1:length(coef_pedlike) if coef_pedlike(k) >= thresh artifact_pedlike_1(k) = 1; else artifact_pedlike_1(k) = 0; end end q = 1; for p = 1:length(artifact_pedlike_1) artifact_pedlike(q:q+4) = artifact_pedlike_1(p); q = q + 5; end artifact_1 = joint_peaks(artifact_pedlike,fs,10); artifact = end_peaks(artifact_1, fs, 2); if artifact(1) == 1 time(e,1) = t(1 + (cycle-1)*length(sig)); e = e + 1; end for c = 2:length(artifact) if artifact(c-1) == 0 && artifact(c) == 1 time(e,1) = t(c + (cycle-1)*length(sig)); e = e + 1; end end for c = 1:length(artifact)-1 if artifact(c) == 1 && artifact(c+1) == 0 time(h,2) = t(c + (cycle-1)*length(sig)); h = h + 1; end end if artifact(end) == 1 time(h,2) = t(cycle*length(sig)); h = h + 1; end if cycle == 1 artifact_1 = artifact; else artifact_1 = [artifact_1 artifact]; end

Page 104: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

cycle = cycle + 1; end end

Page 105: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

APPENDIX VIII

Page 106: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

function [ artifact, time ] = semi_full_zeta( signal, thresh ) fs = 64; % Hz L = length(signal); T = 1/fs; t = (0:L-1)*T; e = 1; h = 1; cycle = 1; wind = fs*60*5; tot_cycle = round(L/wind); for a = 1:wind:L if L-a < wind sig = signal(a:L); else sig = signal(a:a+wind-1); end if length(sig) < 60*fs break end load('zeta_surrogate2.mat') load('zeta_surrogate3.mat') load('zeta_surrogate4.mat') load('zeta_surrogate5.mat') w = 2; for i = 1:length(sig)-fs if sig(i) > 65 || sig(i) < -65 sig(i) = 0; end end clear blu n blu1 blu2 blu3 blu4 n = 1; blu1 = zeros(1, length(sig)-w*fs); blu2 = blu1; blu3 = blu2; blu4 = blu3; z1 = zeta_surrogate2(1:2*fs); z2 = zeta_surrogate3(1:2*fs); z3 = zeta_surrogate4(1:2*fs); z4 = zeta_surrogate5(1:2*fs); for j = 1:length(sig)-w*fs if isnan(sig(j)) == 0 piece = sig(j:j+w*fs-1); blu1(:,j:j+w*fs-1) = diag(corrcoef(piece, z1),1); blu2(:,j:j+w*fs-1) = diag(corrcoef(piece, z2),1); blu3(:,j:j+w*fs-1) = diag(corrcoef(piece, z3),1); blu4(:,j:j+w*fs-1) = diag(corrcoef(piece, z4),1); end end blu = abs(blu1) + abs(blu2) + abs(blu3) + abs(blu4); coef_zeta = blu/max(blu); clear artifact_zeta for k = 1:length(coef_zeta) if coef_zeta(k) >= thresh artifact_zeta(k) = 1; else artifact_zeta(k) = 0; end end artifact_1 = joint_peaks(artifact_zeta,fs,2); artifact = end_peaks(artifact_1, fs, 2); % if m < 0.2 % artifact = zeros(length(artifact), 1); % end if artifact(1) == 1 time(e,1) = t(1 + (cycle-1)*length(sig)); e = e + 1; end for c = 2:length(artifact) if artifact(c-1) == 0 && artifact(c) == 1 time(e,1) = t(c + (cycle-1)*length(sig)); e = e + 1; end end

Page 107: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

for c = 1:length(artifact)-1 if artifact(c) == 1 && artifact(c+1) == 0 time(h,2) = t(c + (cycle-1)*length(sig)); h = h + 1; end end if artifact(end) == 1 time(h,2) = t(cycle*length(sig)); h = h + 1; end if cycle == 1 artifact_1 = artifact; else artifact_1 = [artifact_1 artifact]; end cycle = cycle + 1; end end

Page 108: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

APPENDIX IX

Page 109: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

function [ artifact_1, time ] = semi_full_hfo( signal, thresh ) fs = 64; % Hz L = length(signal); T = 1/fs; t = (0:L-1)*T; e = 1; h = 1; cycle = 1; wind = fs*60*2; tot_cycle = round(L/wind); for a = 1:wind:L if L-a < wind sig = signal(a:L); else sig = signal(a:a+wind-1); end % if length(sig) < 60*fs % break % end clear aeeg d = fs; j = 1; for i = 1:length(sig)-d aeeg(j) = max(sig(i:i+d)) - min(sig(i:i+d)); j = j+1; end for i = 1:d aeeg(j-1+i) = aeeg(j-1); end coef_hfo = 1-aeeg/max(aeeg); clear artifact_hfo for k = 1:length(coef_hfo) if coef_hfo(k) >= thresh artifact_hfo(k) = 1; else artifact_hfo(k) = 0; end end artifact_1 = joint_peaks(artifact_hfo,fs,2); artifact = end_peaks(artifact_1, fs, 2); if artifact(1) == 1 time(e,1) = t(1 + (cycle-1)*length(sig)); e = e + 1; end for c = 2:length(artifact) if artifact(c-1) == 0 && artifact(c) == 1 time(e,1) = t(c + (cycle-1)*length(sig)); e = e + 1; end end for c = 1:length(artifact)-1 if artifact(c) == 1 && artifact(c+1) == 0 time(h,2) = t(c + (cycle-1)*length(sig)); h = h + 1; end end if artifact(end) == 1 time(h,2) = t(cycle*length(sig)); h = h + 1; end if cycle == 1 artifact_1 = artifact; else artifact_1 = [artifact_1 artifact]; end cycle = cycle + 1; end end

Page 110: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

APPENDIX X

Page 111: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

function [ artifact_1, time ] = semi_full_ecg( signal, thresh ) fs = 64; % Hz L = length(signal); T = 1/fs; t = (0:L-1)*T; e = 1; h = 1; cycle = 1; wind = fs*60*1; tot_cycle = round(L/wind); for a = 1:wind:L if L-a < wind sig = signal(a:L); else sig = signal(a:a+wind-1); end if length(sig) < 60*fs break end clear p_dist p_dist1 p = 1; for i = 1:length(sig)-p p_dist(i) = sqrt((sig(i+p)-sig(i)).^2 + (1/fs).^2); end q = 350; for j = 1:q:(length(p_dist)-(q-1)) p_dist1(1,j:j+(q-1)) = mean(p_dist(1,j:j+(q-1))); end coef_ecg = 1-(p_dist1/max(p_dist1)); clear artifact_ecg for k = 1:length(coef_ecg) if coef_ecg(k) >= thresh artifact_ecg(k) = 1; else artifact_ecg(k) = 0; end end artifact_1 = joint_peaks(artifact_ecg,fs,2); artifact = end_peaks(artifact_1, fs, 2); if artifact(1) == 1 time(e,1) = t(1 + (cycle-1)*length(sig)); e = e + 1; end for c = 2:length(artifact) if artifact(c-1) == 0 && artifact(c) == 1 time(e,1) = t(c + (cycle-1)*length(sig)); e = e + 1; end end for c = 1:length(artifact)-1 if artifact(c) == 1 && artifact(c+1) == 0 time(h,2) = t(c + (cycle-1)*length(sig)); h = h + 1; end end if artifact(end) == 1 time(h,2) = t(cycle*length(sig)); h = h + 1; end if cycle == 1 artifact_1 = artifact; else artifact_1 = [artifact_1 artifact]; end cycle = cycle + 1; end end

Page 112: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

APPENDIX XI

Page 113: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

function [ artifact, time ] = semi_full_muscle( signal, thresh ) fs = 64; % Hz L = length(signal); T = 1/fs; t = (0:L-1)*T; e = 1; h = 1; cycle = 1; wind = fs*60*20; tot_cycle = round(L/wind); for a = 1:wind:L if L-a < wind sig = signal(a:L); else sig = signal(a:a+wind-1); end if length(sig) < 60*fs break end for i = 1:length(sig)-fs if sig(i) > 200 || sig(i) < -200 if i >= fs/2 sig(i-fs/2:i+fs/2) = 0; else sig(1:i+fs/2) = 0; end end end clear p_dist coef p_dist1 p = 1; for i = 1:length(sig)-p p_dist(i) = sqrt((sig(i+p)-sig(i)).^2 + (1/fs).^2); end q = 450; for j = 1:q:(length(p_dist)-(q-1)) p_dist1(1,j:j+(q-1)) = mean(p_dist(1,j:j+(q-1))); end coef_muscle = p_dist1./max(p_dist1); clear artifact_muscle for k = 1:length(coef_muscle) if (coef_muscle(k) >= thresh) artifact_muscle(k) = 1; else artifact_muscle(k) = 0; end end artifact_1 = joint_peaks(artifact_muscle,fs,2); artifact = end_peaks(artifact_1, fs, 2); if artifact(1) == 1 time(e,1) = t(1 + (cycle-1)*length(sig)); e = e + 1; end for c = 2:length(artifact) if artifact(c-1) == 0 && artifact(c) == 1 time(e,1) = t(c + (cycle-1)*length(sig)); e = e + 1; end end for c = 1:length(artifact)-1 if artifact(c) == 1 && artifact(c+1) == 0 time(h,2) = t(c + (cycle-1)*length(sig)); h = h + 1; end end if artifact(end) == 1 time(h,2) = t(cycle*length(sig)); h = h + 1; end if cycle == 1 artifact_1 = artifact; else artifact_1 = [artifact_1 artifact];

Page 114: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

end cycle = cycle + 1; end end

Page 115: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

APPENDIX XII

Page 116: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

function [ artifact, time ] = semi_full_movement( signal, ga ) fs = 64; % Hz L = length(signal); T = 1/fs; t = (0:L-1)*T; e = 1; h = 1; cycle = 1; wind = fs*60*2; tot_cycle = round(L/wind); for a = 1:wind:L if L-a < wind sig = signal(a:L); else sig = signal(a:a+wind-1); end if length(sig) < 60*fs break end if ga <= 23 disp('Error. The minimal age is 24 GA.') elseif (24 < ga) && (ga < 29) m = 300; elseif (30 < ga) && (ga < 34) m = 200; elseif (35 < ga) && (ga < 41) m = 100; elseif ga >= 42 m = 50; end alert_1 = zeros(1,length(sig)); for i = 1:length(sig) if sig(i) > m || sig(i) < -m || isnan(sig(i)) == 1 alert_1(i) = 1; else alert_1(i) = 0; end end if sum(alert_1) > fs/2 alert = joint_peaks(alert_1,fs,20); end X = 10; coef_mov = zeros(length(alert), 1); for i = 1:length(alert)-X*fs if alert(i:i+X*fs) == 1 artifact(i:i+X*fs) = 1; end end if m < 0.2 artifact = zeros(length(artifact), 1); end if artifact(1) == 1 time(e,1) = t(1 + (cycle-1)*length(sig)); e = e + 1; end for c = 2:length(artifact) if artifact(c-1) == 0 && artifact(c) == 1 time(e,1) = t(c + (cycle-1)*length(sig)); e = e + 1; end end for c = 1:length(artifact)-1 if artifact(c) == 1 && artifact(c+1) == 0 time(h,2) = t(c + (cycle-1)*length(sig)); h = h + 1; end end if artifact(end) == 1 time(h,2) = t(cycle*length(sig)); h = h + 1; end cycle = cycle + 1; end end

Page 117: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

APPENDIX XIII

Page 118: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

function [out1] = joint_peaks(x1,fs,dur) % This function merges peaks too close to each other and cnsiders the whole % interval as artifactual % if the distance is shorted than 'dur' (in seconds) this function % merges them and considers one larger detection % x1 - signal to process % fs - sampling frequency % dur - time length(in seconds) between detections to merge der = x1(2:end)-x1(1:end-1); start = find(der>0); stop = find(der<0); out1 = x1; if x1(1) == 1 start = [1 start]; end if isempty(find(der==1)) == 1 out1 = x1; else for i = 1:length(start)-1 if abs(start(i+1)-stop(i)) < dur*fs out1(stop(i):start(i+1)) = 1; end end end end

Page 119: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

APPENDIX XIV

Page 120: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

function [out2] = end_peaks(x2,fs,dur) % This function eliminates peaks too short to be considered artifacts % if the peaks are shorted than 'dur' (in seconds) this function % ignores them and turns those into zeros % x2 - signal to process % fs - sampling frequency % dur - time length(in seconds) to eliminate der = x2(2:end)-x2(1:end-1); start = find(der>0); stop = find(der<0); out2 = x2; if x2(1) == 1 start = [1 start]; end if isempty(find(der==1)) == 1 out2 = x2; else for i = 1:length(start)-1 if abs(stop(i)-start(i)) < dur*fs out2(start(i):stop(i)) = 0; end end end end

Page 121: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

APPENDIX XV

Page 122: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

Use Cases

F rom the methods exp la ined in the p resen t d i s se r ta t ion , i t i s c lea r tha t the a lgor i thm s t i l l needs some inpu t f rom the use r , l ike sub jec t s ’ ges ta t iona l age o r wha t type o f a r t i fac t to look fo r . Wi th tha t in mind , and to spec i fy how the use r can in te rac t w i th the a lgor i thm, i t becomes impor tan t to deve lop the concep t o f Use Cases .

Th is append ix focuses on a number o f Use Cases to desc r ibe the des i red func t iona l i ty o f the Ar t i fac t De tec t ion Algor i thm. In each Use Case , i t i s desc r ibed an in te rac t ion be tween the use r and the a lgor i thm, i . e . , how a use r ach ieves a ce r ta in goa l w i th in the a lgor i thm. In add i t ion to tha t , i t i s a l so desc r ibed which use rs a re qua l i f ied fo r each d i f fe ren t Use Case .

Def in i t ions

. Ar t i fac t De tec t ion Algor i thm: a lgor i thm deve loped in th i s p ro jec t , desc r ibed th roughout th i s repor t , tha t a ims a t the de tec t ion o f a r t i fac t s in e lec t roencepha lograph ic da ta f rom neona tes ;

. User : med ica l and techn ica l s ta f f tha t has access to the a lgor i thm and has the poss ib i l i ty to use i t .

The fo l lowing tab le desc r ibes the d i f fe ren t l eve ls a use r can have , a s

we l l a s the d i f fe ren t func t ions tha t co r respond to each leve l and i t s use rs .

User Leve l R ights wi th in the

a lgor i thm Users

1 Selec t a r t i fac t de tec t ion

Unt ra ined medica l s tuden ts

2 Selec t a r t i fac t

de tec t ion and accep t Exper ienced medica l

s tuden ts and medica l s ta f f

3 Selec t a r t i fac t

de tec t ion and modi fy Techn ica l s ta f f

(phys ic i s t s and eng ineers )

4 Selec t a r t i fac t

de tec t ion , accep t and modi fy

Algor i thm deve loper

Page 123: Development of an Algorithm for the Automatic Detection of ...repositorio.ul.pt/bitstream/10451/30778/1/ulfc120831_tm_Filipe... · respiratória ou mesmo oxigenação cerebral através

Use Case 1 – Se lec t a r t i fac t de tec t ion

• Goal – To run the algorithm on EEG data; • Users – Levels 1 to 4; • Description – This level allows all users to run the algorithm and from there

get as a result a plot of the data with the beginning of the artifactual periods marked with a green bar and the end of the same periods with a red bar;

• Risk – If there are errors in the data this use case is not enough to correct them.

Use Case 2 – Accep t

• Goal – To see the results of the algorithm and assess if they are correct (given that the algorithm is still in a preliminary phase of development and is not yet built in any clinical software);

• Users – Levels 1 and 4; • Description – Trained medical staff can recognize artifacts in data due to their

extensive experience with neonatal EEG, as well as the developer of the algorithm due to extensive study and research on the matter. This Case is only accessible to this two users due to the fact that the results from the algorithm ultimately need to be accepted by experienced users, given that the algorithm is still in a premature phase of development;

• Risk – Acceptance of the results is always prone to discrepancies between definitions of artifacts, as well as subjectivity in the assessment of the results.

Use Case 3 – Modi fy

• Goal – To alter the structure of the algorithm in case there’s an error in the algorithm’s functioning;

• Users – Levels 3 and 4; • Description – In case the algorithm needs optimization, these users are the ones

with the skills and knowledge to do so; • Risk – none found.