Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ The PyTorch code resides in `backend.py` and outlines the custom `DementiaMultim
## 馃摐 Academic Reference & License

This project is licensed under the **Apache License 2.0**. Feel free to use, modify, and distribute this codebase for academic and clinical research.
Testing Pair Extraordinaire Achievement 馃殌
Working towards Pull Shark achievement 馃
working with pull requests
Testing GitHub Pull Request Achievement
Expand Down
9 changes: 4 additions & 5 deletions backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# ==========================================
# DATASETS: Where the data is loaded and used
# ==========================================

class DementiaMultimodalDataset(Dataset):
"""
Custom PyTorch Dataset that loads both MRI (ADNI/OASIS)
Expand All @@ -28,9 +28,9 @@ def __len__(self):
def __getitem__(self, idx):
row = self.metadata.iloc[idx]

# 1. Load the dataset for Branch 1 (OASIS / ADNI MRI)

mri_path = os.path.join(self.mri_dir, row['mri_filename'])
# Load 2D/3D MRI slide (converting to RGB for ResNet compatibility here)

mri_image = Image.open(mri_path).convert('RGB')

if self.transform:
Expand Down Expand Up @@ -78,7 +78,7 @@ def __init__(self, tabular_input_dim=128, lstm_hidden_dim=256, num_classes=3):
nn.Softmax(dim=1)
)

# --- Classification Layer ---

self.classifier = nn.Sequential(
nn.Linear(fusion_dim, 256),
nn.ReLU(),
Expand Down Expand Up @@ -151,7 +151,6 @@ def forward(self, mri_imgs, speech_seq):
# Assuming MFCC features have 40 coefficients per frame
model = MultimodalDementiaModel(tabular_input_dim=40, lstm_hidden_dim=256, num_classes=3)

# --- 5. Evaluation / Accuracy Calculation Loop (Example) ---
def calculate_accuracy(model, data_loader, device='cpu'):
model.eval()
correct = 0
Expand Down