OpenFlexure Microscope MATLAB Client

These MATLAB classes make it easy for you to connect and control an OpenFlexure Microscope over a network.
12 Downloads
Updated 27 Jan 2021

A MATLAB client for the OpenFlexure Microscope

These MATLAB classes make it easy for you to connect and control an OpenFlexure Microscope over a network. You are able to move the microscope and get the images from the microscope, as well as run extensions.

Installation:

You just need to download/clone this repository and make sure the files are added to your MATLAB path.

Usage:

To connect to your microscope, you can either:

* Use `microscope.local`.

microscope = OFMClient('microscope.local');

* Use the microscope's **hostname** or **IP address**.

microscope = OFMClient('example.host.name');
microscope = OFMClient('XXX.XXX.XXX.XXX');

If necessary you can also set the port (default is `5000`):

microscope = OFMClient('example.host.name','port');

Check the connection:

To test if your connection has worked, you can run the following block (it is also a script in the repository called `check_the_connection.m`.):

%Test the stage movement
pos = microscope.position_as_matrix();
starting_pos = pos;
pos(1) = pos(1) + 100;
microscope.move(pos);
disp("Is the microscope in the starting position?");
disp(isequal(microscope.position_as_matrix(),starting_pos));
pos(1) = pos(1) - 100;
microscope.move(pos);
disp("Is the microscope in the starting position?");
disp(isequal(microscope.position_as_matrix(),starting_pos));

%Test the autofocus
ret = microscope.autofocus();

%Acquire an image
image = microscope.grab_image();
figure;
imagesc(image);

%List the extensions
disp("Active microscope extensions");
disp(microscope.extensions);

This will test the stage movement, run the autofocus routine, show a picture taken by the microscope and list the extensions that are on the microscope.

See a live video preview:

You can view a video preview in MATLAB using

microscope.preview();

This will launch a window with the video preview direct from the microscope. To use this functionality you will need to install the IP Camera Support from MATLAB. MATLAB should prompt you to install this on first use.

Basic Commands:

The `MicroscopeClient` object has a few basic methods. If you created an instance of the object with the name `microscope` as above, the commands can be found in the readme.

For more information, run `help OFMClient`.

Extensions:

To run methods provided by the microscope extensions, you can use the `extensions` `struct` to make `get` or `post` requests.

**However**, due to MATLAB struct limitation, you need to replace any `.` in your extension name to `_DOT_` and any `-` to `_DASH_`. For example, the extension `org.openflexure.autofocus` should be written as `org_DOT_openflexure_DOT_autofocus`.

For a post request, `data` can be a `struct`, `character vector`, `numeric`, `cell` etc. The full list of supported types for post requests is in the MATLAB documentation: https://uk.mathworks.com/help/matlab/ref/webwrite.

Cite As

Samuel McDermott (2024). OpenFlexure Microscope MATLAB Client (https://github.com/openflexure/openflexure-microscope-matlab-client/releases/tag/v0.1.0), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2020b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
0.1.0

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.