Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 42

CHAPTER 1

INTRODUCTION

1.1 ABOUT DOMAIN


Artificial intelligence (AI) refers to the field of computer science that
focuses on creating intelligent machines or systems that can perform tasks that
typically require human intelligence. AI aims to develop algorithms and models
that enable machines to perceive, reason, learn, and make decisions in a manner
similar to humans. AI systems are designed to analyse and interpret vast
amounts of data, recognize patterns, and extract meaningful insights to support
decision-making or perform specific tasks. These systems can learn from data
and improve their performance over time through the use of machine learning
algorithms.
Machine learning is a subfield of artificial intelligence (AI) that focuses
on the development of algorithms and models that allow computers to learn and
make predictions or decisions based on data, without being explicitly
programmed for specific tasks.

Deep learning is a subfield of artificial intelligence (AI) and machine


learning that focuses on training neural networks with multiple layers to learn
and extract hierarchical representations of data. It is inspired by the structure
and function of the human brain and aims to mimic the learning capabilities of
neural networks. In traditional machine learning algorithms, engineers typically
hand-engineer features that are then used to train models. Deep learning, on the
other hand, allows the model to automatically learn features from raw data
through multiple layers of interconnected nodes (neurons) called artificial
neural networks.

1
1.2 GOAL
The goal of this project is to provide individuals with an estimation or
likelihood of their risk for developing Alzheimer's disease based on the analysis
of their MRI scan data. This application aims to offer a user-friendly platform
where individuals can upload their MRI scans and receive a prediction or risk
assessment regarding their potential susceptibility to Alzheimer's disease. The
dataset for Alzheimer’s disease is classified into four stages i) Non demented ii)
Very Mild demented iii) Mild demented iv) Moderate demented. When user
uploads their MRI scan image the application predict the stage of their disease.
Risk Assessment: The application would analyse the MRI scan data using
machine learning algorithms or predictive models specifically trained on MRI
data related to Alzheimer's disease. It would then provide users with an
assessment of their risk or likelihood of developing Alzheimer's disease based
on the patterns in the MRI scans.

Early Detection: By leveraging advanced image analysis techniques, the website


would aim to identify potential signs of Alzheimer's disease-related
abnormalities or markers in the uploaded MRI scans. Early detection can help
individuals become aware of potential cognitive changes or risks and encourage
them to seek further medical evaluation or interventions.

Accessibility and Convenience: An online platform provides convenient access


to Alzheimer's disease risk assessment. Users can easily upload their MRI scans
from the comfort of their own homes, avoiding the need for physical
appointments or visits to medical facilities. This accessibility encourages more
individuals to undergo screening and assessment for Alzheimer's disease.

2
1.3 ARCHITECTURE

1.3.1 TECHNICAL ARCHITECTURE

Fig 1.3.1 Technical Architecture

3
1.3.2 FLOWCHART

Fig 1.3.2 Flowchart

4
CHAPTER 2
SYSTEM ANALYSIS

System analysis is a structured approach to understanding and evaluating the


components, processes, and interactions within a system. It involves studying
the system's requirements, functionalities, and constraints to ensure that it meets
the intended objectives and stakeholders' needs.

2.1 EXISTING SYSTEM


Developing an automated Alzheimer’s Disease detection and
classification model is a pretty challenging task. But there is some remarkable
research work in this area. Dimensional reduction and variations methods were
used by Aversen et al. [2] to analyse structural MRI data. They have used both
SVM binary classifier and multi-class classifier to detect AD MRI images using
Alzheimer’s Disease Neuroimaging Initiative (ADNI) database [9]. Brosch et
al. [3] developed a deep belief network model and used manifold learning for
AD detection from MRI images. Katherine Gray developed a multi-modal
classification model using random forest classifier to detect AD from MRI and
PET data [6]. Gupta et al. have developed a sparse auto encoder model for AD,
Mild Cognitive Impairment (MCI) and healthy control (HC) classification using
ADNI dataset [7]. HosseiniAs et al. adapted a 3D CNN model for AD
diagnostics [8]. Kloppel et al. used linear SVM to detect AD patients using T1
weighted MRI scan [10]. Liu et al. [12] developed a deep learning model using
a subset of ADNI dataset and classified AD and MCI patients. Liu et al. have
developed a multimodal stacked auto-encoder network using zero-masking
strategy. Their target was to prevent loss of any information of the image data.
They have used SVM to classify the neuroimaging features obtained from
MR/PET data [13].

5
2.2 PROPOSED SYSTEM
In this project we’re using pretrained Xception model in CNN as a feature
extractor. For one of the models, we will use it as a simple feature extractor by
freezing all the five convolution blocks to make sure their weights don’t get
updated after each epoch as we train our own model. Here, we have considered
Image of dimesion (180,180.3). Also, we have assigned include_top = False
because we are using convolution layer for features extraction and wants to train
fully connected layer for our images classification(since it is not the part of
Imagenet dataset). For this purpose we have imported Sequential from
tensorflow.keras.models. As the name suggests it is used to arrange the Keras
layers in a sequential manner. Now from layers we are
importing GlobalAveragiPooling2D. GlobalAveragePooling2D accepts as input
4D tensor. It operates the mean on the height and width dimensionalities for all
the channels.
SeperableConv2D : This function is separable convolution which is a way to
factorize a convolution kernel into two smaller kernels.
BatchNormalization : Batch Norm is a normalization technique done between
the layers of a Neural Network instead of in the raw data. It serves to speed up
training and use higher learning rates, making learning easier.
ReLu activation function has been taken in the dense layers & softmax in the
output layer.
A dense layer is a deeply connected neural network layer. It is the most
common and frequently used layer. Let us create a model object named model
with inputs as resnet.input and output as dense layer.
The number of neurons in the Dense layer is the same as the number of classes
in the training set. The neurons in the last Dense layer, use softmax activation to
convert their outputs into respective probabilities. Understanding the model is a

6
very important phase to properly use it for training and prediction purposes. The
compilation is the final step in creating a model. Once the compilation is done,
we can move on to the training phase. After training the data we can save and
test the model. After successful testing build a webpage and integrate it with
model using flask.

2.3 FEASIBILITY STUDY


The feasibility of the project is analyzed in this phase, and a business
proposal is put forth with a very general plan for the project and some cost
estimates. During system analysis, a feasibility study of the proposed system
is to be carried out. This is to ensure that the proposed system is not a burden
to the developer. There are three key considerations involved in feasibility
analysis.

2.3.1 ECONOMIC FEASIBILITY


Assessing the economic feasibility of this project involves evaluating
the financial aspects and potential economic benefits of the project. Here are
some key considerations for the economic feasibility analysis:

1. Cost Analysis: Determine the costs associated with developing,


operating, and maintaining the website. This includes expenses such as
software development, web hosting, database management,
infrastructure, personnel, marketing, and ongoing maintenance.
Consider both initial investment costs and recurring expenses.
2. Revenue Generation: Identify potential revenue streams for the
website. This can include user fees for accessing the prediction
service, partnerships with healthcare providers or research institutions,
collaborations with pharmaceutical companies or clinical trials, or

7
advertising revenue. Evaluate the projected income from these sources
and estimate the potential revenue generation.
3. Market Demand and Size: Assess the market demand for
Alzheimer's disease prediction services and the potential user base for
the website. Analyze the target market size, growth potential, and
competitive landscape. Consider factors such as the prevalence of
Alzheimer's disease, public awareness, and the willingness of
individuals to pay for prediction services. Estimating the potential
market share and the number of users is essential for assessing the
economic feasibility.
4. Return on Investment (ROI): Calculate the potential return on
investment for the project. Compare the projected revenue generation
with the estimated costs to determine the ROI period. Consider the
timeframe for recovering the initial investment and achieving
profitability. Assess the sensitivity of the ROI to changes in factors
such as user adoption rate, pricing strategy, and market competition.
5. Economic Benefits: Evaluate the potential economic benefits of the
website. Consider the impact on healthcare costs and resource
allocation by facilitating early detection and preventive measures for
Alzheimer's disease. Assess the potential reduction in healthcare
expenses associated with early intervention and improved
management of the disease. Quantify the economic value generated by
the website's services.

2.3.2 TECHNICAL FEASIBILITY


Assessing the technical feasibility of an Alzheimer's disease prediction
website using MRI scans involves evaluating the technical requirements,
capabilities, and challenges associated with developing and operating the
website. Here are some key considerations for the technical feasibility analysis:
8
1. Data Acquisition and Processing: Evaluate the technical aspects of
acquiring and processing MRI data. Consider the compatibility of the
website with various types of MRI scanners and formats. Assess the
capability to handle large volumes of MRI data efficiently, ensuring data
integrity and security during storage and transmission. Evaluate the
availability of suitable data processing and image analysis algorithms to
extract relevant features from the MRI scans.
2. Computational Resources: Assess the computational resources required
for the website. Consider the computing power, memory, and storage
capacity needed to process and analyse the MRI data. Determine if the
existing infrastructure or cloud-based solutions can support the
computational demands of the prediction models and user interactions.
Evaluate scalability options to handle increasing user traffic and data
processing requirements.
3. Algorithm Development and Integration: Determine the technical
feasibility of developing and integrating machine learning algorithms for
Alzheimer's disease prediction. Evaluate the availability of suitable
algorithms and models for analyzing MRI data. Consider the expertise
and resources required to develop, train, and optimize the algorithms for
accurate prediction. Assess the compatibility and integration of the
algorithms with the website's backend infrastructure.
4. System Architecture and Scalability: Evaluate the technical
architecture required for the website. Consider the design of the frontend
user interface, backend processing, and database management. Assess the
scalability and performance of the system to handle multiple concurrent
users and data processing requests. Determine if the system can handle
future growth and increasing demand.

