Ma Data Extraction
Overview
Extract consistent data, capture provenance, and build a clean analysis dataset.
Inputs
04_fulltext/manifest.csv01_protocol/outcomes.md
Outputs
05_extraction/extraction.sqlite05_extraction/extraction.csv05_extraction/llm_suggestions.jsonl(optional)05_extraction/data-dictionary.md05_extraction/extraction-log.md05_extraction/study_map.csv(optional ifrecord_idnot in extraction CSV)05_extraction/source.csv(optional source references)05_extraction/source_validation.md(optional)
Workflow (Web-First Hybrid — Default)
⚠️ Default approach: Run web-based extraction FIRST, then use PDFs only for gaps.
Phase 1: Web-Based Extraction (Default — Run First)
- Define a data dictionary that covers outcomes, covariates, and study identifiers.
- Write to
05_extraction/data-dictionary.md(usereferences/data-dictionary-template.md)
- Write to
- Initialize a normalized SQLite database using
scripts/init_extraction_db.pyviauv run.- Use
scripts/init_extraction_db.py - Creates
05_extraction/extraction.sqlite
- Use
- Run WebSearch extraction for ALL included studies — see WebSearch Extraction (Default) below.
- Read from
03_screening/round-01/included.bibor04_fulltext/manifest.csv - This fills 70-80% of data fields automatically from PubMed, ClinicalTrials.gov, etc.
- Tag all web-sourced values with
[web]in thenotescolumn - Write to
05_extraction/extraction.sqlite(studies table)
- Read from
- Review confidence scores: flag studies/fields with confidence < 0.7.
Phase 2: PDF-Based Extraction (Only for Gaps)
- For studies with low-confidence fields, run
scripts/llm_extract.pyviauv runon available PDFs.- Use
scripts/llm_extract.py - Read PDFs from
04_fulltext/*.pdf - Write to
05_extraction/llm_suggestions.jsonl
- Use
- Extract remaining data with double-entry or verification where possible.
- Update
05_extraction/extraction.sqlite
- Update
- Record unit conversions and assumptions in
05_extraction/extraction-log.md.- Write to
05_extraction/extraction-log.md
- Write to
- Export a tidy CSV for analysis and lock the database snapshot.
- Export
05_extraction/extraction.csvfrom SQLite
- Export
- (Recommended) Record source references in
05_extraction/source.csvand validate withscripts/validate_sources.py.- Write to
05_extraction/source.csv(usereferences/source-template.csv) - Validate with
scripts/validate_sources.py→05_extraction/source_validation.md
- Write to
Resources
scripts/init_extraction_db.pyinitializes a standard extraction schema.scripts/llm_extract.pyprovides LLM-assisted extraction suggestions.scripts/validate_sources.pyvalidates extraction vs source references.references/data-dictionary-template.mdprovides a dictionary scaffold.references/study-map-template.csvmapsrecord_idtostudy_idif needed.references/source-template.csvfor source references. Note:llm_extract.pyrequires a PDF parser such aspdfplumberorpypdf(install viauv add).
WebSearch Extraction (Default)
⚠️ This is the DEFAULT first step — Claude Code should run this BEFORE attempting PDF-based extraction. No scripts or API keys required.
When to Use
- ALWAYS — run as Phase 1 for every extraction workflow
- Fills 70-80% of fields from structured online sources
- Identifies exactly which studies need PDF follow-up
Procedure
- Identify gaps: Scan
extraction.csvfor NULL or empty cells in critical columns (e.g.,n_total,events_intervention,events_control,mean,sd). - Search per study: For each study with gaps, run
WebSearchwith the query pattern:"<first_author> <year> <journal> <intervention> <outcome> results"or"<DOI>"or"PMID:<pmid> abstract"
- Fetch structured sources: Use
WebFetchon high-value URLs:- PubMed abstract:
https://pubmed.ncbi.nlm.nih.gov/<pmid>/ - ClinicalTrials.gov:
https://clinicaltrials.gov/study/<nct_id> - Europe PMC:
https://europepmc.org/article/MED/<pmid>
- PubMed abstract:
- Extract and fill: Read the returned content, extract the missing values, and update
extraction.csv. - Tag provenance: For every web-filled value, append
[web]in thenotescolumn (e.g.,n_total from PubMed abstract [web]). - Log in extraction-log.md: Record which studies/fields were filled via web search, with source URLs.
Confidence Rules
| Source | Confidence | Action |
|---|---|---|
| PubMed structured abstract | 0.90 | Accept |
| ClinicalTrials.gov registry | 0.85 | Accept |
| Journal webpage / press release | 0.70 | Accept with note |
| Conference abstract only | 0.60 | Flag for verification |
| No source found | — | Leave NULL, document gap |
Limitations
- Cannot access paywalled full-text content via WebFetch
- Event counts by subgroup are rarely in abstracts
- Risk-of-bias details require full Methods section
- Always cross-check web-filled values if PDFs become available later
Validation
- Run consistency checks on missingness, ranges, and duplicated entries.
- Reconcile any discrepancies between double entries before analysis.
- Validate source coverage with
scripts/validate_sources.pywhen sources are available.
Pipeline Navigation
| Step | Skill | Stage |
|---|---|---|
| Prev | /ma-fulltext-management |
04 Full-text Management |
| Next | /ma-meta-analysis |
06 Statistical Analysis |
| All | /ma-end-to-end |
Full pipeline orchestration |