Skip to content

Commit

Permalink
Add generated inflammation graphs and links in material
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-crouch committed Oct 7, 2019
1 parent e906c44 commit 7c80b6c
Show file tree
Hide file tree
Showing 9 changed files with 220 additions and 8 deletions.
2 changes: 1 addition & 1 deletion _episodes/11-scientific-numpy.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ So here, we're looking at the maximum inflammation across all days for the first
What if we need the maximum inflammation for each patient over all days (as in the next diagram on the left) or the average for each day (as in the diagram on the right)? As the diagram below shows, we want to perform the operation across an axis:
FIXME: Operations Across Axes image - /fig/python-operations-across-axes.png
![operations-across-axes](../fig/11-python-operations-across-axes.png)
To support this functionality, most array functions allow us to specify the axis we want to work on. If we ask for the average across axis 0 (rows in our 2D example), we get:
Expand Down
14 changes: 7 additions & 7 deletions _episodes/13-visualisation-matplotlib.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ matplotlib.pyplot.show()
~~~
{: .language-python}
FIXME: add Heatmap of the Data ../fig/01-numpy_71_0.png
![inflammation-heatmap-imshow](../fig/13-inflammation-01-heatmap-imshow.svg)
Blue pixels in this heat map represent low values, while yellow pixels represent high values. As we can see, inflammation rises and falls over a 40-day period.
Expand All @@ -66,7 +66,7 @@ matplotlib.pyplot.show()
~~~
{: .language-python}
FIXME: add Average Inflammation Over Time ../fig/01-numpy_73_0.png
![inflammation-average-imshow](../fig/13-inflammation-01-average.svg)
Here, we have put the average per day across all patients in the variable `ave_inflammation`, then asked `matplotlib.pyplot` to create and display a line graph of those values. The result is a roughly linear rise and fall, which is suspicious: we might instead expect a sharper rise and slower fall. Let's have a look at two other statistics:
Expand All @@ -76,15 +76,15 @@ matplotlib.pyplot.show()
~~~
{: .language-python}
FIXME: add Maximum Value Along The First Axis ../fig/01-numpy_75_1.png
![inflammation-maximum-imshow](../fig/13-inflammation-01-maximum.svg)
~~~
min_plot = matplotlib.pyplot.plot(numpy.min(data, axis=0))
matplotlib.pyplot.show()
~~~
{: .language-python}
FIXME: add Minimum Value Along The First Axis ../fig/01-numpy_75_3.png
![inflammation-minimum-imshow](../fig/13-inflammation-01-minimum.svg)
The maximum value rises and falls smoothly, while the minimum seems to be a step function. Neither trend seems particularly likely, so either there's a mistake in our calculations or something is wrong with our data. This insight would have been difficult to reach by examining the numbers themselves without visualization tools.
Expand Down Expand Up @@ -127,7 +127,7 @@ matplotlib.pyplot.show()
~~~
{: .language-python}
FIXME: add generated combined plot
![inflammation-combined-imshow](../fig/13-inflammation-01-combined.png)
## Multiple Plots: Multiple Graphs
Expand Down Expand Up @@ -167,7 +167,7 @@ matplotlib.pyplot.show()
~~~
{: .language-python}
FIXME: add The Previous Plots as Subplots ../fig/01-numpy_80_0.png
![inflammation-separate-imshow](../fig/13-inflammation-01-separate.png)
The call to `loadtxt` reads our data, and the rest of the program tells the plotting library how large we want the figure to be, that we're creating three subplots, what to draw for each one, and that we want a tight layout. (If we leave out that call to `fig.tight_layout()`, the graphs will actually be squeezed together more closely.)
Expand Down Expand Up @@ -220,7 +220,7 @@ When we re-run the script, you should see a new `overlay_graphs.png` file in the
## Dealing with Multiple Datasets
We also have other inflammation datasets, located in FIXME. Let's try to generate and save visualisations for each of these datasets so we can compare them against each other, to increase our confidence that we have sensible datasets.
We also have other inflammation datasets, located in the `data` directory. Let's try to generate and save visualisations for each of these datasets so we can compare them against each other, to increase our confidence that we have sensible datasets.
First, we need to have a way of determining a list of all our inflammation data files. Their filenames all follow the pattern 'inflammation-XX.csv`, where `XX` refers to the number of that dataset. We can use the `glob` library here to help us get these filenames.
Expand Down
Binary file added fig/11-python-operations-across-axes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions fig/13-inflammation-01-average.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fig/13-inflammation-01-combined.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 7c80b6c

Please sign in to comment.