Detection and segmentation the affected brain using ThingSpeak platform based on IoT cloud analysis

The world has accelerated around a new industrial revolution called the Internet of Things, as this technology is expected to enter all aspects of industrial life, commercial and civil applications. The Internet of Things stands for highly important applications in the world of medical applications, which is the access to linking all medical clinics in the world into a single network capable of analyzing patient data and presenting it to medical professionals anywhere in the world. One of the medical applications in the Internet of Things is the discovery of a healthy human brain. This work proposes a health care system based on medical image analysis processes in the programmable ThingSpeak platform using MATLAB built into the platform within the cloud. The analysis is done using the MATLAB program within the Windows operating system and then the analysis is performed within ThingSpeak platform. The analysis includes classification process by using SVM classifier linear kernel in which we achieved 99.4% classification rate as well as using RBF kernel, which achieved 98.6% classification accuracy in classifying infected brains from healthy ones and the work was supported by cross validation technology to ensure effective classification accuracy. The patient brain is segmented then the tumor segment is isolated, its area is calculated, and the tumor boundaries are found, based on the k-mean technique, to support the specialist doctor when performing the analysis process in the cloud environment. Through this work we achieved a match in the analysis processes within the local environment, and ThingSpeak platform environment by 100%, and in order to support our work, we have automated the analysis, visualization and data transfer processes within the cloud and MATLAB environment.


Introduction
Internet platforms are considered technical things that have a large development community in all parts of the world, analyze which means greater opportunities to solve problems and exchange experiences, especially in the medical field and health care, and their ability to integrate with various applications such as smart phones, The ability to schedule tasks and events, collect data, and visualize it within the cloud environment. Researchers are studying the use of supervised and unsupervised machine learning, as well as augmented machine learning in Internet of Things (IoT) technology, Wireless Sensor Network (WSN) technology, and some applications of machine learning algorithms according to these technologies [1]. The researchers shed light on the techniques used in brain segmentation and machine learning methods and comparison between them, in addition to hybrid techniques for the importance of these different techniques in detecting brain tumors [2]. Researchers present a survey of the emerging paradigm of IoT with the target of providing insights into this model and identifying the main current technologies and future challenges with several testified solutions. Researchers have presented the Internet of Things as information and communication technology system located in the field of Cyber Physical Systems (CPS), and IoT has been discussed as an emerging paradigm covering countless areas [3]. Researchers have systematically surveyed brain tumor segmentation techniques and classification of abnormal and normal state from MRI images using various methods and consists of presentation and quantitative investigation of segmentation techniques and conventional classification. [4]. Using the various applications of IoT and linking machine learning to those applications, as it has been suggested to use home devices with machine learning (ML) to conserve energy and smart urban planning, as well as to use machine learning for diagnosis in health care with the latest computerized technologies to detect human diseases. [5]. The researchers provided a summary of the types and tasks of machine learning and its applications in relation to IoT, the possibility of machine learning in giving greater accuracy in calculations and prediction and its ability to deal with a lot of information in short periods of time (analysis in real time) [6]. An automated system is applied to detect a brain tumor. It is used to extract the features, implement linear SVM and use the K-mean algorithm for brain segmentation. Support Vector Machine algorithm classifies tumors into malignant and benign tumors, and after image recognition and characteristics, it has been added to SVM database to increase system accuracy [7]. The use of segmentation for brain tumor detection for an MRI image, including the use of the k-mean algorithm for brain segmentation and the support vector machine (SVM) in the classification processes [8]. The process of dividing the brain into normal and abnormal tissue by using different analysis methods starting with pre-processing to de-noise and Berkeley wavelet to extract features and for the purpose of detecting tumor stages, a support vector machine (SVM) was used [9].Research in the major applications of machine learning of IoT as well as other applications such as advanced computing infrastructure, network management and typical IoT applications [10]. The researchers investigated current approaches to techniques used in segmentation of brain tumor for magnetic resonance imaging for the purpose of computer-aided diagnosis [11]. Presenting a study to detect brain tumor growth in each slice of the MRI image using the Kmean clustering algorithm and calculating the tumor area and surrounding in pixels [12]. Researchers are working to provide a classification of machine learning algorithms and how to apply different technologies to data for extracting higher-level data, in addition to discussing the potential challenges of machine learning in analyzing IoT data. A use case presented for the Support Vector Machine (SVM) application on traffic data [13]. Researchers present a brief questionnaire of basic concepts of algorithms used in machine learning and its applications, including supervised and unsupervised methods, and deliberate applications of machine learning algorithms in various fields involving the Internet of Things (IoT) and health monitoring [14].
This study aims to advance the accuracy of MRI brain tumor classification and help the specialist make an accurate decision. Thus, it makes the following contributions: • Linear KSVM algorithm is proposed to detect normal and abnormal brains based on true Pixel value.
• It suggests a new simpler feature-extraction method for categorizing normal and abnormal brain.
• Makes K-fold cross validation to estimate the proposed algorithm.
• Use of locally used technologies within the cloud in the ThingSpeak platform.
• Matching local analysis with cloud MRI analysis.
• Use the performance metric to verify the accuracy of the work.
• To propose an automated healthcare system. This paper is structured as follows: Section 2: Provides an explanation of the proposed algorithms with an explanation of the K-fold cross validation method used to evaluate the proposed model. Section 3: includes an explanation of IoT technology, the concept of the cloud, and the platform used to analyze and visualize the data. Section 4: includes the definition of the healthcare concept and the proposed healthcare network. Section 5: displays the consequences of the proposed work. Section 6: discusses the paper results. And Section 7: concludes the entire work.

