45
SLEEP ASSISTANCE USING ARTIFICIAL NEURAL NETWORK MUHAMMAD 'ALIUDDIN BIN AZMI BACHELOR OF COMPUTER SCIENCE (SOFTWARE DEVELOPMENT) WITH HONOURS UNIVERSITI SULTAN ZAINAL ABIDIN 2021

MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

SLEEP ASSISTANCE USING ARTIFICIAL NEURAL

NETWORK

MUHAMMAD 'ALIUDDIN BIN AZMI

BACHELOR OF COMPUTER SCIENCE (SOFTWARE

DEVELOPMENT) WITH HONOURS

UNIVERSITI SULTAN ZAINAL ABIDIN

2021

Page 2: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report
Page 3: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

SLEEP ASSISTANCE USING ARTIFICIAL NEURAL NETWORK

MUHAMMAD 'ALIUDDIN BIN AZMI

BACHELOR OF COMPUTER SCIENCE (SOFTWARE

DEVELOPMENT) WITH HONOURS

Universiti Sultan Zainal Abidin

2021

Page 4: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

i

DECLARATION

I hereby declare that the report is based on my original work except for quotations and

citations, which have been duly acknowledged. I also declare that it has not been

previously or concurrently submitted for any other degree at Universiti Sultan Zainal

Abidin or other institutions.

_______________________________

Name: Muhammad' Aliuddin bin Azmi

Date: 31 January 2021

Page 5: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

ii

CONFIRMATION

This is to confirm that:

The research conducted and the writing of this report was under my supervision.

_______________________________

Name: Prof. Madya Ts. Dr. Yousef

Abubaker Mohamed Ahmed El-Ebairy

Date: 31 January 2021

Page 6: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

iii

DEDICATION

In the Name of Allah, the Most Gracious and the Most Merciful.

Alhamdulillah, I thank Allah for His grace and grace, I can prepare and complete this

report successfully.

First, I would like to thank my supervisor, Prof. Madya. Ts. Dr. Yousef Abubaker

Mohamed Ahmed El-Ebairy because with guidance, advice, and thoughtful ideas has

given me the opportunity to prepare this report successfully.

Besides, my gratitude is also to my colleagues who share ideas, opinions, knowledge,

and reminders. They helped me answer every question that was important to me in

completing this report.

Thanks also to my beloved mother and father always support and motivated me to

prepare for this report for Final Year Project.

I would like to take the opportunity to thank all lecturers of the Informatics and

Computing Faculty for their attention, guidance, and advice in helping and sharing ideas

and opinions in making this report successful.

May Allah SWT bless all the efforts that have been given in completing this

report.

Thank you.

Page 7: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

iv

ABSTRACT

Sleep is an essential state that all living things must naturally come to do. It is when the

body and mind take time to recuperate from daily activities. A good night's sleep can

improve overall mental and physical health. In this modern age, the number of people

with sleeping disorders has arisen over the century. Irregular sleeping schedules can

attribute to staying up late at night, overworking, etc.

This project aims to create an intelligent application that generates an optimized

sleeping schedule using an Artificial Neural Network (ANN). On the surface, it is

essentially a smart alarm clock powered by Artificial Intelligence. Unlike a standard

alarm clock, users will not have to worry about forgetting to set their alarm before going

to sleep. This project heavily leverages the well-known fact that people these days own

at least one smartphone. First, we train the neural network using existing datasets that

consist of sleep data analysis. The next step is to incorporate the trained neural network

into the application to recognize the user's sleep-wake patterns and automatically create

an optimized sleep schedule based on that info. A smart alarm built into the application

will dynamically adjust according to the generated sleep schedule.

Page 8: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

v

ABSTRAK

Tidur adalah suatu amalan penting yang mesti dilakukan oleh semua makhluk hidup.

Ia adalah suatu keadaan ketika badan dan minda mengambil masa untuk rehat

daripada aktiviti-aktiviti harian. Tidur malam yang baik dan mencukupi dapat

meningkatkan kesihatan fizikal dan mental secara keseluruhan. Pada zaman moden ini,

jumlah orang yang mengalami penyakit atau gangguan tidur telah meningkat. Jadual

tidur yang tidak seberapa teratur oleh disebabkan terjaga larut malam, bekerja

sehingga lewat malam, dan lain-lain.

