Custom modules
Custom modules#
When putting commonly used code into modules, we can easily reuse that code. We can demonstrate that with the functions developed in the previous notebook. Those functions have been put in the my_module.py
file and that’s why we can import them now and reuse them.
import my_module
my_module.analyse_average_total_intensity("../../data/blobs.tif")
17136.90322580645
If the code is organized well, we can also reuse sub-routines of the complex analysis.
from skimage.io import imread, imshow
from my_module import segment_image
image = imread("../../data/blobs.tif")
labels = segment_image(image)
imshow(labels, cmap="gist_ncar")
<matplotlib.image.AxesImage at 0x2514bc50e50>