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
-
training_mask,outputs -
max_iterations,save_checkpoints_every,save_snapshots_every,devices,sampling -
num_gpus,num_workers -
method,num_workers -
bias,global_bias,filter_fragments,remove_debris -
xy -
thresholds
[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_labelsSet true when the labels are on single sections.
-
gtThe ground truth for the evaluate step.
-
labelsThe path of the labels array, absolute or relative to the working directory. Volumes without labels give no training samples.
-
mask_dilationWith training_mask = "labels", training also uses this many voxels of background around each object. With 2d_labels = true, the mask grows in xy only.
-
outputsThe container for predictions, segmentations and error maps. The default is a container in the round, such as round_01/data.zarr.
-
rawThe 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_maskThe 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_maskUse "labels" for sparse labels, "everywhere" for dense labels, or the path of a mask for dense labels within that mask.
-
voxel_sizeThe 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.
-
devicesThe training devices, as a count such as 1 or a list of GPU indices such as [0]. Lightning selects the accelerator automatically.
-
max_iterationsTraining stops after this many iterations. With save_checkpoints_every = 5000, 30001 saves a last checkpoint at 30000.
-
samplingUse "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_everyThe number of iterations between checkpoints.
-
save_snapshots_everyThe 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_gpusThe number of GPUs for prediction. With more than one, bs predict runs the blocks through daisy.
-
num_workersThe 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_shapeThe block shape in voxels, z y x. The default is the chunk shape of the affinities, deepened to at least 16 sections.
-
blockwiseWith 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.
-
contextThe block context that bs segment --block-context sets, in voxels, z y x.
-
methodThe segmentation method: mws (mutex watershed), ws (watershed, needs the waterz extra) or cc (connected components).
-
num_workersThe 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_offsetThe ROI offset in nm, z y x, as a TOML array such as [0, 0, 0].
-
roi_shapeThe ROI shape in nm, z y x, as a TOML array such as [400, 4000, 4000].
-
seeds_datasetA 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.
-
biasThe value to add to each affinity channel, one per offset. More negative values give more splits.
-
epsilon_agglomerateMerges the watershed fragments of each block by mean-affinity waterz score up to this threshold. 0.0 merges none.
-
filter_fragmentsRemoves 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_xytrue makes watershed fragments section by section, and false makes them in 3D.
-
global_biasThe 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_functionThe 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_distanceThe 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_epsAdds zero-mean Gaussian noise with this standard deviation to the affinities, to break ties.
-
randomized_stridestrue keeps each strided affinity with probability 1/prod(stride), and false keeps a regular grid.
-
remove_debrisRemoves fragments smaller than this many voxels. The filter keeps fragments that contain a seeds_dataset seed.
-
seed_epsSubtracts this value x the voxel distance to the nearest watershed seed from the affinities. Unset means no change.
-
sigmaThe Gaussian smoothing of the affinities, in voxels, z y x. Unset means no smoothing.
-
stridesThe 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.
-
thresholdJoins neighboring voxels whose affinity is above this value, on a 0 to 1 scale. It uses the first three channels.
-
thresholdsWrites 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_fileThe path of an SQLite file.
-
db_hostA PostgreSQL connection setting.
-
db_nameA PostgreSQL connection setting.
-
db_passwordA PostgreSQL connection setting.
-
db_userA 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_workersNumber 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_sizeRemove objects larger than this many voxels. With 0 or no value, the command keeps large objects.
-
min_sizeRemove objects smaller than this many voxels (dust)
-
num_workersThe number of daisy workers that process the blocks.
-
out_arrayThe 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_sizeCompute the mean and standard deviation from the objects with at least this many voxels.
-
num_stdRemove objects whose size differs from the mean by more than this many standard deviations.
-
num_workersThe number of daisy workers that process the blocks.
-
out_arrayThe 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_zRemove objects whose z-extent is this many slices or fewer
-
num_workersThe number of daisy workers that process the blocks.
-
out_arrayThe 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_idsMerge groups as a TOML array of comma-separated strings, such as ["12,34", "56,78"]. Each group merges into its first id.
-
num_workersThe number of daisy workers that process the blocks.
-
out_arrayThe label array to write. Default: the input path with the suffix _remapped.
-
remove_idsComma-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_sizeThe write-block size in xy, in voxels, rounded to a multiple of the chunk size. In z, each block is one chunk deep.
-
contextThe 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_idsLabel ids that dilate never grows and fill-holes never absorbs, such as 1,4,8. In config files, use exclude_ids = [1, 4, 8].
-
iterationsThe number of iterations for dilate, erode, opening and closing.
-
max_areaThe 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_workersThe number of daisy workers that process the blocks.
-
out_arrayThe label array to write. Default: append the operation to the input path, such as labels_fill_holes.
-
xyFills 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_workersThe number of daisy workers that process the blocks.
-
out_arrayThe 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_dirA path the evaluate step writes.
-
out_resultResult JSON path. Each volume gets its own file, and with several checks each file name also gets the check name.
-
roi_offsetThe ROI offset in nm, z y x, as a TOML array such as [0, 0, 0].
-
roi_shapeThe ROI shape in nm, z y x, as a TOML array such as [400, 4000, 4000].
-
seg_datasetsThe segmentations the evaluate step reads, as a list of paths such as ["volume.zarr/labels"].
-
thresholdsThe 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_fileThe path of a ground-truth skeletons file.
bs prepare derives labels_dataset in the run tail.
[evaluate.pred]
-
paramsThe table [evaluate.pred.params].
-
thresholdsTwo 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_sigmaFor 3d_lsds predictions, the Gaussian standard deviation in nm that training used. Use one value or a z y x array.
-
roi_offsetThe ROI offset in nm, z y x, as a TOML array such as [0, 0, 0].
-
roi_shapeThe 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>]:
-
samplesAn 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_dirThe directory that contains the model scripts and checkpoints.
-
voxel_sizeThe voxel size in nm, z y x, as a TOML array such as [40, 4, 4].
From [[train.<model>.samples]]:
-
labelsThe path of the volume's labels.
-
maskThe path of the volume's training mask.
-
rawThe path of the volume's raw array.
-
volumeThe volume's name.
From [predict.<model>]:
-
chain_strThe models before this one, each as <model>_<iteration>, joined by --from--.
-
checkpointThe last checkpoint of the train step, or the shipped one.
-
input_datasetsA list of paths to raw arrays or the preceding predict step's output arrays.
-
output_datasets_prefixA path the predict step writes.
-
roi_offsetThe ROI offset in nm, z y x, as a TOML array such as [0, 0, 0].
-
roi_shapeThe ROI shape in nm, z y x, as a TOML array such as [400, 4000, 4000].
-
setup_dirThe directory that contains the model scripts and checkpoints.
From [segment]:
-
affs_datasetA path the segment step reads.
-
fragments_datasetA path the segment step writes.
-
lut_dirA path the segment step writes.
-
mask_datasetThe target mask.
-
seg_dataset_prefixA path the segment step writes.
From [segment.params]:
-
aff_neighborhoodThe affinity offsets in the model's net_config.json.
From [refine]:
-
in_arrayThe mws segmentation that the segment step writes with its params. For ws or cc, set in_array in [refine].
From [refine.mask]:
-
mask_arrayThe mask array, at the labels' voxel size. Labels become 0 where the mask is 0.
From [evaluate]:
-
mask_datasetThe target mask.
-
seg_datasets_prefixA path the evaluate step reads.
From [evaluate.gt]:
-
labels_datasetA path the evaluate step reads.
From [evaluate.pred]:
-
pred_datasetA path the evaluate step reads.
From [evaluate.pred.params]:
-
aff_neighborhoodThe affinity offsets in the model's net_config.json.