Skip to content

Simple Spring Boot server for analyzing MRI images for potential impairment due to Alzheimer's Disease

Notifications You must be signed in to change notification settings

jtrull101/alz-detection-spring-boot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alzheimer's Disease Detection CNN - Spring Boot


Table of Contents
  1. Description
  2. Key Points
  3. Implementation Details
  4. Contact

Description

This Spring Boot server is primarily designed for diagnosing Alzheimer's Disease (AD) using synthetic or fictitious MRI images. Serving as a launching pad for future full-stack endeavors that integrate machine learning, this project encapsulated a total 6 weekdays, averaging 9 hours of work per day. While certainly limited to just fictitious images, this project provides a valuable foundation for learning, research, and innovation in the fields of Full Stack Java development and Machine Learning with Python integration.

(back to top)

Key Points

  1. Synthetic MRI Analysis: The server specializes in analyzing synthetic MRI images to simulate the diagnosis of AD with the assistance of AI
  2. Educational and Research Tool: This project provides a controlled environment for healthcare professionals, students and researchers to realize the impact AI could provide in early diagnosis of AD
  3. Explore Machine Learning Integration: As a starting point, this project demonstrates the potential integrations of Machine Learning into a Full Stack solution
  4. Use of Real Data: Due to the server supporting the injection of custom saved Tensorflow models, upon the development of a model that has high accuracy with real MRI images, that model can be loaded into this site and predictions with real MRI images can be run. Note that one should never take the findings of this ML model over their own medical providers

(back to top)

Implementation Details

Usecases

Name Description Finished Notes
User desires to see all models available to predict against
  1. The user accesses the Angular frontend
  2. The user can access the view all models endpoint to see all available models and select one
  3. The Angular frontend queries the Spring Boot server to return this list of all models
  4. On selection of a model, that model is treated as the 'active' model in Angular
User wishes to upload their own saved Tensorflow model
  1. The user accesses the Angular frontend
  2. The user selects the option to upload a saved model
  3. The user uploads their model
  4. The Angular frontend sends the uploaded file to the Spring Boot server
  5. If the file passes some preconditions, it is loaded into Tensorflow
  6. Success or failure returned to Angular
  7. On success, the user can access the view all models endpoint to see the new model and select it if desired
User desires to see information about the currently selected model
  1. The user accesses the Angular frontend
  2. The user selects the option to view current model details
  3. The Angular frontend sends a get request for the current model to the Spring Boot server
  4. The Spring Boot server checks if the desired model is in the database, and if true, return the model
  5. Success of failure returned to Angular
Currently not many details to show, only model ID and name
User desires to delete the currently active model
  1. The user accesses the Angular frontend
  2. The user has already selected a model to be active, or must do so now. See prior usecase for more details
  3. The user navigates to the delete endpoint
  4. The user confirms their desire to delete the active model
  5. The Angular server sends the delete request to the Spring Boot backend
  6. If the modelId==1, the Spring Boot server returns a failure, we cannot delete the default model
  7. The Spring Boot server deletes the desired model by ID from the in-memory models and the database
  8. User is able to make requests after this because Angular has reset its active model back to default
User desires to delete all currently loaded models
  1. The user accesses the Angular frontend
  2. The user access the delete all models endpoint
  3. The user confirms their desire to delete all models
  4. The Angular server sends the delete request to the Spring Boot backend
  5. All models except the default model are removed from the Spring Boot in-memory models and the database
  6. Success or failure returned to Angular
  7. User is able to make requests after this because Angular has reset its active model back to default
User desires to have an MRI of their own or someone close to them analyzed
  1. The user accesses the Angular frontend
  2. The user selects a model from which to predict their MRI
  3. The user uploads their MRI to Angular
  4. Angular sends the MRI image to the Spring Boot server
  5. The Spring Boot server processes the file, ensuring its an image, and passing it to the predictive model
  6. The Spring Boot server returns the result to the Angular server
  7. The Angular service shows a predicted level of Impairment due to AD with a confidence rating
User desires to see how the predictive model works with a random test image
  1. The user accesses the Angular frontend
  2. The user selects a model from which to predict their MRI
  3. The user selects the option for random prediction in Angular
  4. Angular sends a random prediction request to the Spring Boot server
  5. The Spring Boot server finds a random image and passes it to the predictive model
  6. The Spring Boot server returns the result to the Angular server
  7. The Angular service shows a predicted level of Impairment due to AD with a confidence rating. Because this was one of the supplied test images, the actual value of Impairment will also be shown
