finish sensitivity analysis
This commit is contained in:
parent
16a8da2dfc
commit
4b406f033a
55
analysis.py
55
analysis.py
@ -17,26 +17,28 @@ def main():
|
|||||||
# parser.add_argument("dir", help="folder containing the cell folders with the fit results")
|
# parser.add_argument("dir", help="folder containing the cell folders with the fit results")
|
||||||
# args = parser.parse_args()
|
# args = parser.parse_args()
|
||||||
|
|
||||||
dir_path = "results/invivo_results/" # args.dir
|
# dir_path = "results/invivo_results/" # args.dir
|
||||||
|
dir_path = "results/results_add__trial_more_iter_NM/invivo_results" # args.dir
|
||||||
|
|
||||||
# if not os.path.isdir(dir_path):
|
# if not os.path.isdir(dir_path):
|
||||||
# print("Argument dir is not a directory.")
|
# print("Argument dir is not a directory.")
|
||||||
# parser.print_usage()
|
# parser.print_usage()
|
||||||
# exit(0)
|
# exit(0)
|
||||||
# sensitivity_analysis(dir_path, max_models=2)
|
sensitivity_analysis(dir_path, max_models=3)
|
||||||
fits_info = get_fit_info(dir_path)
|
|
||||||
|
# fits_info = get_fit_info(dir_path)
|
||||||
errors = calculate_percent_errors(fits_info)
|
#
|
||||||
create_boxplots(errors)
|
# errors = calculate_percent_errors(fits_info)
|
||||||
labels, corr_values, corrected_p_values = behaviour_correlations(fits_info, model_values=False)
|
# create_boxplots(errors)
|
||||||
create_correlation_plot(labels, corr_values, corrected_p_values)
|
# labels, corr_values, corrected_p_values = behaviour_correlations(fits_info, model_values=False)
|
||||||
|
# create_correlation_plot(labels, corr_values, corrected_p_values)
|
||||||
labels, corr_values, corrected_p_values = parameter_correlations(fits_info)
|
#
|
||||||
create_correlation_plot(labels, corr_values, corrected_p_values)
|
# labels, corr_values, corrected_p_values = parameter_correlations(fits_info)
|
||||||
|
# create_correlation_plot(labels, corr_values, corrected_p_values)
|
||||||
create_parameter_distributions(get_parameter_values(fits_info))
|
#
|
||||||
cell_b, model_b = get_behaviour_values(fits_info)
|
# create_parameter_distributions(get_parameter_values(fits_info))
|
||||||
create_behaviour_distributions(cell_b, model_b)
|
# cell_b, model_b = get_behaviour_values(fits_info)
|
||||||
|
# create_behaviour_distributions(cell_b, model_b)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@ -293,7 +295,7 @@ def sensitivity_analysis(dir_path, par_range=(0.5, 1.6, 0.1), contrast_range=(-0
|
|||||||
if "vector_strength" in behaviours:
|
if "vector_strength" in behaviours:
|
||||||
par_responses[par]["vector_strength"][i] = baseline.get_vector_strength()
|
par_responses[par]["vector_strength"][i] = baseline.get_vector_strength()
|
||||||
|
|
||||||
fi_curve = FICurveModel(model_copy, contrasts, eod, trials=10)
|
fi_curve = FICurveModel(model_copy, contrasts, eod, trials=20)
|
||||||
|
|
||||||
if "f_inf_slope" in behaviours:
|
if "f_inf_slope" in behaviours:
|
||||||
par_responses[par]["f_inf_slope"][i] = fi_curve.get_f_inf_slope()
|
par_responses[par]["f_inf_slope"][i] = fi_curve.get_f_inf_slope()
|
||||||
@ -304,7 +306,26 @@ def sensitivity_analysis(dir_path, par_range=(0.5, 1.6, 0.1), contrast_range=(-0
|
|||||||
|
|
||||||
model_behaviour_responses.append(par_responses)
|
model_behaviour_responses.append(par_responses)
|
||||||
|
|
||||||
pass
|
print("sensitivity analysis done!")
|
||||||
|
plot_sensitivity_analysis(model_behaviour_responses, behaviours, parameters, factors)
|
||||||
|
|
||||||
|
|
||||||
|
def plot_sensitivity_analysis(responses, behaviours, parameters, factors):
|
||||||
|
fig, axes = plt.subplots(len(behaviours), len(parameters), sharex="all", sharey="row", figsize=(8, 8))
|
||||||
|
for i, behaviour in enumerate(behaviours):
|
||||||
|
for j, par in enumerate(parameters):
|
||||||
|
|
||||||
|
for model in responses:
|
||||||
|
axes[i, j].plot(factors, model[par][behaviour])
|
||||||
|
|
||||||
|
if j == 0:
|
||||||
|
axes[i, j].set_ylabel("{}".format(behaviour))
|
||||||
|
if i == 0:
|
||||||
|
axes[i, j].set_title("{}".format(par))
|
||||||
|
|
||||||
|
plt.tight_layout()
|
||||||
|
plt.show()
|
||||||
|
plt.close()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user