• Contributors
  • Commercial Partners
  • Announcements
  • Bio-Formats

The solution for reading proprietary microscopy image data and metadata

What is Bio-Formats?

Bio-Formats is a software tool for reading and writing image data using standardized, open formats. Bio-Formats is a community driven project with a standardized application interface that supports open source analysis programs like ImageJ , CellProfiler and Icy , informatics solutions like OMERO and the JCB DataViewer , and commercial programs like MATLAB .

Bio-Formats documentation includes a complete version history, guides for using Bio-Formats as a plugin for ImageJ/Fiji, extensive information on which formats are supported and the level of that support, and also information for developers wanting to extend Bio-Formats or use it in their own software.

Read the Docs

Development and Licensing

Bio-Formats is developed by the Open Microscopy Environment consortium, including development teams at LOCI at the University of Wisconsin-Madison , University of Dundee and Glencoe Software . Licensing and citing information is on the OME licensing page .

File Formats

Bio-Formats 5 improves support for High Content Screening, time lapse imaging, digital pathology and other complex multidimensional image formats, reading over 150 file formats and their metadata to the OME data model standard.

Our Community

Bio-Formats is a community project and we welcome your input . You can find guidance on reporting a bug , upload files to our QA system for testing, and contact us via our mailing lists or forums. Further information about how the OME team works and how you can contribute to our projects is in the Contributing Developer Documentation .

Get started working with your images now

© 2005-2024 University of Dundee & Open Microscopy Environment. Creative Commons Attribution 4.0 International License

OME source code is available under the GNU General public license or more permissive open source licenses, or through commercial license from Glencoe Software Inc. OME, Bio-Formats, OMERO, IDR and their associated logos are trademarks of Glencoe Software Inc. , which holds these marks to protect them on behalf of the OME community.

[ Site Map ]

Version: 2024.02.08

Learn About Us

  • What We Can Do
  • What We’re Up To

Try Our Products

  • OMERO Download
  • Bio-Formats Download
  • OME Files Download

Knowledge Base

  • Documentation
  • User Guides
  • Security Advisories

Search code, repositories, users, issues, pull requests...

Provide feedback.

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly.

To see all available qualifiers, see our documentation .

  • Notifications

A MATLAB class using the OME Bio-Formats library

Biofrontiers-ALMC/bioformats-matlab

  • MATLAB 100.0%
  • Bio-Formats 5.7.1 documentation »
  • Developer Documentation »

Using Bio-Formats in MATLAB ¶

This section assumes that you have installed the MATLAB toolbox as instructed in the MATLAB user information page . Note the minimum supported MATLAB version is R2007b (7.5).

As described in Using Java Libraries , every installation of MATLAB includes a JVM allowing use of the Java API and third-party Java libraries. All the helper functions included in the MATLAB toolbox make use of the Bio-Formats Java API. Please refer to the Javadocs for more information.

Increasing JVM memory settings ¶

The default JVM settings in MATLAB can result in java.lang.OutOfMemoryError: Java heap space exceptions when opening large image files using Bio-Formats. Information about the Java heap space usage in MATLAB can be retrieved using:

Default JVM settings can be increased by creating a java.opts file in the startup directory and overriding the default memory settings. We recommend using -Xmx512m in your java.opts file. Calling:

will also throw a warning if the runtime memory is lower than the recommended value.

If errors of type java.lang.OutOfMemoryError: PermGen space are thrown while using Bio-Formats with the Java bundled with MATLAB (Java 7), you may try to increase the default values of -XX:MaxPermSize and -XX:PermSize via the java.opts file.

[ome-users] Release of OMERO & Bio-Formats 5.1.1

Opening an image file ¶

The first thing to do is initialize a file with the bfopen function:

This function returns an n -by-4 cell array, where n is the number of series in the dataset. If s is the series index between 1 and n :

  • The data{s, 1}{t, 1} element contains the pixel data for the t -th plane in the s -th series.
  • The data{s, 1}{t, 2} element contains the label for the t -th plane in the s -th series.
  • The data{s, 2} element contains original metadata key/value pairs that apply to the s -th series.
  • The data{s, 3} element contains color lookup tables for each plane in the s -th series.
  • The data{s, 4} element contains a standardized OME metadata structure, which is the same regardless of the input file format, and contains common metadata values such as physical pixel sizes - see OME metadata below for examples.

