Skip to content

ahnlabb/BioformatsLoader.jl

Repository files navigation

BioformatsLoader

Build Status Coverage Status codecov.io

Dependencies

Depends on bioformats_package.jar

Install

import Pkg
Pkg.add("BioformatsLoader")

Inside the Julia interactive REPL, you can also use

julia>]add BioformatsLoader

Build Process

The add command will invoke Pkg.build("BioformatsLoader") which will download bioformats_package.jar and ome.xsd into the deps folder. You can use another copy of bioformats_package.jar by manually configuring the class path. See Advanced Usage.

Setup Environment

Set the environmental variable JULIA_COPY_STACKS to 1. On Linux and Mac, this can be done by invoking julia in the following way:

$ JULIA_COPY_STACKS=1 julia

Basic Usage

using BioformatsLoader
BioformatsLoader.init() # Initializes JavaCall with opt and classpath
image = bf_import("file.msr") # Import the image file.msr

Advanced Usage

using BioformatsLoader
using JavaCall

JavaCall.addClassPath(BioformatsLoader.get_bf_path())
# Alternatively, use bioformats_package.jar of at an alternate path
# JavaCall.addClassPath("/path/to/bioformats_package.jar")
# Add other classpath values here

# Setup options
JavaCall.addOpts("-ea") # Enable assertions
JavaCall.addOpts("-Xmx1024M") # Set maximum memory to 1 Gigabyte
# Add other options here

try
        JavaCall.init()
end

To import the file file.msr you then do

image = bf_import("file.msr")

The variable image will contain an array of ImageMetadata, the data will be the type that the format specifies: Int8, UInt8, Int16, UInt16, Int32, UInt32, Float32, Float64 or Bool.

If you just want a plain array of the first frame:

plain_array = copy(arraydata(image[1]))

Viewing Images

Any package that will display a 2D array can be used to view the images. For example, you can use ImageView:

using ImageView
imshow(image[1])