9
5. User Interface and Experience: Assess the technical aspects related to
the user interface and user experience (UI/UX). Design an intuitive and
user-friendly interface that allows users to easily upload MRI scans, view
results, and interact with the system. Consider responsive design
principles to ensure compatibility across different devices and screen
sizes. Evaluate the technical feasibility of incorporating visualization
techniques to present prediction results in a clear and understandable
manner.
6. Testing and Validation: Evaluate the technical feasibility of testing and
validating the website. Plan for rigorous testing procedures to ensure the
accuracy, reliability, and performance of the prediction models and user
interface. Consider techniques such as unit testing, integration testing,
and user acceptance testing to identify and address any technical issues or
bugs.

2.3.3 SOCIAL FEASIBILITY


Assessing the social feasibility of an Alzheimer's disease prediction
website using MRI scans involves evaluating the potential social impact,
acceptance, and ethical considerations associated with the project. Here are
some key considerations for the social feasibility analysis:

1. Social Impact: Assess the potential positive social impact of the website.
Consider how the early detection of Alzheimer's disease through the
prediction website can contribute to improved patient outcomes,
enhanced quality of life, and reduced healthcare costs. Evaluate the
potential benefits for individuals, families, caregivers, and the broader
community in terms of raising awareness, facilitating timely
interventions, and supporting appropriate care and support services.

10
2. User Acceptance: Evaluate the likelihood of user acceptance and
adoption of the website. Consider factors such as user preferences,
attitudes towards technology, and willingness to engage with online
healthcare services. Assess the potential barriers to user acceptance, such
as concerns about privacy, data security, or trust in the prediction models.
Understand the needs, expectations, and experiences of potential users to
ensure the website meets their requirements and addresses any potential
resistance.
3. Ethical Considerations: Evaluate the ethical implications of developing
and operating the prediction website. Consider issues such as informed
consent, privacy, confidentiality, and data ownership. Ensure that the
website adheres to ethical guidelines and legal requirements regarding the
use and storage of sensitive medical data. Assess the measures in place to
protect user privacy, handle data responsibly, and ensure transparency in
the prediction process.
4. Public Awareness and Acceptance: Evaluate the level of public
awareness and acceptance of Alzheimer's disease prediction and the use
of MRI scans for early detection. Assess whether individuals are
receptive to such technology-driven approaches and willing to participate
in the prediction process. Consider factors such as cultural beliefs, stigma
surrounding Alzheimer's disease, and the perceived benefits of early
detection.
5. User Engagement and Empowerment: Assess the potential for the
website to engage and empower users. Evaluate whether the website
provides users with valuable insights, risk assessments, and
recommendations for managing their health. Consider the user interface
design, educational resources, and interactive features that encourage user
engagement and promote a sense of empowerment and control over their
health.

11
CHAPTER 3
SYSTEM REQUIREMENTS

HARDWARE REQUIREMENTS

 Preprocessor : Intel Core i7


 RAM : 8GB
 Hard disk : 60GB
 Keyboard : Standard keyboard
 Monitor : 15 inch Colour Monitor

SOFTWARE REQUIREMENTS

 Operating System : Windows 10


 Front End : HTML, CSS, JAVASCRIPT
 Coding platform : Jupyter Notebook
 Web Framework : FLASK
 Back End : MySQL

12
CHAPTER 4
SYSTEM DESIGN

4.1 USE CASE DIAGRAM


A use case diagram is a visual representation of the interactions between
actors (users or external systems) and the system being analyzed or developed.
It helps to capture the functional requirements of the system from a user's
perspective. Here's the use case diagram for the application:

Fig 4.1 Use case Diagram

13
4.2 SEQUENCE DIAGRAM

A sequence diagram is used to illustrate the interactions between different


objects or components within a system over time. It shows the flow of messages
or method calls between the objects, allowing for a visual representation of the
dynamic behaviour of the system. Here's the sequence diagram for the
application:

Fig 4.2 Sequence Diagram

14
CHAPTER 5
SYSTEM IMPLEMENTATION

This project consist of four modules. The modules and their descriptions are
listed below:

1.Data Collection

2.Data Preprocessing

3.Model Building

4.Application Building

5. MODULE DECRIPTION
5.1 DATA COLLECTION
Alzheimer’s disease classified into four stages i) Non demented ii) very
mild dementia iii) mild dementia iv) moderate dementia.
The datasets collected and separated into test and train set

Fig. 5.1.1. Example of different brain MRI images presenting di fferent AD


stage. (a) Non demented; (b) very mild dementia ; (c) mild dementia; (d)
moderate dementia.

5.2 DATA PREPROCESSING

15
In this module we will be improving the image data that suppresses unwilling
distortions or enhances some image features important for further processing,
although performing some geometric transformations of images like rotation,
scaling, translation, etc.

5.3 MODEL BUILDING

Model building consist of five steps:


1. Pre-Trained CNN model as a feature extractor:
In this module for one of the models, we will use it as a simple feature
extractor by freezing all the five convolution blocks to make sure their
weights don’t get updated after each epoch as we train our own model. Here,
we have considered images of dimension (180,180,3). Also, we have
assigned include_top = False because we are using convolution layer for
features extraction and wants to train fully connected layer for our images
classification(since it is not the part of Imagenet dataset).
2. Create sequential layers:
For this purpose we have imported Sequential from
tensorflow.keras.models. As the name suggests it is used to arrange the
Keras layers in a sequential manner. Now from layers we are
importing GlobalAveragiPooling2D. GlobalAveragePooling2D accepts as
input 4D tensor. It operates the mean on the height and width
dimensionalities for all the channels.
3. Configure learning process:
The compilation is the final step in creating a model. Once the
compilation is done, we can move on to the training phase. The loss function
is used to find errors or deviations in the learning process. Keras requires a
loss function during the model compilation process.Optimization is an
important process that optimizes the input weights by comparing the
prediction and the loss function.

