19
Part 2 Part 2 . . Pre-process seizers data – Pre-process seizers data – looking for test filter looking for test filter . . Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees of coefficient’s energy. For each one of the two stat’ energies trees calculate best basis. Search for different level indexes from the calculated bases First we tried to shrink the lowest energy coefficients in both bases, and look for unique indexes – but this indexes energy was negligible

Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

Embed Size (px)

Citation preview

Page 1: Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

Part 2Part 2..Pre-process seizers data – looking Pre-process seizers data – looking

for test filterfor test filter..

• Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees of coefficient’s energy.

• For each one of the two stat’ energies trees calculate best basis.

• Search for different level indexes from the calculated bases

First we tried to shrink the lowest energy coefficients in both bases, and look for unique indexes – but this indexes energy was negligible

Page 2: Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

Function use for pre-processFunction use for pre-process

•[mean_cof_tree mean_eng_coff_tree mean_coff_eng_var_tree = ] mean_coff_multi_signals (signals_train, num_of_seiz, win_size, qmf, D);

•mean_stat_tree = CalcStatTree_eng (pp_eng_sum_coff_tree, 'Entropy');

•[btree, vtree = ]BestBasis (pp_m_stat_tree,D);

•[indexs = ]find_indexs (btree, win_size);

Each of the above function steps taken for both, pre-preictal and preictal seizers arrays, to get depth of stat’ tree for each of the best basis coefficients.

•[pp_filter p_filter = ]filters (pp_indexs, p_indexs);

Distinction indexes concluded from different depths

Page 3: Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

Function documentationFunction documentation•mean_cof_tree mean_eng_coff_tree mean_coff_eng_var_tree ] = mean_coff_multi_signals

(signals_train, num_of_seiz, win_size, qmf, D);%run over array of signals ,summarize and calculate n*logn mean coff' ,mean

%energies and mean vars%according 50% overlapping windows

•mean_stat_tree = CalcStatTree_eng (pp_eng_sum_coff_tree, 'Entropy');

%A stat tree summarizes the %coefficients eng within a particular block at a given depth

%with an entropy measure based on the coefficients.

•[btree, vtree = ]BestBasis (pp_m_stat_tree,D);

%pick out the best %basis from all the possible bases in the packet table

•[indexs = ]find_indexs (btree, win_size);

%FIND_INDEXS find array of indexes and decomposition level of each of% coefficients in the best basis

767996

12345…win size

Page 4: Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

Function documentation – contFunction documentation – cont’’

•[pp_filter p_filter = ]filters (pp_indexs, p_indexs);%FILTERS return two array of indexes from different depth of stat tree.

First we tried to shrink the lowest energy coefficients in both bases, and look for unique indexes that were included only at one base smallest coefficients, thinking this way we will get distinguished indexes. but this indexes energy was negligible

5687

235…N

767996

12345…win size

756986

12345…win size

6796

235…N

Page 5: Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

Search for consistency diff’ Search for consistency diff’ between calculated indexes setsbetween calculated indexes sets

• Look for consistency difference between pre-preictal and preictal signals that contain in the indexes sets of the pre process data, based on coefficients energy.

• Test of concluded indexes sets on seizers that weren’t part of the pre process and didn’t influence it.

Page 6: Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

Calc_energy - Test functionCalc_energy - Test function

Calculate eng’ stat’ tree of both pre-preictal and preictal seizures array

[cof_tree_test eng_coff_tree_test mean_coff_eng_var_tree_test] =

mean_coff_multi_signals( pp_signals_test, 8-num_of_seiz, win_size,qmf, D);

For each of the calculated stat’ trees, calculate energies of indexes of both filters

[eng_with_filter eng_sum_with_filter] = calc_energy(filter, indexs, eng_coff_tree_test );

% return array of energy for filtered indexes and eng sum

Page 7: Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

ExampleExample :  : 

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.5

1

1.5

preictal filter on test vector red: preictal signal - eng sum : 72.150065,

blue: pre-preictal signal - eng sum : 96.981083

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.5

1

1.5

