Offline Hematology Anemia & Bone Marrow Dysplasia Classifier
Introduction
Hematologic evaluation of refractory anemias and suspected myelodysplastic syndromes (MDS) relies on combining digital microscopic blood smear analysis with automated complete blood count (CBC) differential indices (MCV, RDW, reticulocyte production index) and cytomorphology. In this cookbook, we introduce HematoVision-CNN-v1, an offline vision and tabular deep learning model that analyzes blood smear microphotographs and clinical laboratory data on edge laboratory computers without cloud dependency.
Prerequisites
- Python 3.9+
- PyTorch &
torchvision openphr-cli- High-resolution blood smear micrographs (.png/.jpg) and CBC laboratory telemetry (.json)
Step 1: Load Peripheral Blood Smear & Differential Telemetry
Prepare blood smear micrographs and CBC differential indices for local inference.
import json
from PIL import Image
# Load peripheral blood smear image & laboratory CBC parameters
image_path = "blood_smear_100x.png"
with open("cbc_differential.json", "r") as f:
cbc_data = json.load(f)
# Extract core indices: MCV (fl), RDW (%), Reticulocytes (%)
mcv = cbc_data['mcv']
rdw = cbc_data['rdw']
retic = cbc_data['reticulocytes']
print(f"Loaded CBC Telemetry: MCV={mcv} fL, RDW={rdw}%, Reticulocytes={retic}%")
Step 2: Run Local Classification Pipeline
Execute the openphr-cli pipeline to classify anemia etiology and evaluate dysplasia probability:
openphr-cli run hematovision-cnn-v1 \
--input-smear ./blood_smear_100x.png \
--cbc-telemetry ./cbc_differential.json \
--output-dysplasia-risk ./hematology_classification.json
Expected Outcome
A comprehensive hematology report categorizing anemia type (microcytic/macrocytic, hyperregenerative/hyporegenerative), flag morphologic dysplasias (ring sideroblasts, Pelger-Huët anomalies), and provide IPSS-R risk scores locally while maintaining strict patient privacy.