Contents
A set of algorithms implemented as an extension module to analyse the emotional statements of the users with two main aims:
HELIOS Neuro-behavioral classifier module is one of the HELIOS Module APIs as highlighted in the picture below:
git clone https://github.com/helios-h2020/h.extension-NeuroBehaviouralClassifier.git
Current version of Neurobehaviour module works with TestClient app (app + modules) with the purpose of integrate callings to Neurobehaviour module when the user interacts with Helios chat.
Please follow the next steps to integrate Neurobehaviour module into your app.
Open your app in Android Studio.
File > New > Import Module
Go to neurobehaviouralclassifier folder. Select neurobehaviour folder like source directory. Click Finish to import.
New module should appears in first line of settings.gradle file:
include ':app', ':storage', ':messaging', ':profile', ':security', ':context', ':neurobehaviour'
Open build.gradle file of app module. In dependencies section add:
implementation project(":neurobehaviour")
In order to test all features of Neurobehavioral module, you will need to modify some files in TestClient app folder. Please follow these steps.
Add the repository in build.gradle file of project:
allprojects {
repositories {
google()
jcenter()
maven {
url "https://builder.helios-social.eu/repository/helios-repository/"
credentials {
username = heliosUser
password = heliosPassword
}
}
}
}
Add dependency to the build.gradle file of the app:
dependencies {
implementation 'eu.h2020.helios_social.modules.neurobehaviour:neurobehaviour:1.1.9'
}
It's possible to create an AAR file to use the module like a library for any project.
The build.gradle file of Neurobehaviour module includes a line to set the build configuration:
abiFilters "arm64-v8a", "x86"
This setting allows to generate a build for two architectures, PC (Android emulator) and Android mobile.
In order to limit size of AAR file, we can use only "arm64-v8a" value for a production environment. In other hand, we can use "x86" value to test AAR library with Android Studio emulator.
Helios app should activate Neurobehavioral module with this events and its correspondent calling:
We will use the same calling for all type of message (text / audio / image)
Neurobehaviour module > Trust Manager
Neurobehaviour module extracts metrics from user behaviour:
Calling to egoAlterTrust function
When Trust module make the call, Neurobehaviour module sends this metrics to calculate the new Trust value.
After user has sent or read a message, Neurobehaviour module sends sensor metrics (acceleration average) using SensorValueListener interface (Context module)
DataHandler.java
//Using Context module interface to send acceleration value import eu.h2020.helios_social.core.sensor.ext.DeviceSensor;
obj.msgId = msgId; obj.accelAverage = averageAccel; deviceSensor.receiveValue(obj);
In order to use sensors of Android device, we have to add permissions in AndroidManifest.xml file of the app:
<!-- UPV LAB - Using camera to send photos -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<!-- Only for Google Play: -->
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.flash" android:required="false" />
<!-- UPV LAB - Using audio recording to send voice messages -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<!-- UPV LAB · Provider to manage files · Used by the camera -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="eu.h2020.helios_social.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
How to call module functions from other modules through methods of the listener:
Module view in Android Studio
This class performs a sentimental analysis of each image sent by user using Helios chat. Using deep learning models, this module extracts:
Results are saved in a text file and are drawn over the image:
This class performs too a sentimental analysis of each text sent by user in Helios chat. Using deep learning models, this function extracts:
public class SentimentalAnalysis extends AppCompatActivity {
public void runThread(final Context context, final String fileName, final HeliosMessageListener messageListener, final HeliosTopic topic, final HeliosMessage message)
public int realImageWidth(String resource)
private String getExtension(String word)
private void textAnalysis (Context context, String message, HeliosMessageListener messageListener, HeliosTopic topic)
private void pythonAnalysis (Context context, String script, String picture, Float scale, ImageView imageView, HeliosMessageListener messageListener, HeliosTopic topic)
private void paintingImage(PyObject squares, PyObject emotions, PyObject scores, String imageResource, Float scale, ImageView imageView, Context context, HeliosMessageListener messageListener, HeliosTopic topic)
public String getDate(long time)
private void saveImageData (Context context, int numFaces, String emotionsData, String scoreData)
private void saveTextData (Context context, PyObject origText, PyObject engText, PyObject tags, PyObject emotions)
private String extractList(List<PyObject> list)
private void saveAudioData (Context context, String audioData)
}
The module implements a local storage system to save the sentiment analysis of each message sent or received through Helios chat. This storage system is implemented using a SQLite database and Room like a data object interface.
Design of Neurobehavioral module database:
SQLite + Room database implementation
Unit tests carried out using JUnit4 framework testing library
Instrumented unit tests for Neurobehaviour module in:
Info about Android instrumented unit tests:
https://developer.android.com/training/testing/unit-testing/instrumented-unit-testsResults of unit tests for NeurobehaviourListener class:
Results of unit tests for Acceleration class:
Logcat tags to debug the module
© 2020 helios. platform
This project has received funding from the European Union’s Horizon 2020 Research and Innovation Programme under Grant Agreement N° 825585