pre-preictal filter on test vector red: preictal signal - eng sum : 72.150065,

blue: pre-preictal signal - eng sum : 96.981083

Page 8: Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

Impact of factors that are part Impact of factors that are part of the pre process data:of the pre process data:

WindowWindow sizesize

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

5

10

preictal filter on test vector red: preictal signal - eng sum : 526.049608,

blue: pre-preictal signal - eng sum : 528.307056

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

5

10

pre-preictal filter on test vector red: preictal signal - eng sum : 526.049608,

blue: pre-preictal signal - eng sum : 528.307056

4096

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.5

1

1.5

preictal filter on test vector red: preictal signal - eng sum : 72.150065,

blue: pre-preictal signal - eng sum : 96.981083

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.5

1

1.5

pre-preictal filter on test vector red: preictal signal - eng sum : 72.150065,

blue: pre-preictal signal - eng sum : 96.981083

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

2

4

6

preictal filter on test vector red: preictal signal - eng sum : 69.430150,

blue: pre-preictal signal - eng sum : 68.255171

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

2

4

6

pre-preictal filter on test vector red: preictal signal - eng sum : 69.430150,

blue: pre-preictal signal - eng sum : 68.255171

2048 512

Page 9: Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

Impact of factors that are part ofImpact of factors that are part of

the pre process data. the pre process data. Max depthMax depth

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.2

0.4

preictal filter on test vector red: preictal signal - eng sum : 7.737233,

blue: pre-preictal signal - eng sum : 12.560025

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.1

0.2

pre-preictal filter on test vector red: preictal signal - eng sum : 7.737233,

blue: pre-preictal signal - eng sum : 12.560025

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.5

1

1.5

preictal filter on test vector red: preictal signal - eng sum : 72.150065,

blue: pre-preictal signal - eng sum : 96.981083

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.5

1

1.5

pre-preictal filter on test vector red: preictal signal - eng sum : 72.150065,

blue: pre-preictal signal - eng sum : 96.981083

D=4

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

10

20

30

preictal filter on test vector red: preictal signal - eng sum : 1359.518215,

blue: pre-preictal signal - eng sum : 1395.416214

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

10

20

30

pre-preictal filter on test vector red: preictal signal - eng sum : 1359.518215,

blue: pre-preictal signal - eng sum : 1395.416214

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.5

1

1.5

preictal filter on test vector red: preictal signal - eng sum : 116.905173,

blue: pre-preictal signal - eng sum : 157.329328

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.5

1

1.5

pre-preictal filter on test vector red: preictal signal - eng sum : 116.905173,

blue: pre-preictal signal - eng sum : 157.329328

D=11

D=6 D=7

Page 10: Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

Factors influence summary and Factors influence summary and conclusionsconclusions

Another factor testes was the wavelet filter.

Best distinction obtained with:

‘Daubechies‘ ,4 Win size :2048 Max depth :6

With this factors, pre preictal energy tested indexes, seems to be almost always higher then preictal energy indexes.

The difference was extremely significant in first 10% of the indexes, therefore It can be used as a good indicator.

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.5

1

1.5

preictal filter on test vector red: preictal signal - eng sum : 72.150065,

blue: pre-preictal signal - eng sum : 96.981083

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.5

1

1.5

pre-preictal filter on test vector red: preictal signal - eng sum : 72.150065,

blue: pre-preictal signal - eng sum : 96.981083

Page 11: Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

Tested examples of first and last 10% Tested examples of first and last 10% of the filtered indexes energiesof the filtered indexes energies

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.005

0.01

0.015

tests seiz: 3,6 last 10 precent indexes on test vector

red: preictal signal - eng sum : 0.217844, blue: pre-preictal signal - eng sum : 0.277586

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.02

0.04

0.06

first 10 precent indexes on test vector red: preictal signal - eng sum : 0.692267,

blue: pre-preictal signal - eng sum : 1.365013

Energies of first and last 10% of filtered indexes, at pre-preictal and preictal mean stats trees

Last 10%

First 10%

Page 12: Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10.005

0.01

0.015

