dacapo.gp
Submodules
Package Contents
Classes
A DaCapo Array source node |
|
A Gunpowder node for generating the target from the ground truth |
|
Class for applying gamma noise augmentation. |
|
Elasticly deform a batch. Requests larger batches upstream to avoid data |
|
Reject batches based on the masked-in vs. masked-out ratio. |
|
A class to copy a mask into a new key with the option to drop channels via max collapse. |
|
A provider for serving graph data in gunpowder pipelines. |
|
multiplies two arrays |
- class dacapo.gp.DaCapoArraySource(array: dacapo.experiments.datasplits.datasets.arrays.Array, key: gunpowder.ArrayKey)
A DaCapo Array source node
- Parameters:
Array (Array) – The DaCapo Array to pull data from
key (
gp.ArrayKey) – The key to provide data into
- setup()
To be implemented in subclasses.
Called during initialization of the DAG. Callees can assume that all upstream providers are set up already.
In setup, call
provides()to announce the arrays and points provided by this node.
- provide(request)
To be implemented in subclasses.
This function takes a
BatchRequestand should return the correspondingBatch.- Parameters:
request (
BatchRequest) – The request to process.
- class dacapo.gp.DaCapoTargetFilter(predictor: dacapo.experiments.tasks.predictors.Predictor, gt_key: gunpowder.ArrayKey, target_key: gunpowder.ArrayKey | None = None, weights_key: gunpowder.ArrayKey | None = None, mask_key: gunpowder.ArrayKey | None = None)
A Gunpowder node for generating the target from the ground truth
- Parameters:
Predictor (Predictor) – The DaCapo Predictor to use to transform gt into target
gt (
Array) – The dataset to use for generating the target.target_key (
gp.ArrayKey) – The key with which to provide the target.
- setup()
To be implemented in subclasses.
Called during initialization of the DAG. Callees can assume that all upstream providers are set up already.
In setup, call
provides()orupdates()to announce the arrays and points provided or changed by this node.
- prepare(request)
To be implemented in subclasses.
Prepare for a batch request. Should return a
BatchRequestof needed dependencies. If None is returned, it will be assumed that all of request is needed.
- process(batch, request)
To be implemented in subclasses.
Filter a batch, will be called after
prepare(). Should return aBatchcontaining modified Arrays and Graphs. Keys in the returned batch will replace the associated data in the original batch. If None is returned it is assumed that the batch has been modified in place.requestis the same as passed toprepare(), provided for convenience.- Parameters:
batch (
Batch) – The batch received from upstream to be modified by this node.request (
BatchRequest) – The request this node received. The updated batch should meet this request.
- class dacapo.gp.GammaAugment(arrays, gamma_min, gamma_max)
Class for applying gamma noise augmentation.
- arrays
An iterable collection of np arrays to augment
- gamma_min
A float representing the lower limit of gamma perturbation
- gamma_max
A float representing the upper limit of gamma perturbation
- setup()
Method to configure the internal state of the class
- process()
Method to apply gamma noise to the desired arrays
- __augment()
Private method to perform the actual augmentation
- setup()
Configuring the internal state by iterating over arrays.
- process(batch, request)
Method to apply gamma noise to the desired arrays.
- Parameters:
batch – The input batch to be processed.
request – An object which holds the requested output location.
- class dacapo.gp.ElasticAugment(control_point_spacing, control_point_displacement_sigma, rotation_interval, subsample=1, augmentation_probability=1.0, seed=None, uniform_3d_rotation=False)
Elasticly deform a batch. Requests larger batches upstream to avoid data loss due to rotation and jitter.
- Parameters:
control_point_spacing (
tupleofint) – Distance between control points for the elastic deformation, in voxels per dimension.control_point_displacement_sigma (
tupleoffloat) – Standard deviation of control point displacement distribution, in world coordinates.rotation_interval (
tupleof twofloats) – Interval to randomly sample rotation angles from (0, 2PI).subsample (
int) – Instead of creating an elastic transformation on the full resolution, create one sub-sampled by the given factor, and linearly interpolate to obtain the full resolution transformation. This can significantly speed up this node, at the expense of having visible piecewise linear deformations for large factors. Usually, a factor of 4 can safely be used without noticeable changes. However, the default is 1 (i.e., no sub-sampling).seed (
int) – Set random state for reproducible results (tests only, do not use in production code!!)
- setup()
To be implemented in subclasses.
Called during initialization of the DAG. Callees can assume that all upstream providers are set up already.
In setup, call
provides()orupdates()to announce the arrays and points provided or changed by this node.
- prepare(request)
To be implemented in subclasses.
Prepare for a batch request. Should return a
BatchRequestof needed dependencies. If None is returned, it will be assumed that all of request is needed.
- process(batch, request)
To be implemented in subclasses.
Filter a batch, will be called after
prepare(). Should return aBatchcontaining modified Arrays and Graphs. Keys in the returned batch will replace the associated data in the original batch. If None is returned it is assumed that the batch has been modified in place.requestis the same as passed toprepare(), provided for convenience.- Parameters:
batch (
Batch) – The batch received from upstream to be modified by this node.request (
BatchRequest) – The request this node received. The updated batch should meet this request.
- class dacapo.gp.RejectIfEmpty(gt=None, p=0.5, background=0)
Reject batches based on the masked-in vs. masked-out ratio.
- Parameters:
gt (
ArrayKey, optional) – The gt array to usep (
float, optional) – The probability that we reject until gt is nonempty
- setup()
To be implemented in subclasses.
Called during initialization of the DAG. Callees can assume that all upstream providers are set up already.
In setup, call
provides()orupdates()to announce the arrays and points provided or changed by this node.
- provide(request)
To be implemented in subclasses.
This function takes a
BatchRequestand should return the correspondingBatch.- Parameters:
request (
BatchRequest) – The request to process.
- class dacapo.gp.CopyMask(array_key: gunpowder.ArrayKey, copy_key: gunpowder.ArrayKey, drop_channels: bool = False)
A class to copy a mask into a new key with the option to drop channels via max collapse.
- array_key
Original key of the array from where the mask will be copied.
- Type:
gp.ArrayKey
- copy_key
New key where the copied mask will reside.
- Type:
gp.ArrayKey
- drop_channels
If True, channels will be dropped via a max collapse.
- Type:
bool
- setup()
Sets up the filter by enabling autoskip and providing the copied key.
- prepare()
Prepares the filter by copying the request of copy_key into a dependency.
- process()
Processes the batch by copying the mask from the array_key to the copy_key.
- setup()
Sets up the filter by enabling autoskip and providing the copied key.
- prepare(request)
Prepares the filter by copying the request of copy_key into a dependency.
- Parameters:
request – The request to prepare.
- Returns:
The prepared dependencies.
- Return type:
deps
- process(batch, request)
Processes the batch by copying the mask from the array_key to the copy_key.
If “drop_channels” attribute is True, it performs max collapse.
- Parameters:
batch – The batch to process.
request – The request for processing.
- Returns:
The processed outputs.
- Return type:
outputs
- class dacapo.gp.GraphSource(key: gunpowder.GraphKey, graph: gunpowder.Graph)
A provider for serving graph data in gunpowder pipelines.
The Graph Source loads a single graph to serve to the pipeline based on ROI requests it receives.
- key
The key of the graph to be served.
- Type:
gp.GraphKey
- graph
The graph to be served.
- Type:
gp.Graph
- setup()
Set up the provider. This function sets the provider to provide the graph with the given key.
- provide(request)
Provides the graph for the requested ROI.
This method will be passively called by gunpowder to get a batch. Depending on the request we provide a subgraph of our data, or nothing at all.
- Parameters:
request (gp.BatchRequest) – BatchRequest with the same ROI for
graph. (each requested array and) –
- Returns:
The graph contained in a Batch.
- Return type:
outputs (gp.Batch)
- class dacapo.gp.Product(x1_key: gunpowder.ArrayKey, x2_key: gunpowder.ArrayKey, y_key: gunpowder.ArrayKey)
multiplies two arrays
- setup()
To be implemented in subclasses.
Called during initialization of the DAG. Callees can assume that all upstream providers are set up already.
In setup, call
provides()orupdates()to announce the arrays and points provided or changed by this node.
- prepare(request)
To be implemented in subclasses.
Prepare for a batch request. Should return a
BatchRequestof needed dependencies. If None is returned, it will be assumed that all of request is needed.
- process(batch, request)
To be implemented in subclasses.
Filter a batch, will be called after
prepare(). Should return aBatchcontaining modified Arrays and Graphs. Keys in the returned batch will replace the associated data in the original batch. If None is returned it is assumed that the batch has been modified in place.requestis the same as passed toprepare(), provided for convenience.- Parameters:
batch (
Batch) – The batch received from upstream to be modified by this node.request (
BatchRequest) – The request this node received. The updated batch should meet this request.