- HTML 58.6%
- Python 41.4%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| outputs | ||
| source | ||
| .gitignore | ||
| .gitmodules | ||
| README.md | ||
Medical Images as Biomarkers for Ageing
This is the source code to the submission with the title "Local and Global Patterns Support Medical Imaging as a Biomarker of Ageing".
We investigate how medical images can be used as biomarkers for ageing and provede the source code to reproduce the training and the analyses.
Structure of this Repository
outputs
The outputs folder is used to save result files of the analyses and figures. It also contains the PheWAS results, which can be used in source/analysis/phewas_interactive_plot.py to run the interactive plot. The phewas results are saved in the files phewas_table.csv (without the explicit names of the fields) and phewas_table2.csv with an additional column indicating the feature name.
source
The source folder contains the main source code components. It contains four sub-directories: analysis, cnn, logs, optimizers
analysis
This folder contains python scripts that can be used to perform the analyses of our work.
- The file
config_diseases.pycontainas the ICD10 codes and self-reported disease codes we used to filter for specific diseases. - The file
create_frankenstin.pycreates the altered Digital Twin with replaced organs. - The file
disease_analysis.pycontains the code to run the analysis of the subjects with diseases. - The
environment.yamlfile contains the environment parameters. - The file
linear_correction.pycan be used to perform the linear correction of the initial predictions. - The
paths.pyfile contains all paths - here replaced with pseudo-paths. If you want to run this code, you need to replace all paths to actual data - The file
perform_phewas.pycan be used to perform the PheWAS analysis. The result of our PheWAS analysis is saved in the outpts folder asphewas_table.csv, which can be used to run the interactive plot. phewas_manhattan_plot.htmlis the intgeractive Manhattan plot as an html file, which can be opened in the browser.- The file
predict_frankenstein.pycan be used to predict the age of the Frankenstein creations. - The file
survival.pycan be used to analyse the correlation between accelerated ageing and survival. - The file
utils.pycontains utility functions necessary to run the anlayses.
cnn
- The folder
datasetcontains all python scripts regarding the datasets - The folder
modelcontains all python code regarding the models - The file
data_info.jsoncontains all paths relevant for training the models including data paths, checkpoint paths and paths to csv files containing the train/test/val subjects. - The file
predict.pycan be used to run the prediction with a trained model. - The file
train_utils.pycontains utility functions for training. - The file
train.pyis the main script to start the training. - The file
trainer.pyis been called bytrain.pyto start the training.
registration
This folder contains the code to perform the affine and deformable registration we use for the assessment pipeline and for creating the "Frankenstein Monsters". It also contains a separate environment file ukbb_reg.yaml which can be used to create a new conda environment for the registration code. (see below how to create conda environments.)
Using the Code Base
1. Create conda env and install packages
conda env create --file environment.yaml
conda env activate age_biomarkers
2. Run the training scripts
The training of the Models can be started using the following command. The segmentation parameter indicates the specific organ (e.g. "liver", "lungs", or "all" for the whole body) and the modality parameter specifies whether you want to use the brain images or the whole-body images.
python cnn/train.py --modality whole_body_3d --segmentation lungs
3. Run the predictions
After training, the predict.py file can be used to generate the predicitons of the train/test/val sets. Here no augmentation is applied. The resutls/predictions are then stored in csv files containing the subject IDs, their actual age, the predicted age.
4. Analyse the results
By running the scripts in the analysis folder, the different analyses can be run.
5. Registration pipeline
For running the registration pipleine, the file registration.py in the registration folder can be executed. The subject IDs that are supposed to be set as reference and moving images as well as the paths to the data need to be customised.