{"id":36985176,"url":"https://github.com/efrod/bca-survival-analyzer","last_synced_at":"2026-01-13T23:01:04.166Z","repository":{"id":329020572,"uuid":"1112233315","full_name":"eFroD/bca-survival-analyzer","owner":"eFroD","description":"A tool that helps you performing survival analysis on body composition data.","archived":false,"fork":false,"pushed_at":"2025-12-16T22:47:55.000Z","size":5438,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-13T19:44:54.823Z","etag":null,"topics":["python","statistics","survival-analysis"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eFroD.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-08T10:40:21.000Z","updated_at":"2025-12-16T23:59:47.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/eFroD/bca-survival-analyzer","commit_stats":null,"previous_names":["efrod/bca-survival-analyzer"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/eFroD/bca-survival-analyzer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eFroD%2Fbca-survival-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eFroD%2Fbca-survival-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eFroD%2Fbca-survival-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eFroD%2Fbca-survival-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eFroD","download_url":"https://codeload.github.com/eFroD/bca-survival-analyzer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eFroD%2Fbca-survival-analyzer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28405148,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","statistics","survival-analysis"],"created_at":"2026-01-13T23:00:51.856Z","updated_at":"2026-01-13T23:01:04.151Z","avatar_url":"https://github.com/eFroD.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/eFroD/bca-survival-analyzer/actions/workflows/ci.yml/badge.svg)](https://github.com/eFroD/bca-survival-analyzer/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/github/eFroD/bca-survival-analyzer/graph/badge.svg?token=JUUDEAQJ96)](https://codecov.io/github/eFroD/bca-survival-analyzer)\n[![Documentation](https://img.shields.io/badge/docs-latest-blue.svg)](https://eFroD.github.io/bca-survival-analyzer/)\n[![PyPI](https://img.shields.io/pypi/v/bca-survival.svg)](https://pypi.org/project/bca-survival/)\n[![Python Version](https://img.shields.io/pypi/pyversions/bca-survival.svg)](https://pypi.org/project/bca-survival/)\n\n\n# Survival Analysis Package\n\nA Python package for analyzing survival data with a focus on body composition assessment. It was designed to utilize the results obtained by the [BOA - Body and Organ Analysis](https://github.com/UMEssen/Body-and-Organ-Analysis) workflow. In this repository we provide tools to reorganize the result of this algorithm to merge it to the patient table, add tools for data cleaning and a [lifelines](https://zenodo.org/records/10456828) wrapper for automatical explorative anaylsis on survival outcomes given the Body-Composition results. \n\n## Features\n\n- **Survival Analysis**: Cox proportional hazards regression and Kaplan-Meier survival curves\n- **Body Composition Analysis**: Tools for processing and analyzing BCA data\n- **BOA Extractor**: Command-line tool for extracting measurements from BOA data\n- **Data Preprocessing**: Utilities for cleaning and preparing survival data\n- **CLI Tools**: Command-line utilities for data merging, format conversion, and PDF encryption\n\n## Installation\n\n```bash\npip install bca-survival\n```\n\n## Usage\n\n### Basic Survival Analysis\n```python\nfrom bca_survival.analyzer import BCASurvivalAnalyzer\n\n# Load your data, sharing the same identifiers\ndf_main = pd.read_csv('clinical_data.csv')\ndf_measurements = pd.read_csv('bca_measurements.csv')\n\n# Initialize the analyzer\nanalyzer = BCASurvivalAnalyzer(\n    df_main, df_measurements,\n    main_id_col='patient_id', measurement_id_col='id',\n    start_date_col='diagnosis_date', event_date_col='event_date', event_col='event_status'\n)\n\n# Perform univariate analysis\ncolumns = ['l5::WL::imat::mean_ml', 'l5::WL::tat::mean_ml', 'age', 'gender']\nresults = analyzer.univariate_cox_regression(columns)\n\n# Generate Kaplan-Meier plot\nanalyzer.kaplan_meier_plot('l5::WL::imat::mean_ml', split_strategy='median')\n\n# Perform multivariate analysis\nmodel = analyzer.multivariate_cox_regression(columns)\n```\n\n## Command-Line Tools\n\nThe package includes several command-line tools for common data processing tasks:\n\n### BOA Extractor\n\nExtract measurements from BOA (Body Composition Assessment) data:\n```bash\nboa-extract /path/to/data /path/to/output\n```\n\n**Purpose**: Processes BOA data files and extracts relevant measurements for survival analysis.\n\n**Arguments**:\n- `data_path`: Path to the directory containing BOA data files\n- `output_path`: Path where extracted measurements will be saved\n\n---\n\n### BCA Merger\n\nMerge two Excel files based on ID columns:\n```bash\nbca-merge \u003cfirst_file\u003e \u003csecond_file\u003e \u003cid_column_name\u003e\n```\n\n**Purpose**: Combines clinical data with body composition measurements by matching on ID columns.\n\n**Arguments**:\n- `first_file`: Path to the first Excel file (e.g., clinical data)\n- `second_file`: Path to the second Excel file (e.g., BCA measurements)\n- `id_column_name`: Name of the ID column in the first file to match with 'StudyID' in the second file\n\n**Example**:\n```bash\nbca-merge clinical_data.xlsx bca_measurements.xlsx patient_id\n```\n\n**Output**: Creates a file named `{first_file}_merged.xlsx` with:\n- All rows from both files (outer join)\n- Matched records combined into single rows\n- Date columns formatted as DD.MM.YYYY\n- No duplicate StudyID columns\n\n**Notes**:\n- The second file must have a column named 'StudyID'\n- Uses outer merge to preserve all data from both files\n- Automatically removes duplicate ID columns\n\n---\n\n### Survival Result Converter\n\nConvert Excel files to multiple formats (PDF, CSV, TXT):\n```bash\nsurvival-result-converter [directory]\n```\n\n**Purpose**: Batch converts Excel files to multiple formats for reporting and data sharing.\n\n**Arguments**:\n- `directory`: Directory to scan for Excel files (default: current directory)\n\n**Example**:\n```bash\n# Convert all Excel files in current directory\nsurvival-result-converter\n\n# Convert Excel files in specific directory\nsurvival-result-converter /path/to/results\n```\n\n**Output Structure**:\n```\ndirectory/\n├── PDF/\n│   ├── file1.pdf\n│   └── file2.pdf\n├── CSV/\n│   ├── file1.csv\n│   ├── file2_sheet1.csv\n│   └── file2_sheet2.csv\n└── TXT/\n    ├── file1.txt\n    └── file2.txt\n```\n\n**Features**:\n- Recursively processes all `.xlsx` files in the directory tree\n- Creates separate output folders (PDF, CSV, TXT)\n- For multi-sheet Excel files:\n  - PDF: All sheets in single file\n  - CSV: Separate file per sheet\n  - TXT: All sheets in single file with separators\n- PDF generation supports two methods:\n  - Windows: Uses COM automation for high-quality output\n  - Cross-platform: Uses fpdf library with automatic column sizing\n\n**PDF Features**:\n- Landscape orientation for better table visibility\n- Automatic column width adjustment\n- Fits tables to page width\n- Handles large tables (up to 1000 rows per sheet)\n- Text wrapping for long content\n\n---\n\n### PDF Report Extractor\n\nEncrypt and organize PDF files from a directory tree:\n```bash\npdf-report-extractor \u003cinput_path\u003e \u003coutput_path\u003e \u003cpassword\u003e\n```\n\n**Purpose**: Finds PDF files in a directory structure, copies them with standardized names, and encrypts them for secure distribution.\n\n**Arguments**:\n- `input_path`: Root directory to search for PDF files\n- `output_path`: Destination directory for encrypted PDFs\n- `password`: Password to encrypt the PDFs with\n\n**Example**:\n```bash\npdf-report-extractor /data/patient_reports /encrypted_reports MySecureP@ss123\n```\n\n**Behavior**:\n- Recursively searches for all `.pdf` files\n- Copies files to destination with naming pattern: `encrypted_{parent_folder_name}.pdf`\n- Encrypts each file using user password protection\n- Requires `pdftk` to be installed\n\n**Check pdftk Installation**:\n```bash\npdf-report-extractor --check-pdftk\n```\n\n**Installing pdftk**:\n- Ubuntu/Debian: `sudo apt-get install pdftk`\n- macOS: `brew install pdftk-java`\n- Windows: Download from [PDFtk website](https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/)\n\n**Output Summary**:\n```\nProcessing: /data/patient_reports/folder1/report.pdf\n  -\u003e /encrypted_reports/encrypted_folder1.pdf\n  -\u003e Encrypted successfully\n\nProcessing complete:\n  - Files processed successfully: 15\n  - Errors: 0\n```\n\n**Notes**:\n- Original files remain unchanged\n- If encryption fails, the unencrypted copy is removed from destination\n- Parent folder name is used for output filename (one level up from the PDF)\n\n---\n\n## Documentation\n\nRefer to the documentation in the `docs/` directory for detailed information:\n\n1. Install the package with documentation dependencies:\n```bash\n   pip install -e \".[docs]\"\n```\n\n2. Build the documentation on Windows:\n```bash\n   cd docs\n   make.bat html\n```\n   \n   Or on Linux/macOS:\n```bash\n   cd docs\n   make html\n```\n\n3. Open `docs/build/html/index.html` in your browser\n\n## Development\n\nClone the repository and install in development mode:\n```bash\ngit clone https://gitlab.com/your-group/survival-analysis.git\ncd survival-analysis\npip install -e \".[dev]\"\n```\n\n## Requirements\n\n### Core Dependencies\n- pandas\n- openpyxl (for Excel file handling)\n- lifelines (for survival analysis)\n\n### Optional Dependencies\n- **For PDF conversion** (survival-result-converter):\n  - Windows: pywin32\n  - Cross-platform: fpdf, openpyxl\n- **For PDF encryption** (pdf-report-extractor):\n  - pdftk (external dependency)\n\n## Common Workflows\n\n### Workflow 1: Complete Data Processing Pipeline\n```bash\n# 1. Merge clinical and BCA data\nbca-merge clinical.xlsx measurements.xlsx PatientID\n\n# 2. Perform survival analysis (Python)\n# ... (use BCASurvivalAnalyzer)\n\n# 3. Convert results to multiple formats\nsurvival-result-converter ./results\n\n# 4. Encrypt PDF reports for distribution\npdf-report-extractor ./results/PDF ./encrypted_reports SecurePassword123\n```\n\n### Workflow 2: Quick Data Conversion\n```bash\n# Convert a directory of Excel results to PDF\nsurvival-result-converter /path/to/results\n\n# PDFs are created in /path/to/results/PDF/\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefrod%2Fbca-survival-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fefrod%2Fbca-survival-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefrod%2Fbca-survival-analyzer/lists"}