Accessing planes ¶

Here is an example of how to unwrap specific image planes for easy access:

Displaying images ¶

If you want to display one of the images, you can do so as follows:

This will display the first image of the first series with its associated color map (if present). If you would prefer not to apply the color maps associated with each image, simply comment out the calls to colormap .

If you have the image processing toolbox, you could instead use:

You can also create an animated movie (assumes 8-bit unsigned data):

Retrieving metadata ¶

There are two kinds of metadata:

  • Original metadata is a set of key/value pairs specific to the input format of the data. It is stored in the data{s, 2} element of the data structure returned by bfopen .
  • OME metadata is a standardized metadata structure, which is the same regardless of input file format. It is stored in the data{s, 4} element of the data structure returned by bfopen , and contains common metadata values such as physical pixel sizes, instrument settings, and much more. See the OME Model and Formats documentation for full details.

Original metadata ¶

To retrieve the metadata value for specific keys:

To print out all of the metadata key/value pairs for the first series:

OME metadata ¶

Conversion of metadata to the OME standard is one of Bio-Formats’ primary features. The OME metadata is always stored the same way, regardless of input file format.

To access physical voxel and stack sizes of the data:

For more information about the methods to retrieve the metadata, see the MetadataRetrieve Javadoc page.

To convert the OME metadata into a string, use the dumpXML() method:

Changing the logging level ¶

By default, bfopen uses bfInitLogging to initialize the logging system at the WARN level. To change the root logging level, use the DebugTools methods as described in the Logging section.

Reading from an image file ¶

The main inconvenience of the bfopen.m function is that it loads all the content of an image regardless of its size.

To access the file reader without loading all the data, use the low-level bfGetReader.m function:

You can then access the OME metadata using the getMetadataStore() method:

Individual planes can be queried using the bfGetPlane.m function:

To switch between series in a multi-image file, use the setSeries(int) method. To retrieve a plane given a set of (z, c, t) coordinates, these coordinates must be linearized first using getIndex(int, int, int)

Saving files ¶

The basic code for saving a 5D array into an OME-TIFF file is located in the bfsave.m function.

For instance, the following code will save a single image of 64 pixels by 64 pixels with 8 unsigned bits per pixels:

And the following code snippet will produce an image of 64 pixels by 64 pixels with 2 channels and 2 timepoints:

By default, bfsave will create a minimal OME-XML metadata object containing basic information such as the pixel dimensions, the dimension order and the pixel type. To customize the OME metadata, it is possible to create a metadata object from the input array using createMinimalOMEXMLMetadata.m , add custom metadata and pass this object directly to bfsave :

For more information about the methods to store the metadata, see the MetadataStore Javadoc page.

Improving reading performance ¶

Initializing a Bio-Formats reader can consume substantial time and memory. Most of the initialization time is spend in the setId(java.lang.String) call. Various factors can impact the performance of this step including the file size, the amount of metadata in the image and also the file format itself.

One solution to improve reading performance is to use Bio-Formats memoization functionalities with the loci.formats.Memoizer reader wrapper. By essence, the speedup gained from memoization will only happen after the first initialization of the reader for a particular file.

The simplest way to make use the Memoizer functionalities in MATLAB is illustrated by the following example:

If the time required to call setId(java.lang.String) method is larger than DEFAULT_MINIMUM_ELAPSED or the minimum value passed in the constructor, the initialized reader will be cached in a memo file under the same folder as the input file. Any subsequent call to setId() with a reader decorated by the Memoizer on the same input file will load the reader from the memo file instead of performing a full reader initialization.

More constructors are described in the Memoizer javadocs allowing to control the minimal initialization time required before caching the reader and/or to define a root directory under which the reader should be cached.

As Bio-Formats is not thread-safe, reader memoization offers a new solution to increase reading performance when doing parallel work. For instance, the following example shows how to combine memoization and MATLAB parfor to do work on a single file in a parallel loop:

Bio-Formats

Page contents.

  • Increasing JVM memory settings
  • Accessing planes
  • Displaying images
  • Original metadata
  • OME metadata
  • Changing the logging level
  • Reading from an image file
  • Saving files
  • Improving reading performance

Previous topic

Converting files from FV1000 OIB/OIF to OME-TIFF

Using Bio-Formats in Python

Quick search

Enter search terms or a module, class or function name.

  • Show Source
  • Show on GitHub
  • Edit on GitHub

MATLAB Answers

  • Trial software

You are now following this question

  • You will see updates in your followed content feed .
  • You may receive emails, depending on your communication preferences .

Bio formats in Matlab - Bfopen - string for filename

ian Handsportman

Direct link to this question

https://www.mathworks.com/matlabcentral/answers/623563-bio-formats-in-matlab-bfopen-string-for-filename

   0 Comments Show -2 older comments Hide -2 older comments

Sign in to comment.

Sign in to answer this question.

Accepted Answer

Walter Roberson

Direct link to this answer

https://www.mathworks.com/matlabcentral/answers/623563-bio-formats-in-matlab-bfopen-string-for-filename#answer_522253

   4 Comments Show 2 older comments Hide 2 older comments

ian Handsportman

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/623563-bio-formats-in-matlab-bfopen-string-for-filename#comment_1080923

Walter Roberson

https://www.mathworks.com/matlabcentral/answers/623563-bio-formats-in-matlab-bfopen-string-for-filename#comment_1080928

https://www.mathworks.com/matlabcentral/answers/623563-bio-formats-in-matlab-bfopen-string-for-filename#comment_1080983

Mario Malic

https://www.mathworks.com/matlabcentral/answers/623563-bio-formats-in-matlab-bfopen-string-for-filename#comment_1081098

More Answers (1)

Mario Malic

https://www.mathworks.com/matlabcentral/answers/623563-bio-formats-in-matlab-bfopen-string-for-filename#answer_522238

Community Treasure Hunt

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

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

  • América Latina (Español)
  • Canada (English)
  • United States (English)
  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 简体中文 Chinese
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Contact your local office

IMAGES

  1. Using Bio-Formats in MATLAB

    bio formats matlab

  2. Bio in for Matics

    bio formats matlab

  3. Bioinformatics Toolbox

    bio formats matlab

  4. Bio-Formats

    bio formats matlab

  5. 9 Simple Bio Data Formats For Job Pdf Word Free Download

    bio formats matlab

  6. Installing Bio-Formats in ImageJ

    bio formats matlab

