NeuroPAL_ID Internal Data Classes

Back to overview

Program.volume()

class Program.volume

VOLUME A class that encapsulates a volumetric (or possibly video) dataset.

Glossary: - helper class: This class relies on helper classes in

+DataHandling/+Helpers, one per file format. For example, +DataHandling/+Helpers/nwb.m is the helper class for nwb files, +DataHandling/+Helpers/nd2.m is the helper class for nd2 files, etc.

  • cursor: A struct specifying chunking-compatible indices. Most

    file types we work with do not support partial indexing when lazy loading, so we need to specify entire ranges for every dimension when attempting to read a specific chunk. For example, if you’re trying to access the 5th slice of the 1st frame particular video file, the cursor would look as such:

    cursor = struct(

    ‘x1’, {1}, … ‘x2’, {size of the x dimension}, … ‘y1’, {1}, … ‘y2’, {size of the y dimension}, … ‘z1’, {5}, … ‘z2’, {5}, … ‘c1’, {1}, … ‘c2’, {size of the c dimension}, … ‘t1’, {1}, … ‘t2’, {1});

    You can use the Program.GUI.cursor class to generate cursors on the fly.

Example usage:

vol = volume(‘C:datamyImage.nwb’); first_slice = vol.read(‘z’, 1);

Constructor Summary
volume(path)

VOLUME Constructor function for the volume class.

Inputs: - path: String/char representing a file path.

Outputs: - obj: volume instance.

Property Summary
c
channels

Channels

device

Metadata

dims

[nx, ny, nz, nc, nt]

Type:

Array of size (1,5)

dtype

Datatype numeric code

dtype_max

Integer maximum for this volume’s datatype.

dtype_str

Datatype string, e.g. ‘uint8’, ‘double’, etc.

fmt

Path info

is_valid_dtype
is_video

Boolean indicating video vs. single-volume; -1 if uninitialized

name

Name of volume file

native_dims

Dims as loaded from file

nc

Number of channels

nt

Number of timepoints (frames)

nx

Dimensionality

ny

Height of the volume

nz

Depth of the volume

path

Complete volume path

processing_steps
read_class

References to helper classes for reading/writing the volume

read_mod

Reader module returned by nwbRead.

read_obj

Reader object (e.g. returned by nwbRead, bfGetReader, etc.)

rgb

Indices of channels corresponding to [R,G,B] if relevant

settings

NeuroPAL_ID settings for this volume.

subject

The subject captured in this volume.

t
x

Cursor

y
z
Method Summary
convert(fmt)

CONVERT Create a new file of format fmt, chunk-write current volume’s contents, and return a new volume instance referencing that file.

Example

newVol = vol.convert(‘tiff’);

get(query)
info()

INFO Return a struct of the volume’s public properties

Inputs: - obj: volume instance.

Outputs: - info_struct: Struct containing volume properties.

load()

LOAD Populate the volume’s properties with metadata read from the file specified by its path property.

Inputs: - obj: volume instance.

Outputs: - obj: volume instance.

read(cursor, varargin)

READ This function reads a specified section of the volume’s raw data array.

Inputs: - obj: volume instance. - cursor: A struct specifying chunking-compatible

indices.

  • varargin: A cell array with a variable number of

    elements, which represent key/value pairs of additional input arguments to be parsed.

Outputs: - data: The requested array.

read_metadata()

READ_METADATA This function reads in what metadata we can from a given volume’s file using its helper class.

Inputs: - obj: volume instance.

Outputs: - mdata: Struct containing the metadata.

render(varargin)

RENDER Return a selected portion of a given volume’s data array, processed to account for gammas, histogram limits, et cetera.

Inputs: - obj: volume instance. - varargin: A cell array with a variable number of

elements, which represent key/value pairs of additional input arguments to be parsed.

Outputs: - array: The processed data array. - raw_array: The raw data array.

update_channels(target)
write(varargin)

WRITE Writes a requested chunk to the volume file, using the underlying helper’s writer. This is the complement of read(…).

