diff --git a/README.md b/README.md index a9813b7..667774f 100644 --- a/README.md +++ b/README.md @@ -126,9 +126,10 @@ Time-series data with one row per scan. Includes all primary metrics and derived - `RMR_cal_per_day` - Resting metabolic rate ### 2. `regional.csv` -Regional body composition breakdown (Arms, Legs, Trunk, Android, Gynoid, Total). +Regional body composition breakdown (Arms, Legs, Trunk, Android, Gynoid, Total). Each scan adds 6 rows (one per region). **Columns:** +- `MeasuredDate` - Date of scan (YYYY-MM-DD) - `Region` - Body region name - `FatPercent` - Fat percentage in this region - `LeanPercent` - Lean tissue percentage in this region @@ -138,9 +139,12 @@ Regional body composition breakdown (Arms, Legs, Trunk, Android, Gynoid, Total). - `BMC_lb` - Bone mineral content in the region ### 3. `muscle_balance.csv` -Left/right limb comparison for tracking muscle symmetry. +Left/right limb comparison for tracking muscle symmetry. Each scan adds 6 rows (one per region). -**Regions:** Arms Total, Right Arm, Left Arm, Legs Total, Right Leg, Left Leg +**Columns:** +- `MeasuredDate` - Date of scan (YYYY-MM-DD) +- `Region` - Arms Total, Right Arm, Left Arm, Legs Total, Right Leg, Left Leg +- `FatPercent`, `TotalMass_lb`, `FatMass_lb`, `LeanMass_lb`, `BMC_lb` ### 4. `overall.json` Structured JSON format containing all extracted data in a hierarchical format. diff --git a/dexa_extract.py b/dexa_extract.py index d04d4b0..1a8d664 100644 --- a/dexa_extract.py +++ b/dexa_extract.py @@ -578,12 +578,13 @@ def process_single_pdf(pdf_path, height_in, weight_lb, outdir, batch_mode=False) write_or_append_csv(os.path.join(outdir, "overall.csv"), overall_row, overall_cols) # Regional table - regional_cols = ["Region","FatPercent","LeanPercent","TotalMass_lb","FatTissue_lb","LeanTissue_lb","BMC_lb"] + regional_cols = ["MeasuredDate","Region","FatPercent","LeanPercent","TotalMass_lb","FatTissue_lb","LeanTissue_lb","BMC_lb"] reg_rows = [] for name, r in d.get("regional", {}).items(): # Calculate lean percentage (lean tissue only, not including BMC - matches BodySpec report) lean_pct = round(100 * r["lean_tissue_lb"] / r["total_mass_lb"], 1) if r["total_mass_lb"] > 0 else None reg_rows.append({ + "MeasuredDate": measured_date, "Region": name, "FatPercent": r["fat_percent"], "LeanPercent": lean_pct, @@ -600,10 +601,11 @@ def process_single_pdf(pdf_path, height_in, weight_lb, outdir, batch_mode=False) df_regional.to_csv(regional_path, index=False) # Muscle balance - mb_cols = ["Region","FatPercent","TotalMass_lb","FatMass_lb","LeanMass_lb","BMC_lb"] + mb_cols = ["MeasuredDate","Region","FatPercent","TotalMass_lb","FatMass_lb","LeanMass_lb","BMC_lb"] mb_rows = [] for name, r in d.get("muscle_balance", {}).items(): mb_rows.append({ + "MeasuredDate": measured_date, "Region": name, "FatPercent": r["fat_percent"], "TotalMass_lb": r["total_mass_lb"],