Skip to content

Commit

Permalink
added bland-altman on folders
Browse files Browse the repository at this point in the history
  • Loading branch information
haesleinhuepf committed Jul 2, 2023
1 parent 504717e commit 94aaf13
Show file tree
Hide file tree
Showing 3 changed files with 588 additions and 0 deletions.
562 changes: 562 additions & 0 deletions docs/41_descriptive_statistics/bland_altman_on_folders_of_images.ipynb

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions docs/41_descriptive_statistics/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# A function for drawing Bland-Altman plots
# source: modified from https://stackoverflow.com/questions/16399279/bland-altman-plot-in-python
import matplotlib.pyplot as plt
import numpy as np

def bland_altman_plot(data1, data2, measure="", title="", *args, **kwargs):
"""
Draws a Bland-Altman plot from two lists of measurements.
The physical measure should be given to put in axis labels.
The given title will show on top of the plot.
"""
data1 = np.asarray(data1)
data2 = np.asarray(data2)
mean = np.mean([data1, data2], axis=0)
diff = data1 - data2 # Difference between data1 and data2
md = np.mean(diff) # Mean of the difference
sd = np.std(diff, axis=0) # Standard deviation of the difference

plt.scatter(mean, diff, *args, **kwargs)
plt.axhline(md, color='gray', linestyle='--')
plt.axhline(md + 1.96*sd, color='gray', linestyle='--')
plt.axhline(md - 1.96*sd, color='gray', linestyle='--')
plt.xlabel("average " + measure)
plt.ylabel("difference " + measure)
plt.title(title)
1 change: 1 addition & 0 deletions docs/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ parts:
- file: 41_descriptive_statistics/basic_descriptive_statistics
- file: 41_descriptive_statistics/descriptive_statistics_label_images
- file: 41_descriptive_statistics/Bland_altman_analysis
- file: 41_descriptive_statistics/bland_altman_on_folders_of_images

# - file: 44_hypothesis_testing/readme
# sections:
Expand Down

0 comments on commit 94aaf13

Please sign in to comment.