Quickstart

Quickstart

Dimensions

To get the dimensions of a file, use nd2dim(path_nd2). This returns a tuple of dimensions in (x, y, z, t, c).

Reading a time point

To read a time point, use nd2read(path_nd2). By default, it reads the first ch at first time point. The ch and t can be specified using keywords ch and t (e.g. nd2read(path_nd2, ch=1, t=10)).

Preview

A file can be quickly previewed with nd2preview(), which displays MIP (maximum intensity projection) of first, middle, and last time points in the file. Later if you'd like to use nd2preview_crop, set keyword argument return_data=true. The returned array can be fed into nd2preview_crop.

Cropping in z dimension

If you'd like to crop in z dimension, use keyword argument z_crop (default: nothing). For example, nd2preview(nd2_path, z_crop=5:10) will only load z slices from 5 to 10.

Previewing rotation and x/y cropping

You can preview rotation and x/y cropping with nd2preview_crop()

nd2_stack = nd2preview(nd2_path, z_crop=2:38, return_data=true)
nd2preview_crop(nd2_stack, θ=0.5, x_crop=150:450, y_crop=50:475)

Converting

HDF5

The whole file can be converted into an HDF5 file with nd2_to_h5(). The minimal arguments are the following:

nd2_to_h5(path_nd2, path_save, spacing_lat, spacing_axi)

The HDF5 file is saved in an array with dimension (x,y,z,t,c) and chunked with (x,y,1,1,1). The axial and lateral spacings are saved as metadata.

MHD

nd2_to_mhd saves each time point volume into a .mhd file. It can also save MIP previews in .png.

Rotation and cropping

Before saving into file(s), the function can rotate and crop images when supplied with the keywords: θ (rotation angle), x_crop, y_crop, z_crop. If you don't want to perform those operations, simply ignore as the default is nothing.