tests seiz: 2,7 last 10 precent indexes on test vector

red: preictal signal - eng sum : 0.257163, blue: pre-preictal signal - eng sum : 0.298867

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.02

0.04

0.06

first 10 precent indexes on test vector red: preictal signal - eng sum : 0.674518,

blue: pre-preictal signal - eng sum : 1.176928

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.005

0.01

0.015

tests seiz: 4,7 preictal filter on train vector

red: preictal signal - eng sum: 0.221408, blue: pre-preictal signal - eng sum :0.272593

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.05

0.1

pre-preictal filter on train vector red: preictal signal - eng sum 0.802362,

blue: pre-preictal signal - eng sum :2.649696

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 16

8

10

12x 10

-3

tests seiz: 2,4 preictal filter on train vector

red: preictal signal - eng sum: 0.224535, blue: pre-preictal signal - eng sum :0.309663

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.05

0.1

pre-preictal filter on train vector red: preictal signal - eng sum 0.492849,

blue: pre-preictal signal - eng sum :2.137923

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.01

0.02

0.03

tests seiz: 6,8 preictal filter on train vector

red: preictal signal - eng sum: 0.320147, blue: pre-preictal signal - eng sum :0.559163

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.1

0.2

pre-preictal filter on train vector red: preictal signal - eng sum 1.417437,

blue: pre-preictal signal - eng sum :3.780230

Page 13: Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

Test all options and calculated statisticsTest all options and calculated statistics

To get statistics: run over all possible options (S-seizures number)

for i=1:8

for j=1:8

if((i~=j)&(i<j))

count=count+1;

ind=[];

test_ind=[i j];

for k=1:8

if ((k~=j)& (k~=i))

ind= [ind k];

end

end

pp_signals_train=subj.pp(ind,:); % array of seizures to pre process

p_signals_train=subj.p(ind,:);

pp_signals_test=subj.pp(test_ind,:); % array of seizures to test

p_signals_test=subj.p(test_ind,:);

[ ratio_pp bigger ] =run_test( pp_signals_train,pp_signals_test, p_signals_train, p_signals_test, i, j );

success=[success bigger]

ratios =[ratios ratio_pp] %collect statistics

2

S

Page 14: Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

Statistics: subj1 Statistics: subj1 Define parameters for statistics:Define parameters for statistics:1. ratio = pp_eng / p_eng; 1. ratio = pp_eng / p_eng; 2. success=> pp_eng > p_eng2. success=> pp_eng > p_eng

1th elec82% successAverage ratio :1.39success =

Columns 1 through 10

1 1 1 1 1 1 1 1 1 1

Columns 11 through 20

1 1 1 1 1 1 1 1 0 0

Columns 21 through 28

0 0 0 1 1 1 1 1

ratios =

Columns 1 through 6

1.6769 1.3722 1.4593 1.4570 1.2970 1.3948

Columns 7 through 12

1.4532 1.4432 1.2104 2.2393 1.9019 1.9222

Columns 13 through 18

2.0789 1.0381 1.2948 1.3306 1.3663 1.3651

Columns 19 through 24

0.9422 0.9024 0.9161 0.9635 0.9000 1.4200

Columns 25 through 28

      1.4916 1.5438 1.6157   1.0966

2th elec100% successAverage ratio : 1.36

success = Columns 1 through 10 1 1 1 1 1 1 1 1 1 1 Columns 11 through 20 1 1 1 1 1 1 1 1 1 1 Columns 21 through 28 1 1 1 1 1 1 1 1

ratios = Columns 1 through 6 1.0222 1.4952 1.3414 1.4958 1.7264 1.6503 Columns 7 through 12 1.8840 1.3453 1.1130 1.0418 1.1514 1.1389 Columns 13 through 18 1.0953 1.3817 1.2202 1.6701 1.6150 1.3207 Columns 19 through 24 1.4066 1.4354 1.4069 1.5478 1.3763 1.1016 Columns 25 through 28 1.0487 1.8725 1.0475 1.1983

3th elec89% successAverage ratio : 2.13