Example

vol.write(‘t’,1, ‘z’,2, ‘arr’, some2Dmatrix);

Program.channel()

class Program.channel
Constructor Summary
channel(fluorophore)
Property Summary
arr_idx

Index of this channel in its parent volume. -1 if uninitialized.

color
emission
excitation
fluorophore

Name of this channel’s associated fluorophore. Program.Handlers.channels.fluorophore_map is a dictionary whose every key is a color (e.g. ‘red’, ‘blue’, ‘white’, ‘gfp’) and whose corresponding value is a cell array of possible fluorophores that produce this color.

gamma

Float that is equal to the value of the gui{‘gamma_field’} component.

gui

app.proc_cX_gamma

gui_idx

Index of this channel in the channel editor. -1 if uninitialized.

is_known

Boolean indicating whether this channel is associated with a fluorophore that is named somewhere in Program.Handlers.channels.fluorophore_map.

is_rendered

Boolean indicating whether this channel’s checkbox (referenced in gui{‘checkbox’}) is currently checked.

is_rgb

Boolean indicating whether this channel is one of red, green, or blue.

lh_in

Empty array.

lh_out

This is an array of size (1, 2) whose first value is calculated by dividing the lower value of the gui{‘sliders’} component by the limit of the gui{‘histogram’} component, and whose second value is calculated by doing the same with the higher value of the gui{‘sliders’} component.

parent

Reference to this channel’s associated volume object.

styling

Program.Handlers.channels.config{‘label_colors’} is a cell array containing, in order, the background color for red, green, blue, white, dic, and gfp.

Method Summary
assign_gui()
delete_channel()
freeze()
identify()
is_pseudocolor()
set(keyword, value)
update(query)
validate(~, keyword, value)

Program.subject()

class Program.subject

SUBJECT Summary of this class goes here Detailed explanation goes here

Constructor Summary
subject(metadata)
Property Summary
age
body
notes
sex
strain
Method Summary
set(keyword, value)
validate()

File Reading & Writing

+DataHandling
DataHandling.imreadAny(filename)

IMREADANY Read in any image format (all purpose reader).

[IMAGE, METADATA] = IMREADANY(FILENAME)

Input: filename - the filename of the ND2 image

Outputs: image - the image, a struct with fields:

pixels = the number of pixels as (x,y,z) scale = the pixel scale, in meters, as (x,y,z) channels = the names of the channels colors = the color for each channel as (R,G,B) dicChannel = the DIC channel number lasers = the laser wavelength for each channel emissions = the emssion band for each channel as (min,max) data = the image data as (x,y,z,channel)

metadata - the meta data, a struct with fields:

keys = the meta data keys (the names for the meta data) values = the meta data values (the values for the meta data) hashtable = a Java Hashtable of keys and their values

DataHandling.imreadCZI(filename)

IMREADCZI Read in a Zeiss CZI image.

[IMAGE, METADATA] = IMREADCZI(FILENAME)

Input: filename - the filename of the CZI image

Outputs: image - the image, a struct with fields:

pixels = the number of pixels as (x,y,z) scale = the pixel scale, in meters, as (x,y,z) channels = the names of the channels colors = the color for each channel as (R,G,B) dicChannel = the DIC channel number lasers = the laser wavelength for each channel emissions = the emssion band for each channel as (min,max) data = the image data as (x,y,z,channel)

metadata - the meta data, a struct with fields:

keys = the meta data keys (the names for the meta data) values = the meta data values (the values for the meta data) hashtable = a Java Hashtable of keys and their values

DataHandling.imreadLif(filename)

IMREADANY Read .lif format (all purpose reader).

[IMAGE, METADATA] = IMREADANY(FILENAME)

Input: filename - the filename of the lif image idx - index of the series (0 to n-1)

Outputs: image - the image, a struct with fields:

