V4.1.0e - Upgraded cnn to V0.06. Tidied up main menu a bit. Added active algorithm display to main activiy. Pulled all of the algorithm activiation checkboxes to the top of the seizure detection settings so they are easier to find.

This commit is contained in:
Graham Jones
2022-09-25 20:20:17 +01:00
parent e56284c79d
commit 726369c308
10 changed files with 169 additions and 19 deletions

View File

@@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="uk.org.openseizuredetector" package="uk.org.openseizuredetector"
android:versionCode="107" android:versionCode="108"
android:versionName="4.1.0d"> android:versionName="4.1.0e">
<!-- android:allowBackup="false" --> <!-- android:allowBackup="false" -->
<uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

Binary file not shown.

View File

@@ -30,6 +30,7 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
@@ -44,6 +45,7 @@ import android.view.View;
import android.view.ViewConfiguration; import android.view.ViewConfiguration;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.Button; import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
@@ -112,6 +114,7 @@ public class MainActivity extends AppCompatActivity {
// Initialise the User Interface // Initialise the User Interface
setContentView(R.layout.main); setContentView(R.layout.main);
//getWindow().getDecorView().setBackgroundColor(okColour);
/* Force display of overflow menu - from stackoverflow /* Force display of overflow menu - from stackoverflow
* "how to force use of..." * "how to force use of..."
@@ -425,6 +428,8 @@ public class MainActivity extends AppCompatActivity {
tv = (TextView) findViewById(R.id.versionTv); tv = (TextView) findViewById(R.id.versionTv);
String versionName = mUtil.getAppVersionName(); String versionName = mUtil.getAppVersionName();
tv.setText(getString(R.string.AppTitleText) + " " + versionName); tv.setText(getString(R.string.AppTitleText) + " " + versionName);
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
if (mUtil.isServerRunning()) { if (mUtil.isServerRunning()) {
mUtil.writeToSysLogFile("MainActivity.onStart - Binding to Server"); mUtil.writeToSysLogFile("MainActivity.onStart - Binding to Server");
@@ -503,10 +508,15 @@ public class MainActivity extends AppCompatActivity {
TextView tv; TextView tv;
if (mUtil.isServerRunning()) { if (mUtil.isServerRunning()) {
LinearLayout ll = (LinearLayout) findViewById(R.id.statusLayout);
ll.setBackgroundColor(okColour);
ll = (LinearLayout) findViewById(R.id.watchStatusLl);
ll.setBackgroundColor(okColour);
tv = (TextView) findViewById(R.id.serverStatusTv); tv = (TextView) findViewById(R.id.serverStatusTv);
if (mConnection.mBound) if (mConnection.mBound) {
if (mConnection.mSdServer.mSdDataSourceName.equals("Phone")) { if (mConnection.mSdServer.mSdDataSourceName.equals("Phone")) {
tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + "Phone"+"\n"+"(Demo Mode)"); tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + "Phone" + "\n" + "(Demo Mode)");
tv.setBackgroundColor(warnColour); tv.setBackgroundColor(warnColour);
tv.setTextColor(warnTextColour); tv.setTextColor(warnTextColour);
} else { } else {
@@ -514,6 +524,63 @@ public class MainActivity extends AppCompatActivity {
tv.setBackgroundColor(okColour); tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour); tv.setTextColor(okTextColour);
} }
tv = (TextView) findViewById(R.id.osdAlgTv);
tv.setText("OSD ");
if (mConnection.mSdServer.mSdData.mOsdAlarmActive) {
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
tv.setPaintFlags(tv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
} else {
tv.setBackgroundColor(warnColour);
tv.setTextColor(warnTextColour);
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
tv = (TextView) findViewById(R.id.cnnAlgTv);
tv.setText("CNN ");
if (mConnection.mSdServer.mSdData.mCnnAlarmActive) {
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
tv.setPaintFlags(tv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
} else {
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
tv = (TextView) findViewById(R.id.hrAlgTv);
tv.setText("HR ");
if (mConnection.mSdServer.mSdData.mHRAlarmActive) {
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
tv.setPaintFlags(tv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
} else {
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
tv = (TextView) findViewById(R.id.o2AlgTv);
tv.setText("O2 ");
if (mConnection.mSdServer.mSdData.mO2SatAlarmActive) {
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
tv.setPaintFlags(tv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
} else {
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
tv = (TextView) findViewById(R.id.fallAlgTv);
tv.setText("Fall");
if (mConnection.mSdServer.mSdData.mFallActive) {
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
tv.setPaintFlags(tv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
} else {
tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour);
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
}
tv = (TextView) findViewById(R.id.serverIpTv); tv = (TextView) findViewById(R.id.serverIpTv);
tv.setText(getString(R.string.AccessServerAt) + " http://" tv.setText(getString(R.string.AccessServerAt) + " http://"
+ mUtil.getLocalIpAddress() + mUtil.getLocalIpAddress()
@@ -572,7 +639,7 @@ public class MainActivity extends AppCompatActivity {
// Pebble Connected Phrase - use for HR if active instead. // Pebble Connected Phrase - use for HR if active instead.
tv = (TextView) findViewById(R.id.pebbleTv); tv = (TextView) findViewById(R.id.pebbleTv);
if (mConnection.mSdServer.mSdData.mHRAlarmActive) { //if (mConnection.mSdServer.mSdData.mHRAlarmActive) {
if (mConnection.mSdServer.mSdData.mO2Sat>0) { if (mConnection.mSdServer.mSdData.mO2Sat>0) {
tv.setText(getString(R.string.HR_Equals) + mConnection.mSdServer.mSdData.mHR + " bpm\n" tv.setText(getString(R.string.HR_Equals) + mConnection.mSdServer.mSdData.mHR + " bpm\n"
+ "O2 Sat = " + mConnection.mSdServer.mSdData.mO2Sat + "%"); + "O2 Sat = " + mConnection.mSdServer.mSdData.mO2Sat + "%");
@@ -590,7 +657,7 @@ public class MainActivity extends AppCompatActivity {
tv.setBackgroundColor(okColour); tv.setBackgroundColor(okColour);
tv.setTextColor(okTextColour); tv.setTextColor(okTextColour);
} }
} else { /*} else {
if (mConnection.mSdServer.mSdData.watchConnected) { if (mConnection.mSdServer.mSdData.watchConnected) {
tv.setText(R.string.HRAlarmOff); tv.setText(R.string.HRAlarmOff);
tv.setBackgroundColor(okColour); tv.setBackgroundColor(okColour);
@@ -602,6 +669,8 @@ public class MainActivity extends AppCompatActivity {
tv.setTextColor(warnTextColour); tv.setTextColor(warnTextColour);
} }
} }
*/
tv = (TextView) findViewById(R.id.appTv); tv = (TextView) findViewById(R.id.appTv);
if (mConnection.mSdServer.mSdData.watchAppRunning) { if (mConnection.mSdServer.mSdData.watchAppRunning) {
tv.setText(R.string.WatchAppOK); tv.setText(R.string.WatchAppOK);

View File

@@ -25,7 +25,7 @@ import java.util.Map;
public class SdAlgNn { public class SdAlgNn {
private final static String TAG = "SdAlgNn"; private final static String TAG = "SdAlgNn";
private final static String MODEL_PATH = "best_model_v0.05.tflite"; private final static String MODEL_PATH = "best_model_v0.06.tflite";
private String mUrlBase = "https://osdApi.ddns.net"; private String mUrlBase = "https://osdApi.ddns.net";
private InterpreterApi interpreter; private InterpreterApi interpreter;
private Context mContext; private Context mContext;

View File

@@ -6,23 +6,85 @@
<TextView <TextView
android:id="@+id/versionTv" android:id="@+id/versionTv"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Android OpenSeizureDetector Version x.xx" /> android:text="Android OpenSeizureDetector Version x.xx" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/statusLayout"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <!--<TextView
android:id="@+id/serverStatusTv" android:id="@+id/serverStatusTv"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0.5" android:layout_weight="0.5"
android:gravity="center" android:gravity="center"
android:text="textView1" /> android:text="textView1" />
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/serverStatusTv"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="---" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:orientation="vertical">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/osdAlgTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="---" />
<TextView
android:id="@+id/cnnAlgTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="---" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/hrAlgTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="---" />
<TextView
android:id="@+id/o2AlgTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="---" />
<TextView
android:id="@+id/fallAlgTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="---" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<TextView <TextView
android:id="@+id/serverIpTv" android:id="@+id/serverIpTv"
@@ -34,6 +96,7 @@
</LinearLayout> </LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/watchStatusLl"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">

View File

@@ -28,14 +28,14 @@
android:icon="@drawable/ic_action_settings" android:icon="@drawable/ic_action_settings"
app:showAsAction="never|withText" app:showAsAction="never|withText"
android:title="@string/data_log_manager" /> android:title="@string/data_log_manager" />
<!--
<item <item
android:id="@+id/action_authenticate_api" android:id="@+id/action_authenticate_api"
android:enabled="true" android:enabled="true"
android:icon="@drawable/ic_action_settings" android:icon="@drawable/ic_action_settings"
app:showAsAction="never|withText" app:showAsAction="never|withText"
android:title="@string/data_sharing_log_in" /> android:title="@string/data_sharing_log_in" />
-->
<item <item
android:id="@+id/action_about_datasharing" android:id="@+id/action_about_datasharing"
android:enabled="true" android:enabled="true"

View File

@@ -3,8 +3,8 @@
<string name="app_name">OpenSeizureDetector</string> <string name="app_name">OpenSeizureDetector</string>
<string name="changelog"> <string name="changelog">
"\n "\n
\nV4.0.7 - imporovements to Data Sharing data log manager screen. \nV4.1.0 - Added Machine Learning (Artificial Intelligence) Detection Algorithm Option
\nV4.0.6 - First public relase with Data Sharing feature enabled. \nV4.0.7 - Improvements to Data Sharing data log manager screen.
- Introduced the &lt;b>Data Sharing&lt;/b> feature to allow users to share their seizure and false alarm data - Introduced the &lt;b>Data Sharing&lt;/b> feature to allow users to share their seizure and false alarm data
with researchers to help improve the system.&lt;br/> with researchers to help improve the system.&lt;br/>
- Fixed &lt;b>SMS Location Alerts&lt;/b> on Android V10+ (new permissions screens)&lt;br/> - Fixed &lt;b>SMS Location Alerts&lt;/b> on Android V10+ (new permissions screens)&lt;br/>
@@ -106,7 +106,7 @@
<string name="AlarmFreqMaxSummary">Maximum Frequency of ROI (Hz) (Default = 8 Hz)</string> <string name="AlarmFreqMaxSummary">Maximum Frequency of ROI (Hz) (Default = 8 Hz)</string>
<string name="AlarmFreqMinTitle">AlarmFreqMin (Hz)</string> <string name="AlarmFreqMinTitle">AlarmFreqMin (Hz)</string>
<string name="AlarmFreqMinSummary">Minimum Frequency of ROI (Hz) (Default = 3 Hz)</string> <string name="AlarmFreqMinSummary">Minimum Frequency of ROI (Hz) (Default = 3 Hz)</string>
<string name="HRAlarmEnabledTitle">Heart Rate Alarm Enabled</string> <string name="HRAlarmEnabledTitle">Enable Heart Rate Alarm</string>
<string name="HRAlarmEnabledSummary" /> <string name="HRAlarmEnabledSummary" />
<string name="HRNullAlarmTitle">Treat a Null heart rate as an alarm condition</string> <string name="HRNullAlarmTitle">Treat a Null heart rate as an alarm condition</string>
<string name="HRNullAlarmSummary" /> <string name="HRNullAlarmSummary" />
@@ -122,7 +122,7 @@
<string name="test_alarm_beep">Test Alarm Beep</string> <string name="test_alarm_beep">Test Alarm Beep</string>
<string name="test_warning_beep">Test Warning Beep</string> <string name="test_warning_beep">Test Warning Beep</string>
<string name="test_sms_alarm_notification">Test SMS Alarm Notification</string> <string name="test_sms_alarm_notification">Test SMS Alarm Notification</string>
<string name="data_log_manager">Data Log Manager</string> <string name="data_log_manager">Data Sharing</string>
<string name="view_log_entries">View Log Entries</string> <string name="view_log_entries">View Log Entries</string>
<string name="export_data">Export Data</string> <string name="export_data">Export Data</string>
<string name="settings">Settings</string> <string name="settings">Settings</string>
@@ -262,7 +262,7 @@
<string name="sample_freq_summary">Higher Frequency is more Accurate, but uses more battery power.</string> <string name="sample_freq_summary">Higher Frequency is more Accurate, but uses more battery power.</string>
<string name="sample_freq_title">Select Sample Frequency</string> <string name="sample_freq_title">Select Sample Frequency</string>
<string name="fall_detect_title">Fall Detector Settings</string> <string name="fall_detect_title">Fall Detector Settings</string>
<string name="fall_detect_active_title">Activate Fall Detection Function</string> <string name="fall_detect_active_title">Enable Fall Detection Function</string>
<string name="fall_thresh_min_title">Fall Detection Lower Threshold (milli-g)</string> <string name="fall_thresh_min_title">Fall Detection Lower Threshold (milli-g)</string>
<string name="fall_thresh_max_title">Fall Detection Upper Threshold (milli-g)</string> <string name="fall_thresh_max_title">Fall Detection Upper Threshold (milli-g)</string>
<string name="fall_window_title">Fall Detection Window (milli-seconds)</string> <string name="fall_window_title">Fall Detection Window (milli-seconds)</string>
@@ -312,7 +312,7 @@
<string name="title_activity_authenticate">Log in to OpenSeizureDetector Data Sharing</string> <string name="title_activity_authenticate">Log in to OpenSeizureDetector Data Sharing</string>
<string name="logout">Log Out</string> <string name="logout">Log Out</string>
<string name="logged_in_with_token">Logged in to\nData Sharing</string> <string name="logged_in_with_token">Logged in to\nData Sharing</string>
<string name="local_database">Logged Data Manager</string> <string name="local_database">Data Sharing Manager</string>
<string name="remote_database">Shared Data</string> <string name="remote_database">Shared Data</string>
<string name="num_local_events">Number of Events Stored on Phone: </string> <string name="num_local_events">Number of Events Stored on Phone: </string>
<string name="num_local_datapoints">"Number of Datapoints Stored on Phone: "</string> <string name="num_local_datapoints">"Number of Datapoints Stored on Phone: "</string>
@@ -438,8 +438,9 @@
<string name="not_logged_in_dialog_title">Not Logged in to Data Sharing</string> <string name="not_logged_in_dialog_title">Not Logged in to Data Sharing</string>
<string name="not_logged_in_dialog_message">You must be logged in to the Data Sharing system to be able to report seizures.</string> <string name="not_logged_in_dialog_message">You must be logged in to the Data Sharing system to be able to report seizures.</string>
<string name="include_warnings">Include Warnings</string> <string name="include_warnings">Include Warnings</string>
<string name="OsdAlarmEnabledSummary">Enable the original deterministic OpenSeizureDetector Algorithm to generate alarms.</string> <string name="OsdAlarmEnabledSummary">Enable the original deterministic OpenSeizureDetector Algorithm to generate alarms. ***Disabling this algorithm is NOT recommended except for testing purposes***</string>
<string name="OsdAlarmEnabledTitle">Enable Original OSD Algorithm</string> <string name="OsdAlarmEnabledTitle">Enable Original OSD Algorithm</string>
<string name="CnnAlarmEnabledTitle">Enable AI (Neural Network) Algorithm</string> <string name="CnnAlarmEnabledTitle">Enable AI (Neural Network) Algorithm</string>
<string name="CnnAlarmEnabledSummary">Enable the Artificial Intelligence (Neural Network) algorithm to generate alarms.</string> <string name="CnnAlarmEnabledSummary">Enable the Artificial Intelligence (Neural Network) algorithm to generate alarms.</string>
<string name="AlgorithmSelectionTitle">Seizure Detection Algorithms Selection</string>
</resources> </resources>

View File

@@ -2,7 +2,7 @@
<!-- The ListPreference data is defined in pebble_datasource_values.xml --> <!-- The ListPreference data is defined in pebble_datasource_values.xml -->
<PreferenceScreen <PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"> xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/SeizureDetectorSettingsTitle"> <PreferenceCategory android:title="@string/AlgorithmSelectionTitle">
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="true" android:defaultValue="true"
android:key="OsdAlarmActive" android:key="OsdAlarmActive"
@@ -13,6 +13,23 @@
android:key="CnnAlarmActive" android:key="CnnAlarmActive"
android:summary="@string/CnnAlarmEnabledSummary" android:summary="@string/CnnAlarmEnabledSummary"
android:title="@string/CnnAlarmEnabledTitle" /> android:title="@string/CnnAlarmEnabledTitle" />
<CheckBoxPreference
android:defaultValue="false"
android:key="HRAlarmActive"
android:summary="@string/HRAlarmEnabledSummary"
android:title="@string/HRAlarmEnabledTitle" />
<CheckBoxPreference
android:defaultValue="false"
android:key="O2SatAlarmActive"
android:summary="@string/O2Sat_enabled_summary"
android:title="@string/O2Sat_enabled_title" />
<CheckBoxPreference
android:defaultValue="false"
android:key="FallActive"
android:summary=""
android:title="@string/fall_detect_active_title" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/SeizureDetectorSettingsTitle">
<EditTextPreference <EditTextPreference
android:defaultValue="5" android:defaultValue="5"
android:key="WarnTime" android:key="WarnTime"