Commit 2c438255 authored by rhaase's avatar rhaase

added code and slides

parent 93f73563
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"10\n"
]
}
],
"source": [
"import math_library\n",
"\n",
"x = 3\n",
"y = 7\n",
"\n",
"result = math_library.add(x, y)\n",
"print(result)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-4\n"
]
}
],
"source": [
"from math_library import subtract\n",
"\n",
"\n",
"result = subtract(x, y)\n",
"print(result)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
This diff is collapsed.
from skimage.io import imread
from skimage import filters
from skimage import measure
def analyse_image(filename, gaussian_blur_sigma, threshold=None):
"""
This function analyses an image by blurring it and applying a threshold.
Parameters
----------
filename
Image file to open and analyse
gaussian_blur_sigma
Sigma of a Gaussian blur filter kernel to be
applied to the image before thresholding
threshold
Optional, the grey-value threshold to
differentiate foreground and background
Returns
-------
count
Number of objects in the image
"""
# load image
image = imread(filename);
# Gaussian blur
gaussian_blurred_image = filters.gaussian(image, 5)
# thresholding
if threshold is None:
threshold = filters.threshold_otsu(gaussian_blurred_image)
thresholded_image = gaussian_blurred_image >= threshold
# run connected components analysis
label_image = measure.label(thresholded_image)
# analyse objects
table = measure.regionprops_table(label_image)
return len(table["label"])
analyse_image("blobs.tif", 2)
def add(a, b):
return a + b;
def subtract(a, b):
return a - b;
\ No newline at end of file
import matplotlib.pyplot as plt
def draw_curation_time_histogram(data, description):
fig, ax = plt.subplots()
ax.hist(data, bins=10)
ax.set_title('Curation time of ' + str(len(data)) + ' ' + description)
ax.set_ylabel("count")
ax.set_xlabel("Curation time / days")
plt.show()
test_data = [1,1, 3,3, 5,6,7, 9,9]
draw_curation_time_histogram(test_data, "examples")
from numpy import random
def placebo_group(number_of_patients):
# generate random numbers following a normal distribution
x = random.normal(loc=7, scale=2, size=number_of_patients)
return x
def treatment_group(number_of_patients):
# generate random numbers following a normal distribution
x = random.normal(loc=7, scale=2, size=number_of_patients)
return x
from numpy import random
def ripen(number_of_tomatoes):
# generate random numbers following a normal distribution
x = random.normal(loc=24.5, scale=2, size=number_of_tomatoes)
return x
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment