Update peak detection

This commit is contained in:
Sebastian H. Gabrielli 2024-11-23 21:00:35 +01:00
parent 898c11a67b
commit c205f1f827
3 changed files with 65 additions and 64 deletions

View File

@ -1,26 +1,26 @@
{
"name": "tauri-eval",
"private": true,
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview",
"tauri": "tauri"
},
"dependencies": {
"@tauri-apps/api": "^2.1.1",
"@tauri-apps/plugin-shell": "^2.0.1",
"chart.js": "^4.4.4",
"vue": "^3.3.4",
"vue-chartjs": "^5.3.1"
},
"devDependencies": {
"@tauri-apps/cli": "^2.1.0",
"@vitejs/plugin-vue": "^5.0.5",
"typescript": "^5.2.2",
"vite": "^5.3.1",
"vue-tsc": "^2.0.22"
}
"name": "IELET3109 Heart Rate Monitor",
"private": true,
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview",
"tauri": "tauri"
},
"dependencies": {
"@tauri-apps/api": "^2.1.1",
"@tauri-apps/plugin-shell": "^2.0.1",
"chart.js": "^4.4.4",
"vue": "^3.3.4",
"vue-chartjs": "^5.3.1"
},
"devDependencies": {
"@tauri-apps/cli": "^2.1.0",
"@vitejs/plugin-vue": "^5.0.5",
"typescript": "^5.2.2",
"vite": "^5.3.1",
"vue-tsc": "^2.0.22"
}
}

View File

@ -92,7 +92,7 @@ fn create_data_listener(websockets_uri: String, data: Arc<Mutex<Vec<ECGData>>>)
.collect();
ecg_data.push(ECGData {
value: -voltage,
value: voltage,
timestamp: Utc::now(),
});
@ -114,7 +114,8 @@ fn calculate_heartrate(data: State<'_, Arc<Mutex<Vec<ECGData>>>>) -> Result<usiz
let filtered_data: Vec<f32> = data.into_iter().map(|entry| entry.value).collect();
let mut peak_finder = find_peaks::PeakFinder::new(&filtered_data);
peak_finder.with_min_prominence(1.);
peak_finder.with_min_prominence(0.5);
peak_finder.with_max_prominence(1.5);
//peak_finder.with_min_height(0.);
Ok(peak_finder.find_peaks().len())
@ -139,8 +140,8 @@ async fn main() {
let ecg_data: Arc<Mutex<Vec<ECGData>>> = Arc::new(Mutex::new(Vec::with_capacity(2 ^ 13)));
// Create the websockets listener
//create_data_listener("ws://192.168.128.50:81".to_string(), ecg_data.clone());
create_data_listener("ws://192.168.66.210:81".to_string(), ecg_data.clone());
create_data_listener("ws://192.168.128.50:81".to_string(), ecg_data.clone());
//create_data_listener("ws://192.168.66.210:81".to_string(), ecg_data.clone());
tauri::Builder::default()
.plugin(tauri_plugin_shell::init())

View File

@ -1,37 +1,37 @@
{
"build": {
"beforeDevCommand": "npm run dev",
"beforeBuildCommand": "npm run build",
"frontendDist": "../dist",
"devUrl": "http://localhost:1420"
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
},
"productName": "tauri-eval",
"mainBinaryName": "tauri-eval",
"version": "0.1.0",
"identifier": "com.tauri-eval.app",
"plugins": {},
"app": {
"security": {
"csp": null
},
"windows": [
{
"title": "tauri-eval",
"width": 800,
"height": 600,
"useHttpsScheme": true
}
]
}
"build": {
"beforeDevCommand": "npm run dev",
"beforeBuildCommand": "npm run build",
"frontendDist": "../dist",
"devUrl": "http://localhost:1420"
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
},
"productName": "tauri-eval",
"mainBinaryName": "tauri-eval",
"version": "0.1.0",
"identifier": "com.tauri-eval.app",
"plugins": {},
"app": {
"security": {
"csp": null
},
"windows": [
{
"title": "IELET3109 Heart Rate Monitor",
"width": 800,
"height": 600,
"useHttpsScheme": true
}
]
}
}