Difference between revisions of "Programming"

From biophysics
Jump to navigation Jump to search
 
(48 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
==Introduction==
 
==Introduction==
  
Most work in the Biophysics group is done with help of Matlab (Experiments, data manipulation, graphics). Embedded systems are mostly written in C++. Tucker Davis equipment have their own graphical programming system.
+
Most work in the Biophysics group is done with help of Matlab (Experiments, data manipulation, graphics). Software for embedded systems like Arduino's and Raspberry Pi's are mostly written in C++. Tucker Davis equipment like the [[TDT RZ6|RZ6]] have their own graphical programming system.
  
 
==Best practices==
 
==Best practices==
Line 7: Line 7:
 
When programming one of the first things you have to consider is how your program will be used.  
 
When programming one of the first things you have to consider is how your program will be used.  
  
 +
*Will it be more than say 50 lines of code?
 
*Will other people use the program?  
 
*Will other people use the program?  
 
*Will it be used for a long time?  
 
*Will it be used for a long time?  
Line 20: Line 21:
 
*Don’t use the same lines of code more than once
 
*Don’t use the same lines of code more than once
 
*Be sparse with nesting
 
*Be sparse with nesting
*Use refactoring of larger pieces of code
+
*Use refactoring of larger pieces of code (split it up in functions or classes)
 
*Make room for ample testing
 
*Make room for ample testing
  
Line 29: Line 30:
 
==Matlab==
 
==Matlab==
  
The experiment computers in the labs are all windows computers. Most of the experimental programs running on these computers are written in Matlab.
+
The experiment computers in the labs are all windows computers. Most of the experimental programs running on these computers are written in Matlab. Matlab is also the program environment of choice for analysis of experimental data.
  
The Matlab IDE gets updated almost every year. Different experimental computers and your own computer will probably run different version of Matlab. Most of the programs will be compatible, but user interfaces often not. On [[Gitlab]] we have several libraries for experiments and data manipulation.
+
The Matlab IDE gets updated almost every year. Different experimental computers and your own computer will probably run different version of Matlab. Most of the programs will be compatible, but user interfaces often not.  
  
 
<todo>
 
<todo>
  
===Installation===
+
=== MATLAB Installation and Licensing ===
<todo>
+
Instructions for installing Matlab can be found in [https://cncz.pages.science.ru.nl/licenses/Matlab/ https://cncz.pages.science.ru.nl/licenses/Matlab/]
===License===
+
 
<todo>
+
''if you need additional assistance ask [[Günter Windau]]''
 +
 
 +
===Gitlab repository===
 +
Matlab code for experiments and analysis is available on [[gitlab]] repositories. You can sign in here https://gitlab.science.ru.nl/users/sign_in.
 +
 
 +
The following repositories are available:
 +
*[[Gitlab Repository Biofysica|Biofysica]]
 +
*[[Gitlab Repository Matrix|Matrix]]
 +
*[[Gitlab Repository fNIRS|fNIRS]]
 +
 
 +
===Programming Topics===
 +
*[[Programming a GUI]] in Matlab
 +
*[[Programming an experiment]] in Matlab
 +
*Matlab code in [[Gitlab]]
 +
*[[BIOX]] for the RZ6
 +
*[[LabStreamingLayer|LabStreamingLayer (LSL)]]
 +
*[[Coordinate systems]] and transformations
 +
*[[Units in Matlab]]
 +
*[[Colors in Matlab]]
 +
*[[Coordinate systems]]
  
 
==Programming Embedded Systems==
 
==Programming Embedded Systems==
Embedded systems are devices that have their own CPU and run their own software. Examples are: Arduino, Raspberry Pi or a digital sound processor (DSP) like the RZ6.
+
Embedded systems are devices that have their own CPU and run their own software. Examples are: Arduino, Raspberry Pi or a digital sound processor (DSP) like the RZ6.  
  
 
===Digital sound processor (DSP)===
 
===Digital sound processor (DSP)===
Within the Biophysics group the  most used DSP is the RZ6 of Tucker Davis. Also the older RP2.1 and the Medusa RA16 base station are still in use. These are programmed in the RPvdsEx IDE. For the RZ6 we have BIOX, which is a RPvdsEx file with an Matlab toolbox.
+
Within the Biophysics group the  most used DSP is the [[TDT RZ6|RZ6]] of Tucker Davis. Also the older RP2.1 and the Medusa RA16 base station are still in use. These are programmed in the RPvdsEx IDE.  
  
Sometimes MOTU DSP's are used.
+
*For the RZ6 there is the [[BIOX|'''BIOX''']] toolbox, which is a RPvdsEx file with a set of Matlab functions.
  
====BIOX====
+
Sometimes MOTU DSP's are used ([[MOTU Ultra Lite MK3]], [[MOTU Ultra Lite MK5]]). They are also called audio interface.
[[BIOX]] (BIOphysics eXperiment software) is a Matlab interface for the RZ6. The software is available on [[Gitlab]]
 
  
 
===Other embedded systems===
 
===Other embedded systems===

Latest revision as of 14:19, 18 November 2024

Introduction

Most work in the Biophysics group is done with help of Matlab (Experiments, data manipulation, graphics). Software for embedded systems like Arduino's and Raspberry Pi's are mostly written in C++. Tucker Davis equipment like the RZ6 have their own graphical programming system.

Best practices

When programming one of the first things you have to consider is how your program will be used.

  • Will it be more than say 50 lines of code?
  • Will other people use the program?
  • Will it be used for a long time?
  • Will it be used for science?
  • Do other people need to understand or be able to edit your code?
  • Do you anticipate changes in the future?

If you can answer one of these questions with yes you should use best programming practices

  • Use proper code indentation
  • Use meaningful names
  • Use comments that add context
  • Don’t use the same lines of code more than once
  • Be sparse with nesting
  • Use refactoring of larger pieces of code (split it up in functions or classes)
  • Make room for ample testing

Your code is worthless if you are the only one who can understand it.

Good coding needs effort, patience, discipline and courage to rethink.

Matlab

The experiment computers in the labs are all windows computers. Most of the experimental programs running on these computers are written in Matlab. Matlab is also the program environment of choice for analysis of experimental data.

The Matlab IDE gets updated almost every year. Different experimental computers and your own computer will probably run different version of Matlab. Most of the programs will be compatible, but user interfaces often not.

<todo>

MATLAB Installation and Licensing

Instructions for installing Matlab can be found in https://cncz.pages.science.ru.nl/licenses/Matlab/

if you need additional assistance ask Günter Windau

Gitlab repository

Matlab code for experiments and analysis is available on gitlab repositories. You can sign in here https://gitlab.science.ru.nl/users/sign_in.

The following repositories are available:

Programming Topics

Programming Embedded Systems

Embedded systems are devices that have their own CPU and run their own software. Examples are: Arduino, Raspberry Pi or a digital sound processor (DSP) like the RZ6.

Digital sound processor (DSP)

Within the Biophysics group the most used DSP is the RZ6 of Tucker Davis. Also the older RP2.1 and the Medusa RA16 base station are still in use. These are programmed in the RPvdsEx IDE.

  • For the RZ6 there is the BIOX toolbox, which is a RPvdsEx file with a set of Matlab functions.

Sometimes MOTU DSP's are used (MOTU Ultra Lite MK3, MOTU Ultra Lite MK5). They are also called audio interface.

Other embedded systems

Some devices have embedded systems like arduino, ESP32 and raspberry Pi's.

Examples are:

Arduino

Arduino is an Italian open-source hardware and software company, project, and user community that designs and manufactures single-board microcontrollers and microcontroller kits for building digital devices.
Arduino devices (or compatible embedded CPU's) are programmed with the Arduino IDE. The programming language is C++.
For questions about Arduino programming ask Ruurd Lof

ESP32

ESP32 is a family of system on a chip devices developed by Espressif Systems. Some of these devices can be programmed with the Arduino IDE.
For questions about ESP32 programming ask Ruurd Lof

Raspberry Pi

Raspberry Pi is a series of small single-board computers (SBCs) developed in the United Kingdom by the Raspberry Pi Foundation in association with Broadcom.
For questions about Raspberry Pi programming ask Günter Windau