Projek ini bertujuan untuk menghasilkan sebuah aplikasi pintar yang mampu membuat

jadual tidur yang optimum menggunakan teknologi rangkaian saraf tiruan (ANN). Di

samping itu, ia merupakan juga sebuah jam penggera pintar yang dikuasakan oleh

teknologi kecerdasan buatan (AI). Pengguna tidak perlu risau untuk mengatur

penggera mera sebelum tidur kerana aplikasi ini akan melakukannya secara automatik.

Projek ini mangambil kesempatan atas dasar bahawa kebanyakkan orang pada hari ini

memiliki sekurang-kurangnya sebuah telefon pintar. Pertama sekali, kami akan melatih

rangkaian saraf menggunakan set data yang sedia ada. Seterusnya, kita akan

memasukkan rangkaian saraf yang dilatih tersebut ke dalam aplikasi untuk

mengenalpasti pola tidur-bangun pengguna. Kemudian, ia akan menjanakan jadual

tidur yang optimum secara autonomi berdasarkan maklumat yang tersebut. Penggera

pintar didalam aplikasi akan disesuaikan secara dinamik mengikut jadual tidur yang

dihasilkan.

Page 9: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

vi

CONTENTS

PAGE

DECLARATION i CONFIRMATION ii DEDICATION iii ABSTRACT iv

ABSTRAK v CONTENTS vi

LIST OF TABLES vii LIST OF FIGURES viii LIST OF ABBREVIATIONS ix CHAPTER 1 INTRODUCTION 1

1.1 Introduction 1

1.2 Project Background 1 1.3 Problem Statement 2 1.4 Objectives 2 1.5 Scope 3

1.6 Limitation of Work 4 1.7 Expected Result 4

1.8 Summary of the Chapter 5 CHAPTER 2 LITERATURE REVIEW 6

2.1 Introduction 6 2.2 Artificial Neural Network 6 2.3 Applications of Neural Network 9

2.4 Science of Sleep and Artificial Neural Network 9 2.5 Artificial Neural Network in Clinical Psychology 11

2.6 Literature Review Summary 12 CHAPTER 3 METHODOLOGY 16

3.1 Introduction 16 3.2 Methodology Selection 17

3.3 Methodology Phases 19 3.3.1 Requirements Analysis Phase 19 3.3.2 System Design Phase 19 3.3.3 Implementation Phase 20

3.3.4 Testing Phase 20 3.3.5 Deployment Phase 20 3.3.6 Maintenance Phase 21

3.4 System Requirement 22 3.4.1 Hardware Requirement 22 3.4.2 Software Requirement 23

3.5 System Design 24

3.5.1 Context Diagram (CD) 24 3.5.2 Data Flow Diagram (DFD) 26 3.5.3 Entity Relationship Diagram (ERD) 28

3.5.4 Use Case Diagram (UCD) 29 REFERENCES 31

Page 10: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

vii

LIST OF TABLES

Table No. Title Page

Table 2.1 - Summary of LR 12

Table 3.1 - List of Hardware Requirement 22

Table 3.2 - List of Software Requirement 23

Page 11: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

viii

LIST OF FIGURES

Figure No. Title Page

Figure 3.1 - Waterfall Model 17

Figure 3.2 - Context Diagram 24

Figure 3.3 - Data Flow Diagram Level 0 26

Figure 3.4 - Entity Relationship Diagram 28

Figure 3.5 - Use Case Diagram 29

Page 12: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

ix

LIST OF ABBREVIATIONS

FYP Final Year Project

ANN Artificial Neural Network

AI Artificial Intelligence

RNN Recurrent Neural Network

MLP Multi-Layer Perceptron

PSG Polysomnography

EEG Electroencephalography

ECG Electrocardiography

EOG Electrooculography

EEG Electromyography

SDLC System Development Life Cycle

SNNAS Smart Neural Net Alarm System

CD Context Diagram

DFD Data Flow Diagram

ERD Entity Relationship Diagram

Page 13: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

1

CHAPTER 1

INTRODUCTION

1.1 Introduction

This is the introductory chapter of this report. In section 1.2, we will describe the project

background while section 1.3 will involve stating all the problems that led to this

project. Next, section 1.4 will list all the objectives and section 1.5 will declare all the

intended scope of the project. Then, section 1.6 will explain the limitations of work

