Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CardiacDissect MnM2 Concept Analysis

This repository contains a cleaned, GitHub-ready version of the exploratory CardiacDissect notebooks for MnM2 cardiac MRI slices.

The code supports two concept vocabularies:

  • original_3: original segmentation concepts LV, MYO, and RV.
  • derived_9: long-axis derived concepts LV/MYO/RV x basal/mid/apical.

Repository Layout

cardiacdissect/
  analysis.py        # DataLoader and full association-matrix pipeline
  concepts.py        # Original and derived concept-mask extraction
  config.py          # Config dataclass and YAML loader
  dataset.py         # MnM2 long-axis dataset loader
  metrics.py         # Mask resizing, patches, IoU/Dice/precision/recall
  model.py           # DenseNet checkpoint loading and activation hooks
  visualization.py   # Demo plots
notebooks/
  demo_cardiacdissect.ipynb
tests/
  test_*.py

Setup

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Copy the example config and update the paths:

cp config.example.yaml config.yaml

Edit config.yaml:

mnm2_root: "/absolute/path/to/MnM2"
model_path: "/absolute/path/to/best_densenet161_MnMs.pth"
concept_set: "derived_9"
layer: "features.denseblock4"

The old notebooks hard-coded personal absolute paths. This refactor keeps paths out of the code and reads them from config instead.

Demo Notebook

Open:

notebooks/demo_cardiacdissect.ipynb

The notebook demonstrates:

  1. Loading config.
  2. Selecting original_3 or derived_9.
  3. Loading DenseNet-161 and registering an activation hook.
  4. Loading LA MnM2 slices.
  5. Visualizing one sample and its concept masks.
  6. Ranking neuron-concept overlaps for one image.
  7. Optionally running the full association-matrix pipeline.

Set this in the notebook to choose the concept vocabulary:

CONCEPT_SET = "derived_9"  # or "original_3"

Set RUN_FULL_PIPELINE = True only when you want to process the full LA subset.

About

Implementation of proof-of-concept CardiacDissect study on cardiac MRI data

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages