Professional Documents
Culture Documents
A Measurement and Data Processing Software Suite
A Measurement and Data Processing Software Suite
2013-09-10 / 2013-09-11
What this tutorial is about
2
Agenda
4
Motivation
Matlab Labview
itom
• Fast, well-established, easy to use scripting
language (Python)
• Homogeneous hardware integration
• Automation of measurement systems
• Fast data processing and analysis
• Easy to customize
5
Requirements and Solutions
Requirements Solution
6
itom
Windows 7
7
itom
Windows 8
Debian KDE
8
itom – main features
Scripting
- Integrated Python programming environment
- Almost full Python functionality
- Controlling itom by specific Python module
Plugins
- C++ libraries (e.g. dll)
- Hardware and algorithm integration
- Integration of complex dialogs and windows
GUI
- Intuitive
- Optimized for implementation of measurement systems
- Ability to integrate customized user interfaces
9
Agenda
10
Python
11
Python
• Variables have an Python internal type, mainly: int, float, complex
• Casting uses the functions int(), float()…
• Assignment: a=1 a,b=1,2
• Comparison operators: ==, >, <, <=, >=, !=
• Bitwise-Operators: &, |, ~, ^
• Basic arithmetic: a = a+1, a += 1, a=a**2
• Operators also work on many non-basic types (arrays, lists, dictionaries…)
Example: Factorial
Scipy
scientific library
itom
scikit-image
Matplotlib
image processing
plots and graphs
tools
13
Python-Module itom
14
Numpy
Numeric package • Array creating and
• Support of large, multi-dimensional arrays manipulation
• Binary operations
• Large library of mathematical functions and
• Linear algebra
operators • Masked arrays
• itom’s own array object is compatible to • Polynomials
Numpy arrays. • Random Sampling
• Sorting, Searching,
Counting
Example: Solve Ax=b • Fourier Transforms
from numpy import * • …
from numpy.linalg import solve
a = array([[3,1,5],[1,0,8],[2,1,4]])
b = array([6,7,8])
x = solve(a,b)
print(x) # This is our solution
[-3.28571429 9.42857143 1.28571429]
15
Scipy
Scientific Algorithms • Optimization
• Extension for numpy • Linear Algebra
• Integration
• Provide more functions from the field of
• Interpolation
numeric, statistic and optimization • FFT
• Itself extendable by scikits • Signal Processing
• ODE Solvers
• Optimization
• Basic image processing
Example: • Sparse Matrices
Find root of 2 0 around 0.3
import numpy as np
from scipy.optimize import root
def func(x):
return x + 2 * np.cos(x)
16
Matplotlib
Plotting package
• Python package for math plots
• Based on numpy
• Syntax close to Matlab
• Export in various image formats:
png, pdf, eps…
• Fully integrated in itom
• Can be integrated in custom GUIs
17
scikit-image
Image processing package • Segmentation
• Transformation
• Based on Numpy arrays
• Morphology
• Algorithms written in Python and C • Measure
• Uses Matplotlib for plotting results • IO
• Image filtering
• Rank filters
• Feature detection
18
Agenda
19
itom Plugin System
20
Interface “dataIO + Grabber”
Primary functionality
Primary Functionality
Signals about position and status of the actuator can be linked to and
processed by the GUI.
22
Interface “algo”
Call:
• From a Python script
• By other plugins
23
Agenda
24
GUI
25
GUI – Command Line
27
GUI – File System
28
GUI – Plugins
29
Scripting window
30
Syntax Help and Auto Completion
• Syntax help
31
Plots
32
Custom GUIs (Qt Designer)
• Design of custom GUIs in the external Qt Designer
WYSIWYG tool (drag&drop).
• Events created by the GUI (button click) can be
linked to Python functions
Preview
Elements custom
GUI:
• Hierarchy
• Layouts
Dialog: gui
34
Multithreading
Python Interpreter
Plugin Organizer
Python Debugger
…
35
Agenda
36
License
37
Agenda
38
Data Object
Goal:
• Different basic types of data (including complex)
• Processing of large, multi-dimensional data sets (series of images)
• Compatible with Matlab, Numpy, OpenCV
Implementation:
• DataObject very similar to OpenCV data structures
• Basic data types supported: int8, uint8, int16, uint16, int32, uint32, float,
double, complex(float), complex(double)
• DataObject supports tags (axes units, descriptions, title…)
39
Data Storage
Series of 2D-images
3D data stack
Plane 0
Plane 1
Plane 2
40
Data Storage
Assume: Series of 2D-images (3 x 2 x 5)
(0,0,0)
Plane 0
Plane 1
Plane 2
(2,1,0) (2,1,4)
41
Data Storage
DataObject:
1 (1,0,0) Plane 1
2 (2,1,4) Plane 2
0 1 2
42
Agenda
43
User Documentation
Help pages
• Table of content
• Search
• Bookmarks
itom.bitbucket.org/latest/docs
44
Additional User Help within Python
1. Syntax help and auto completion in
the Python editor
Questions?
46
itom
Show Cases
Show-Case I: Fringe Projection
Situation
Objective
camera
chip
H ∆x
camera lens
∆z
object
49
Show-Case I: Structured Illumination
Cosine-fringes (mod 2PI)
LCOS-Display or
DMD-Projector
absolute coding
Grey-Code
50
Show-Case I: Basic Set-up
Camera + lens
Projector
51
Show-Case II: MacroSim
Situation
Objective
52
Show-Case II: MacroSim
Solution
itom MacroSim
MacroSim Tracer
Plugin
53
Raytracing: A versatile tool
CPU-Parallelization
- very flexible
- straightforward implementation
- More than 4 cores quickly become expensive
GPU-Parallelization
- Restriction to Thread Coherence
- Specific Implementation
- Standard GPUs come with 200-500 cores
GPU-Parallelization
- Restriction to Thread Coherence
- Specific Implementation
- Standard GPUs come with 200-500 cores
58
Interaction with itom
GUI based
• Start MacroSim GUI by Python command (createNewPluginWidget)
• Start simulation manually
• GUI emits a signal with the final detector matrix (dataObject)
• Connect a Python function to this signal (called when simulation done)
Script based
• Optional: Start MacroSim GUI and create scene (XML-file)
• Call function runSimulation of MacroSim plugin and pass XML-file
(simulation is executed)
• The function finally returns the detector matrix as dataObject
59
Show-Case III: Confocal Microscopy
60
Show-Case III: Confocal Microscopy
Situation
Objective
itom should be used to…
− control the measurement process
− provide a user-friendly control panel
− visualize the results
− provide functionality for data evaluation (roughness,
alignment, geometrical fitting…)
61
Show-Case III: Confocal Microscopy
Object
FWHM ~ 1/NA
Point Detector
62
Show-Case III: Confocal Microscopy
Object
Point Detector
63
Show-Case III: Confocal Microscopy
GUI
64