involved in this project and section 1.7 will outline the expected results of this project.

Lastly, section 1.8 will summarize the chapters.

1.2 Project Background

The goal of this project is to record the sleeping pattern of a person as input, analyse the

pattern, and train a model using Artificial Neural Network (ANN) so it can be used to

produce personalized sleep schedules. Those personalized sleep schedules would be fed

into a smart alarm application that would automatically work for the user. The smart

alarm will alert the user when they should go to bed and wake up from their bed.

Artificial neural networks, or only neural networks, are a branch of machine learning

based on biological neural networks in animal brains. Due to its ability to function like

a brain, ANN can learn by themselves and produce an output not restricted by their

input. It is very adaptive and will evolve accordingly to real-time data. This approach

can be applied to help people with sleeping problems.

Page 14: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

2

This application is mostly a self-therapy, meaning the user would have to follow the

application's neural network's specified scheduling. However, the application will adapt

accordingly should the users deviate from their personalized schedules.

1.3 Problem Statement

The project has recognized several vital problems or concerns that led to a call of action

for proposal, as listed below:

i. Certain people have always had trouble keeping track of time when they are

invested in an activity, especially late at night.

ii. People who have disrupted circadian rhythm due to abnormal sleep schedules

and desire to fix those issues.

iii. People who could not afford the time to meet psychologists who can assess

and help with their sleep problems.

1.4 Objectives

The objectives of this project are listed below:

i. To study the normal and abnormal sleeping schedules using existing

polysomnography dataset.

ii. To model the collected sleep schedule data using Artificial Neural Network

(ANN).

iii. To develop a mobile application that can generate personalized and

optimized sleep schedules for an individual with built-in smart alarm.

Page 15: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

3

1.5 Scope

The scopes of the project are listed below:

i. User

a. Users will be able to use the application to enter and check their

current sleeping patterns.

b. Users will be able to use the application to follow a recommended

sleep schedule created by the application’s neural networks

c. Users will be able to go to bed when the application notifies them

and wake up accordingly when the application’s smart alarm

activates.

ii. Developer

a. Developers will insert the sleep pattern data into the artificial neural

network to train the model.

b. Developers will be able to monitor the artificial neural network’s

model to ensure the application can work as intended.

Page 16: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

4

1.6 Limitation of Work

There may be several limiting factors that would occur for this application, as listed

below:

i. The application's effectiveness depends on the user's willingness to follow

the recommended sleep schedule generated by the application.

ii. The application cannot work as intended if the device's clock is not

synchronized with real-time.

1.7 Expected Result

Based on the objectives of the development, the application will function as listed

below:

i. This application is based on the Android platform.

ii. This application will help users to create an optimal sleeping schedule to

benefit their health.

iii. This application will support the autonomous smart alarm feature.

Page 17: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

5

1.8 Summary of the Chapter

This report begins with Chapter 1 as an introductory chapter. The upcoming chapter 2

will explain the literature review of related papers and journals. Then, chapter 3 will

discuss about the project's methodology and its related activities that would be

implemented in the next phase of the project's software development.

Page 18: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

6

CHAPTER 2

LITERATURE REVIEW

2.1 Introduction

In this chapter, the literature review and research about the systems that are of similar

functionality to this application will be thoroughly discussed. In section 2.2, we will

describe the details of artificial neural network. Then in section 2.3, we will discuss

about the current applications of artificial neural network. Following is section 2.4, we

will discuss the neural network in science of sleep. In section 2.5, we will discuss the

neural network in clinical psychology while in the last section 2.6, we will summarize

the articles and journals used in this literature review.

2.2 Artificial Neural Network

A neural network is a composition of neurons that functions in a network. There are two

types of neural networks, biological and artificial. Biological neural networks are the

ones that exists within the brain of living things, such as us humans. They allow us to

think, make decisions, and solve problems. So, in a similar vein, artificial neural

networks are simply computerized model of a brain. Artificial neural network is literally

the brain of an Artificial Intelligence, or AI. It is a powerhouse of machine learning in

this current day.

The primary objective of developing ANN system is creating a system that can work

and think with human-like precision whilst outperforming the existing traditional

systems. It is a computing technique that solve problems in parallel that are normally

unachievable via linear computing. ANNs have three key components such as artificial

Page 19: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

7