16
4. Train the Model
Train the model upto 16 epochs
5. Save the Model
6. Test the Model
Test the model with any image in the test set.

5.4 APPLICATION BUILDING

Building an application in HTML and integrating it with the model using flask.
Application consist of a Home page, MRI scan upload page and prediction
page.

5.4.1 HOME PAGE

User can login to home page and navigate to predict page to predict the
Alzheimer’s disease.

Fig 5.4.1 Home page

17
5.4.2 MRI SCAN UPLOAD PAGE
User can upload their MRI scan and click predict button to view the results.

Fig 5.4.2 MRI scan upload page

5.4.3 PREDICTION PAGE


User can view the predicted result.

Fig 5.4.3 Prediction page

18
CHAPTER 6
SYSTEM TESTING

In order to test the validity of the system, there are four possible testing steps are
carried out.
The details of testing activities are listed below.
a. Unit testing
b. Integration testing
c. System testing

6.1 UNIT TESTING


Unit testing is a software testing technique used to verify the individual
components or units of a system to ensure that they function correctly. In the
context of an Alzheimer's disease prediction website, unit testing can be
performed on various components or units of the system. Here are some
examples of unit tests that can be conducted:
1. Upload MRI Scan Unit Test:
 Test the functionality of the upload module by simulating the
upload of various types of MRI scan files.
 Verify that the uploaded files are properly received and stored by
the system.
 Test error handling for invalid or unsupported file formats.
2. MRI Scan Processing Unit Test:
 Test the pre-processing and validation module by providing test
data representing different MRI scans.
 Verify that the pre-processing steps, such as data normalization and
noise removal, are applied correctly.

19
 Validate the system's handling of exceptional cases, such as
missing or corrupt MRI scan data.
3. Prediction Generation Unit Test:
 Test the prediction engine by providing mock input data and
verifying the accuracy of the generated predictions.
 Compare the predicted results against expected outcomes for a set
of predefined test cases.
 Cover different scenarios, including positive and negative cases, to
ensure reliable predictions.
When performing unit testing, it is important to design test cases that cover
different scenarios, including normal and exceptional cases. Test inputs should
encompass a range of possibilities to validate the robustness and reliability of
the system's components. Additionally, automated testing frameworks and tools
can be employed to streamline the unit testing process and facilitate regression
testing as the system evolves.
By conducting thorough unit testing, you can identify and rectify any defects or
issues in the individual components of the Alzheimer's disease prediction
website, ensuring the reliability and accuracy of the system's functionalities.

6.2 INTEGRATION TESTING


Integration testing is performed to verify the interactions and data flow
between different components or modules of a system. In the context of an
Alzheimer's disease prediction website, integration testing ensures that the
website, prediction engine, and other external systems or APIs work together
correctly. Here are some examples of integration tests that can be conducted:

1. Upload MRI Scan and Processing Integration Test:


- Simulate the upload of an MRI scan file through the website's user interface.

20
- Verify that the uploaded scan is correctly received by the website and
forwarded to the prediction engine for processing.
- Validate that the pre-processing and validation steps are executed
successfully on the received MRI scan data.
2. Prediction Generation and Result Display Integration Test:
- Perform a test where the prediction engine generates a prediction based on a
predefined set of MRI scan data.
- Ensure that the prediction results are correctly retrieved by the website.
- Validate that the prediction results are displayed accurately to the user
through the website's user interface..
3. External System/API Integration Test:
- If the Alzheimer's disease prediction website interacts with external systems
or APIs, perform integration tests to ensure proper communication and data
exchange.
- Test scenarios such as retrieving patient data from a healthcare database,
integrating with electronic health record systems, or connecting to research
platforms for data sharing.
- Verify that data is exchanged accurately and securely between the website
and the external systems or APIs.
4. Error Handling and Exception Scenarios Integration Test:
- Conduct tests to validate the system's behaviour in error or exceptional
scenarios.
- Simulate scenarios such as network errors, system failures, or unexpected
responses from external systems.
- Verify that the website handles these scenarios gracefully, providing
appropriate error messages or fall back mechanisms to maintain user experience
and data integrity.
During integration testing, it is crucial to ensure that the interactions between
different components or systems are thoroughly tested to identify any issues

21
related to data exchange, communication protocols, or compatibility. Automated
testing tools and frameworks can be employed to streamline the integration
testing process and facilitate regression testing as the system evolves.
By performing comprehensive integration testing, you can verify the correct
functioning and interoperability of the various components of the Alzheimer's
disease prediction website, ensuring seamless integration and reliable operation
of the system as a whole.

6.3 SYSTEM TESTING


