diff --git a/app/release/app-release-4.1.0g.apk b/app/release/app-release-4.1.0.apk similarity index 89% rename from app/release/app-release-4.1.0g.apk rename to app/release/app-release-4.1.0.apk index 7cdafae..5e06efd 100644 Binary files a/app/release/app-release-4.1.0g.apk and b/app/release/app-release-4.1.0.apk differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ff50739..dca18b3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="112" + android:versionName="4.1.0"> diff --git a/app/src/main/assets/best_model_v0.09.tflite b/app/src/main/assets/best_model_v0.09.tflite deleted file mode 100644 index cfd9ee8..0000000 Binary files a/app/src/main/assets/best_model_v0.09.tflite and /dev/null differ diff --git a/app/src/main/assets/best_model_v0.12.tflite b/app/src/main/assets/best_model_v0.12.tflite new file mode 100644 index 0000000..d842356 Binary files /dev/null and b/app/src/main/assets/best_model_v0.12.tflite differ diff --git a/app/src/main/java/uk/org/openseizuredetector/LogManager.java b/app/src/main/java/uk/org/openseizuredetector/LogManager.java index 55820cd..58598e8 100644 --- a/app/src/main/java/uk/org/openseizuredetector/LogManager.java +++ b/app/src/main/java/uk/org/openseizuredetector/LogManager.java @@ -82,7 +82,7 @@ public class LogManager { private boolean mUploadInProgress; private long mEventDuration = 120; // event duration in seconds - uploads datapoints that cover this time range centred on the event time. public long mDataRetentionPeriod = 1; // Prunes the local db so it only retains data younger than this duration (in days) - private long mRemoteLogPeriod = 60; // Period in seconds between uploads to the remote server. + private long mRemoteLogPeriod = 10; // Period in seconds between uploads to the remote server. private ArrayList mDatapointsToUploadList; private String mCurrentEventRemoteId; private long mCurrentEventLocalId = -1; diff --git a/app/src/main/java/uk/org/openseizuredetector/SdAlgNn.java b/app/src/main/java/uk/org/openseizuredetector/SdAlgNn.java index a51ae83..2204d66 100644 --- a/app/src/main/java/uk/org/openseizuredetector/SdAlgNn.java +++ b/app/src/main/java/uk/org/openseizuredetector/SdAlgNn.java @@ -25,7 +25,7 @@ import java.util.Map; public class SdAlgNn { private final static String TAG = "SdAlgNn"; - private final static String MODEL_PATH = "best_model_v0.09.tflite"; + private final static String MODEL_PATH = "best_model_v0.12.tflite"; private String mUrlBase = "https://osdApi.ddns.net"; private InterpreterApi interpreter; private Context mContext; diff --git a/app/src/main/java/uk/org/openseizuredetector/SdDataSource.java b/app/src/main/java/uk/org/openseizuredetector/SdDataSource.java index 1ccf730..488ebd1 100644 --- a/app/src/main/java/uk/org/openseizuredetector/SdDataSource.java +++ b/app/src/main/java/uk/org/openseizuredetector/SdDataSource.java @@ -112,7 +112,6 @@ public abstract class SdDataSource { mSdDataReceiver = sdDataReceiver; mSdData = new SdData(); - mSdAlgNn = new SdAlgNn(mContext); } /** @@ -133,6 +132,13 @@ public abstract class SdDataSource { Log.v(TAG, "start()"); mUtil.writeToSysLogFile("SdDataSource.start()"); updatePrefs(); + + if (mSdData.mCnnAlarmActive) { + mSdAlgNn = new SdAlgNn(mContext); + } else { + mSdData.mPseizure = 0; + } + // Start timer to check status of watch regularly. mDataStatusTime = new Time(Time.getCurrentTimezone()); // use a timer to check the status of the pebble app on the same frequency @@ -220,7 +226,9 @@ public abstract class SdDataSource { mUtil.writeToSysLogFile("SDDataSource.stop() - error - " + e.toString()); } - mSdAlgNn.close(); + if (mSdData.mCnnAlarmActive) { + mSdAlgNn.close(); + } } @@ -490,7 +498,9 @@ public abstract class SdDataSource { // Use the neural network algorithm to calculate the probability of the data // being representative of a seizure (sets mSdData.mPseizure) - nnAnalysis(); + if (mSdData.mCnnAlarmActive) { + nnAnalysis(); + } // Check this data to see if it represents an alarm state. alarmCheck(); @@ -744,9 +754,14 @@ public abstract class SdDataSource { void nnAnalysis() { //Check the current set of data using the neural network model to look for alarms. Log.d(TAG,"nnAnalysis"); - float pSeizure = mSdAlgNn.getPseizure(mSdData); - Log.d(TAG,"nnAnalysis - nnResult="+pSeizure); - mSdData.mPseizure = pSeizure; + if (mSdData.mCnnAlarmActive) { + float pSeizure = mSdAlgNn.getPseizure(mSdData); + Log.d(TAG, "nnAnalysis - nnResult=" + pSeizure); + mSdData.mPseizure = pSeizure; + } else { + Log.d(TAG, "nnAnalysis - mCnAlarmActive is false - not analysing"); + mSdData.mPseizure = 0; + } } /** diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 299e945..22ac4ba 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -3,8 +3,7 @@ OpenSeizureDetector "\n - \nV4.1.0g - CNN V0.09 - \nV4.1.0 - Added Machine Learning (Artificial Intelligence) Detection Algorithm Option + \nV4.1.0 - Added Machine Learning (Artificial Intelligence) Detection Algorithm Option (CNN V0.12) \nV4.0.7 - Improvements to Data Sharing data log manager screen. - Introduced the <b>Data Sharing</b> feature to allow users to share their seizure and false alarm data with researchers to help improve the system.<br/>