neurons, connections and its associated weights, and propagation functions. Artificial

neurons are nodes that have inputs and produce singular output which is then sent to

other neurons. The neural network has connections that links the neurons together, with

a connection providing the output of a neuron as input to the other neurons. Those

connections also have weights associated to them to signify their relative importance.

The propagation function is a transport mechanism used to bring values throughout the

neurons. This is done by adding up the input values thus creating a weighted sum, and

then passing it to the activation function which produces an output.

ANN consist of at least two layers, the input layer, and the output layer. However,

occasionally a third hidden layer is added as a summation layer, responsible for adding

up the outputs of the previous layer and weighed by the weight factor. During the design

process, only the input and output layers are known while the hidden layer is calculated

by the neural network itself. This hidden layer is what gives neural network its adaptive

and self-learning trait. (Mehrotra, Kishan, Mohan, Chilukuri K., Ranka, n.d.)

Page 20: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

8

There are several types of neural networks, which is listed as below:

i. Feed Forward Neural

Network

ii. Radial Basis Function

Neural Network

iii. Multi-Layer Perceptron

(MLP)

iv. Convolutional Neural

Network

v. Recurrent Neural Network

(RNN)

vi. Modular Neural Network

vii. Sequence-to-Sequence

Neural Model

Page 21: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

9

2.3 Applications of Neural Network

The practical use of artificial neural network is becoming more prevalent as technology

advances. Some of the applications of ANN are listed below:

i. Spam Mail Filter – Various email service providers utilized ANNs to detect

and remove unwanted or even dangerous emails that might reach the

recipient.

ii. Pattern Recognition – Automated recognition can use ANNs to increase the

overall accuracy level. An example of pattern recognition using ANN is

recognizing the trends and patterns of the stock market.

iii. Sequence Recognition – ANNs can be used to identify sequential actions

such as speech, handwriting, and gesture.

iv. Machine Translation – Language translation can be greatly improved with

use of ANNs. Google Translate for example uses ANN called Google

Neural Machine Translation (GNMT), therefore allowing for better fluency

and accuracy while also maintaining a natural translation.

2.4 Science of Sleep and Artificial Neural Network

Sleep is a basic psychological need and it is an important function for most critical

processes in our body, such as immunity. As we adapt with the rapidly advancing

modern lifestyle, our overall quality of sleep becomes influenced in a way or another.

It is crucial that diagnostics of sleep disorders and its adverse effects are properly

studied and understood.

Page 22: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

10

Sleep disorders are one of the serious problems that plagues the modern world. The rise

of unhealthy lifestyles and the pressure of work cause an impact in sleep quality, which

can later present variety of mental illnesses. Furthermore, the existence of sleep

disorders can become probable causes for diseases such as obesity. There are several

sleep disorders, most well-known ones are insomnia, hypersomnia, narcolepsy, and

sleep apnea.

When a human goes to sleep, they will go through three primary sleep stages: W

(wakefulness), Rapid Eye Movement (REM), and Non-rapid Eye Movement (NREM).

Each of these stages are further subdivided into three more stages: N1, N2, and N3.

About four to five times the NREM-REM sleep occurs during a night's sleep, lasting

from about 1 hour and 30 minutes, all the way up to 1 hour and 50 minutes.

Statistical data is recorded using polysomnography (PSG), also known as sleep study.

PSG records EEG, ECG, EOG, and EMG. EEG is electroencephalography, which

records the activity of the brain in real time. ECG is electrocardiography and it records

the electrical impulses that keeps the heart beating in correct sequence. EOG is

electrooculography, which is responsible for recording the eye movements. Finally,

EMG is electromyography which records muscular activity. (Ebrahimi et al., 2008;

Ronzhina et al., 2012)

However, PSG tools are normally laboratory equipment thus not readily available

within everyone's reach. Fortunately, in this modern day, more accessible consumer-

grade solutions are available to gain access to sleep study data. Variety of sleep

monitoring tools called sleep trackers can be bought off the online marketplace, ranging

from contactless devices that sit underneath the mattress to wearable armbands. Most

Page 23: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

11

of these devices possess sensors that allows them to gather polysomnography data.

Typically, these devices can only make estimation based on the amount of time you are

asleep. In a way, they are not as accurate as true sleep study although they are still

definitely useful. (Lajnef et al., 2015; Malafeev et al., 2018)