System testing is performed to evaluate the complete system's compliance
with the specified requirements and to ensure that it functions as expected. In
the case of an Alzheimer's disease prediction website using MRI scans, system
testing involves testing the entire system to validate its overall functionality,
performance, and usability. Here are some examples of system tests that can be
conducted:

1. Functional Testing:
- Test the functional requirements of the website by executing various user
scenarios, such as uploading MRI scans, viewing prediction results, and
managing user accounts.
- Verify that all system functions and features work as intended and meet the
specified requirements.
- Validate the accuracy of prediction results generated by the system.
2. User Interface Testing:
- Test the user interface of the website to ensure it is user-friendly, intuitive,
and responsive.
- Verify that all elements, buttons, forms, and links function correctly and
provide the expected user experience.

22
- Validate the compatibility of the website across different web browsers and
devices.
3. Performance Testing:
- Assess the website's performance under different load conditions, ensuring it
can handle a sufficient number of concurrent users.
- Measure and analyze response times, throughput, and resource utilization to
identify any performance bottlenecks or scalability issues.
- Validate that the system meets the performance requirements, such as
response time thresholds.
4. Usability Testing:
- Evaluate the website's usability by involving representative users to perform
specific tasks.
- Gather user feedback on the website's ease of use, intuitiveness, and overall
user experience.
- Identify areas for improvement and refine the user interface based on user
feedback.
5. Data Integrity Testing:
- Test the system's ability to handle and process different types of MRI scan
data without data corruption or loss.
- Validate that data is stored and retrieved accurately from databases or
external systems.
- Verify the system's data backup and recovery mechanisms.
6. Security Testing:
- Perform security testing to identify vulnerabilities and ensure the system's
protection against unauthorized access, data breaches, and other security threats.
- Test authentication and authorization mechanisms, data encryption, and
secure communication protocols.
- Validate compliance with security standards and best practices for handling
sensitive medical data.

23
7. Compatibility Testing:
- Test the website's compatibility with different operating systems, web
browsers, and mobile devices.
- Validate that the website displays and functions correctly across various
platforms, ensuring a consistent user experience.
8. Regression Testing:
- Perform regression tests to ensure that system modifications or bug fixes do
not introduce new issues or regress existing functionality.
- Re-run previously executed tests to verify that previously functional areas
remain unaffected by system changes.

By conducting thorough system testing, you can ensure that the Alzheimer's
disease prediction website using MRI scans meets the specified requirements,
performs reliably, and provides a satisfactory user experience. It helps to
identify and resolve any defects, performance issues, or usability concerns
before the system is deployed in a production environment.

24
CHAPTER 7
CONCLUSION AND FUTURE ENHANCEMENT

7.1 CONCLUSION
In conclusion, the project "Cognitive Care: Early Intervention for
Alzheimer's Disease" demonstrates the potential of utilizing MRI scans as
input and employing a pretrained Xception model in a convolutional neural
network (CNN) to display results. This innovative approach offers several
significant contributions:
Firstly, by leveraging MRI scans, the project enables early detection of
Alzheimer's disease, which is crucial for timely intervention and improved
treatment outcomes. The utilization of deep learning techniques and the
pretrained Xception model enhances the accuracy of the results, providing
reliable predictions.
Secondly, the project provides a non-invasive and cost-effective method for
diagnosing Alzheimer's disease. MRI scans are widely available and do not pose
any direct risks to patients, making this approach accessible to a broader
population. Furthermore, the personalized care facilitated by the CNN analysis
of individual MRI scans empowers healthcare professionals to tailor treatment
plans and interventions according to each patient's specific condition. This
personalized approach has the potential to optimize treatment outcomes and
improve the quality of life for individuals affected by Alzheimer's disease. The
time-efficient diagnosis offered by the automated nature of the CNN-based
analysis is another significant advantage. The deep learning model accelerates
the diagnostic process, providing prompt results and reducing patient anxiety.
Moreover, the scalability and accessibility of this project are noteworthy. Once
developed and validated, the methodology can be implemented in various

25
healthcare settings, reaching a larger number of patients and contributing to the
early detection and intervention of Alzheimer's disease.
Overall, the "Cognitive Care: Early Intervention for Alzheimer's Disease"
project showcases the potential of using MRI scans and a pretrained Xception
model in a CNN to facilitate early detection, personalized care, and prompt
intervention. These advancements hold promise for improving treatment
outcomes, enhancing the quality of life for individuals affected by Alzheimer's
disease, and advancing our understanding of this complex condition.

7.2 FTURE ENHANCEMENT


