Inspiration

Within the last few decades, mental healthcare has gained a lot of attention – which isn't without reason. In Canada, 1 in 5 Canadians are reported to experience mental health issues and by the age 40, 50% of the population will have or have had a mental illness. However, the focus of this project is with anxiety disorders reported to affect 5% of the population and the 1 in 10 Canadians that have been reported to annually use health services related to mood and anxiety disorders. In 2012, 2.4 million Canadians aged 15 and above reported symptoms which were compatible with generalized anxiety disorder (GAD) during their lifetime. These symptoms include: persistent worrying or anxiety, overthinking plans and solutions to all possible worst-case outcomes, indecisiveness and fear of making the wrong decision, inability to set aside or let go of a worry, fatigue, difficulty sleeping, sweating, nausea, diarrhea or irritable bowel syndrome and irritability – just to name a few. Besides GAD, anxiety disorders constitute an even longer list of illnesses including: panic disorder, agoraphobia, social phobia, OCD and PTSD. As such, it's easy to understand how the various forms of anxiety can drastically impair one's quality of life.

In current practice, chemical tests are not performed to diagnose mental illnesses, including anxiety. Instead, doctors assess a patient's family history and perform psychological evaluations through the use of questionnaires. This typically involves asking patients about their thoughts, feelings, symptoms, lifestyle habits, and daily activities. Based on the answers that are provided, doctors can diagnose the patient in accordance with the DSM-5 (Diagnostic and Statistical Manual of Mental Disorders - 5th Edition) and prescribe medication or adjust current dosages. The problem with the current diagnostic method is that clinicians make subjective interpretations based on the patient’s self-reported and qualitative information. Additionally, the care provided is strongly dependent on the patient's ability to advocate for their own needs, which is not something everyone is able to do easily.

When it comes to anxiety and stress, our central nervous system responds through the activation of the hypothalamic-pituitary-adrenal (HPA) system. This means that our hypothalamus in our brain releases corticotropin-releasing hormones (CRH), signalling our pituitary glands to release adrenocorticotropic hormone (ACTH), which finally signals the adrenal glands to release cortisol, the key player in our entire project. A patient with anxiety experiences chronic stress, resulting in the persistent activation of the HPA system and impairment of cortisol to regulate its own production. Subsequently, the elevation of cortisol levels will lead to dysregulation of other important biochemicals, through decreased estrogen and testosterone levels, and impaired signalling of the serotonin pathways.

In an attempt to address this issue, we present CortiCare. We propose a method to objectively measure anxiety levels, allowing for more accurate diagnoses and efficient treatment plans. Using this technology, patients can track their own salivary cortisol levels using a web app in the form of data accessible to their doctors online.

What it does

CortiCare

The patients will obtain a kit containing a phone cover, cortisol test strips and capillary tubes to collect the saliva. They’ll be asked to collect saliva samples at daily scheduled time(s) 30 minutes prior to eating and place it onto the test strip. Once the salivary sample is placed onto our test strip, it undergoes a process called lateral flow immunoassay (LFIA), a technique commonly used for pregnancy tests. It indicates the concentration of our target analyte, cortisol, which is proportional to the intensity of the observed red strip colour. The saliva moves from the sample pad to the conjugate pad, where cortisol will bind to the cortisol-specific antibodies with a detection label. The cortisol-bound antibodies will then migrate to the test line and bind to additional antibodies and where a red line will be observed. LFIA

The cortisol test strip will then be placed into the phone cover for proper alignment. The patient will log into the web app and take a picture of the test strip. The RGB values of the red line of the test strip will be converted into signal data and present the cortisol measurements in ng/mL. The cortisol data will be presented in a graph for users to visually see the trends of cortisol levels, and in return anxiety levels, of the patient throughout time. As an additional feature, patients can also log their emotions/mood for that day which will be presented as a monthly radar chart.

How we built it

Our web app was built using python flask, pillow and sqlite database. While the base template is an open source template obtained for a flask admin dashboard, all of its features were built by us.

Our boilerplate contained:

  • DBMS: SQLite, PostgreSQL (production)
  • DB Tools: SQLAlchemy ORM, Alembic (schema migrations)
  • Modular design with Blueprints, simple codebase
  • Session-based authentication (via flask_login), forms validation
  • Deployment scripts: Docker, Gunicorn/Nginx, Heroku

Features we implemented:

  • Dedicated admin login with doctor dashboard
  • Admin verification for regular user page
  • Admin only user route to view users - revamped and our idea implemented
  • Test strip uploading and using our algorithm to determine cortisol scor
  • Numpy and pillow added to list of imports
  • User routes, pages revamped and our idea implemented
  • Database schema edited for more user related information
  • Graphs and charts generated from our data on the chart.js templates
  • Various HTML, CSS and JS embellishments throughout

We moved app to git and heroku. Deployed on heroku with our domain.com domain name, "corticare.online" (http://corticare.com or corticare.com). CNAME edited on domain.com to point to heroku host.

For the algorithm to detect the cortisol score, we initially take an image as an input and break it into a numpy array. After this, we locate all black pixels (the rectangle which exists on the strips) and extract the region of interest. From the ROI, we obtain all colors present in the picture and are able to calculate a score by multiplying the R value from RGB with the amount of pixels. Using the score from images of test strips with known concentrations of cortisol (ng/mL), the values were plotted on a graph and the equation of the trendline was determined. This equation was then used to calculate the concentration of cortisol from images of test strips where the concentration was unknown.

CalibrationGrap

Challenges we ran into

We faced some challenges using pillow, as it's something we aren't too experienced with. Additionally, developing the correct algorithm, for the correct pixel mapping from cortisol test strip pictures, required extensive research about RGB and HSV values. When taking these pictures, we had to ensure that pictures were consistent for the algorithm especially for calibration. As a result, we had to ensure that each picture had the same lighting, pixel density, size, etc.

Accomplishments that we're proud of

We’re really proud of the current demo we are able to showcase to the judges as the web app is able to extract cortisol measurements from the RGB values of the test strips. Although there is room for improvement, we know that our algorithm is capable of reporting more accurate measurements with additional calibration samples. We’re proud of the connections we were able to make between science and technology to develop an idea that holds a lot of promise for change in the current healthcare system.

What we learned

In the research stages of this project, it was interesting to learn more about the current diagnostic methods for mental illnesses. From its original inspiration, our idea continued to expand as we dived more into the literature. While working on the project, we learned how to make a fully functional flask web app and integrate it with a custom algorithm. We also learned a lot about RGB and HSV values.

What's next for CortiCare

The most important next steps for CortiCare is improving the calibration of RGB values to cortisol concentrations. After developing the cortisol LFIA test strips and phone covers, we can calibrate it with even more samples than our original six. This will improve its accuracy of measuring and reporting the concentrations of a patient’s salivary cortisol. Since the camera quality differs between various smartphone models, a one-time calibration could be incorporated for the camera of each patient. From the collected data, it would be useful to host an API endpoint with the anonymized cortisol measurements for clinical research use. Additionally, we hope to add more features to the web app by incorporating patient information/history, current prescriptions and the ability for doctors to add personal notes.

Share this project:

Updates