User wishes to get the results from a prior MRI prediction
  1. The user accesses the Angular frontend
  2. The user selects the model from which the prediction was originally fetched
  3. The user selects the option to get prediction by ID in Angular
  4. The user inputs the desired prediction ID to fetch
  5. Angular sends the get request to the Spring Boot server
  6. The Spring Boot server searches its database of predictions and returns the result if present
  7. The Angular service shows the predicted levels of Impairment for that MRI image
For security, user wishes to delete MRI image from prediction database
  1. The user accesses the Angular frontend
  2. The user selects the option to delete prediction by ID in Angular
  3. The user inputs the desired prediction ID to delete
  4. Angular sends the get request to the Spring Boot server
  5. The Spring Boot server searches its database of predictions and deletes the desired entry
  6. Success or failure returned to Angular
  7. Angular reports result

(back to top)

Test Cases

Description Automated
Spring Boot
Automated
Angular
Notes
Start server, verify it comes up as expected
Stop server, clean shutdown. Verify DB persists on restart
Stop server, kill. Verify DB persists on restart
Load default model, verify predictions
Load new model, verify predictions
Load invalid model, verify Bad Request
Get info on loaded model. Accuracy, loss, etc.. No accuracy/loss saved in database currently
Get info on invalid model ID, verify Not Found
Delete model with valid model ID
Delete model with invalid model ID, verify Not Found
Run prediction for an MRI file, verify confidence returned
Run prediction for invalid MRI file, verify Bad Request
Run prediction for random file in Impairment category, verify confidence returned
Verify unable to run predictions invalid Impairment category, verify Bad Request
Run prediction for random test image, verify confidence returned
Verify unable to run predictions for invalid model ID, verify Bad Request

(back to top)

Backend Implementation

The backend server is implemented with Spring Boot, utilizing an H2 database that persists on disk. The Rest API exposed by this server supports most basic CRUD requests to interact with both Tensorflow models and individual MRI prediction.

None of the model training occurs on this Spring Boot server. While we are leveraging Amazon's DJL framework that enables Deep Learning support in Java, the models were all trained using the Neural Network found at the following link:

Python Alzheimer's Convolutional Neural Network

(back to top)

Frontend Implementation

The frontend server is implemented with Angular and serves as a simplistic yet clean interface to interact with the Spring Boot server than the Rest API. The home page can be seen below, accessed at http://localhost:4200

From the homepage, a user can navigate to one of several options under both the Models and Predictions headers. In this readme, we've just shown the pages required to access to submit a prediction to the default model. To choose the default model, navigate to Models -> Choose Active Model. Click one of the following options and verify the text stating 'Current Model: {ID}' updates correctly. The default model will always have ID == 1.

Next, navigate to Predictions -> Submit new MRI for Assessment to see the next screenshot shown below. From here, choose a file to upload to the predictive model that you have chosen. For convenience, test images (that the default model was not trained on) are included in src/main/resources/images/Combined Dataset.zip. Unzip this and choose an image. Each fictitious MRI in this dataset is sorted by the Impairment level that the MRI was emulating. Because of this fact, we will have confidence if the model is performing as expected after uploading some MRIs and verifying their predictions match our actual value.

(back to top)

Pending Work

  • Automated testing for Angular frontend - using Karma: https://karma-runner.github.io/6.4/index.html
  • Increase test coverage for Spring Boot server
  • Angular frontend not handling exceptions from the backend
  • Implement safer keys in the database. Currently just incrementing
  • Add Users - should have their own inventory of models and predictions
  • SSL for security when dealing with real data
  • Fix concurrency issues
  • Remove test images from Angular server, rely on images in backend
  • Fix packaging of final jar - currently not executable

(back to top)

Open Questions

  • When running predict() on an image, should we run predict for every model? (under user?)

(back to top)

Contact

Email: jttrull0@gmail.com

LinkedIn
GitHub

(back to top)


About

Simple Spring Boot server for analyzing MRI images for potential impairment due to Alzheimer's Disease

Topics

Resources

Stars

Watchers

Forks