Potrebno je učitati signale iz CSV fajla i trasformisati ih (ispeglati) tako da dobijemo detalje. Suština je da prikažemo učitan i transformisan signal jedan preko drugog, kako bi uočili koji wavelet (talasić) i koja skala (LEVEL) najbolje ističe detalje koji su nam važni za analizu. Biblioteka funkcija koje rade wawlet transformaciju je pywt. Dakle: import pywt coeffs = pywt.wavedec([1,2,3,4,5,6,7,8], 'db1', level=2) Nama trebaju koeficienti dekompozicije, što će nam vratiti funkcija gore. Sve što treba je da napravimo izbor kojim ćemo izabrati koji red CSV fajla ćemo učitati u niz (koji je sada u primeru 1,2,3,4,5,6,7,8). Naši nizovi su prilično duži. Takođe treba napraviti izbor za vrstu waveleta db1, db2, db4, sym1 i drugi, kao i level 1-8. Šta radimo sa koeficijentima? Koristimo matplotlib.pyplot za prikaz signala. Treba malo iščitati dokumentaciju i premiere. Ja sam testirao na sledeći način. Kod je malo duži jer sam upotrebio pravi, tj. naš signal iz baze: import pywt import matplotlib.pyplot as plt signal =([ 11767,11681,11596,11520,11453,11406,11367,11348,11320,11253,11101,10854,10464,9921,9256,8523,7753,7001,6316,5726,5232,4804,4433,4090,3757,3424,3101,2787,2492,2226,1997,1797,1617,1407,1141,770,275,-371,-1141,-1988,-2863,-3719,-4528,-5241,-5878,-6440,-6934,-7382,-7791,-8181,-8580,-9018,-9531,-10159,-10930,-11853,-12909,-14022,-15144,-16229,-17218,-18074,-18826,-19482,-20081,-20652,-21213,-21756,-22089,-22012,-21318,-19796,-17227,-13555,-9122,-4356,332,4509,7734,9760,10749,10977,10721,10235,9788,9579,9550,9627,9722,9731,9589,9227,8685,7990,7210,6383,5565,4775,4033,3348,2730,2178,1712,1322,998,703,418,123,-209,-589,-1008,-1455,-1912,-2368,-2815,-3234,-3652,-4071,-4518,-4994,-5536,-6135,-6792,-7477,-8190,-8904,-9617,-10292,-10958,-11586,-12176,-12747,-13270,-13765,-14240,-14716,-15211,-15734,-16305,-16942,-17656,-18455,-19339,-20329,-21423,-22564,-23535,-24124,-24077,-23173,-21175,-18017,-14031,-9608,-5117,-951,2511,5041,6763,7857,8495,8837,9075,9313,9550,9741,9864,9893,9788,9541,9151,8628,7981,7229,6373,5450,4480,3538,2673,1921,1350,970,751,656,637,656,656,618,523,342,66,-332,-865,-1522,-2273,-3053,-3814,-4509,-5089,-5527,-5878,-6221,-6592,-7068,-7705,-8533,-9474,-10473,-11472,-12385,-13156,-13755,-14250,-14707,-15182,-15753,-16495,-17389,-18350,-19254,-19977,-20414,-20443,-19967,-18978,-17446,-15363,-12699,-9436,-5669,-1664,2273,5859,8789,10787,11738,11843,11358,10521,9579,8761,8200,7829,7572,7334,7039,6592,5964,5203,4356,3500,2673,1931,1303,789,371,38,-237,-456,-637,-818,-998,-1208,-1484,-1835,-2273,-2777,-3339,-3928,-4537,-5136,-5726,-6297,-6858,-7420,-7962,-8504,-9056,-9646,-10273,-10996,-11805,-12747,-13812,-14925,-16038,-17094,-18017,-18759,-19311,-19767,-20214,-20728,-21423,-22374,-23496,-24486,-25000,-24695,-23249,-20319,-15943,-10597,-4842,808,5812,9646,12100,13422,13898,13803,13413,12994,12718,12538,12442,12395,12357,12309,12224,12052,11786,11386,10825,10083,9160,8133,7096,6107,5260,4632,4223,3976,3814,3681,3491,3186,2739,2187,1588,970,380,-133,-570,-941,-1274,-1588,-1912,-2264,-2663,-3129,-3662,-4290,-5013,-5850,-6773,-7762,-8770,-9750,-10664,-11472,-12157,-12756,-13299,-13803,-14297,-14821,-15268,-15458,-15173,-14212,-12357,-9427,-5498,-960,3776,8285,12176,15039,16771,17608,17760,17484,17009,16562,16248,16029,15848,15677,15468,15173,14773,14278,13708,13042,12319,11529,10692,9845,8999,8190,7458,6811,6269,5831,5498,5260,5136,5108,5136,5184,5175,5041,4737,4195,3415,2482,1455,409,-570,-1436,-2149,-2749,-3281,-3767,-4252,-4756,-5308,-5917,-6582,-7305,-8105,-8970,-9883,-10787,-11624,-12338,-12871,-13156,-13127,-12661,-11653,-9998,-7591,-4337,-361,3985,8390,12490,15962,18474,19996,20728,20899,20728,20424,20205,20129,20138,20186,20205,20129,19920,19549,19035,18388,17636,16790,15858,14887,13907,12956,12081,11320,10711,10245,9912,9655,9455,9275,9094,8875,8618,8314,7952,7534,7039,6478,5888,5270,4651,4052,3491,2968,2463,1950,1417,837,199,-494,-1227,-1969,-2711,-3434,-4109,-4727,-5279,-5755,-6154,-6478,-6697,-6744,-6478,-5793,-4547,-2606,123,3510,7258,11073,14649,17675,19882,21270,22050,22412,22555,22678,22973,23458,24001,24514,24885,25000,24752,24172,23344,22374,21347,20367,19520,18807,18188,17627,17085,16514,15867,15163,14431,13698,13004,12376,11843,11396,11015,10654,10302,9912,9465,8951,8390,7781,7144,6468,5793,5108,4423,3767,3139,2549,2016,1522,1036,551,28,-551,-1208,-1950,-2777,-3691,-4680,-5745,-6887,-7971,-8828,-9294,-9179,-8323,-6582,-4042,-960,2416,5850,9103,11938,14316,16276,17865,19130,20100,20833,21356,21708,21917,22003,22012,21965,21860,21670,21385,20966,20414,19701,18854,17931,16999,16086,15258,14564,13993,13508,13070,12652,12214,11719,11177,10616,10045,9484,8961,8485,8047,7610,7134,6582,5926,5136,4233,3272,2292,1360,504,-218,-827,-1360,-1874,-2387,-2968,-3624,-4366,-5146,-5917,-6668,-7343,-7933,-8476,-9046,-9722,-10597,-11729,-13165,-14697,-15962,-16647,-16419,-14935,-11938,-7734,-2806,2321,7153,11187,13984,15620,16400,16581,16476,16352,16457,16799,17256,17751,18160,18407,18378,18093,17579,16866,16000,14992,13898,12756,11624,10549,9579,8780,8190,7772,7477,7248,7039,6782,6440,6002,5507,4956,4366,3767,3177,2578,1978,1379,761,123,-542,-1208,-1883,-2539,-3167,-3748,-4280,-4765,-5222,-5641,-6050,-6440,-6839,-7277,-7762,-8333,-9008,-9836,-10806,-11824,-12766,-13479,-13860,-13746,-13051,-11786,-10007,-7772,-5136,-2159,1084,4471,7810,10958,13755,16029,17656,18702,19301,19568,19634,19625,19634,19663,19653,19577,19387,19025,18483,17770,16914,15962,14935,13888,12842,11834,10911,10112,9465,9027,8808,8761,8799,8847,8837,8675,8314,7781,7115,6364,5584,4813,4090,3415,2758,2130,1493,846,171,-513,-1198,-1864,-2501,-3072,-3595,-4071,-4537,-5003,-5517,-6097,-6754,-7515,-8352,-9294,-10321,-11434,-12614,-13708,-14554,-14992,-14830,-13926,-12157,-9665,-6659,-3320,142,3548,6716,9598,12186,14459,16390,17960,19159,20015,20557,20804,20795,20557,20119,19549,18892,18198,17522,16933,16457,16057,15686,15296,14830,14250,13508,12652,11719,10759,9826,8970,8209,7572,7049,6630,6335,6154,6078,6050,5993,5859,5565,5060,4299,3348,2292,1217,209,-656,-1322,-1845,-2273,-2692,-3158,-3738,-4461,-5298,-6192,-7087,-7914,-8628,-9189,-9665,-10112,-10625,-11263,-12090,-13118,-14126,-14849,-15039,-14431,-12785,-9969,-6288,-2111,2197,6278,9760,12404,14297,15572,16381,16875,17199,17456,17656,17798,17893,17922,17893,17789,17589,17265,16790,16133,15277,14212,13013,11786,10616,9598,8828,8342,8076,7952,7886,7791,7581,7201,6697,6088,5431,4765,4119,3529,2996,2520,2092,1702,1360,1046,732,390,-9,-494,-1103,-1835,-2663,-3548,-4452,-5327,-6145,-6877,-7553,-8200,-8856,-9550,-10312,-11149,-11976,-12718,-13308,-13641,-13660,-13280,-12471,-11196,-9417,-7106,-4214,-808,2901,6649,10188,13270,15648,17189,18027,18321,18255,17988,17684,17446,17246,17047,16809,16466,16010,15391,14678,13907,13127,12385,11738,11196,10749,10340,9969,9570,9132,8637,8095,7515,6915,6326,5745,5194,4661,4128,3586,3034,2454,1835,1198,542,-123,-799,-1464,-2130,-2787,-3453,-4128,-4832,-5555,-6297,-7039,-7762,-8418,-8999,-9465,-9836,-10169,-10540,-11006,-11643,-12519,-13613,-14716,-15639,-16152,-16057,-15154,-13356,-10882,-7914,-4670,-1369,1797,4680,7286,9617,11653,13422,14906,16114,17047,17722,18131,18293,18188,17865,17351,16714,16000,15249,14526,13850,13203,12557,11900,11206,10454,9655,8828,8028,7286,6640,6135,5764,5507,5308,5117,4899,4604,4214,3738,3186,2558,1883,1160,399,-371,-1132,-1874,-2568,-3205,-3776,-4318,-4870,-5450,-6097,-6849,-7714,-8647,-9646,-10664,-11672,-12661,-13565,-14374,-15030,-15487,-15715,-15658,-15287,-14507,-13261,-11491,-9113,-6069,-2444,1493,5450,9151,12290,14602,16010,16676,16790,16552,16152,15781,15506,15296,15097,14849,14497,13984,13308,12519,11662,10768,9912,9122,8418,7781,7191,6630,6059,5479,4861,4233,3614,3006,2425,1902,1417,960,523,76,-390,-894,-1445,-2045,-2692,-3367,-4081,-4823,-5584,-6354,-7096,-7810,-8466,-9046,-9570,-10093,-10683,-11377,-12243,-13327,-14592,-15877,-17028,-17884,-18293,-18093,-17275,-15934 ]) coeffs = pywt.wavedec(signal, 'db1', level=2) cA2, cD2, cD1 = coeffs //ovo je mislim aproksimacija i dekompozicija 1. i 2. reda reconstructed_signal = pywt.waverec(coeffs, 'db1') //db1 neije database 1, već vrsta waveleta! fig, ax = plt.subplots(figsize=(8,4)) ax.plot(signal[:1000], label='signal') ax.plot(cA2[:1000], label='signal') ax.plot(cD2[:1000], label='signal') ax.plot(cD1[:1000], label='signal') ax.plot(reconstructed_signal[:1000], label='reconstructed signal', linestyle='--') ax.legend(loc='upper left') ax.set_title('de- and reconstruction using wavedec()') plt.show() Ovo radi, s tim što su mi transformisani signali kraći po vremenskoj liniji, pa se ne podudaraju sa ulaznim, sirovim signalom. Ne znam kako to da rešim. Šta je suština zadatka? Treba da treniram ANN (veštačku neuronsku mrežu) kako bi mi dala predviđanja ima li dikrotnog zareza (useka)? VIše o tome na: https://usp2022.epizy.com/ppg/?i=1 Dikrotni zarez nam može biti pokazatelj elastičnosti krvnih sudova, što je vazna komponenta kod utvrđivanja starosti osobe. Baze za naš zadatak se takođe mogu pronaći na ovom linku. U ekscelu su (db1.xls i db1.xls), ali se lako mogu konvertovati u csv. Signali su po redovima, a prva vrednost su godine starosti. To nam ne treba za sada. Trebaće nam tek kada budemo trenirali veštačke neuronske mreže - ANN. Ovde ima nekih zadataka, s tim što je korišćen ECG, a ne PPG signal i sisu korišćene ANN, već CNN: https://ataspinar.com/2018/12/21/a-guide-for-using-the-wavelet-transform-in-machine-learning/ Ovo ćemo koristiti, samo ćemo upotrebiti naše izlazne nizove kao bazu za treniranje. Umesto 1 i 0 na izlazu imaćemo godine starosti, a suština transformacije je da imamo manji ulaz u mrežu, jer nećemo upotrebiti sirovi signal, već koeficiente za koje vizuelno utvrdimo da nam daju najviše podataka o dikrotnom zarezu : https://machinelearningmastery.com/tutorial-first-neural-network-python-keras/ () Pozdrav! This paste expires in <1 day. Public IP access. Share whatever you see with others in seconds with Context.Terms of ServiceReport this