Given the data that is collected by the wearable's sensors, we can utilize ANN's sensor

fusion, which interprets the values from multiple different sensors, and allow the neural

network to learn and model the given individual's sleeping pattern. The model is then

used to feed the intended smart alarm which will automatically notify the individual

about their sleep times and wake-up times. The sleeping pattern model may also be used

to analyse for any possible abnormalities in the pattern that might develop into sleeping

disorders. This proactive strategy can serve as an effective prevention of disorders from

developing.

2.5 Artificial Neural Network in Clinical Psychology

Since artificial neural networks are analogous to a brain, they can be trained and used

to model human psychological behaviour. Unlike physiology, also called physical

health, psychology is mental health and is much harder to diagnose than in comparison.

An individual can be diagnosed by building its mental model and then comparing to the

psychological metrics taken in real-time. Typically, most mental illnesses are incurable,

yet they are treatable by minimizing the symptoms. However, early detection allows for

the prevention of the disease from occurring in the first place. (Price et al., 2000)

Theoretically, an individual's mental model would account for various factors that

actively influence the individual's mental state. This mental model would include

mimicking the psychological variables such as positive and negative emotions. A

Page 24: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

12

simulated mental state of the individual can accurately predict if an unusual or abnormal

pattern would precipitate. Since not all individuals are willing to divulge their

psychological problems, an unaided system without an expert's supervision would make

an artificial neural network a strong choice.

2.6 Literature Review Summary

The list of articles, journals, and research papers used in this Literature Review is

summarized as shown in Table 2-1 below.

Table 2.1 - Summary of LR

AUTHOR TITLE METHOD ADVANTAGE DISADVANTAGE

R. K. Price

E. L.

Spitznagel,

T. J.

Downey,

D. J.

Meyer,

N. K. Risk,

Applying

Artificial

Neural

Network

Models to

Clinical

Decision

Making

Multi-Layer

perceptron

ANN

Linear modeling

Artificial

neural

networks are

capable of

outperforming

most if not all

the

conventional

statistical

methods

available.

Linear models and

ANNs are both

sensitive to low

prevalence. Small

sample sizes can

result in a small

number of false-

negative results.

Page 25: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

13

O. G. el-

Ghazzawy

(2000)

Marina

Ronzhina,

Oto

Janoušek,

Jana

Kolářová,

Marie

Nováková,

Petr

Honzík,

Ivo

Provazník

(2011)

Sleep

Scoring

using

Artificial

Neural

Networks

Single-Layer

perceptron

ANN

Multi-Layer

perceptron

ANN

Genetic

Algorithms

An automatic

scoring

system

powered by

artificial

neural

networks can

entirely and

theoretically

substitute

human

scoring.

No practical

automatic scoring

systems exist

during the

publication of the

article

Page 26: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

14

F.

Ebrahimi

M. Mikaeli

E. Estrada

H. Nazeran

Automatic

Sleep Stage

Classification

Based on

EGG Signals

by Using

Neural

Networks

and Wavelet

Packet

Coefficients

Tree-layer Feed

Forward

Perceptron

ANN

Levenberg-

Marquardt

backpropagation

(trainlm)

Gradient

descent with

momentum and

adaptive

learning rate

backpropagation

(traingdx)

It was noted

that increasing

the number of

neurons

effectively

increases the

mean of

accuracy and

decreases the

standard

deviation.

There was a

difference in

performance

when comparing

the trainlm and

traingdx training

functions.

A.

Malafeev

D. Laptev

S. Bauer

X. Omlin

A.

Wierzbicka

A.

Wichniak

W.

Jernajczyk

Automatic

Human Sleep

Stage

Scoring

Using Deep

Neural

Networks

Classification

based on

features using

Random Forest

and ANNs

Classification

based on raw

data using

ANNs

A noticeable

improvement

in the quality

of the

classification.

Research only

utilized two

datasets retrieved

from laboratories.

The networks are

expected to

perform better if

trained with more

datasets.

Page 27: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

15

R. Riener

J.

Buhmann

P.

Achermann

(2018)

Deep neural

networks

Recurrent

neural networks

Page 28: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

16

CHAPTER 3

METHODOLOGY

3.1 Introduction

This chapter will discuss the methodology used in the development of this application.

A project's success will hinge on the quality of planning and execution of the project