A potential future enhancement for the "Cognitive Care: Early
Intervention for Alzheimer's Disease" project could be the incorporation of
multimodal data fusion. Currently, the project utilizes MRI scans as the sole
input for the pretrained Xception model in the CNN. However, Alzheimer's
disease is a complex neurodegenerative condition, and integrating multiple
types of data could provide a more comprehensive understanding and
potentially improve the accuracy of predictions. By combining MRI scans with
other modalities such as functional MRI (fMRI), positron emission tomography
(PET) scans, and cognitive assessments, the project could leverage the strengths
of each data source to capture a broader range of information related to
Alzheimer's disease progression.
For example, fMRI data can provide insights into brain activity and functional
connectivity, while PET scans can offer information about metabolic changes
and the presence of specific biomarkers associated with Alzheimer's disease.
Cognitive assessments, on the other hand, can provide additional behavioral and
cognitive performance measures. The integration of these different modalities
could enable the development of a more robust and comprehensive predictive
model. By training the CNN on multimodal data, it could learn complex
relationships and patterns that are not evident in a single modality alone. This
26
enhanced model could potentially improve the accuracy of early detection and
intervention, leading to more targeted and effective treatment strategies.
Moreover, the inclusion of multimodal data fusion could also contribute to a
better understanding of the underlying mechanisms of Alzheimer's disease. The
combined analysis of structural, functional, and behavioural data could help
uncover new insights and correlations, leading to advancements in our
knowledge of the disease and potential therapeutic targets. However, it is
important to note that incorporating multimodal data fusion would require
careful data preprocessing, feature extraction, and model architecture design to
effectively combine and interpret the different data sources. Additionally, the
availability and cost of acquiring multiple types of data should also be
considered in the implementation of this enhancement. By capturing and
analysing MRI scans from the same individuals at multiple time points, the
project could track changes in brain structure and identify patterns of
progression specific to each patient. Longitudinal data analysis could enable the
detection of subtle changes over time that may not be apparent in isolated scans,
improving the accuracy of early detection and intervention.
Additionally, incorporating longitudinal data could facilitate the development of
predictive models that take into account the temporal aspect of Alzheimer's
disease. By considering the trajectory of changes observed in MRI scans, the
models could provide more personalized predictions regarding disease
progression and the potential effectiveness of different interventions.
Overall, the future enhancement of incorporating multimodal data fusion into
the "Cognitive Care: Early Intervention for Alzheimer's Disease" project holds
the potential to enhance the accuracy of predictions, improve treatment
outcomes, and advance our understanding of this complex neurological
condition.

27
APPENDIX 1
SAMPLE SOURCE CODE
MODEL
adp.h5
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from tensorflow.keras.layers import Dense, Flatten,
Input
from tensorflow.keras.models import Model
from tensorflow.keras.preprocessing import image
from tensorflow.keras.preprocessing.image import
ImageDataGenerator, load_img
from tensorflow.keras.applications.xception import
Xception, preprocess_input
from glob import glob
#Assigning a vriable and passing the folder path to
it
trainpath='/content/Alzheimers_Dataset/train'
testpath='/content/Alzheimers_Dataset/test'
#image preprocessing as per the given parameters
from tensorflow.keras.preprocessing.image import
ImageDataGenerator as IDG
IMG_SIZE = 180
IMAGE_SIZE = [180, 180]
DIM = (IMG_SIZE,IMG_SIZE)
ZOOM = [.99, 1.01]
BRIGHT_RANGE = [0.8, 1.2]
28
HORZ_FLIP = True
FILL_MODE = "constant"
DATA_FORMAT = "channels_last"
WORK_DIR='/content/Alzheimers_Dataset/train'
work_dr = IDG(rescale = 1./255,
brightness_range=BRIGHT_RANGE, zoom_range=ZOOM,
data_format=DATA_FORMAT, fill_mode=FILL_MODE,
horizontal_flip=HORZ_FLIP)
train_data_gen =
work_dr.flow_from_directory(directory=WORK_DIR,
target_size=DIM, batch_size=6500, shuffle=False)
#Handling imbalance data
train_data, train_labels = train_data_gen.next()
#before oversampling
print(train_data.shape, train_labels.shape)
#performing over-sampling of the data, since the
classes are imbalanced
#after oversampling
from imblearn.over_sampling import SMOTE
sm = SMOTE(random_state=42)
train_data, train_labels =
sm.fit_resample(train_data.reshape(-1, IMG_SIZE *
IMG_SIZE *3),train_labels)
print(train_data.shape, train_labels.shape)
#reshape train_data
train_data = train_data.reshape(-1, IMG_SIZE,
IMG_SIZE, 3)
#model building
IMAGE_SIZE = [180,180]

29
xcep_model = Xception(input_shape=IMAGE_SIZE+[3],
weights='imagenet', include_top=False)
for layer in xcep_model.layers:
layer.trainable=False
#creating sequential layers
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import SeparableConv2D,
BatchNormalization, GlobalAveragePooling2D, Dropout
custom_inception_model = Sequential([
xcep_model,
Dropout(0.5),
GlobalAveragePooling2D(),
Flatten(),
BatchNormalization(),
Dense(512, activation='relu'),
BatchNormalization(),
Dropout(0.5),
Dense(256, activation='relu'),
BatchNormalization(),
Dropout(0.5),
Dense(128, activation='relu'),
BatchNormalization(),
Dropout(0.5),
Dense(64, activation='relu'),
Dropout(0.5),
BatchNormalization(),
Dense(4, activation='softmax')
], name="inception_cnn_model")
import tensorflow

30
METRICS =
[tensorflow.keras.metrics.CategoricalAccuracy(name='a
cc'),
tensorflow.keras.metrics.AUC(name='auc')]
custom_inception_model.compile(optimizer='rmsprop',

loss=tensorflow.losses.CategoricalCrossentropy(),
metrics=METRICS)
custom_inception_model.summary()
history = custom_inception_model.fit(train_data,
train_labels, validation_data=(val_data, val_labels),
epochs=16)
custom_inception_model.save('/content/adp.h5')
#import load_model class for loading h5 file
from tensorflow.keras.models import load_model
#import image class to process the images
from tensorflow.keras.preprocessing import image
from tensorflow.keras.applications.xception import
preprocess_input
import numpy as np

model = load_model('/content/adp.h5')

img=image.load_img('/content/Alzheimers_Dataset/
test/VeryMildDemented/26
(44).jpg',target_size=(180,180))
x=image.img_to_array(img)
import numpy as np
x=np.expand_dims(x,axis=0)

31
img_data=preprocess_input(x)
img_data.shape
img_data.shape
model.predict(img_data)
output=np.argmax(model.predict(img_data), axis=1)
output

HTML CODE
home.html
<!DOCTYPE html>
<html>
<head>
<title> COGNITIVE CARE</title>
</head>
<body style="background-image: url('../static/add.jpg');background-
size:cover;background-repeat:unset;">
<div style="height: 50px;display: flex;align-items: center;justify-content:
space-between;">
<div style="display: flex; color: white;font-family: 'Courier New', Courier,
monospace;">
<img src="../static/icon.jpg" style="width: 30px;height: 30px;margin-top:
15px;">
&nbsp;
<h2>COGNITIVE CARE</h2>
</div>
<div style="display: flex;width: 400px;justify-content: space-around;font-
family: 'Courier New', Courier, monospace;">

32
<a href="#" style="color: white;text-decoration: none;" >Home</a>
<a href="#" style="color: white;text-decoration: none;">About us</a>
<a href="./index" style="color: white;text-decoration: none;">Predict</a>
<a href="#" style="color: white;text-decoration: none;">Contact us</a>
</div>
</div>

</body>
</html>

index.html
<!DOCTYPE html>
<html>
<head>
<title>COGNITIVE CARE</title>
<style>
body {
font-family: 'Courier New', Courier, monospace;
text-align: left;
background-image: url('../static/add.jpg');
background-color: violet; /* Replace 'background.jpg' with the path to
your background image */
background-size: cover;
background-repeat: no-repeat;
}

#content {
background-color: rgba(255, 255, 255, 0.7);
padding: 20px;

33
max-width: 500px;
margin: 0 auto;
margin-top: 50px;
margin-left: 20px; /* Adjust the margin value as per your preference */
border-radius: 10px;
}
</style>
</head>
<body>
<div id="content">
<h1>COGNITIVE CARE</h1>
<form id="uploadForm" action="/index" method="post"
enctype="multipart/form-data">
<label for="imageUpload"><b>Upload your MRI scan
here:<b></label>
<br>
<br>

<div style="position: relative; border: 1px solid black; width: 70px;


height: 30px; line-height: 30px; text-align: center;" >
Upload
<input type="file" id="imageUpload" name="image"
accept="image/*" style="opacity: 0; position: absolute; top: 0; left: 0; bottom: 0;
right: 0; width: 100%; height:100%;" />
</div>
</form>
<br>
<img id="uploadedImage" src="" width="300" style="display: none;">
<br>

34
<button id="predictButton" onclick="predict() " style="width:
300px;height: 30px;border-radius: 20px;">Predict</button>

<p id="predictionText"></p>
</div>

<script>
// Display uploaded image
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();

reader.onload = function (e) {


document.getElementById('uploadedImage').src = e.target.result;
document.getElementById('uploadedImage').style.display = 'block';
}

reader.readAsDataURL(input.files[0]);
}
}

// Handle file upload


document.getElementById('imageUpload').addEventListener('change',
function () {
readURL(this);
});

// Predict function
function predict() {

35
var form = document.getElementById('uploadForm');
var data = new FormData(form);

var xhr = new XMLHttpRequest();


xhr.open(form.method, form.action, true);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
var predictionText = document.getElementById('predictionText');
predictionText.innerText = xhr.responseText;
}
};

xhr.send(data);
}
</script>
</body>
</html>

Predict.html
<!DOCTYPE html>
<html>
<head>
<title>COGNITIVE CARE</title>
<style>
body {
font-family: 'Courier New', Courier, monospace;
text-align: left;
background-image: url('../static/add.jpg');
/* Replace 'background.jpg' with the path to your background image */

36
background-size: cover;
background-repeat: no-repeat;
}

#content {
background-color: rgba(255, 255, 255, 0.7);
padding: 20px;
max-width: 500px;
margin: 0 auto;
margin-top: 50px;
margin-left: 20px; /* Adjust the margin value as per your preference */
border-radius: 10px;
}
</style>
</head>
<body>
<div id="content">
<h1>COGNITIVE CARE</h1>
<h2>{{prediction}}</h2>
</div>

</body>
</html>

37
FLASK CODE
app.py
import numpy as np
import os
from tensorflow.keras.preprocessing import image
from tensorflow.keras.applications.xception import preprocess_input
from tensorflow import keras
import pandas as pd
import cv2
import tensorflow as tf
#flask utils
from flask import Flask, request, render_template
from werkzeug.utils import secure_filename
from tensorflow.python.keras.backend import set_session
from tensorflow.python.keras.models import load_model
from keras.models import load_model

global graph

tf.compat.v1.disable_eager_execution()
sess = tf.compat.v1.Session()

graph=tf.compat.v1.get_default_graph()

app = Flask(__name__)
set_session(sess)

@app.route('/',methods=['GET'])

38
def index():
return render_template('Home.html')

@app.route('/index')
def index1():
return render_template('index.html')

@app.route('/index', methods=['POST'])
def upload():
if request.method == 'POST':
#Get the file from post request
f = request.files['image']
#save the file to ./uploads
print(f.filename)
basepath = os.path.dirname(__file__)
file_path = os.path.join(basepath, 'uploads', secure_filename(f.filename))
print(file_path)
f.save(file_path)
img = image.load_img(file_path, target_size=(180, 180))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
img_data=preprocess_input(x)
print(img_data.shape)
#img_data.shape
#model._make_predict_function()
#sess = tf.compat.v1.Session()

with graph.as_default():
#sess = tf.compat.v1.Session()

39
#set_session(sess)
#with tf.Session() as sess:
#sess.run(tf.global_variables_initializer()
# with sess.as_default():

model = load_model('adp.h5')
output=np.argmax(model.predict(img_data), axis=1)

if output == 0:
text = "Mild Demented"
elif output == 1:
text = "Moderate Demented"
elif output == 2:
text = "Non Demented"
else:
text = "Very Mild Demented"

return render_template('predict.html', prediction=text)

if __name__ == "__main__":
app.run(debug=True)

40
REFERENCES

1. Ali, E.M., Seddik, A.F., Haggag, M.H.: Automatic detection and


classification of alzheimer’s disease from mri using tannn. International
Journal of Computer Applications 148(9) (2016)
2. Arvesen, E.: Automatic Classification of Alzheimers Disease from
Structural MRI. Master’s thesis (2015)
3. Brosch, T., Tam, R., Initiative, A.D.N.: Manifold learning of brain mris
by deep learning. In: International Conference on Medical Image
Computing and Computer-Assisted Intervention. pp. 633–640. Springer
(2013)
4. Deng, J., Dong, W., Socher, R., Li, L.J., Li, K., Fei-Fei, L.: Imagenet: A
large-scale hierarchical image database. In: Computer Vision and Pattern
Recognition, 2009. CVPR 2009. IEEE Conference on. pp. 248–255.
IEEE (2009)
5. Grady, C.L., McIntosh, A.R., Beig, S., Keightley, M.L., Burian, H.,
Black, S.E.: Evidence from functional neuroimaging of a compensatory
prefrontal network in alzheimer’s disease. Journal of Neuroscience
23(3), 986–993 (2003)
6. Gray, K.R.: Machine learning for image-based classification of
Alzheimers disease. Ph.D. thesis, Imperial College London (2012)

41
7. Gupta, A., Ayhan, M., Maida, A.: Natural image bases to represent
neuroimaging data. In: ICML (3). pp. 987–994 (2013)
8. Hosseini-Asl, E., Keynton, R., El-Baz, A.: Alzheimer’s disease
diagnostics by adaptation of 3d convolutional network. In: Image
Processing (ICIP), 2016 IEEE International Conference on. pp. 126–130.
IEEE (2016)
9. Jack, C.R., Bernstein, M.A., Fox, N.C., Thompson, P., Alexander, G.,
Harvey, D., Borowski, B., Britson, P.J., L Whitwell, J., Ward, C.: The
alzheimer’s disease neuroimaging initiative (adni): Mri methods. Journal
of magnetic resonance imaging 27(4), 685–691 (2008)
10. Klo¨ppel, S., Stonnington, C.M., Chu, C., Draganski, B., Scahill, R.I.,
Rohrer, J.D., Fox, N.C., Jack, C.R., Ashburner, J., Frackowiak, R.S.:
Automatic classification of mr scans in alzheimer’s disease. Brain
131(3), 681–689 (2008)
11. Litjens, G., Kooi, T., Bejnordi, B.E., Setio, A.A.A., Ciompi, F.,
Ghafoorian, M., van der Laak, J.A., van Ginneken, B., Sa´nchez, C.I.: A
survey on deep learning in medical image analysis. arXiv preprint
arXiv:1702.05747 (2017)
12. Liu, F., Shen, C.: Learning deep convolutional features for mri based
alzheimer’s disease classification. arXiv preprint arXiv:1404.3366
(2014)
13. Liu, S., Liu, S., Cai, W., Che, H., Pujol, S., Kikinis, R., Feng, D.,
Fulham, M.J.: Multimodal neuroimaging feature learning for multiclass
diagnosis of alzheimer’s disease. IEEE Transactions on Biomedical
Engineering 62(4), 1132–1140 (2015)

42

You might also like