Add MeasuredDate column to all CSV files

CHANGES:
- Added MeasuredDate as first column in regional.csv
- Added MeasuredDate as first column in muscle_balance.csv
- Updated README to document new column structure

BENEFITS:
 Track regional changes over time (e.g., Arms fat % across scans)
 Easy time-series analysis with pandas/Excel
 Filter by date range for progress tracking
 Consistent date column across all 3 CSV files
 Enables queries like: 'Show me trunk fat % over last 6 months'

EXAMPLE USAGE:
  import pandas as pd
  regional = pd.read_csv('regional.csv')
  arms = regional[regional['Region'] == 'Arms']
  # Now you can track Arms progress over time!

Each scan now adds:
- 1 row to overall.csv
- 6 rows to regional.csv (one per region)
- 6 rows to muscle_balance.csv (one per limb comparison)
This commit is contained in:
Mac DeCourcy 2025-10-07 15:24:29 -07:00
parent 130f0ba994
commit c7d2e32d7d
2 changed files with 11 additions and 5 deletions

View file

@ -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.

View file

@ -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"],