pixels = the number of pixels as (x,y,z) scale = the pixel scale, in meters, as (x,y,z) channels = the names of the channels colors = the color for each channel as (R,G,B) dicChannel = the DIC channel number lasers = the laser wavelength for each channel emissions = the emssion band for each channel as (min,max) data = the image data as (x,y,z,channel)

metadata - the meta data, a struct with fields:

keys = the meta data keys (the names for the meta data) values = the meta data values (the values for the meta data) hashtable = a Java Hashtable of keys and their values

DataHandling.imreadND2(filename)

IMREADND2 Read in a Nikon ND2 image.

[IMAGE, METADATA] = IMREADCZI(FILENAME)

Input: filename - the filename of the ND2 image

Outputs: image - the image, a struct with fields:

pixels = the number of pixels as (x,y,z) scale = the pixel scale, in meters, as (x,y,z) channels = the names of the channels colors = the color for each channel as (R,G,B) dicChannel = the DIC channel number lasers = the laser wavelength for each channel emissions = the emssion band for each channel as (min,max) data = the image data as (x,y,z,channel)

metadata - the meta data, a struct with fields:

keys = the meta data keys (the names for the meta data) values = the meta data values (the values for the meta data) hashtable = a Java Hashtable of keys and their values

DataHandling.imreadVlab(filename)

IMREADVLAB Read in VLab image data from a given folder.

[IMAGE, METADATA] = IMREADVLAB(FILENAME)

Input: folder - the folder containing the data

Outputs: image - the image, a struct with fields:

pixels = the number of pixels as (x,y,z) scale = the pixel scale, in microns, as (x,y,z) channels = the names of the channels colors = the color for each channel as (R,G,B) dicChannel = the DIC channel number lasers = the laser wavelength for each channel emissions = the emsspyeion band for each channel as (min,max) data = the image data as (x,y,z,channel)

metadata - the meta data, a struct with fields:

keys = the meta data keys (the names for the meta data) values = the meta data values (the values for the meta data) hashtable = a Java Hashtable of keys and their values

class DataHandling.NeuroPALImage

NEUROPALIMAGE Convert various image formats to a NeuroPAL format.

NeuroPAL files contain 4 variable:

data = the image data (x,y,z,c) info = the image information

scale = pixel scale in microns (x,y,z) RGBW = the (R,G,B,W) color channel indices (nan = no data) GFP = the GFP color channel index(s) (can be empty) DIC = the DIC channel index (can be empty) gamma = the gamma correction for the image

prefs = the user preferences

RGBW = the (R,G,B,W) color channel indices (nan = no data) GFP = the GFP color channel index(s) (can be empty) DIC = the DIC channel index (can be empty) gamma = the gamma correction for the image rotate.horizontal = rotate horizontal? rotate.vertical = rotate vertical?

worm = the worm information
body = ‘Whole Worm’, ‘Head’, ‘Midbody’, ‘Anterior Midbody’.

‘Central Midbody’, ‘Posterior Midbody’, or ‘Tail’

age = ‘Adult’, ‘L4’, L3’, ‘L2, ‘L1’, or ‘3-Fold’ sex = ‘XX’ or ‘XO’ strain = strain name notes = experimental notes

mp = matching pursuit (neuron detection) parameters neurons = the neurons in the image

Method Summary
static open(file)

OPEN Open an image in NeuroPAL format.

Input:

file = the NeuroPAL format filename

Output:

data = the image data info = the image information prefs = the user preferences worm = the worm information mp = matching pursuit (neuron detection) parameters neurons = the neurons in the image

np_file = the NeuroPAL image file id_file = the NeuroPAL ID file

class DataHandling.PNGViewer

PNGVIEWER View PNG files.

Method Summary
static show(file, name)

SHOW Show the PNG file.

DataHandling.readAnnoH5(path)
DataHandling.readStimFile(path)
DataHandling.readTrackmate(file)
DataHandling.sysOpenPDF(fileName)

OPENPDF Opens a PDF file in the appropriate viewer/editor.

class DataHandling.writeNWB

Functions responsible for handling our dynamic GUI solutions.

Method Summary
static create_channels(optical_table)

Populate channel data

static create_device(name, description, manufacturer)
static create_file(ctx)
static create_module(module, ctx)
static create_segmentation(preset, ctx)
static create_traces(ctx)
static create_volume(preset, module, ctx)
static write_order(app, path, progress)

Full-shot NWB save routine

DataHandling.writeTrackMate(video_info, video_neurons, output_file, figure)
DataHandling.Helpers
class DataHandling.Helpers.h5

HDMF Summary of this class goes here Detailed explanation goes here

Method Summary
load_tracks(filepath)
class DataHandling.Helpers.java

Class java - Handles conversion of Java hashtable keys and values into MATLAB structures and manages string validity based on specified character constraints.

Property Summary
max_characters

Maximum number of characters allowed for valid strings.

Method Summary
static parse_hashtable(table)

Converts a Java hashtable into a MATLAB structure with valid field names.

Parameters:

table – A Java hashtable object containing key-value pairs.

Returns:

A MATLAB struct where keys are converted to valid MATLAB field names.

Return type:

obj

static search_key(metadata, query)
static to_valid(raw_str)

Converts an input string to a valid MATLAB field name by replacing or truncating characters.

Parameters:

raw_str – Original string to be validated and formatted.

Returns:

Modified string that meets MATLAB field name requirements.

Return type:

valid_str

static value_to_string(val)

Convert a Java-based metadata value to a MATLAB string

class DataHandling.Helpers.mat
Method Summary
static get_channels(file)
static get_dimensions(file)
static get_plane(varargin)

GET_PLANE Extract a specific plane or slice from the ND2 file based on the given coordinates.

Parameters:
  • x (varargin - Input parser options for)

  • y

  • z

  • c

  • dimensions. (t)

Returns:

obj - Multidimensional array containing image planes.

static load_metadata(file)
static open(file)
class DataHandling.Helpers.nd2

ND2 Class for handling and extracting metadata and images from ND2 files.

Property Summary
channel_keys

Keys used to identify channel metadata

key_map
name_substr

Base substring used to identify channel names globally

Method Summary
static autosort(channels)
static channels_from_file(file)
static get_channel_names(reader)
static get_channels(reader)
static get_dimensions(file)
static get_plane(file, varargin)

GET_PLANE Extract a specific plane or slice from the ND2 file based on the given coordinates.

Parameters:
  • x (varargin - Input parser options for)

  • y

  • z

  • c

  • dimensions. (t)

Returns:

obj - Multidimensional array containing image planes.

static get_ttl(file)
static get_ttl_data(file)
  1. Determine number of frames in the series

static get_ttl_keys(file, target)
static open(file)

OPEN Open an ND2 file, returning a reader object or image data and metadata.

Parameters:

file. (file - Path to the ND2)

Returns:

obj - Reader object or image data depending on lazy loading status. metadata - Struct containing metadata information for the file.

static to_npal(file)

CONVERTND2 Convert an ND2 file to NeuroPAL format.

nd2_file = the ND2 file to convert np_file = the NeuroPAL format file

class DataHandling.Helpers.npal

NPAL Summary of this class goes here Detailed explanation goes here

Method Summary
static create_neurons(varargin)
class DataHandling.Helpers.nwb
Method Summary
static get_channel_names(f, module)
static get_plane(varargin)
static load_tracks(filepath)
static open(file)
static search(file, module)

to be merged from loader branch

static to_npal(file, is_video)

CONVERTNWB Convert an NWB file to NeuroPAL format.

nwb_file = the NWB file to convert np_file = the NeuroPAL format file

static volume_path(new_path)
static write_data(np_file, data_pipe, dims)
class DataHandling.Helpers.tif

TIF Summary of this class goes here Detailed explanation goes here

Property Summary
Property1
Method Summary
static to_npal(file)

CONVERTND2 Convert an ND2 file to NeuroPAL format.

nd2_file = the ND2 file to convert np_file = the NeuroPAL format file