Proposed method
The work of this paper uses data collected by The Cancer Imaging Archive (TCIA) [15]. Our proposed method designs an algorithm for classifying MRI images and detecting a brain tumor, it isolates and finds the boundaries of the brain tumor, and calculates the tumor area within the Internet of Things platform (ThingSpeak) using the MATLAB program as an intelligent tool integrated into the platform. Additionally, apply the suggested policy within the Windows operating system environment. The figure 1 shows a flowchart of the proposed method.

Improving MRI images (Noise cancellation)
The process of improving digital images is one of the important and extensively used stages in the field of image processing, and because digital images are exposed when dealing with them or sending them through certain channels to noise or interference, so it is necessary to use methods and methods to filter them from noise . Digital images filters may be applied in the spatial or frequency domain [16].

K-Fold Cross validation
Since the classifier used is trained by a specific set of data, this results in a high classification accuracy of the training data only. Consequently, we need a technique for validating the method used. Cross validation will not increase the final classification accuracy but it does give reliability to the classifier used and can be generalized to other independent data sets. Datasets are randomly divided into separate k-folds of approximately equal size, and each fold is employed for testing the induced model. A classifier is evaluated by an average accuracy of k [17].
Where k: number of experiments.

Kernel support vector machine (KSVM Classifier)
Support Vector Machine stands for a supervised learning algorithm for analysing the data in order to classify it statistically and accomplish the necessary regression analysis. The input to the process is part of the data to check the algorithm, and its working principle is based on finding the hyper plane [18,19]. The Support Vector Machine (SVM) is trained based on the pixel values of brain images with a size of (200 x 200) pixels. In other words, pixel values are used as a feature that reflects the diversity in the shapes of the images. The linear kernel function is usually described as follow: The RBF kernel function depends on its calculation of the distance from some point. It describes as follow: Where ||xxi || is Euclidean distance between x & xi, and kernel function parameter. Performance metric (accuracy, sensitivity, and specificity) can evaluate the achieved consequences by the KSVM [20]. They are probability measures of classification accuracy. Accuracy is a measure of classification of a data set, sensitivity is a measure of expected abnormalities, and specificity is a measure of expected normal states. Table 1 explains the calculations of evaluation metrics.

K-means clustering
The clustering is the process of targeting the affected area in the brain. When the brain is classified as a patient, brain is segmented using (K-Means), and isolate the tumor area [21]. Is a method for the purpose of vector quantization, which aims to divide data into k-clusters, where each element belongs to a block with the nearest average (centroid) which represents an initial model for the block [22].
To calculate the number of pixels and area of the tumor region, equations (4) and (5)

Internet of things
The Internet of Things (IoT) describes a network of physical objects related to sensors, software and other technologies to exchange data on Internet with other devices and systems [23]. Driven by the convergence of numerous technologies, real-time analyses (which enable them to share information in real time without human involvement), machine learning, sensors, and embedded systems [24], the evolution of things takes place. The IoT is enabled by the wireless sensing network, control and automation systems (such as home automation, building automation, etc.) and health systems. Physical objects can share and collect data with minimal human intervention by means of low-cost computing, mobile and cloud technologies. Every interaction between connected objects can be recorded, monitored, and managed by digital systems [25].

Cloud and data analysis
The cloud refers to the servers that can be accessed over the Internet and the programs and databases running on those servers. Cloud servers are located in data centers around the world. With cloud computing processes, users and companies do not have to manage physical servers themselves or run programs and applications on their devices .The cloud gives users the ability to access files and applications from any device, because computing and storage operations are on servers in data centers, rather than on the user's device [26].

ThingSpeak platform
ThingSpeak is an open source IoT application and API used in the "HTTP and MQTT" protocol to store and retrieve data from objects through the Internet. ThingSpeak has built-in MATLAB digital software that allows users of ThingSpeak to scan and visualize uploaded data using MATLAB [27,28,29].

MATLAB visualizations in ThingSpeak platform
With the built-in MATLAB engine in ThingSpeak, it is possible to perform calibration, analytics development, and IoT data transformation. ThingSpeak Commercial License can also use MATLAB Toolboxes for machine learning and signal processing, provided there is a license for the toolbox [29,30].

MATLAB analysis in ThingSpeak platform
ThingSpeak platform enables developers to use MATLAB to develop their own data analysis applications. Interactive functions and applications help design accurate and fast predictive models. It can then be deployed in the target systems .ThingSpeak platform is open source, which means that the source code can be edited ,this makes application development and data analysis easy and accessible [28,29,30].

