This cookbook details how to deploy a localized 3D Time-of-Flight (TOF) magnetic resonance angiography (MRA) and high-resolution vessel wall MRI (HR-VW-MRI) volume processing engine to segment circle of Willis intracranial arterial anatomy, measure sac maximum diameter (mm), aspect ratio, volume ($\text{mm}^3$), quantify circumferential wall enhancement (CWE ratio), and stage Intracranial Aneurysm Rupture Risk (PHASES Score) according to AHA/ASA and ESMINT guidelines without cloud API dependence.
Unruptured intracranial aneurysms (UIAs) are present in 3–5% of the adult population. Aneurysmal subarachnoid hemorrhage (aSAH) carries a 40–50% 30-day mortality rate and high morbidity. In neurovascular suites, stroke centers, and neuroradiology reading rooms, localized automated 3D TOF-MRA and black-blood HR-VW-MRI volume processing standardizes 3D aneurysm sac segmentation, morphometric shape analysis (aspect ratio = dome height / neck width), and vessel wall gadolinium enhancement (CWE > 1.3 indicating active wall inflammation) to guide preventive endovascular coiling / flow diversion vs. conservative imaging surveillance according to AHA/ASA and ESMINT consensus guidelines.
This engine enables:
[ 3D TOF-MRA & HR-VW-MRI Brain Angiography DICOM Series ]
│
▼
[ VascNeuroNet-Aneurysm-v1 ]
├── Circle of Willis & Aneurysm Sac/Neck Segmenter
└── CWE Wall Enhancement & Morphometric Aspect Ratio Meter
│
▼
[ Aneurysm-Rupture-Staging-CLI ]
├── Sac Size (mm), Aspect Ratio, CWE Ratio & PHASES Score
└── AHA/ASA Endovascular Coiling vs Surveillance Triage
│
▼
[ Structured Vascular Neurology Summary JSON ]
Ensure Python 3.10+, pydicom, torch, torchvision, scikit-image, and OpenCV are installed:
pip install pydicom torch torchvision opencv-python-headless scikit-image numpy
Clone the offline model weights:
git clone https://github.com/OpenPHRorg/vascneuronet-aneurysm-local.git
cd vascneuronet-aneurysm-local
Preprocess 3D TOF-MRA and co-registered T1-Contrast black-blood vessel wall MRI:
import pydicom
import cv2
import numpy as np
def preprocess_brain_mra(tof_mra_path, hrvw_mri_path):
ds_tof = pydicom.dcmread(tof_mra_path)
ds_vw = pydicom.dcmread(hrvw_mri_path)
img_tof = ds_tof.pixel_array.astype(float)
img_vw = ds_vw.pixel_array.astype(float)
# Normalize TOF-MRA high-flow vessel brightness
norm_tof = (img_tof - np.min(img_tof)) / (np.max(img_tof) - np.min(img_tof) + 1e-5) * 255.0
norm_tof = norm_tof.astype(np.uint8)
# Adaptive contrast enhancement of aneurysm sac lumen
clahe = cv2.createCLAHE(clipLimit=3.5, tileGridSize=(8, 8))
enhanced_tof = clahe.apply(norm_tof)
# Calculate Vessel Wall Contrast Enhancement Ratio (CWE)
cwe_map = img_vw / (np.mean(img_vw) + 1e-5)
return enhanced_tof, cwe_map
# Example preprocessing
prep_tof, cwe_map = preprocess_brain_mra("sample_tof_mra.dcm", "sample_hrvw_mri.dcm")
cv2.imwrite("enhanced_mra_vessels.png", prep_tof)
print("3D TOF-MRA & HR-VW-MRI preprocessing completed.")
Execute 3D morphometric segmentation and compute endovascular treatment triage:
import torch
def evaluate_intracranial_aneurysm(prep_tof, cwe_map, patient_age, has_hypertension, prior_sah):
model = torch.hub.load('OpenPHRorg/vascneuronet-aneurysm-local', 'mraaneurysm_v1', pretrained=True)
model.eval()
tensor_input = torch.from_numpy(prep_tof).unsqueeze(0).unsqueeze(0).float() / 255.0
with torch.no_grad():
seg_mask, ane_outputs = model(tensor_input)
dome_height_mm = float(ane_outputs['dome_mm'][0, 0].item()) # Dome Height (mm)
neck_width_mm = float(ane_outputs['neck_mm'][0, 0].item()) # Neck Width (mm)
max_diameter_mm = float(ane_outputs['max_dia_mm'][0, 0].item()) # Max Diameter (mm)
cwe_ratio = float(ane_outputs['cwe_ratio'][0, 0].item()) # Circumferential Wall Enhancement Ratio
location_code = int(ane_outputs['location'][0, 0].item()) # 0: ICA, 1: MCA, 2: ACom/PCom/Basilar
# Morphometric Aspect Ratio (Dome / Neck)
aspect_ratio = dome_height_mm / max(0.1, neck_width_mm)
# Calculate PHASES Rupture Risk Score (0 - 22 Points)
phases_score = 0
if patient_age >= 70: phases_score += 1
if has_hypertension: phases_score += 1
if prior_sah: phases_score += 1
# Size points
if max_diameter_mm >= 20.0: phases_score += 10
elif max_diameter_mm >= 10.0: phases_score += 6
elif max_diameter_mm >= 7.0: phases_score += 3
# Location points (ACom / PCom / Basilar carry higher risk)
if location_code == 2: phases_score += 3
elif location_code == 1: phases_score += 2
# AHA/ASA & ESMINT Endovascular Triage Guidelines
# Active Wall Enhancement (CWE > 1.3), Aspect Ratio > 1.6, or PHASES >= 5 indicates high risk
if cwe_ratio >= 1.3 or aspect_ratio >= 1.6 or phases_score >= 6:
risk_stage = f"High-Risk Unruptured Aneurysm (PHASES = {phases_score} / Active CWE Wall Enhancement = {cwe_ratio:.2f})"
endovascular_indicated = True
procedure = "Preventive Endovascular Pipeline Flow Diverter / Microcoil Embolization"
elif max_diameter_mm >= 7.0 or phases_score >= 3:
risk_stage = f"Moderate-Risk Aneurysm (PHASES = {phases_score} / Max Size = {max_diameter_mm:.1f} mm)"
endovascular_indicated = True
procedure = "Multidisciplinary Neurovascular Board Evaluation for Endovascular Coiling vs. Surgery"
else:
risk_stage = f"Low-Risk Small Aneurysm (PHASES = {phases_score} / Max Size = {max_diameter_mm:.1f} mm)"
endovascular_indicated = False
procedure = "Annual 3D TOF-MRA Imaging Surveillance & Blood Pressure Control"
return {
"aneurysm_max_diameter_mm": round(max_diameter_mm, 1),
"dome_to_neck_aspect_ratio": round(aspect_ratio, 2),
"circumferential_wall_enhancement_cwe_ratio": round(cwe_ratio, 2),
"phases_5yr_rupture_risk_score": phases_score,
"active_wall_inflammation_instability_flag": cwe_ratio >= 1.3,
"aha_asa_rupture_risk_classification": risk_stage,
"endovascular_preventive_treatment_candidate": endovascular_indicated,
"vascular_neurology_clinical_triage_guidance": f"Schedule Interventional Neuroradiology Procedure: {procedure}" if endovascular_indicated else f"Conservative Management: {procedure}"
}
# Run assessment
result = evaluate_intracranial_aneurysm(prep_tof, cwe_map, patient_age=62, has_hypertension=True, prior_sah=False)
print(f"Vascular Neurology Diagnostic Summary: {result}")
This engine delivers instant, offline brain MRA aneurysm summaries conforming to AHA/ASA (American Heart Association / American Stroke Association) and ESMINT guidelines.