Open Science with MATLAB
Jan Studnička
studnicka@humusoft.cz
Jan Daněk
danek@humusoft.cz
www.humusoft.cz
info@humusoft.cz
16.2.2024 MUNI www.mathworks.com
What is MATLAB and Simulink
• MATLAB Statistics a optimization
– Engineering tool for technical computing Signal Processing and Comm.
– Graphical and computational tools Image Processing and CV
– High-level programming language Computational Finance
– Intuitive user interface (GUI) Computational Biology
– Modular, open architecture Neural Network, Fuzzy
• Simulink Physical Modeling
– Modeling, simulation and analysis of multidomain Control System Design
dynamic systems Event-Based Modeling
– Block diagram environment Test and Measurement
– Model Based Design Application Deployment
– Integrated with MATLAB Code Generation and Verification
• Toolboxes
MATLAB in the Industry
Aerospace and defense Automotive Biotech Pharmaceutical
Communications Earth and Ocean Electronics Energy Production
Industrial Automation Medical Devices Metals and Mining Neuroscience
Applied Physics Railway Systems Finance Software and Internet
3 https://www.mathworks.com/solutions.html#industries
Applications specialized
autonomous systems and robotics
predictive maintenance and IoT
basic automotive systems and ADAS
image processing and data analysis and
computer vision data science
computational biology
aerospace and UAV
signal processing
MATLAB physical modeling
financial analysis
Simulink
test and measurement control systems
systems engineering
RF systems and antennas code generation and
real-time applications
wireless communication systems code verification and certification
4
Data Analysis Workflow
Access Explore & Discover Share
Files Reporting and
Data Analysis Documentation
& Modeling
Algorithm
Software Outputs for Design
Development
Code & Applications
Application
Development
Hardware Deployment
Automate
5
Workshop information
• MATLAB Online
– matlab.mathworks.com
• Examples
– humusoft.cz/muni
If you don’t have account,
create one with your
university’s email address
6
MATLAB desktop
Toolstrip Workspace
file and data management, APPS variables in MATLAB memory
Documentation
syntax, examples
Current Folder
folder browser
Command Window
interactive command prompt
7
What is Open Science?
FAIR Science
Open Infrastructure • MATLAB on Science Gateways
• MATLAB on Jupyter
• MATLAB on HPC infrastructure
• Diverse data formats
• Public open data sets
• Big Data
Open Data Interoperable Workflows
• Interoperable MATLAB code
• Deep Learning in MATLAB
• Open Source MATLAB Toolboxes Reproducable
• Runnable MATLAB on GitHub
• MATLAB on reproducibility portals
Results
• MathWorks support for community
Agenda
SHARE
–
Use case
Programmatically Access Open Data from MATLAB
Brain Observatory Toolbox for Allen Brain Data
Available via
• GitHub – Open with MATLAB Online
• Add-Ons drop-down in MATLAB
• Dandi Hub
Brain Observatory Toolbox
Brain Observatory Toolbox:
Data Source & Environment Use Cases
MATLAB Ease of Setup
Online
AWS S3
Bucket
DANDIHub
Science
Gateway
DANDI
Archive BOT
Local
Machine
Allen (remote data)
Institute
RESTful MATLAB on
Web API AWS for More Data
Neuroscience Capacity
Data Sources User Environments
Brain Observatory Toolbox
Cloud Workflow
No downloads
No installs
Accessible to anyone, anywhere
Make Your MATLAB Code Open
Open with MATLAB Online
SHARE -
Example
Programmatically Access Open Data from MATLAB
The Image Data Resource (IDR)
A MATLAB Live Script with accompanying
• Jupyter Notebook
• m file
• reproducible code capsule on Code Ocean
to access and analyze Microscopy image data
sets from the IDR database
Open-Microscopy-Data-MATLAB
MATLAB Live Script Notebooks
Tell a story… with code, words, pictures, equations, images, and controls…
Live Editor
Open Source MATLAB Community Toolboxes
1 click install via Add-Ons
• „Set and Forget“ for authors
• Automatically updates with new releases
Open Source Community Toolboxes
Link your GitHub repo
Open MATLAB Code on GitHub – Click and Run
DOI
200,000+ MATLAB
code repositories…
Including tools authored by
experts in their fields with
thousands of downloads per
year
Create Interoperable Workflows
Why researchers often need more than one tool
▪ Use functionality of one in another
▪ Run code available in another language (hybrid workflows)
▪ Collaborate
Call MATLAB from Python Call Python from MATLAB
$ pip install matlabengine
>>> py.math.sqrt(42)
>>> import matlab.engine
>>> py.importlib.import_module()
>>> m = matlab.engine.start_matlab()
>>> x = m.sqrt(42)
Using MATLAB with Python
Create Interoperable Workflows
Import DL models from other frameworks
MATLAB
Tensorflow Pytorch
Caffe2 ONNX MXNet
Cognitive
Core ML Chainer
Toolkit
importTensorFlowNetwork Deep Interpolation Toolbox
importNetworkFromPytorch
importONNXNetwork
Interoperable with DL frameworks
SCALE
UP
MATLAB Kernel on Jupyter
MATLAB Desktop via Browser on Jupyter
EGI - Run MATLAB on EGI infrastructure
Data
Compute
Code
https://www.egi.eu/case-study/mathworks/
31
Parallelize Code with Minimal Changes
MATLAB
Workers
a = zeros(5, 1); a = zeros(5, 1);
b = pi; b = pi;
for i = 1:5 parfor i = 1:5
a(i) = i + b; a(i) = i + b;
end end
disp(a) disp(a)
University of Cambridge Accelerates Neuroimaging
Data Analysis to Study Healthy Cognitive Aging
Challenge
Analyze terabytes of MRI and MEG imaging data for
a study on cognitive abilities in old age
Solution
Use MATLAB to process the data on a high-
performance computing cluster and to apply
advanced statistical, optimization, and machine
learning techniques Structural MRI images of the brain of a typical healthy 19-year old
(left) and typical healthy 86-year old (right).
Results
▪ Multistep image processing pipeline automated “MATLAB Parallel Server not only reduces processing time;
▪ Data analysis accelerated on a 1200-core cluster it also lowers the barrier to entry into parallel computing—an
▪ Key influences on late-life cognitive health important consideration given the wide range of technical
identified abilities among our scientists.”
- Richard Henson, University of Cambridge
Link to technical article
MATLAB Parallel Computing at IT4Innovations
• When you are ready to run your MATLAB application beyond your desktop,
IT4Innovations has powerful HPC resources that allow you to run MATLAB
to scale using MATLAB Parallel Server
GPU
Multi-core CPU
Parallel Computing Toolbox
MATLAB Parallel Server
• To get started:
– https://docs.it4i.cz/software/numerical-languages/matlab
– support@it4i.cz
RE-USE
Code Ocean: Code from Papers for Sharing and Reuse
Code Ocean
Code Ocean: Code from Papers for Sharing and Reuse
Open any code in the browser
No license required
Reproduce and verify results
What Can You Do With MATLAB Code?
SHARE SCALE UP REUSE
MATLAB Campus-Wide a Institute-Wide licence v ČR a SR
https://www.humusoft.cz/univerzity/
40
Questions?
studnicka@humusoft.cz