bca_survival.tools.bca_totalseg_extraction module
BOA Results extractor
This script processes BOA data by extracting measurements from the individual JSON files across a directory structure. It targets two types of measurement files: - total-measurements.json: Contains segmentation measurements for various organs - bca-measurements.json: Contains body composition analysis measurements
The script consolidates these measurements into Excel spreadsheets for further analysis.
- Usage:
boa-extract base_path output_path python -m survival_analysis.boa_extractor base_path output_path
Author: Eric
- bca_survival.tools.bca_totalseg_extraction.process_json_files(root_dir)[source]
Walks through the directory structure, identifies relevant JSON files, processes them, and compiles the data into pandas DataFrames.
- Parameters:
root_dir (str) – The root directory to search for measurement files
- Returns:
- A tuple containing two DataFrames:
final_total_df: DataFrame with organ segmentation measurements
final_bca_df: DataFrame with body composition analysis measurements
- Return type:
tuple
- bca_survival.tools.bca_totalseg_extraction.process_totalseg_measurements(file_path, dirpath)[source]
Processes an individual total-measurements.json file to extract organ segmentation measurements.
- Parameters:
file_path (str) – Path to the JSON file
dirpath (str) – Directory path containing the file (used to extract the study ID)
- Returns:
A DataFrame with one row representing the measurements from the file
- Return type:
pandas.DataFrame
- bca_survival.tools.bca_totalseg_extraction.process_bca_measurements(folder_path)[source]
Processes the bca-measurements.json file in the given folder and extracts the measurement data.
- Parameters:
folder_path (str) – The path to the folder containing the bca-measurements.json file.
- Returns:
- A DataFrame containing the measurement data with formatted
column names, or None if the file doesn’t exist.
- Return type:
pandas.DataFrame or None
- bca_survival.tools.bca_totalseg_extraction.main(root_path, output_path)[source]
Main function to iterate over folders, process the JSON files, and save the results to Excel files.
- Parameters:
root_path (str) – The base directory containing the folders with JSON files
output_path (str) – Path to save the resulting Excel files
- Return type:
None