Bootstrapper Bootstrapper docs

Configuration

A TOML file describes one step or a whole round.

Tables and derived values

[volumes.<name>] describes the data. Step tables are [train.<name>], [predict.<name>], [segment], [segment.<name>], [refine] and [evaluate]. A step needs a name only when its kind has several steps.

Values show what bs prepare writes, or the default when a key is absent. The [run.<step>] tables below your keys contain derived paths and checkpoints. The last section of this page lists them.

Common keys

[volumes.<name>]

A file's volumes come from its [volumes.<name>] tables, or from the volumes.toml beside it when the file has none. A glob makes one volume per match, named after the match's container. The matches of a volume's globs pair up in sorted order.

  • 2d_labels

    Set true when the labels are on single sections.

  • gt

    The ground truth for the evaluate step.

  • labels

    The path of the labels array, absolute or relative to the working directory. Volumes without labels give no training samples.

  • mask_dilation

    With training_mask = "labels", training also uses this many voxels of background around each object. With 2d_labels = true, the mask grows in xy only.

  • outputs example "/scratch/data.zarr"

    The container for predictions, segmentations and error maps. The default is a container in the round, such as round_01/data.zarr.

  • raw

    The path of the raw Zarr array, such as data.zarr/raw/s0 or an OME-Zarr level. It cannot be a tif or an image folder, but bs prepare --raw converts those to a Zarr array.

  • target_mask

    The segment and evaluate steps work only inside this mask. A [refine.mask] op zeros the labels outside it. bs predict covers the mask's ROI, cut to the raw ROI.

  • training_mask

    Use "labels" for sparse labels, "everywhere" for dense labels, or the path of a mask for dense labels within that mask.

  • voxel_size

    The voxel size in nm, z y x.

Other keys: An array path under a custom key. A likely misspelling of a known key is an error: pgt is a custom name, but lables is a typo of labels.

[train.<model>]

bs train passes these keys to the train function in the model's train.py. bs train reads sampling itself.

  • devices bs prepare writes 1

    The training devices, as a count such as 1 or a list of GPU indices such as [0]. Lightning selects the accelerator automatically.

  • max_iterations bs prepare writes 30001

    Training stops after this many iterations. With save_checkpoints_every = 5000, 30001 saves a last checkpoint at 30000.

  • sampling example "equal"

    Use "equal" for equal batch shares, "labels" for shares by training-mask voxels (labelled voxels without a mask), or "inv" for inverse shares. Custom weights are a list in sample order, such as [3, 1], or a table by volume name.

  • save_checkpoints_every bs prepare writes 5000

    The number of iterations between checkpoints.

  • save_snapshots_every bs prepare writes 1000

    The number of iterations between snapshots, which are training batches you can view.

bs prepare derives samples, setup_dir, voxel_size in the run tail.

[[train.<model>.samples]]

bs prepare derives labels, mask, raw, volume in the run tail.

[predict.<model>]

Run the [predict.*] steps of CONFIG_FILE in file order, or select one with --step.

  • num_gpus bs prepare writes 1

    The number of GPUs for prediction. With more than one, bs predict runs the blocks through daisy.

  • num_workers bs prepare writes 1

    The number of prediction workers. With more than one, bs predict runs the blocks through daisy.

bs prepare derives chain_str, checkpoint, input_datasets, output_datasets_prefix, roi_offset, roi_shape, setup_dir in the run tail.

Scan and daisy at the last block

With at most one GPU and one worker, bs predict uses gunpowder Scan; otherwise, daisy assigns the blocks.

bs predict extends the Scan ROI to a whole number of output blocks to match daisy's block grid. Both methods can process blocks beyond the requested ROI, but the output arrays keep the requested ROI.

[segment]

Segment affinities using the [segment] settings in CONFIG_FILE.

Set the method key to ws, mws or cc, or override it with -ws, -mws or -cc.

  • block_shape example [32, 512, 512]

    The block shape in voxels, z y x. The default is the chunk shape of the affinities, deepened to at least 16 sections.

  • blockwise bs prepare writes true

    With true, bs segment works in blocks with several workers, unless block_shape = "roi". With false, it segments the ROI as one block. Only ws and mws support blockwise = true. Use false for cc.

  • context

    The block context that bs segment --block-context sets, in voxels, z y x.

  • method bs prepare writes "mws"

    The segmentation method: mws (mutex watershed), ws (watershed, needs the waterz extra) or cc (connected components).

  • num_workers bs prepare writes 10

    The number of block workers. With SQLite, the workers share one file, and each write waits up to 10 min for its lock. For more than 10 workers, use PostgreSQL in [segment.db].

  • roi_offset

    The ROI offset in nm, z y x, as a TOML array such as [0, 0, 0].

  • roi_shape

    The ROI shape in nm, z y x, as a TOML array such as [400, 4000, 4000].

  • seeds_dataset

    A path the segment step reads.

bs prepare derives affs_dataset, fragments_dataset, lut_dir, mask_dataset, seg_dataset_prefix in the run tail.

[segment.params]

Each key lists the methods that accept it and their defaults. For an unset default, leave the key out.

  • bias ws unset; mws [-0.4, -0.4, -0.4, -0.7, -0.7, -0.7, -0.7, -0.7, -0.7]

    The value to add to each affinity channel, one per offset. More negative values give more splits.

  • epsilon_agglomerate ws 0.0

    Merges the watershed fragments of each block by mean-affinity waterz score up to this threshold. 0.0 merges none.

  • filter_fragments ws 0.1; mws 0.1

    Removes fragments whose mean affinity over the first three channels is below this value. The filter keeps fragments that contain a seeds_dataset seed.

  • fragments_in_xy ws true

    true makes watershed fragments section by section, and false makes them in 3D.

  • global_bias mws [1.0, -0.5]

    The weight and bias of each edge score, which is weight x mean affinity + bias. A positive score attracts and a negative one repels. A repulsion can block a later merge.

  • merge_function ws "mean"

    The waterz score: mean, hist_quant_10, hist_quant_25, hist_quant_50, hist_quant_75 or hist_quant_90. Each hist_quant score can also take the suffix _initmax.

  • min_seed_distance ws 10; mws unset

    The width in voxels of the maximum filter that puts seeds at the peaks of the distance to the boundary. In mws, leaving it unset makes no seeds. mws stops with an error when you set it together with seeds_dataset.

  • noise_eps ws unset; mws 0.001; cc unset

    Adds zero-mean Gaussian noise with this standard deviation to the affinities, to break ties.

  • randomized_strides mws true

    true keeps each strided affinity with probability 1/prod(stride), and false keeps a regular grid.

  • remove_debris ws 64; mws 64; cc 64

    Removes fragments smaller than this many voxels. The filter keeps fragments that contain a seeds_dataset seed.

  • seed_eps ws unset

    Subtracts this value x the voxel distance to the nearest watershed seed from the affinities. Unset means no change.

  • sigma ws unset; mws unset; cc unset

    The Gaussian smoothing of the affinities, in voxels, z y x. Unset means no smoothing.

  • strides mws [[1, 1, 1], [1, 1, 1], [1, 1, 1], [2, 9, 9], [2, 9, 9], [2, 9, 9], [3, 27, 27], [3, 27, 27], [3, 27, 27]]

    The z y x stride of each affinity channel, one per offset. A larger stride keeps fewer edges. Fewer repulsive edges can give fewer splits, and fewer attractive edges can give more splits.

  • threshold cc 0.5

    Joins neighboring voxels whose affinity is above this value, on a 0 to 1 scale. It uses the first three channels.

  • thresholds ws [0.2, 0.35, 0.5]

    Writes one segmentation for each merge-score threshold.

bs prepare derives aff_neighborhood in the run tail.

[segment.db]

SQLite takes db_file. PostgreSQL takes db_host, db_name, db_password, db_user. bs prepare writes the table commented out, below the comment "Keep this table commented out for an SQLite file beside the segmentations. For more than 10 workers, use PostgreSQL:"

  • db_file

    The path of an SQLite file.

  • db_host example "localhost"

    A PostgreSQL connection setting.

  • db_name example "bootstrapper"

    A PostgreSQL connection setting.

  • db_password example "..."

    A PostgreSQL connection setting.

  • db_user example "postgres"

    A PostgreSQL connection setting.

[refine]

Run a refine step's ops in order on each volume. Each op reads the output of the op before it. A volume's op table, such as [run.refine.<volume>.mask], merges over the step's.

  • num_workers

    Number of workers

bs prepare derives in_array in the run tail.

[refine.size-filter]

Remove objects outside a [min_size, max_size] voxel-count range, blockwise. The op runs bs refine size-filter.

  • max_size

    Remove objects larger than this many voxels. With 0 or no value, the command keeps large objects.

  • min_size default 0

    Remove objects smaller than this many voxels (dust)

  • num_workers default 20

    The number of daisy workers that process the blocks.

  • out_array

    The label array to write. Default: the input path with the suffix _size_filtered.

[refine.outlier-filter]

Remove objects whose size is an outlier, large or small, blockwise. The op runs bs refine outlier-filter.

  • min_size default 0

    Compute the mean and standard deviation from the objects with at least this many voxels.

  • num_std default 3.0

    Remove objects whose size differs from the mean by more than this many standard deviations.

  • num_workers default 20

    The number of daisy workers that process the blocks.

  • out_array

    The label array to write. Default: the input path with the suffix _outlier_filtered.

[refine.z-filter]

Remove thin objects that span few z-slices, blockwise. The op runs bs refine z-filter.

  • min_z default 1

    Remove objects whose z-extent is this many slices or fewer

  • num_workers default 20

    The number of daisy workers that process the blocks.

  • out_array

    The label array to write. Default: the input path with the suffix _z_filtered.

[refine.remap]

Remove label ids, merge groups of ids, or both, blockwise. The op runs bs refine remap.

  • merge_ids

    Merge groups as a TOML array of comma-separated strings, such as ["12,34", "56,78"]. Each group merges into its first id.

  • num_workers default 20

    The number of daisy workers that process the blocks.

  • out_array

    The label array to write. Default: the input path with the suffix _remapped.

  • remove_ids

    Comma-separated label ids to remove (set to 0)

[refine.fill-holes]

Apply a morphological operation to a labelled volume, blockwise. The op runs bs refine morph --op fill-holes.

  • block_size default 2048

    The write-block size in xy, in voxels, rounded to a multiple of the chunk size. In z, each block is one chunk deep.

  • context default 64

    The halo in voxels, in xy with --xy and otherwise in xy and z. The minimum is the iteration count for dilate and erode, twice the iteration count for opening and closing, and the width of the largest hole plus its wall for fill-holes.

  • exclude_ids

    Label ids that dilate never grows and fill-holes never absorbs, such as 1,4,8. In config files, use exclude_ids = [1, 4, 8].

  • iterations default 1

    The number of iterations for dilate, erode, opening and closing.

  • max_area default 0

    The largest enclosed region in which fill-holes absorbs objects, in voxels (pixels with --xy), such as 84000. A value of 0 keeps every object.

  • num_workers default 20

    The number of daisy workers that process the blocks.

  • out_array

    The label array to write. Default: append the operation to the input path, such as labels_fill_holes.

  • xy bs prepare writes true; default false

    Fills holes section by section; false fills them in 3D.

[refine.dilate]

Apply a morphological operation to a labelled volume, blockwise. The op runs bs refine morph --op dilate.

It takes the keys of [refine.fill-holes]; xy defaults to false.

[refine.erode]

Apply a morphological operation to a labelled volume, blockwise. The op runs bs refine morph --op erode.

It takes the keys of [refine.fill-holes]; xy defaults to false.

[refine.opening]

Apply a morphological operation to a labelled volume, blockwise. The op runs bs refine morph --op opening.

It takes the keys of [refine.fill-holes]; xy defaults to false.

[refine.closing]

Apply a morphological operation to a labelled volume, blockwise. The op runs bs refine morph --op closing.

It takes the keys of [refine.fill-holes]; xy defaults to false.

[refine.mask]

Zero every label outside a mask, blockwise. The op runs bs refine mask.

  • num_workers default 20

    The number of daisy workers that process the blocks.

  • out_array

    The label array to write. Default: the input path with the suffix _masked.

bs prepare derives mask_array in the run tail.

[evaluate]

Evaluate segmentations using the [evaluate] settings in CONFIG_FILE.

bs evaluate compares segmentations with ground truth when [evaluate.gt] exists, and with predictions when [evaluate.pred] exists. The --gt and --pred flags select a mode instead. With no table and no flag, bs evaluate only reports each segmentation.

  • out_dir

    A path the evaluate step writes.

  • out_result

    Result JSON path. Each volume gets its own file, and with several checks each file name also gets the check name.

  • roi_offset

    The ROI offset in nm, z y x, as a TOML array such as [0, 0, 0].

  • roi_shape

    The ROI shape in nm, z y x, as a TOML array such as [400, 4000, 4000].

  • seg_datasets

    The segmentations the evaluate step reads, as a list of paths such as ["volume.zarr/labels"].

  • thresholds bs prepare writes [0.1, 1.0]

    The lower and upper bounds for the mean squared affinity or LSD error. The error mask includes values strictly between these bounds.

bs prepare derives mask_dataset, seg_datasets_prefix in the run tail.

[evaluate.gt]

  • skeletons_file

    The path of a ground-truth skeletons file.

bs prepare derives labels_dataset in the run tail.

[evaluate.pred]

  • params

    The table [evaluate.pred.params].

  • thresholds

    Two values that override [evaluate] thresholds.

bs prepare derives pred_dataset in the run tail.

[evaluate.pred.params]

The table takes the keyword arguments of compute_errors in bootstrapper.eval.compute_errors.

  • lsd_sigma

    For 3d_lsds predictions, the Gaussian standard deviation in nm that training used. Use one value or a z y x array.

  • roi_offset

    The ROI offset in nm, z y x, as a TOML array such as [0, 0, 0].

  • roi_shape

    The ROI shape in nm, z y x, as a TOML array such as [400, 4000, 4000].

bs prepare derives aff_neighborhood in the run tail.

[run.<step>]

The run tail has the keys that bs prepare derives for each step from the volumes and the keys above. derive reads array metadata and net_config.json files, never voxels. A key that you set above stays out of the tail, and the keys that bs prepare derives from it use your value.

Per-volume settings override step settings, which override values in the run tail.

A [run.<step>] table takes the keys of its step table above.

From [train.<model>]:

  • samples

    An array of tables, [[train.<model>.samples]], one per labelled volume. Not taken by 3d_affs_from_2d_affs, 3d_affs_from_2d_lsd, 3d_affs_from_2d_mtlsd, 3d_affs_from_3d_lsd.

  • setup_dir

    The directory that contains the model scripts and checkpoints.

  • voxel_size

    The voxel size in nm, z y x, as a TOML array such as [40, 4, 4].

From [[train.<model>.samples]]:

  • labels

    The path of the volume's labels.

  • mask

    The path of the volume's training mask.

  • raw

    The path of the volume's raw array.

  • volume

    The volume's name.

From [predict.<model>]:

  • chain_str

    The models before this one, each as <model>_<iteration>, joined by --from--.

  • checkpoint

    The last checkpoint of the train step, or the shipped one.

  • input_datasets

    A list of paths to raw arrays or the preceding predict step's output arrays.

  • output_datasets_prefix

    A path the predict step writes.

  • roi_offset

    The ROI offset in nm, z y x, as a TOML array such as [0, 0, 0].

  • roi_shape

    The ROI shape in nm, z y x, as a TOML array such as [400, 4000, 4000].

  • setup_dir

    The directory that contains the model scripts and checkpoints.

From [segment]:

  • affs_dataset

    A path the segment step reads.

  • fragments_dataset

    A path the segment step writes.

  • lut_dir

    A path the segment step writes.

  • mask_dataset

    The target mask.

  • seg_dataset_prefix

    A path the segment step writes.

From [segment.params]:

  • aff_neighborhood mws [[-1, 0, 0], [0, -1, 0], [0, 0, -1], [-2, 0, 0], [0, -9, 0], [0, 0, -9], [-3, 0, 0], [0, -27, 0], [0, 0, -27]]

    The affinity offsets in the model's net_config.json.

From [refine]:

  • in_array

    The mws segmentation that the segment step writes with its params. For ws or cc, set in_array in [refine].

From [refine.mask]:

  • mask_array

    The mask array, at the labels' voxel size. Labels become 0 where the mask is 0.

From [evaluate]:

  • mask_dataset

    The target mask.

  • seg_datasets_prefix

    A path the evaluate step reads.

From [evaluate.gt]:

  • labels_dataset

    A path the evaluate step reads.

From [evaluate.pred]:

  • pred_dataset

    A path the evaluate step reads.

From [evaluate.pred.params]:

  • aff_neighborhood

    The affinity offsets in the model's net_config.json.