Internet of things healthcare
Patient contact with doctors had been restricted to visits, telephone calls and text messages prior to the Internet of Things. Doctors or hospitals could not continuously monitor a patient's health and make recommendations. Medical devices that support the Internet have facilitated remote monitoring in the field of health care, maintained the security and health of patients and made it possible for doctors to provide high-level healthcare, and facilitated, faster and more efficient interactions with doctors. Furthermore, remote patient health monitoring helps reduce hospital stays and prevent re-entry. The Internet of Things also has a major impact on cost reduction and treatment improvement.
The Internet of Things is changing healthcare systems by defining the space for devices and people interacting in providing healthcare solutions. The Internet of Things has applications in healthcare that benefit patients, doctors, hospitals, as well as insurance companies [31,32,33]. Figure 3 represents a proposed automated health system where computerized MRI images are sent through the system's network to the regulator unit, which represents a control unit belonging to the public network. The person in charge of this unit manages the processes of receiving the magnetic resonance images and uploading them to the safe website(https://www.dropbox.com/h). Where they are read in form automatically by the specialist in brain tumor when log to the thingSpeak platform and start the analysis and visualization of the image by operating the automated system, diagnosing the patient's condition and sending a case report to the organizer unit through e-mail.

Proposed automated healthcare system
. Figure 3. Data flow across the healthcare network

Rersults and evaluation
In this paper, we assessed the performance of the classifier using the k-fold technique in order to ensure a high level of classification sensitivity without the occurrence of an overfiting problem. To support the cross validation analysis we used five folds of 250 MRI images divided into training and test data for the proposed model, which represent the input to the validation algorithm, and obtained a rating of 98.4% and 97.2 for linear and RBF classes respectively as shown in Table 2. In order to support the brain tumor specialist in diagnosing Patient MRI images When performing image analysis on the ThingSpeak platform, we carefully isolated the tumor fraction and found the boundaries and area of the tumor as shown in Table 3.
• Linear Kernel Accuracy = 100-(0.016*100) = 98.4 % • RBF Kernel Accuracy = 100-(0.028*100) = 97.2 % Table 2. KSVM -Cross validation The classification process using the linear-core SVM classifier enhanced by the k-mean technique gave good results inside the cloud in classification and clustering operations, and by using the analytical power of the MATLAB program built into the ThingSpeak platform gave identical analysis resultes with the local analysis.
The approach used in the analysis and matching processes enabled us to propose an automated healthcare system, based on the Internet of Things (IoT) protocols and the creation of application programming interface (API) keys that use the (MQTT, RESRful) protocols for sending text messages through the used applications and creation of a software architecture for interactive applications that use web services within the ThingSpeak platform,where we send images and are read and analyzed by the brain oncologists using the platform. A brain oncologist can access to ThingSpeak through an ID obtained from the organizer unit for the purpose of accessing the platform's account to perform the required analysis and automatically send a message to the regulator after a 30-minute period of analysis as shown in the figure 5 including the date on which the patient's final report.   Table 3 show an analysis of abnormal brain models in which the brain is divided into clusters and the tumor segment is isolated and its boundaries are found using an analytical program based on the k-mean segmentation principle and using four clusters where the tumor segment is isolated by finding the relationship that links the white pixels with their neighbors within the fourth cluster, depending on the "region" characteristic.

Results of validation methods
We evaluated the validations of the proposed model, and in order to improve medical image analysis in the cloud, we used a confusion matrix-based performance scale to calculate (accuracy, specificity, and sensitivity) according to the dataset listed in Table 4. The results obtained for evaluating the projected model using the techniques of cross validation and the evaluation of the model based on "test data" of the performance scale showed a close match in the accuracy results shown in the frequency chart in Figure 7 and the results of the cross-validation analysis in Table 2 and by using a linear kernel and an RBF kernel, respectively. Table 4. Data of proposed system Figure 7. Evaluation metrics for two classes

Discussion
Based on the above approaches and consequences, the MRI images are published on ThingSpeak platform for proposed system analysis. Linear KSVM is used as a classifier algorithm with k-mean algorithm for tumor segment isolation and a set of pre-processing. These algorithms are applied at the cloud level and rely on Cloud MATLAB functionality built within the ThingSpeak platform. A samples of MRI images of affected brains was successfully posted to the Thingspeak platform "https://thingspeak.com/apps/matlab_visualizations/369885" and the SVM algorithm for tumor detection was implemented locally using Matlab R2018a software and in the ThingSpeak platform as depicted in Figure 4. Therefore, based on the above results, we conclude that the proposed online classifier algorithm has outstanding processing consequences compared with the same algorithm applied locally and with a 100% match rate in the analysis and processing operations.

Conclusions
This research introduces a recent IoT-based AI technology through the ThingSpeak IoT platform. IoT technology has been employed to run the SVM classifier as an artificial intelligent over the cloud. .An automated healthcare system has been proposed using the ThingSpeak platform to detect brain tumors and obtain medical advice from specialized doctors in various countries of the world. The accuracy of the algorithm used was verified using different verification methods and the work was performed in two different environments to verify the accuracy of the work on the used platform, and benefit from ThingSpeak API switches to send messages and automate suggested work.