management methodology. It should be organized in a way that the problems are solved

systematically and scientifically to effectively achieve the objectives of the project. A

successful project possesses the characteristics of great planning, efficient scoping and

resourcing, realistic expectations, and rigid management support. The development of

this project utilized the System Development Life Cycle (SDLC) to facilitate the

development from its beginning until its conclusion. SDLC is a strong guideline for

project development, providing an adaptive yet consistent medium for changes

throughout the development to meet the project's goals.

For this chapter, section 3.2 will describe and justify the methodology chosen for this

project while section 3.3 will elaborate on the phases involved in the chosen software

development methodology. Furthermore, section 3.4 will list all the system

requirements for the development of this project. Lastly, section 3.5 will encompass the

critical components of system design such as context diagram, data flow diagram, entity

relationship diagram, and use case diagram.

Page 29: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

17

3.2 Methodology Selection

The methodology chosen for the development of this system is the Waterfall Model.

Being of the earliest Software Development Life Cycle approach, the Waterfall Model

is easy to understand and use. In this approach, the process is linear and sequential

where each phase must be completed in order before the subsequent phase can begin.

There is no backtracking as the process resembles a waterfall where the water cannot

go back up the fall.

This model is suitable for projects with specified goals and specifications. Following

this approach, projects that require constant changes should not be carried out as this

model lacks flexibility. If the project has stringent deadlines, then the Waterfall Model

allows to project to be completed while adhering to the time limits assuming that

adequate resources are available.

The Waterfall Model is divided into six (6) phases, Requirements Analysis, System

Design, Implementation, Testing, Deployment, and Maintenance.

Figure 3.1 - Waterfall Model

Page 30: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

18

Figure 3.1 is an illustration of the Waterfall Model framework, showing the

development cycle from planning phase until the deployment phase.

Page 31: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

19

3.3 Methodology Phases

The Waterfall Model of software development encompasses in six (6) successive

phases:

3.3.1 Requirements Analysis Phase

The first phase of the Waterfall Model. It primarily involves conducting a study on the

system requirements. The specifications of the final product are studied and considered

for the development. It is imperative that the limitations and constraints that can

considerably affect the development process are thought-through. Overall, the problem

statement, objectives, scopes, and expected result are studied and identified in this phase

3.3.2 System Design Phase

In this phase, the requirement specifications developed from the Requirements Analysis

phase are studied so the system design can be constructed. The system design will

specify the hardware and system requirements such as the data layers, programming

languages, user interfaces, and so forth. The comprehensive system architecture is also

detailed which consists of high-level design and low-level design.

During this phase, the Context Diagram, Data Flow Diagram, and Entity Relationship

Diagram are made to illustrate the software's data flow and processes. Any changes can

still occur during the Implementation phase due to user requirements.

Page 32: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

20

3.3.3 Implementation Phase

Once the requirements and design phase are completed, the next step in the SDLC of

this model is the Implementation phase, also known as the actual development stage of

the software.

This phase involves the software development proper where the source code is written

in accordance with the requirements. The system is developed in small programs called

units, which are later combined in a process called integration. The individual units are

also verified by the developer through Unit Testing.

3.3.4 Testing Phase

In this phase, the source code developed from the Implementation phase is passed over

to the testing team. The testers will thoroughly check the programs for any potential

defects, by executing test cases either manually or via automation using test scripts. In

addition, the client is also directly involved in this phase to ensure the intended

requirements are achieved. To fulfil Quality Assurance (QA), the bugs and flaws found

during testing must be fixed.

3.3.5 Deployment Phase

This is the phase where the software is deployed into a live environment, such as the

client's own server, with the intention of evaluating its performance and functionality.

Once deployment has occurred, the software itself becomes available to end-users.

Additionally, this phase serves to train real-time users to express the advantages of the

system.

Page 33: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

21

3.3.6 Maintenance Phase

After the deployment phase, the following step is to provide support and maintenance

for the software, making sure it operates smoothly and as expected. If the client and

users encounter errors, defects, or bugs during normal use, then it is important to resolve

them during this phase.

Page 34: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

22

3.4 System Requirement

System requirement is the essential components needed to run the system on a platform.

There are two requirements that need to be met in the development process, hardware

requirement and software requirement. The tables below show the hardware and

software needed.

3.4.1 Hardware Requirement

The specific hardware requirement used in the development of this project is shown in

Table 3.1 below.

Table 3.1 - List of Hardware Requirement

HARDWARE DESCRIPTION

Custom-built Desktop PC

• Desktop PC used for documentation and

development of mobile application

❖ AMD Ryzen 5 2600 Six-Core 3.4GHz

❖ 16GB DDR4 RAM

❖ RTX 2060 Super 8GB

❖ 512GB NVMe SSD

❖ Windows 10 64-bit, x64 based processor

One Plus 7T

• Android 10 smartphone to test and run application

• Qualcomm Snapdragon 855+ (7nm)

• 8GB RAM

Honor 8

• Android 7 smartphone to test and run application

• Kirin 950 (16nm)

• 4GB RAM

Page 35: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

23

3.4.2 Software Requirement

The software requirement used in the development of this project is shown in Table 3.2

below.

Table 3.2 - List of Software Requirement

SOFTWARE DESCRIPTION

Android Studio Integrated Development Environment (IDE)

for developing Android-based applications

Microsoft Word Word processor by Microsoft for writing

report and proposal

Microsoft Excel

Spreadsheet used for calculation and tracking

specific data. Also used for creating Gantt

Chart

Mozilla Firefox A primary web browser used for conducting

most web searches

Google Chrome Another web browser as an alternative testing

platform

Dropbox A cloud-based data backup software used to

store backups of critical files

Visual Studio Code A free source code editor by Microsoft

XAMPP 3.2.4 A free open-source web server to run local

server and database

Weka 3.8.4 Machine learning tool used for data analysis

and data modelling

diagrams.net

A free online diagram software, used to sketch

the Context Diagram, Data Flow Diagram, and

Entity Relationship Diagram

Page 36: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

24

3.5 System Design

System design is the method of establishing elements of the system based on the

specified specifications, such as modules, architecture, components and their interfaces,

and data for the system. This method aims to identify, implement, and construct the

system that satisfies the business or organization's needs and requirements.

3.5.1 Context Diagram (CD)

The context diagram is used to evaluate the context and limits of the system to be

modelled: which entities are modelled inside and outside the system, and what the

system's relationships have with these external entities. A context diagram is also called

a level-0 data-flow diagram, a top-level diagram drawn to describe and explain the

limits of the software system. It defines the data flows between the system and the

external entities. The whole software system is seen as a singular process

Figure 3.2 - Context Diagram

Page 37: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

25

The Context Diagram for Sleep Assistance Using Artificial Neural Network is shown

in the Figure 3.2. The "SNNA System" stands for Smart Neural Net Alarm System,

which is the central process in the diagram. The two entities placed on either side of the

central process are the User and the WEKA. The User entity will have to register and

login before they can enter their health details and desired sleeping times, to which in

return the system will generate a personalized alarm schedule which will alert the user

when to sleep and wake up. The WEKA entity will feed the training data to the system's

neural network engine.

Page 38: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

26

3.5.2 Data Flow Diagram (DFD)

Often shortened as DFD, data flow diagrams are utilized to graphically represent the

flow of data in a business information system. DFD presents the processes that are

involved in the movement of data from the input to the storage of files and generating

reports. Data flow diagrams can be separated into physical and logical. The physical

data flow represents the implementation of the logical data flow. The logical data

defines the flow of data through the system to execute certain tasks of a business.

Figure 3.3 - Data Flow Diagram Level 0

Page 39: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

27

Figure 3.3 shows the Level 0 of the Data Flow Diagram. There are two external entities,

five processes, and four data stores. The external entities are the User and WEKA.

The User entity has three input data flows, which moves the data “user details”, “health

details”, and “target schedule” into its respective processes. The “user details” is

processed by User Management process and then stored in the User Profile data store.

Meanwhile, the “health details” is processed by the Health Detail Management process

and stored in the Health Profile data store. Afterward, the “target schedule” gets

processed by the Target Sleep Schedule process which is then stored in the Sleep Pattern

Profile data store. The WEKA entity only has one data flow, which is moving the

“training data” into the Neural Network Engine process. The data stored in the Health

Profile and Sleep Pattern Profile is used as inputs for the Neural Network Engine

process, which is responsible for creating the alarm data. This data is stored in the Alarm

Schedule Profile data store and is used by the Smart Alarm process to create the alarms

schedule for the User.

Page 40: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

28

3.5.3 Entity Relationship Diagram (ERD)

The entity relationship diagram illustrates the relationships of entity sets contained in a

database. An entity is an object, the data portion in this sense, while an entity set is the

series of related entities. These entities can have attributes that specify its properties.

An ER diagram demonstrates the logical structure of databases by describing the

entities, their attributes, and illustrating those entities' relationships. There are numerous

symbols and connectors in an ERD that visualise the essential data.

Figure 3.4 - Entity Relationship Diagram

Page 41: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

29

3.5.4 Use Case Diagram (UCD)

A use case diagram is the primary type of system or software requirements for a new

software program underdeveloped. Use cases define the "what" and the "how". The

"what" is the desired behaviour while the "how" is the non-precise way of making it

happen. Use cases once established can be denoted both textual and visual

representation, in a form of use case diagram. The core concept of use case modelling

is that it allows one to build a system from the perspective of an end-user. It is an

effective technique to convey system behaviour in the user's terms by identifying all the

externally visible system behaviours.

Figure 3.5 - Use Case Diagram

Page 42: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

30

Figure 3.5 shows the Use Case Diagram of the system. There is only one active actor,

the User. Then there are about seven use cases that are interactable by the actor User.

User can opt to register an account in order to access more information. They can also

view their profile, with or without having to log into the system. As part of the view

profile use case, User can also manage their profile and manage their health details. The

User can primarily use the Smart Alarm, which notifies them when they need to sleep

or wake up.

Page 43: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

31

REFERENCES

Ebrahimi, F., Mikaeili, M., Estrada, E., & Nazeran, H. (2008). Automatic sleep stage

classification based on EEG signals by using neural networks and wavelet packet

coefficients. Proceedings of the 30th Annual International Conference of the IEEE

Engineering in Medicine and Biology Society, EMBS'08 - "Personalized Healthcare

through Technology," February, 1151–1154.

https://doi.org/10.1109/iembs.2008.4649365

Lajnef, T., Chaibi, S., Ruby, P., Aguera, P. E., Eichenlaub, J. B., Samet, M., Kachouri,

A., & Jerbi, K. (2015). Learning machines and sleeping brains: Automatic sleep stage

classification using decision-tree multi-class support vector machines. Journal of

Neuroscience Methods, 250, 94–105. https://doi.org/10.1016/j.jneumeth.2015.01.022

Malafeev, A., Laptev, D., Bauer, S., Omlin, X., Wierzbicka, A., Wichniak, A.,

Jernajczyk, W., Riener, R., Buhmann, J., & Achermann, P. (2018). Automatic human

sleep stage scoring using deep neural networks. Frontiers in Neuroscience, 12(NOV),

1–15. https://doi.org/10.3389/fnins.2018.00781

Mehrotra, Kishan, Mohan, Chilukuri K., Ranka, S. (n.d.). Elements of Artificial Neural

Networks - Kishan Mehrotra, Chilukuri K. Mohan, Sanjay Ranka - Google Books.

Retrieved January 6, 2021, from

https://books.google.com.my/books?lr=&id=6d68Y4Wq_R4C&oi=fnd&pg=PA1&dq

=artificial+neural+networks&ots=6ty4O1y3G7&sig=Ado4Nx8mxeqhefRdUjcM0b_o

Xzo&redir_esc=y#v=onepage&q=artificial neural networks&f=false

Price, R. K., Downey, T. J., Meyer, D. J., Spitznagel, E. L., Risk, N. K., & El-

Page 44: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report

32

Ghazzawy, O. G. (2000). Applying artificial neural network models to clinical decision

making. Psychological Assessment, 12(1), 40–51. https://doi.org/10.1037/1040-

3590.12.1.40

Ronzhina, M., Janoušek, O., Kolářová, J., Nováková, M., Honzík, P., & Provazník, I.

(2012). Sleep scoring using artificial neural networks. Sleep Medicine Reviews, 16(3),

251–263. https://doi.org/10.1016/j.smrv.2011.06.003

Page 45: MUHAMMAD 'ALIUDDIN BIN AZMI...Name: Muhammad' Aliuddin bin Azmi Date: 31 January 2021 ii CONFIRMATION This is to confirm that: The research conducted and the writing of this report