Skip to content

This project estimates bone age based on spatial features extracted from multiplex images, aiming to relate the spatial remodeling introduced by treatment with the aging process.

License

Notifications You must be signed in to change notification settings

MLO-lab/BoneAgeEstimation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BoneAgeEstimation

This project estimates bone age based on spatial features extracted from multiplex images, aiming to relate the spatial remodeling introduced by treatment with the aging process. The pipeline includes data loading, spatial transformation, probability density estimation, machine learning-based age prediction, and visualization of results.


Requirements

This pipeline relies on several Python packages, which can be installed automatically via the provided Conda environment file.

Installation

  1. Ensure you have Conda installed on your system.
  2. Clone the repository and navigate to the directory
  3. Create the Conda environment using the environment.yml file:
    conda env create -f environment.yml
  4. Activate the environment:
    conda activate BoneAgeEstimation

These commands will set up the necessary environment with all required dependencies.

Data Arrangement

To ensure proper functionality, organize your data in the following folder structure within the project's root directory:

data_bone_age: Organize other data files following this structure:

  • <condition>/: For the condition of interest (e.g., "3mo", "5fu30d"). One subfolder for one condition. The .ims files should be placed under the corresponding condition folder.
  • affinity_matrices/: For cluster affinity matrices.
  • The positions CSV files should be placed under the folder directly.

Workflow

0. Libraries and Parameters

This section initializes the required libraries and sets user-defined parameters.

1. Data Loading

The first step is to import the necessary data files, which include:

  • CSV Files: Contains quantitative data (positions).
  • IMS Image Files: Images for bone samples for the bone space alignment and transformation.
  • Affinity Matrices: Pre-computed matrices that represent the spatial relationships between different clusters within the bone samples.

2. Data Inspection and Preprocessing

After loading the data, this step visually inspects the image data and performs adjustments, such as flipping the image on the x or y axis to ensure proper orientation.

3. Bone Alignment and Transformation

In this step, each bone sample is aligned to a reference bone. All samples are transformed to the reference space, ensuring consistency across data.

4. Components Calculation and Estimation

The pipeline calculates the PDFs of the spatial distributions of HSCs, RDs, and cKits. It also computes the spatial cluster compositions for each sample. The results are saved in a structured format for further analysis.

5. Bone Age Estimation

This section includes the following:

  • Utility Functions: Functions to assist in the bone age estimation process.
  • Training Data Generation: Generates training data for linear and Gaussian models separately.
  • Weight Optimization: Optimizes the weights for the linear model.
  • Age Prediction: Uses the optimized models to predict the bone age based on the input data.

6. Visualization

This section generates various visualizations to interpret the results of the bone age estimation process. The visualizations include:

  • Element-wise bone age maps
  • Spatial density maps of HSCs, RDs, and cKits
  • Heatmap of cKit cluster affinities
  • Bone age visualizations
  • SHAP visualizations for model interpretability

Usage

  1. Run each section of the pipeline sequentially, ensuring all paths and parameters are correctly set for your specific dataset.
  2. Inspect intermediate visualizations to verify data quality and make adjustments as needed.
  3. Save output figures and clustering data as needed for further analysis or reporting.

Example

The transforamtion.ipynb notebook serves as an example illustrating the transformation of the bone samples to a reference space. It used the real outlines saved under the folder examples, which includes the following steps:

  1. Parameter Setting: Keep the parameters as they are, or adjust them according to your needs based on the recommendations in the notebook.
  2. Outline Visualization: Visualize the outlines of the bone samples.
  3. Generate Data: Randomly generate data as the cells. Optionally, we also included horizontal lines as anoter example of the data.
  4. Generate Structured Anchors: Generate structured anchors for the transformation.
  5. Perform Transformation: Perform the transformation of the data to the reference space.

About

This project estimates bone age based on spatial features extracted from multiplex images, aiming to relate the spatial remodeling introduced by treatment with the aging process.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published