Skip to content

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# NeuroCodex - Parkison, Demntia, Depresiion, Alzheimer Detection Platform

A web application for early Parkison, Demntia, Depresiion, Alzheimer detection using cognitive assessment games and AI-powered risk prediction.

🧠 Features

  • 7 Cognitive Assessment Games: Trail Making, Spiral, Word Recall, Pattern Replication, Verbal Fluency, Stroop, and Go/No-Go tests
  • AI-Powered Risk Prediction: Uses trained Alzheimer model for risk assessment
  • Modern UI/UX: Futuristic health-tech theme with dark mode and neon accents
  • Comprehensive Reporting: Detailed PDF reports with recommendations
  • Admin Dashboard: Monitor users and system performance
  • Responsive Design: Works on desktop and mobile devices

🚀 Tech Stack

Backend

  • FastAPI: Modern Python web framework
  • Machine Learning: Pre-trained Alzheimer detection model
  • Authentication: JWT-based auth system
  • Data Storage: In-memory storage (hackathon-ready)

Frontend

  • React.js: Modern React with hooks
  • Tailwind CSS: Utility-first CSS framework
  • Framer Motion: Smooth animations
  • Lucide React: Beautiful icons

📁 Project Structure

diseases/
├── backend/
│   ├── main.py                 # FastAPI application
│   ├── requirements.txt        # Python dependencies
│   └── wsgi.py                 # WSGI configuration
├── frontend/
│   ├── src/
│   │   ├── components/         # React components
│   │   │   ├── games/         # Cognitive test games
│   │   │   ├── Navbar.js      # Navigation component
│   │   │   └── ProtectedRoute.js
│   │   ├── contexts/          # React contexts
│   │   │   └── AuthContext.js # Authentication context
│   │   ├── pages/             # Main pages
│   │   │   ├── Login.js       # Login page
│   │   │   ├── Signup.js      # Signup page
│   │   │   ├── Dashboard.js   # Main dashboard
│   │   │   ├── Questionnaire.js # Health questionnaire
│   │   │   ├── Games.js       # Cognitive tests
│   │   │   ├── Report.js      # Results report
│   │   │   └── AdminDashboard.js # Admin panel
│   │   ├── App.js             # Main app component
│   │   ├── index.js           # React entry point
│   │   └── index.css          # Global styles
│   ├── public/
│   │   └── index.html         # HTML template
│   ├── package.json           # Node.js dependencies
│   ├── tailwind.config.js     # Tailwind configuration
│   └── postcss.config.js      # PostCSS configuration
├── model_training/
│   ├── saved_models/
│   │   ├── alz_model.pkl      # Trained Alzheimer model
│   │   └── feature_names.pkl  # Model feature names
│   └── scripts/               # Training scripts
└── README.md                  # This file

🎮 Cognitive Tests

1. Trail Making Test

  • Measures: Cognitive flexibility and processing speed
  • Task: Click numbers in sequential order (1-25)
  • Scoring: Based on time and accuracy

2. Spiral Test

  • Measures: Motor control and tremors
  • Task: Draw a smooth spiral following a guide
  • Scoring: Based on smoothness and accuracy

3. Word Recall Test

  • Measures: Short-term memory
  • Task: Memorize and recall words
  • Scoring: Based on number of correctly recalled words

4. Pattern Replication Test

  • Measures: Visuospatial reasoning
  • Task: Recreate colored block patterns
  • Scoring: Based on accuracy and speed

5. Verbal Fluency Test

  • Measures: Semantic memory and executive function
  • Task: Generate words from categories
  • Scoring: Based on number of unique words

6. Stroop Test

  • Measures: Attention and inhibitory control
  • Task: Identify ink colors while ignoring word meanings
  • Scoring: Based on accuracy and reaction time

7. Go/No-Go Test

  • Measures: Sustained attention and response inhibition
  • Task: Respond to "Go" signals, ignore "No-Go" signals
  • Scoring: Based on accuracy and impulse control

🚀 Quick Start