success = Columns 1 through 10 1 1 1 1 1 1 1 1 1 1 Columns 11 through 20 1 1 1 1 1 1 1 1 1 1 Columns 21 through 28 1 1 0 1 1 0 0 1

ratios = Columns 1 through 6 4.9850 5.1478 2.3811 3.2855 3.6381 3.9826 Columns 7 through 12 3.9992 1.8633 1.7732 1.4555 1.6410 1.7448 Columns 13 through 18 1.7519 1.3344 1.8341 1.9718 2.1192 2.1282 Columns 19 through 24 1.1754 1.7240 1.7657 1.7684 0.9206 1.0632 Columns 25 through 28 1.0771 0.8059 0.8902 1.3074

Page 15: Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

Statistics: subj2 Statistics: subj2 Define perameters for statistics:Define perameters for statistics:1. ratio = pp_eng / p_eng; 1. ratio = pp_eng / p_eng; 2. success=> pp_eng > p_eng2. success=> pp_eng > p_eng

1th elec

100% Success

Average ratio : 1.74

success =

1 1 1 1 1 1

ratios =

3.5326 1.4864 1.0614 2.0028 1.1171 1.2608

>>

2th elec

83.3% Success

Average ratio : 1.196

success =

1 1 1 1 0 1

ratios =

1.1122 1.4158 1.0665 1.2976 0.9627 1.1859

>>

3th elec

66% Success

Average ratio :1.12

success =

1 1 0 1 1 0

ratios =

1.5025 1.0026 0.9505 1.0438 1.3039 0.8776

>>

Page 16: Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

Real time indication filterReal time indication filter

Motivated by the results, I calculate the energy of each window alone and average the energies.

len=length(signal);

Count=1;

while e_win<=len; %run over the signal

……

cof_tree=find_coff(win,qmf,D); %calc window coff’ stat’ trees’

sum_eng_coff=cof_tree.^2; %calc window coff’s energies stat’ trees’

[arr sum_eng] = calc_energy(filter, indexs, sum_eng_coff); %calc filter inxdes eng

eng=[eng sum_eng]; % collect windows energies

if (count <150)

avg=[avg sum(eng)/count];

end

if (count >150)

avg=[avg sum(eng(count-150:count))/150];

end

count=count+1;

……..

Calculated energy of single window and

average it with the last 150 windows

Page 17: Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

Singles windows energy, and Singles windows energy, and energies averageenergies average

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

10

20

30

40r: pp windows eng , b: p windows eng

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

5

10

15r: pp windows eng , b: p windows eng

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

5

10

15

20r:avg pp eng 150 win , b:avg p eng 150 win

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

1

2

3r:avg pp eng 150 win , b:avg p eng 150 winWindows(time)

Windows(time)time

time

Ene

rgy

Ene

rgy

Page 18: Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

ContCont’’

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

10

20

30

40r: pp windows eng , b: p windows eng

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

5

10r: pp windows eng , b: p windows eng

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

5

10

15

20r:avg pp eng 150 win , b:avg p eng 150 win

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

1

2

3r:avg pp eng 150 win , b:avg p eng 150 win

Windows(time)

time

Windows(time)

time

Ene

rgy

Ene

rgy

Page 19: Part 2. Pre-process seizers data – looking for test filter. Run over array of pre-preictal and preictal given signals, and creating two mean stat’ trees

-20 0 20 40 60 80 100 120 140 1600

5

10

15

-20 0 20 40 60 80 100 120 140 1600

5

10

15

-20 0 20 40 60 80 100 120 140 1600

5

10

15

20

-20 0 20 40 60 80 100 120 140 1600

5

10

15

-20 0 20 40 60 80 100 120 140 1600

5

10

15

-20 0 20 40 60 80 100 120 140 1600

5

10

15

-20 0 20 40 60 80 100 120 140 1600

2

4

6

8

10

-20 0 20 40 60 80 100 120 140 1600

5

10

15

-50 0 50 100 150 2000

5

10

15

-20 0 20 40 60 80 100 120 140 1600

5

10

15