COMMENTS

  1. MATLAB

    Installation ¶ Download the MATLAB toolbox from the Bio-Formats downloads page . Unzip bfmatlab.zip and add the unzipped bfmatlab folder to your MATLAB path. Usage ¶ Please see Using Bio-Formats in MATLAB for usage instructions.

  2. Bio-Formats Downloads

    A bundle of functions for using Bio-Formats from MATLAB with bioformats_package.jar already included. For more info, see the MATLAB documentation. Download (29.97 MB) Octave Package bioformats-octave-7.1..tar.gz A bundle of functions for using Bio-Formats from Octave. You'll need to install bioformats_package.jar separately.

  3. Bioformats Image Toolbox

    The Bioformats Image Toolbox provides a way to read microscope files (such as Nikon's ND2 format) into MATLAB. The toolbox implements a MATLAB class to use the Bio-Formats Image Package Java library. Prerequisites MATLAB R2016b or newer (it is highly likely that an earlier version will work). Quick Navigation Released toolboxes Documentation Thanks

  4. MATLAB

    Calling Bio-Formats from MATLAB is fairly straightforward, since MATLAB has built-in interoperability with Java. We have created a set of scripts for reading image files. Note the minimum supported MATLAB version is R2007b (7.5). Installation ¶ Download the MATLAB toolbox from the Bio-Formats downloads page .

  5. Bio-Formats

    Bio-Formats is a community driven project with a standardized application interface that supports open source analysis programs like ImageJ, CellProfiler and Icy, informatics solutions like OMERO and the JCB DataViewer, and commercial programs like MATLAB.

  6. Set output display format

    Description example format (style) changes the output display format to the format specified by style. For example, format ("shortG") displays numeric values in a compact form with 5 total digits. Numeric formats affect only how numbers appear in the display, not how MATLAB ® computes or saves them.

  7. Using Bio-Formats in MATLAB

    We recommend to use 512 MB in general, but you don't need to decrease the value if the default value is bigger than 512 MB.</p>\n<p dir=\"auto\"><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"/ome/bio-formats-documentation/blob/master/sphinx/images/matlab_memory_pref512MB.png\"><img alt=\"../images/matlab_memory_pref512MB.png\" src=\"/o...

  8. MATLAB

    Calling Bio-Formats from MATLAB is fairly straightforward, since MATLAB has built-in interoperability with Java. We have created a set of scripts for reading image files. Note the minimum supported MATLAB version is R2007b (7.5). Installation ¶ Download the MATLAB toolbox from the Bio-Formats downloads page.

  9. Help installing Bio-Formats

    1 Link Edited: Paul Stroe on 25 Oct 2018 I want to use Bio-Formats to directly work with .nd2 files. As the website instructs https://docs.openmicroscopy.org/bio-formats/5.8.2/users/matlab/index.html, I downloaded and unzipped the folder. I then added the .m files to my Matlab path, including the .jar file 'bioformats_package.jar'.

  10. MATLAB

    Installation ¶ Download the MATLAB toolbox from the Bio-Formats downloads page . Unzip bfmatlab.zip and add the unzipped bfmatlab folder to your MATLAB path. Usage ¶ Please see Using Bio-Formats in MATLAB for usage instructions.

  11. MATLAB

    Calling Bio-Formats from MATLAB is fairly straightforward, since MATLAB has built-in interoperability with Java. We have created a toolbox for reading and writing image files. Note the minimum recommended MATLAB version is R2017b. Note

  12. GitHub

    Welcome to the Bioformats Image Toolbox! The Bioformats Image Toolbox provides a way to read microscope files (such as Nikon's ND2 format) into MATLAB. The toolbox implements a MATLAB class to use the Bio-Formats Image Package Java library. Prerequisites MATLAB R2016b or newer (it is highly likely that an earlier version will work).

  13. Qu for MATLAB

    Qu for MATLAB is a MATLAB toolbox for the visualization and analysis of multi-channel 4-dimensional datasets targeted to the field of biomedical imaging, developed by Aaron Ponti. Uses Bio-Formats to read files. Open source software available under the Mozilla Public License.

  14. Using Bio-Formats in MATLAB

    Using Bio-Formats in MATLAB ¶ This section assumes that you have installed the MATLAB toolbox as instructed in the MATLAB user information page. Note the minimum supported MATLAB version is R2007b (7.5). As described in Using Java Libraries , every installation of MATLAB includes a JVM allowing use of the Java API and third-party Java libraries.

  15. MATLAB

    Calling Bio-Formats from MATLAB is fairly straightforward, since MATLAB has built-in interoperability with Java. We have created a toolbox for reading and writing image files. Note the minimum recommended MATLAB version is R2017b. Note

  16. Supported Formats

    The better this score, the wider the variety of information that can be effectively stored in the format. Export This indicates whether Bio-Formats is capable of writing the format (Bio-Formats can read every format on this list). BSD This indicates whether format is BSD-licensed. By default, format readers and writers are GPL-licensed.

  17. bfopen function within Bio-Formats

    bfopen function within Bio-Formats. I try to use the bfopen function to open my .nd2 files but it tells me bfopen is "undefined". I tried searching for it within the Matlab search but it tells me this function doesn't exist. Is it possible Bio-Formats doesn't work for the 2019a version and if so is there a version this file that it does work on?

  18. image

    1 2 MATLAB works fine with Java as it is implemented in BioFormats. There shouldn't be any need to make extra declarations or integrations as long as the .jar file is in the proper location on your machine. Can you provide an example of your code and the error that is generated? - Staus Nov 4, 2014 at 23:42 Hello Thanks so much for your response.

  19. Bio formats in Matlab

    Copy Directory="/home/ian/Zenfiles/airy-neuron/"; Dirlist=dir (fullfile (Directory,'*.czi')); Filecounter=2 %a loop in full code Filenamein=Dirlist (Filecounter).name Newimagename=fullfile (Directory+Filenamein); Newimage=bfopen (Newimagename);

  20. MATLAB

    Using Bio-Formats in MATLAB showinf command line tool If you encounter an error trying to open JPEG-2000 data in MATLAB but the file will open e.g. in Fiji using Bio-Formats, it may be due to conflicting versions of JAI ImageIO in different JARs. As discussed on the component page, JAI ImageIO