Prerequisites

Step 1: Clone the Repository

# Clone the repository
git clone <repository-url>
cd diseases

# Verify the project structure
ls
# You should see: backend/, frontend/, model_training/, README.md

Step 2: Backend Setup

# Navigate to backend directory
cd backend

# Create virtual environment (recommended)
python -m venv venv

# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate

# if u see error in creating venv environment then
🔧 Fix Steps:
1. Remove the broken venv
rmdir /s /q venv


(or just delete the venv folder manually inside backend).

2. Create a fresh venv in the current project
python -m venv venv

3. Activate the new venv
.\venv\Scripts\activate


You should see (venv) again in your terminal.

4. Install requirements
python.exe -m pip install --upgrade pip
pip install -r requirements.txt


# Install Python dependencies
pip install -r requirements.txt

# if numpy_core error comes
pip install --upgrade --force-reinstall numpy==1.26.4


# Start the FastAPI server
python main.py

Expected Output:

SUCCESS: FastAPI server starting...
INFO:     Started server process [PID]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)

✅ Backend is running at: http://localhost:8000 📚 API Documentation: http://localhost:8000/docs

Step 3: Frontend Setup

Open a NEW terminal window (keep backend running):

# Navigate to frontend directory
cd frontend

# Install Node.js dependencies
npm install

# Start the React development server
npm start

Expected Output:

Compiled successfully!

You can now view alzheimer-detection-frontend in the browser.

  Local:            http://localhost:3000
  On Your Network:  http://192.168.x.x:3000

Note that the development build is not optimized.
To create a production build, use npm run build.

✅ Frontend is running at: http://localhost:3000 ✅ alzheimer is running at: http://localhost:3000/alzheimer ✅ depression is running at: http://localhost:3000/depression ✅ dementia is running at: http://localhost:3000/dementia ✅ chatbot is running at: http://localhost:3000/chatbot

Step 4: Access the Application

  1. Open your browser and go to http://localhost:3000
  2. Sign up for a new account or login with existing credentials
  3. Complete the health questionnaire
  4. Take the 7 cognitive assessment games
  5. View your personalized risk assessment report

🛠️ Troubleshooting

Backend Issues:

# If port 8000 is busy:
# Kill existing processes
taskkill /f /im python.exe  # Windows
# or
pkill -f python            # macOS/Linux

# If dependencies fail to install:
pip install --upgrade pip
pip install -r requirements.txt --force-reinstall

Frontend Issues:

# If port 3000 is busy:
# Kill existing processes
taskkill /f /im node.exe   # Windows
# or
pkill -f node             # macOS/Linux

# If npm install fails:
npm cache clean --force
npm install

# If React fails to start:
rm -rf node_modules package-lock.json
npm install
npm start

Model Loading Issues:

If you encounter NumPy compatibility issues with the original model:

  • The app uses main_simple.py which has a simplified prediction algorithm
  • This ensures the app works without model loading issues
  • All features remain fully functional

🔧 Development Commands

Backend Commands:

cd backend
python main_simple.py          # Start server
python -m uvicorn main:app --reload  # Alternative start method

Frontend Commands:

cd frontend
npm start                      # Start development server
npm run build                  # Create production build
npm test                       # Run tests
npm run eject                  # Eject from Create React App

📱 Mobile Testing

The app is fully responsive and works on mobile devices:

  1. Start both backend and frontend
  2. Find your computer's IP address
  3. Access http://YOUR_IP:3000 from mobile device
  4. Test the cognitive games on touch devices

🔧 API Endpoints

Authentication

  • POST /auth/signup - User registration
  • POST /auth/login - User login

Assessment

  • POST /questionnaire - Submit health questionnaire
  • POST /games/score - Submit cognitive test scores
  • POST /predict - Get AI risk prediction
  • GET /report/{prediction_id} - Get assessment report
  • GET /report/{prediction_id}/pdf - Download PDF report

Admin

  • GET /admin/users - Get all users
  • GET /admin/reports - Get all reports
  • GET /admin/stats - Get system statistics

🎯 Usage Flow

  1. Sign Up/Login: Create account or sign in
  2. Health Questionnaire: Complete demographic and health questions
  3. Cognitive Tests: Take 7 interactive cognitive assessment games
  4. AI Prediction: Get personalized risk assessment
  5. Report Generation: View detailed results and recommendations

🧪 Model Details

The Alzheimer detection model is trained on:

  • Features: Age, MMSE score, Memory complaints
  • Algorithm: Logistic Regression
  • Accuracy: 74.42% on test set
  • Output: Risk probability (0-100%)

🎨 UI/UX Features

  • Dark Theme: Futuristic health-tech aesthetic
  • Neon Accents: Blue, green, purple color scheme
  • Smooth Animations: Framer Motion for transitions
  • Responsive Design: Works on all screen sizes
  • Accessibility: Keyboard navigation and screen reader support

📊 Admin Dashboard

  • User Management: View all registered users
  • Report Analytics: Monitor assessment results
  • Risk Distribution: Visualize risk level statistics
  • Export Features: Download reports and data

🔒 Security Features

  • JWT Authentication: Secure token-based auth
  • Input Validation: Pydantic models for data validation
  • CORS Protection: Configured for frontend communication
  • Error Handling: Comprehensive error management

🚀 Deployment Ready

The application is designed for easy deployment:

  • Backend: Can be deployed on any Python hosting service
  • Frontend: Can be deployed on Vercel, Netlify, or similar
  • Database: Currently uses in-memory storage (easily upgradeable)

🤝 Contributing

This is a hackathon project designed for rapid development and demonstration. For production use, consider:

  • Adding a real database (PostgreSQL, MongoDB)
  • Implementing proper user roles and permissions
  • Adding more comprehensive error handling
  • Implementing data encryption
  • Adding unit tests

📄 License

This project is created for hackathon purposes. Please ensure compliance with healthcare data regulations if used in production.

🆘 Support

For questions or issues:

  1. Check the console for error messages
  2. Ensure both backend and frontend are running
  3. Verify all dependencies are installed
  4. Check network connectivity between frontend and backend

Built with ❤️ for cognitive health awareness

# NeuroCodex - Alzheimer Detection Platform

A hackathon-ready web application for early Alzheimer detection using cognitive assessment games and AI-powered risk prediction.

🧠 Features

  • 7 Cognitive Assessment Games: Trail Making, Spiral, Word Recall, Pattern Replication, Verbal Fluency, Stroop, and Go/No-Go tests
  • AI-Powered Risk Prediction: Uses trained Alzheimer model for risk assessment
  • Modern UI/UX: Futuristic health-tech theme with dark mode and neon accents
  • Comprehensive Reporting: Detailed PDF reports with recommendations
  • Admin Dashboard: Monitor users and system performance
  • Responsive Design: Works on desktop and mobile devices

🚀 Tech Stack

Backend

  • FastAPI: Modern Python web framework
  • Machine Learning: Pre-trained Alzheimer detection model
  • Authentication: JWT-based auth system
  • Data Storage: In-memory storage (hackathon-ready)

Frontend

  • React.js: Modern React with hooks
  • Tailwind CSS: Utility-first CSS framework
  • Framer Motion: Smooth animations
  • Lucide React: Beautiful icons

📁 Project Structure

