brain_age_prediction package
Subpackages
- brain_age_prediction.utils package
Submodules
brain_age_prediction.functional_model_selection module
Perform Model Selection for the functional model
brain_age_prediction.joint_model_selection module
Perform Model Selection for the joint model
brain_age_prediction.mae_analysis module
Study the distribution of absolute errors for the three different models and study the significance of the differences in means.
- brain_age_prediction.mae_analysis.compute_mae(model, df_s, df_f, model_type)
Analyze regression model results by computing Mean Absolute Error (MAE).
- Parameters:
model (keras.models.Model) – Trained regression model.
df_s (pandas.DataFrame) – DataFrame for structural features.
df_f (pandas.DataFrame) – DataFrame for functional features.
model_type (str) – Model type (‘structural’, ‘functional’, or ‘joint’).
This function preprocesses input data, splits it into test sets, and evaluates the model’s performance by computing the Mean Absolute Error (MAE). The results are printed, and absolute errors are returned.
- brain_age_prediction.mae_analysis.plot_distributions(ae_1, ae_2, label1, label2)
Plot an histogram of Absolute Error (AE) distributions.
- Parameters:
ae_1 (numpy.ndarray) – Absolute errors from the first model.
ae_2 (numpy.ndarray) – Absolute errors from the second model.
label1 (str) – Label for the first model.
label2 (str) – Label for the second model.
This function plots the histogram of the absolute error distributions for two models, calculates the empirical p-value, and saves the plot.
brain_age_prediction.model_assessment module
Retrain the selected model on the entirety of the training se, and assess its performances on the test set.
- brain_age_prediction.model_assessment.load_model_architecture(model_type)
Load a saved Keras model architecture with the best hyperparameters found.
- Parameters:
model_type (str) – Type of the model (‘structural’, ‘functional’, or ‘joint’).
- Returns:
The loaded Keras model.
- Return type:
keras.models.Sequential
- brain_age_prediction.model_assessment.plot_loss(history, model_type)
Plot the training and test loss during model training.
- Parameters:
history (dict) – The training history obtained from model training.
model_type (str) – Type of the model (‘structural’, ‘functional’, or ‘joint’).
- brain_age_prediction.model_assessment.retrain(x_train, y_train, x_test, y_test, model_type)
Re-train the best model obtained through model selection on all the available data of the training set. Then evaluate the model on the test set. Finally, save the model to file.
- Parameters:
x_train (numpy.ndarray) – Input features of the training set.
y_train (numpy.ndarray) – Targets of the training set.
x_test (numpy.ndarray) – Input features of the test set.
y_test (numpy.ndarray) – Targets of the test set.
model_type (str) – Type of the model (‘structural’, ‘functional’, or ‘joint’).
- brain_age_prediction.model_assessment.save_model(model, model_type)
Save the Keras model architecture and weights to disk.
- Parameters:
model (keras.models.Sequential) – The Keras model to be saved.
model_type (str) – Type of the model (‘structural’, ‘functional’, or ‘joint’).
brain_age_prediction.pad_analysis module
Given the ML models already trained on the TD group, apply them to the study of ASD subject. In particular, study the Predicted Age Difference (PAD) distributions for the different models, and look for significant differences.
- brain_age_prediction.pad_analysis.asd_analysis(model, df_s, df_f, model_type)
Analyze ASD data using the regression model.
- Parameters:
model (keras.models.Sequential) – The trained Keras regression model.
df_s (pd.DataFrame) – Dataframe containing structural features for ASD group.
df_f (pd.DataFrame) – Dataframe containing functional features for ASD group.
model_type (str) – Type of the model (‘structural’, ‘functional’, or ‘joint’).
- Returns:
Predicted Age Difference (PAD) for ASD group.
- Return type:
numpy.ndarray
- brain_age_prediction.pad_analysis.plot_distributions(pad_td, pad_asd, model_type)
Plot Predicted Age Difference (PAD) distributions.
- Parameters:
pad_td (numpy.ndarray) – PAD for TD group.
pad_asd (numpy.ndarray) – PAD for ASD group.
model_type (str) – Type of the model (‘structural’, ‘functional’, or ‘joint’).
- brain_age_prediction.pad_analysis.td_analysis(model, df_s, df_f, model_type)
Analyze TD data using the regression model.
- Parameters:
model (keras.models.Sequential) – The trained Keras regression model.
df_s (pd.DataFrame) – Dataframe containing structural features for TD group.
df_f (pd.DataFrame) – Dataframe containing functional features for TD group.
model_type (str) – Type of the model (‘structural’, ‘functional’, or ‘joint’).
- Returns:
Predicted Age Difference (PAD) for TD group.
- Return type:
numpy.ndarray
brain_age_prediction.structural_model_selection module
Perform Model Selection for the structural model