Sort a bank of ECG samples to 2 groups

2 次查看(过去 30 天)
Hey,
I've a bank of 2 types of ECG samples: link, some of them were measured while exercising and some while resting
all the samples are 5 seconds long, and were measured at 1k[Hz] frequency
I'm having a hard time develop an algorithem to sort that bank to 2 groups (exercising and resting)
any ideas?
  3 个评论
Portalboi
Portalboi 2023-1-6
unfortunatly all the files together are too big, I did it with 600 samples so you can still have something to look at, while remaining under the size limits.
please take a look at this and tell me if it's fine.

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2023-1-8
编辑:Star Strider 2023-1-8
This is the best I can do for these.
They required a significant amount of processing to remove the baseline variation and high-frequency noise. (The processing uses two filters, the first a notch filter to remove the 50 Hz line noise, and the second bandpass filter to eliminate baseline variation and high frequency noise. The detrend call removes any baseline variation left after filtering.) The ‘Before’ and ‘After’ plots are displayed for the first 20. The table at the end displays the rate and voltage for each filtered EKG. Some of them (for example #5 and #20) are so noisy that it is difficult to do anything with them. The noise can simply swamp the data, and it is difficult to do anything about that.
Of note, #2, #4, #14 and #18 display a strain pattern (significant S-T depression) that I find worrisome.
I’m not certain how best to classify them. There can be significant uncertainty since there can be individual variation that can make that difficult. It would be easier to classify the data for a single subject between rest and exercise than for all subjects.
Uz1 = unzip('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1254867/DataECG600Shorted.zip')
Uz1 = 1×600 cell array
Columns 1 through 416 {'0002b2dba0d9.mat'} {'001b36ff8b94.mat'} {'001d7d64db68.mat'} {'002e3c327f10.mat'} {'00a5bf323a09.mat'} {'00ac68cda108.mat'} {'00ae2c296cc1.mat'} {'00b163c73907.mat'} {'00b959094606.mat'} {'00c313014dfe.mat'} {'00c598ebf618.mat'} {'00c603a16306.mat'} {'00cbffe18d0c.mat'} {'00de737afad9.mat'} {'00e171825750.mat'} {'00e1b761ca9c.mat'} {'00ec3d0b04ff.mat'} {'01a7617b3e86.mat'} {'01a7ec52aaca.mat'} {'01ae48689da5.mat'} {'01b0821bd3d5.mat'} {'01b260f94fe8.mat'} {'01b4bd319267.mat'} {'01b508fef1b0.mat'} {'01b74dc707f1.mat'} {'01c3a8c0f088.mat'} {'01c5d8cbec31.mat'} {'01c8dd40de26.mat'} {'01d175c5b657.mat'} {'01d373a8485c.mat'} {'01db9e467ea6.mat'} {'01dbf803145c.mat'} {'01ddd3ff1ade.mat'} {'01e0345f6705.mat'} {'01e19bf730f3.mat'} {'01e1ee8d697d.mat'} {'01eda580841f.mat'} {'01f4aac02808.mat'} {'01f6c1575e75.mat'} {'02a74bcc5bcf.mat'} {'02a778e8eba9.mat'} {'02bb2ed3e1f7.mat'} {'02bba42441a9.mat'} {'02bfc6e840e4.mat'} {'02c59dd89d74.mat'} {'02c7e9e1ff34.mat'} {'02c928528a10.mat'} {'02ccb8493592.mat'} {'02cef7e938bd.mat'} {'02d5dc2084d5.mat'} {'02e1795b06db.mat'} {'02ea7f0a8308.mat'} {'02ecd68a104e.mat'} {'02fbcde2707d.mat'} {'0a1030f60e24.mat'} {'0a15bd0ec4ae.mat'} {'0a171ce9fd6a.mat'} {'0a2200070294.mat'} {'0a3212bce141.mat'} {'0a39985ed0c1.mat'} {'0a455341515e.mat'} {'0a4959afe743.mat'} {'0a4a1877ebb1.mat'} {'0a4d4828aeb9.mat'} {'0a4ee70d2847.mat'} {'0a588708b0a9.mat'} {'0a5a3bb8ddc7.mat'} {'0a6120024303.mat'} {'0a68c6640c64.mat'} {'0a6c7a88d035.mat'} {'0a7141e59e29.mat'} {'0a79125ddfa7.mat'} {'0a8d684e2ed8.mat'} {'0aa378790d67.mat'} {'0aaadb1099e3.mat'} {'0ab629c5b545.mat'} {'0ab8b661efc6.mat'} {'0ab9bc54ff24.mat'} {'0abe1cd05d35.mat'} {'0ac112b51fae.mat'} {'0acbfffaebba.mat'} {'0accab3eb008.mat'} {'0acfba1b6b2e.mat'} {'0aed1b9cb736.mat'} {'0aed655a0d78.mat'} {'0aed88b0042b.mat'} {'0b161c136a86.mat'} {'0b28baa6e0ab.mat'} {'0b2bb21c40d0.mat'} {'0b308d79be56.mat'} {'0b31e802e936.mat'} {'0b3a737b9f04.mat'} {'0b3d4d7158f7.mat'} {'0b4a0520a8fe.mat'} {'0b4ccb26ee99.mat'} {'0b4dd5b378b1.mat'} {'0b588df7f523.mat'} {'0b5b606d6c59.mat'} {'0b5d856fef20.mat'} {'0b60224d980b.mat'} {'0b70dad59e90.mat'} {'0b7ad95f9393.mat'} {'0b7b26d5f05b.mat'} {'0b7b31e6654d.mat'} {'0b7e2fbf7947.mat'} {'0b7f0b638d6a.mat'} {'0b870e9297c6.mat'} {'0b8c6a094b78.mat'} {'0b9efc6bd6f5.mat'} {'0ba0ab443654.mat'} {'0bb10798b269.mat'} {'0bb6a5831df8.mat'} {'0bbb6bc6a9e0.mat'} {'0bbc127b7aac.mat'} {'0bbf4c6d8567.mat'} {'0bc4780fc9bf.mat'} {'0bcf6081b583.mat'} {'0bd2f0eacbbb.mat'} {'0bdc6e754953.mat'} {'0bdf054475b4.mat'} {'0be6a2edad2e.mat'} {'0be930a9a576.mat'} {'0bf0de6beaf7.mat'} {'0c11be7d7768.mat'} {'0c14147a40c5.mat'} {'0c17751c2d8c.mat'} {'0c2c8ef2638d.mat'} {'0c3674a79241.mat'} {'0c369bd68688.mat'} {'0c3b74f62d55.mat'} {'0c44ab99762c.mat'} {'0c4b206af56e.mat'} {'0c4dd778de2e.mat'} {'0c552cfaa8b7.mat'} {'0c5da7277a1d.mat'} {'0c601ffeee8e.mat'} {'0c607f717e8b.mat'} {'0c645774b19c.mat'} {'0c74eafc36c9.mat'} {'0c7bdae44abd.mat'} {'0c7eae9a7011.mat'} {'0c7fac7f20bc.mat'} {'0c8129e1fc79.mat'} {'0c831d8b73eb.mat'} {'0c84b114eaea.mat'} {'0c9c672a822d.mat'} {'0ca08ecc0957.mat'} {'0ca3a92f3400.mat'} {'0cb5277da04a.mat'} {'0cb66237030a.mat'} {'0cbda2745ab3.mat'} {'0cbf795050a2.mat'} {'0cc1440b89dc.mat'} {'0cc84bcf1ab3.mat'} {'0ccb98aa2ed2.mat'} {'0ccee993a89b.mat'} {'0cdf47630c4e.mat'} {'0ce716b637dd.mat'} {'0ce97ac46cc5.mat'} {'0cf0f6a1534a.mat'} {'0cff2f6ceccf.mat'} {'0d10a22055f6.mat'} {'0d1cadd2d0a4.mat'} {'0d2748480161.mat'} {'0d28e462a8d1.mat'} {'0d294d3c7029.mat'} {'0d2c263a205a.mat'} {'0d2cf734d4bc.mat'} {'0d303c552729.mat'} {'0d321572f6ee.mat'} {'0d349e40625a.mat'} {'0d465e68bbd5.mat'} {'0d4e07f900a3.mat'} {'0d4f5e366290.mat'} {'0d55d888a131.mat'} {'0d5e4e08b57c.mat'} {'0d66d6628cae.mat'} {'0d6da2d62e52.mat'} {'0d89fc4d3574.mat'} {'0d8b7673d340.mat'} {'0d8c5c3d8492.mat'} {'0d8c9e06171d.mat'} {'0d8ddb18dde2.mat'} {'0d92098409d5.mat'} {'0d9394f1681e.mat'} {'0d96a4afcba0.mat'} {'0d9a483d458c.mat'} {'0d9d032329e8.mat'} {'0da34ac5d116.mat'} {'0da45cea170a.mat'} {'0dac1253e92e.mat'} {'0db85f58401b.mat'} {'0dbd16a02519.mat'} {'0dce0bc6518a.mat'} {'0dd7af9abd2c.mat'} {'0ddaf5f61ae2.mat'} {'0de853f1a2ee.mat'} {'0deb380cadca.mat'} {'0ded819fab86.mat'} {'0def51edee3a.mat'} {'0dfcec7813e6.mat'} {'0dfeb8ba26de.mat'} {'0e03533ecb93.mat'} {'0e0ec7281a3c.mat'} {'0e0f58bc8ce0.mat'} {'0e1a568c1c13.mat'} {'0e1bf7ba1c3a.mat'} {'0e201e3a2806.mat'} {'0e304a0321de.mat'} {'0e31a2e4705a.mat'} {'0e36579ce834.mat'} {'0e3e89692753.mat'} {'0e3f1553ff50.mat'} {'0e459e10c0bf.mat'} {'0e47bfc73083.mat'} {'0e5c5ca7838f.mat'} {'0e5db5a401ff.mat'} {'0e62af0f8faa.mat'} {'0e673e769fac.mat'} {'0e68b3977051.mat'} {'0e72dfa6d875.mat'} {'0e76497fbcdd.mat'} {'0e77d062b043.mat'} {'0e7fbe6c1cd2.mat'} {'0e83e4becc00.mat'} {'0e88c480ef24.mat'} {'0e9071090979.mat'} {'0e9faf91f18b.mat'} {'0ea41576596c.mat'} {'0ea6b16fd8b6.mat'} {'0eac6c1a0a96.mat'} {'0eb6967eb0bd.mat'} {'0ec26d3f332b.mat'} {'0ec751d954f6.mat'} {'0ecad93cdc2e.mat'} {'0ecf47314a4a.mat'} {'0ee9c2d108db.mat'} {'0eec0fc35853.mat'} {'0ef26baecc11.mat'} {'0ef5cda3f8ab.mat'} {'0ef8deedba1a.mat'} {'0efdc742cb37.mat'} {'0f03e66b8191.mat'} {'0f0ed1e7ee89.mat'} {'0f0f96323aef.mat'} {'0f1037a37119.mat'} {'0f17e9811fea.mat'} {'0f1f309c736a.mat'} {'0f23968de992.mat'} {'0f3267f037ec.mat'} {'0f37a870da18.mat'} {'0f4fd3978ebd.mat'} {'0f521db8803c.mat'} {'0f704848514e.mat'} {'0f7823952b6e.mat'} {'0f7ad273b11a.mat'} {'0f8af26dd810.mat'} {'0f9a939ffe25.mat'} {'0f9b6f277b34.mat'} {'0fa29434b2d6.mat'} {'0fa2a573a156.mat'} {'0fae4947b1ab.mat'} {'0fb2915aaf15.mat'} {'0fb3db7fd301.mat'} {'0fb9cedff7cb.mat'} {'0fbb690cb3c6.mat'} {'0fbb6ad8b310.mat'} {'0fbc0a015d7f.mat'} {'0fd5adc6ff4e.mat'} {'0fdcd8a95eb9.mat'} {'0fe04c58c2e3.mat'} {'0fe15cb27861.mat'} {'0feec2ef218b.mat'} {'0ff09a4b8898.mat'} {'0ff7ea45c52f.mat'} {'0fff14701beb.mat'} {'1a05dc0cc328.mat'} {'1a08eee9e92c.mat'} {'1a0ca9cc522d.mat'} {'1a0f509eec85.mat'} {'1a153727e9bf.mat'} {'1a176d788504.mat'} {'1a1b88140898.mat'} {'1a22703d466b.mat'} {'1a2ece5e8645.mat'} {'1a3155e5a6e8.mat'} {'1a316e39e4e5.mat'} {'1a32a84cfc0a.mat'} {'1a35a512469e.mat'} {'1a39f6bce021.mat'} {'1a3dafa8fbba.mat'} {'1a48494bfb2d.mat'} {'1a4980da6c5f.mat'} {'1a5218f6c242.mat'} {'1a548ff49bd5.mat'} {'1a56d2f5e64c.mat'} {'1a5c19c9218a.mat'} {'1a5cd8e0737a.mat'} {'1a6c43b912ad.mat'} {'1a6e41e5cf5a.mat'} {'1a70216ba750.mat'} {'1a8419a6eb6c.mat'} {'1a8bb8471b0f.mat'} {'1a95acb18f65.mat'} {'1a9e26572aa4.mat'} {'1aa1c5de619c.mat'} {'1aa4c818fbb3.mat'} {'1aa63ed8f47b.mat'} {'1ab2feae5f29.mat'} {'1ab3dd11aa89.mat'} {'1ab58119320a.mat'} {'1ab81fc03a17.mat'} {'1abc77fc85c6.mat'} {'1abd3a7d530d.mat'} {'1abf9bff3534.mat'} {'1ac10afc17c9.mat'} {'1acee5f56afc.mat'} {'1aec3dcfad7d.mat'} {'1aee71e8cd18.mat'} {'1af231a7fdb1.mat'} {'1af76147296b.mat'} {'1afce6485c86.mat'} {'1afffa6290bb.mat'} {'1b0238a2676c.mat'} {'1b07fc26e26e.mat'} {'1b22a2093ce5.mat'} {'1b2832ee3465.mat'} {'1b295cbe8a9e.mat'} {'1b3012b3ec0e.mat'} {'1b37e54e0f30.mat'} {'1b437242acf9.mat'} {'1b68b4a837f6.mat'} {'1b793bb7b41a.mat'} {'1b7c75ecfd71.mat'} {'1b9abbd5d145.mat'} {'1b9bf741ccbe.mat'} {'1ba1cc598a68.mat'} {'1ba66c7bc806.mat'} {'1bb41e6d7893.mat'} {'1bbd7499a617.mat'} {'1bcce6d392bd.mat'} {'1bcd7dcb3670.mat'} {'1bd4682dd83d.mat'} {'1bd5ebcd4dd6.mat'} {'1bd737d48ee2.mat'} {'1bdbace67a3c.mat'} {'1be17ece1331.mat'} {'1be97548f792.mat'} {'1beb7794ea64.mat'} {'1bfab704cf90.mat'} {'1c0519fec41b.mat'} {'1c05cf1eebf0.mat'} {'1c075154220b.mat'} {'1c07de92fa8f.mat'} {'1c0a29cec522.mat'} {'1c136029673c.mat'} {'1c151f875d28.mat'} {'1c1d2f4d0e4a.mat'} {'1c1ef921074f.mat'} {'1c22d28ac3a0.mat'} {'1c2975e3c4ad.mat'} {'1c2a6911f39d.mat'} {'1c3b25fcf3c8.mat'} {'1c3dbd95cc65.mat'} {'1c491d09b2bb.mat'} {'1c4be26e14a1.mat'} {'1c4d3429fc0c.mat'} {'1c5440fae792.mat'} {'1c56d5f26e61.mat'} {'1c61aac1e8be.mat'} {'1c6862e5ddd6.mat'} {'1c6b070c5afa.mat'} {'1c7785c890eb.mat'} {'1c781179d999.mat'} {'1c786bc26310.mat'} {'1c83a75dc37f.mat'} {'1c87e7c5d73d.mat'} {'1c8f62bdf05f.mat'} {'1c91e420fd7d.mat'} {'1c978c9bd2fc.mat'} {'1c9a61f24fae.mat'} {'1cabba3604a8.mat'} {'1cb310f67c35.mat'} {'1cb96638eedf.mat'} {'1cbdbd7e23ec.mat'} {'1cc07f0f6153.mat'} {'1cc1052536c2.mat'} {'1cc3b7d73f84.mat'} {'1ccf6261f804.mat'} {'1ccf76ceb4ae.mat'} {'1ccfb1c3fed7.mat'} {'1cd058d199a5.mat'} {'1cd21ef00e67.mat'} {'1cdea033b9b4.mat'} {'1ce022f5ba7b.mat'} {'1d077273abd1.mat'} {'1d0ac2c2170f.mat'} {'1d0f1ba4e0a7.mat'} {'1d10f7768b52.mat'} {'1d185fe2bf13.mat'} {'1d203a433f8a.mat'} {'1d2375d5ce0a.mat'} {'1d25de2ca17b.mat'} {'1d28b6499d1f.mat'} {'1d31addacc06.mat'} {'1d34076c8973.mat'} {'1d36729b50c0.mat'} {'1d3a1640eac2.mat'} {'1d53a4bce40f.mat'} {'1d61d6258af1.mat'} {'1d62c87bd1d9.mat'} {'1d6b6e4e9e41.mat'} {'1d7ba0385fea.mat'} {'1d946d26ffd8.mat'} {'1d952c78e3cb.mat'} {'1dad85008495.mat'} Columns 417 through 600 {'1dafb51ad7c4.mat'} {'1db6136084cd.mat'} {'1dd529108ff1.mat'} {'1dd646ada98f.mat'} {'1ddd72ab6438.mat'} {'1de0ba026c6d.mat'} {'1de8e72395c1.mat'} {'1df67103dab4.mat'} {'1df6ba70a35a.mat'} {'1e02037b4706.mat'} {'1e0d43c54344.mat'} {'1e135d114ee9.mat'} {'1e203242ab00.mat'} {'1e2530b725d5.mat'} {'1e2d62b5519a.mat'} {'1e3a67fbcdcc.mat'} {'1e3ad16be6f5.mat'} {'1e3d36abfa98.mat'} {'1e43835a2e42.mat'} {'1e49634a060d.mat'} {'1e4f6340ddd8.mat'} {'1e5622e5ac05.mat'} {'1e5692a6f2e1.mat'} {'1e660af05881.mat'} {'1e680e5d0687.mat'} {'1e6b4ce99a94.mat'} {'1e6da02ca2e3.mat'} {'1e6e2e445e97.mat'} {'1e79772138eb.mat'} {'1e799d2ae716.mat'} {'1e7d5d4cf563.mat'} {'1e810afe150e.mat'} {'1e85d3f24e74.mat'} {'1e8baf0dc00d.mat'} {'1e9166c79efe.mat'} {'1e9d0f245844.mat'} {'1ea3fe3cc20e.mat'} {'1eb0ebecbbbd.mat'} {'1eb142f26419.mat'} {'1ebd8f0a7fbd.mat'} {'1ec854ed8a35.mat'} {'1eda6664c5e8.mat'} {'1edd4a6c389b.mat'} {'1ede80fa044a.mat'} {'1edf75331795.mat'} {'1ef54c04b33c.mat'} {'1ef71e4e8629.mat'} {'1ef7d034e913.mat'} {'1efeba681353.mat'} {'1f02bf5f4a15.mat'} {'1f0432799500.mat'} {'1f052b8f236b.mat'} {'1f0d694c02ab.mat'} {'1f18367c39c6.mat'} {'1f19eb26505e.mat'} {'1f1bc6b5487a.mat'} {'1f384fbc32d5.mat'} {'1f3b7736acdb.mat'} {'1f3ed789046d.mat'} {'1f40e4d4515c.mat'} {'1f4a53a88234.mat'} {'1f4a8e922d76.mat'} {'1f4dc745554a.mat'} {'1f50b6fc96d3.mat'} {'1f554c220dde.mat'} {'1f647b4b338f.mat'} {'1f64e6b19906.mat'} {'1f74507c4ea5.mat'} {'1f800c3a2e50.mat'} {'1f8215364d84.mat'} {'1f824ec68e99.mat'} {'1f83264d0055.mat'} {'1f8aa6ec0cf7.mat'} {'1f8bd73aada6.mat'} {'1f957a8937fa.mat'} {'1f96c95470da.mat'} {'1f977cc725b5.mat'} {'1f98fe2ea7b2.mat'} {'1fcd40fd3486.mat'} {'1fd7a3b689cd.mat'} {'1fe1e634f27a.mat'} {'1ff659a0533d.mat'} {'1ffb2f07ef40.mat'} {'2a05912d7597.mat'} {'2a0abed6bfe1.mat'} {'2a1a62cf8bac.mat'} {'2a1a71057ad8.mat'} {'2a1bd66f5402.mat'} {'2a1fcd7bb30a.mat'} {'2a204951fa3d.mat'} {'2a248b1e0191.mat'} {'2a3a19c29a02.mat'} {'2a3a4dd19613.mat'} {'2a3bd3d392a5.mat'} {'2a41a50c232d.mat'} {'2a47be0bef6e.mat'} {'2a48bae5dba9.mat'} {'2a4b013de34b.mat'} {'2a5627ce2f25.mat'} {'2a597ecd1c89.mat'} {'2a5ba70b9e50.mat'} {'2a6444c3d559.mat'} {'2a645b47fce0.mat'} {'2a6b5b2fc79a.mat'} {'2a6def4618ad.mat'} {'2a6eda97ac8a.mat'} {'2a72c450a3bc.mat'} {'2a76a2295943.mat'} {'2a7bd804bee4.mat'} {'2a80ebf2d4f6.mat'} {'2a8248ede61f.mat'} {'2a8619e75184.mat'} {'2aaa145e374c.mat'} {'2ab63848ebe1.mat'} {'2abc7b524f26.mat'} {'2ac216864cce.mat'} {'2ac64c4dfd16.mat'} {'2ac76233e21d.mat'} {'2acbf1b4646d.mat'} {'2ace9a0302e0.mat'} {'2ad6a1395883.mat'} {'2ae0d162ddbd.mat'} {'2ae7d26443fb.mat'} {'2af6b009e74d.mat'} {'2af73b9ec31b.mat'} {'2b044f059c1c.mat'} {'2b09c5dfffd4.mat'} {'2b0a2eac25bb.mat'} {'2b140b60c52b.mat'} {'2b1f4a2feb20.mat'} {'2b5c9386c28b.mat'} {'2b6140d857fe.mat'} {'2b6fd83cda31.mat'} {'2b7c4e5c2efc.mat'} {'2b8041403bfa.mat'} {'2b844ab77e76.mat'} {'2b84c9ff9921.mat'} {'2b872961773d.mat'} {'2b888394ec27.mat'} {'2b9f362aeb9a.mat'} {'2bafda58cfc1.mat'} {'2bb52ff15328.mat'} {'2bc2ef5e4e92.mat'} {'2bc4a3213614.mat'} {'2bc577d9a4d9.mat'} {'2bc85799e830.mat'} {'2bcd42885716.mat'} {'2bea38ee0f0c.mat'} {'2beadb4c06e7.mat'} {'2bec8c57f73d.mat'} {'2c0403972e11.mat'} {'2c04b00090a3.mat'} {'2c06366222d1.mat'} {'2c07f2fc6790.mat'} {'2c1562572dea.mat'} {'2c2d2ca51daf.mat'} {'2c3847a187f2.mat'} {'2c3ac1d23afd.mat'} {'2c49c19c310c.mat'} {'2c4b0c52bd8d.mat'} {'2c4bb29e287f.mat'} {'2c4c72892a0a.mat'} {'2c4e48f46351.mat'} {'2c50d38ec5b8.mat'} {'2c5192bcae30.mat'} {'2c5927cf1253.mat'} {'2c63b6ee6e3c.mat'} {'2c66dc9d81c5.mat'} {'2c6cf5a28107.mat'} {'2c7c70d3cd6e.mat'} {'2c88deecf548.mat'} {'2c89630c813c.mat'} {'2c8db9c25937.mat'} {'2c9463f3194a.mat'} {'2c96c16f6c56.mat'} {'2c9bf002d135.mat'} {'2ca6b5abaec1.mat'} {'2cab38701b76.mat'} {'2cab5aebca5c.mat'} {'2caebf31bf92.mat'} {'2cb23f6e33f2.mat'} {'2cc0a5def7d3.mat'} {'2cd497c6d719.mat'} {'2cdca58a7836.mat'}
% Uz2 = unzip('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1254872/DataECG600Shorted.zip')
Fs = 1E+3;
Fn = Fs/2;
L = 5001;
t = linspace(0, L-1, L).'/Fs;
N = 20;
for k = 1:N%numel(Uz1)
LD = load(Uz1{k});
EKG1(:,k) = LD.thisSignal;
end
Wp = [45 55]/Fn; % Passband Frequency (Normalised)
Ws = [48 52]/Fn; % Stopband Frequency (Normalised)
Rp = 1; % Passband Ripple
Rs = 60; % Passband Ripple (Attenuation)
[n,Wp] = ellipord(Wp,Ws,Rp,Rs); % Elliptic Order Calculation
[z,p,k] = ellip(n,Rp,Rs,Wp,'stop'); % Elliptic Filter Design: Zero-Pole-Gain
[sos1,g1] = zp2sos(z,p,k); % Second-Order Section For Stability
figure
freqz(sos1, 2^16, Fs) % Filter Bode Plot
Wp = [0.20 60]/Fn; % Passband Frequency (Normalised)
Ws = [0.10 65]/Fn; % Stopband Frequency (Normalised)
Rp = 1; % Passband Ripple
Rs = 60; % Passband Ripple (Attenuation)
[n,Wp] = ellipord(Wp,Ws,Rp,Rs); % Elliptic Order Calculation
[z,p,k] = ellip(n,Rp,Rs,Wp); % Elliptic Filter Design: Zero-Pole-Gain
[sos2,g2] = zp2sos(z,p,k); % Second-Order Section For Stability
figure
freqz(sos2, 2^16, Fs) % Filter Bode Plot
figure
for k = 1:N
subplot(N/5,5,k)
plot(t, EKG1(:,k))
grid
title(sprintf('%3d',k))
end
sgtitle('Original')
NFFT = 2^nextpow2(L);
Fv = linspace(0, 1, NFFT/2+1)*Fn
Fv = 1×4097
0 0.1221 0.2441 0.3662 0.4883 0.6104 0.7324 0.8545 0.9766 1.0986 1.2207 1.3428 1.4648 1.5869 1.7090 1.8311 1.9531 2.0752 2.1973 2.3193 2.4414 2.5635 2.6855 2.8076 2.9297 3.0518 3.1738 3.2959 3.4180 3.5400
Iv = 1:numel(Fv);
for k = 1:N
FTEKG1(:,k) = fft(EKG1(:,k)-mean(EKG1(:,k)),NFFT)/L;
end
% NrSp = size(EKG1,2);
figure
for k = 1:N
subplot(N/5,5,k)
plot(Fv, abs(FTEKG1(Iv,k))*2)
grid
xlim([00 60])
title(sprintf('EKG1 %3d',k))
end
for k = 1:size(EKG1,2)
EKG1(:,k) = filtfilt(sos1,g1,EKG1(:,k));
EKG1(:,k) = filtfilt(sos2,g2,EKG1(:,k));
EKG1(:,k) = detrend(EKG1(:,k),7);
end
figure
for k = 1:N
subplot(N/5,5,k)
plot(t, EKG1(:,k))
grid
[pks,locs] = findpeaks(EKG1(:,k), 'MinPeakProminence',(max(EKG1(:,k)))*0.75);
Ratev = 60./(diff(t(locs)));
Rate(k,:) = mean(Ratev);
RateSD(k,:) = std(Ratev);
V(k,:) = mean(pks);
VSD(k,:) = std(pks);
title(sprintf('EKG1 %3d',k))
end
sgtitle('Filtered')
EKG1_Nr = (1:N).';
RateVoltage = table(EKG1_Nr,Rate,RateSD,V,VSD)
RateVoltage = 20×5 table
EKG1_Nr Rate RateSD V VSD _______ ______ _______ ______ ______ 1 67.27 1.5015 241.39 23.72 2 58.626 2.1835 217.96 23.116 3 133.7 1.0487 139.12 25.277 4 69.981 4.2635 243.16 32.659 5 108.31 49.523 9.7718 3.6276 6 125.28 1.6384 178.06 9.3044 7 167.41 76.17 146.59 21.607 8 112.97 3.2368 115.67 3.8871 9 101.82 2.5095 58.848 6.8476 10 100.08 0.73725 67.919 19.926 11 160 43.114 89.831 30.63 12 95.054 37.807 146.45 50.934 13 94.06 7.5359 99.355 6.2704 14 63.155 3.6628 221.59 23.772 15 89.628 6.7647 92.713 1.8705 16 92.555 8.6227 90.693 5.4217
EDIT — (8 Jan 2023 at 11:54)
Added ‘RateSD’ and ‘VSD’ to calculations and to the table. Code otherwise unchanged.
.
  2 个评论
Portalboi
Portalboi 2023-1-11
Thank you so much for the help and all the explanations.
highly appreciate.
Star Strider
Star Strider 2023-1-11
As always, my pleasure!
The standard deviation (specifically ‘coefficient of variation’, defined as the standard deviation divided by the mean) can be helpful is assessing the quality of the data. The larger it is, the less reliable the data are.

请先登录,再进行评论。

更多回答(1 个)

Vilém Frynta
Vilém Frynta 2023-1-6
编辑:Vilém Frynta 2023-1-6
Hello,
as Star Strider already mentioned, you can filter data based on the R-amplitude and or heart rate (time between R–R).
I have tried to plot your data and it seems there is quite a big difference in amplitudes, so it appears that it could be a reliable filter.
Also, I am not very confident whether this is valid option, but I tried to perform FFT on your data, and it looks like there might be a difference between resting ECG and excersing ECG. But it is possible that I have chosen some data that are "perfect" and this might not be the case for the rest of your data.
See images below;
== example 1 and it's FFT ==
FFT
== example 2 and it's FFT ==

类别

Help CenterFile Exchange 中查找有关 ECG / EKG 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by