diseases/
├── backend/
│   ├── main.py                 # FastAPI application
│   ├── requirements.txt        # Python dependencies
│   └── wsgi.py                 # WSGI configuration
├── frontend/
│   ├── src/
│   │   ├── components/         # React components
│   │   │   ├── games/         # Cognitive test games
│   │   │   ├── Navbar.js      # Navigation component
│   │   │   └── ProtectedRoute.js
│   │   ├── contexts/          # React contexts
│   │   │   └── AuthContext.js # Authentication context
│   │   ├── pages/             # Main pages
│   │   │   ├── Login.js       # Login page
│   │   │   ├── Signup.js      # Signup page
│   │   │   ├── Dashboard.js   # Main dashboard
│   │   │   ├── Questionnaire.js # Health questionnaire
│   │   │   ├── Games.js       # Cognitive tests
│   │   │   ├── Report.js      # Results report
│   │   │   └── AdminDashboard.js # Admin panel
│   │   ├── App.js             # Main app component
│   │   ├── index.js           # React entry point
│   │   └── index.css          # Global styles
│   ├── public/
│   │   └── index.html         # HTML template
│   ├── package.json           # Node.js dependencies
│   ├── tailwind.config.js     # Tailwind configuration
│   └── postcss.config.js      # PostCSS configuration
├── model_training/
│   ├── saved_models/
│   │   ├── alz_model.pkl      # Trained Alzheimer model
│   │   └── feature_names.pkl  # Model feature names
│   └── scripts/               # Training scripts
└── README.md                  # This file

🎮 Cognitive Tests

1. Trail Making Test

  • Measures: Cognitive flexibility and processing speed
  • Task: Click numbers in sequential order (1-25)
  • Scoring: Based on time and accuracy

2. Spiral Test

  • Measures: Motor control and tremors
  • Task: Draw a smooth spiral following a guide
  • Scoring: Based on smoothness and accuracy

3. Word Recall Test

  • Measures: Short-term memory
  • Task: Memorize and recall words
  • Scoring: Based on number of correctly recalled words

4. Pattern Replication Test

  • Measures: Visuospatial reasoning
  • Task: Recreate colored block patterns
  • Scoring: Based on accuracy and speed

5. Verbal Fluency Test

  • Measures: Semantic memory and executive function
  • Task: Generate words from categories
  • Scoring: Based on number of unique words

6. Stroop Test

  • Measures: Attention and inhibitory control
  • Task: Identify ink colors while ignoring word meanings
  • Scoring: Based on accuracy and reaction time

7. Go/No-Go Test

  • Measures: Sustained attention and response inhibition
  • Task: Respond to "Go" signals, ignore "No-Go" signals
  • Scoring: Based on accuracy and impulse control

🚀 Quick Start

Prerequisites

Step 1: Clone the Repository

# Clone the repository
git clone <repository-url>
cd diseases

# Verify the project structure
ls
# You should see: backend/, frontend/, model_training/, README.md

Step 2: Backend Setup

# Navigate to backend directory
cd backend

# Create virtual environment (recommended)
python -m venv venv

# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate

# if u see error in creating venv environment then
🔧 Fix Steps:
1. Remove the broken venv
rmdir /s /q venv


(or just delete the venv folder manually inside backend).

2. Create a fresh venv in the current project
python -m venv venv

3. Activate the new venv
.\venv\Scripts\activate


You should see (venv) again in your terminal.

4. Install requirements
pip install --upgrade pip
pip install -r requirements.txt


# Install Python dependencies
pip install -r requirements.txt

# Start the FastAPI server
python main_simple.py

Expected Output:

SUCCESS: FastAPI server starting...
INFO:     Started server process [PID]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)

✅ Backend is running at: http://localhost:8000 📚 API Documentation: http://localhost:8000/docs

Step 3: Frontend Setup

Open a NEW terminal window (keep backend running):

# Navigate to frontend directory
cd frontend

# Install Node.js dependencies
npm install

# Start the React development server
npm start

Expected Output:

Compiled successfully!

You can now view alzheimer-detection-frontend in the browser.

  Local:            http://localhost:3000
  On Your Network:  http://192.168.x.x:3000

Note that the development build is not optimized.
To create a production build, use npm run build.

✅ Frontend is running at: http://localhost:3000

Step 4: Access the Application

  1. Open your browser and go to http://localhost:3000
  2. Sign up for a new account or login with existing credentials
  3. Complete the health questionnaire
  4. Take the 7 cognitive assessment games
  5. View your personalized risk assessment report

🛠️ Troubleshooting

Backend Issues:

# If port 8000 is busy:
# Kill existing processes
taskkill /f /im python.exe  # Windows
# or
pkill -f python            # macOS/Linux

# If dependencies fail to install:
pip install --upgrade pip
pip install -r requirements.txt --force-reinstall

Frontend Issues:

# If port 3000 is busy:
# Kill existing processes
taskkill /f /im node.exe   # Windows
# or
pkill -f node             # macOS/Linux

# If npm install fails:
npm cache clean --force
npm install

# If React fails to start:
rm -rf node_modules package-lock.json
npm install
npm start

Model Loading Issues:

If you encounter NumPy compatibility issues with the original model:

  • The app uses main_simple.py which has a simplified prediction algorithm
  • This ensures the app works without model loading issues
  • All features remain fully functional

🔧 Development Commands

Backend Commands:

cd backend
python main_simple.py          # Start server
python -m uvicorn main:app --reload  # Alternative start method

Frontend Commands:

cd frontend
npm start                      # Start development server
npm run build                  # Create production build
npm test                       # Run tests
npm run eject                  # Eject from Create React App

📱 Mobile Testing

The app is fully responsive and works on mobile devices:

  1. Start both backend and frontend
  2. Find your computer's IP address
  3. Access http://YOUR_IP:3000 from mobile device
  4. Test the cognitive games on touch devices

🔧 API Endpoints

Authentication

  • POST /auth/signup - User registration
  • POST /auth/login - User login

Assessment

  • POST /questionnaire - Submit health questionnaire
  • POST /games/score - Submit cognitive test scores
  • POST /predict - Get AI risk prediction
  • GET /report/{prediction_id} - Get assessment report
  • GET /report/{prediction_id}/pdf - Download PDF report

Admin

  • GET /admin/users - Get all users
  • GET /admin/reports - Get all reports
  • GET /admin/stats - Get system statistics

🎯 Usage Flow

  1. Sign Up/Login: Create account or sign in
  2. Health Questionnaire: Complete demographic and health questions
  3. Cognitive Tests: Take 7 interactive cognitive assessment games
  4. AI Prediction: Get personalized risk assessment
  5. Report Generation: View detailed results and recommendations

🧪 Model Details

The Alzheimer detection model is trained on:

  • Features: Age, MMSE score, Memory complaints
  • Algorithm: Logistic Regression
  • Accuracy: 74.42% on test set
  • Output: Risk probability (0-100%)

🎨 UI/UX Features

  • Dark Theme: Futuristic health-tech aesthetic
  • Neon Accents: Blue, green, purple color scheme
  • Smooth Animations: Framer Motion for transitions
  • Responsive Design: Works on all screen sizes
  • Accessibility: Keyboard navigation and screen reader support

📊 Admin Dashboard

  • User Management: View all registered users
  • Report Analytics: Monitor assessment results
  • Risk Distribution: Visualize risk level statistics
  • Export Features: Download reports and data

🔒 Security Features

  • JWT Authentication: Secure token-based auth
  • Input Validation: Pydantic models for data validation
  • CORS Protection: Configured for frontend communication
  • Error Handling: Comprehensive error management

🚀 Deployment Ready

The application is designed for easy deployment:

  • Backend: Can be deployed on any Python hosting service
  • Frontend: Can be deployed on Vercel, Netlify, or similar
  • Database: Currently uses in-memory storage (easily upgradeable)

🤝 Contributing

This is a hackathon project designed for rapid development and demonstration. For production use, consider:

  • Adding a real database (PostgreSQL, MongoDB)
  • Implementing proper user roles and permissions
  • Adding more comprehensive error handling
  • Implementing data encryption
  • Adding unit tests

📄 License

This project is created for hackathon purposes. Please ensure compliance with healthcare data regulations if used in production.

🆘 Support

For questions or issues:

  1. Check the console for error messages
  2. Ensure both backend and frontend are running
  3. Verify all dependencies are installed
  4. Check network connectivity between frontend and backend

Built with ❤️ for cognitive health awareness

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages