NeuroLight

MRI based Sex Classification Project

NeuroLight

MRI-based Sex Classification Project

NeuroLight is a comprehensive deep learning pipeline for sex classification from MRI data, built with PyTorch and designed for reproducibility and scalability. This page showcases features, project structure, and usage instructions in a visually engaging format.

This is a beginner-friendly guide to using artificial intelligence with neuroimaging data. This tutorial takes you step-by-step through the entire process, starting from loading and understanding MRI data, to building and training deep learning models in PyTorch. Along the way, you’ll learn essential AI and machine learning concepts, see how to set up a dataset for training, and explore real-world tasks like classifying brain images. With clear explanations and practical examples, this tutorial is designed to make complex ideas easy to understand, helping you get hands-on experience with AI in healthcare applications and giving you the skills to work on exciting neuroimaging projects from start to finish


🚀 Feature Showcase

Left: MRI data loading and preprocessing.
Middle: Deep neural network training for sex classification.
Right: Simple Fully Convolutional Network model.

📦 Project Structure

  • sex_classification.ipynb
    Beginner-friendly notebook for sex classification using PyTorch.
    Step-by-step guide with dataset, model, and workflow.
    See the Medium Tutorial for a detailed walkthrough.

  • crossvalidation_sexclassification.py
    Implements K-Fold Cross Validation for robust model evaluation.
    Run independently to assess generalization.

  • ddp_sex.py
    Distributed Data Parallel (DDP) script for efficient multi-GPU training.
    Run with: torchrun –standalone –nproc_per_node=7 ddp_sex.py

Requires correct folder structure and dependencies.

  • /data
  • dataset.py: Dataset class for loading and preprocessing.
  • dataloader.py: Handles batching, shuffling, and data loaders.

  • /utils
  • trainer.py: Training loop, forward/backward passes, evaluation.
  • visualisation.py: Visualizes training loss, confusion matrices, and more.

  • /models
    Model architectures:
  • SFCN (Simple Fully Convolutional Network)
  • ResNet

  • /configs
  • config.yaml: Hyperparameters and model settings.

  • requirements.txt
    Python dependencies. Install with: pip install -r requirements.txt

K-Fold cross-validation ensures robust and reliable model evaluation.

🛠️ How to Use

1. Clone the Repository

git clone https://github.com/blackpearl006/Neurolight cd Neurolight

2. Install Dependencies

pip install -r requirements.txt

3. Run the Code

  • Tutorial Notebook
    Open sex_classification.ipynb in Jupyter and run the cells.

  • K-Fold Cross-Validation
    python3 crossvalidation_sexclassification.py

  • Distributed Training
    torchrun –standalone –nproc_per_node=7 ddp_sex.py


📁 Folder Overview

/data - Dataset and data processing utilities /utils - Training and visualization scripts /models - Model definitions (SFCN, ResNet, etc.) /configs - Hyperparameter and model config files —

Distributed training (left) helps scale your experiments. Confusion matrices (right) provide model insight.

🎯 Conclusion

NeuroLight offers a robust, scalable, and well-documented pipeline for sex classification using MRI data and deep learning.
From beginner tutorials to advanced distributed training, this project provides everything you need to advance your neuroimaging AI research.


Ready to illuminate your research with NeuroLight? Dive into the code and let the discoveries begin!