mlreco.utils.deghosting module

mlreco.utils.deghosting.compute_rescaled_charge(input_data, deghost_mask, last_index=6, batch_col=0)[source]

Computes rescaled charge after deghosting

Note

This function should work on Numpy arrays or Torch tensors.

Parameters
  • input_data (np.ndarray or torch.Tensor) – Shape (N, 4+num_features) where 4 corresponds to batch_id,x,y,z

  • deghost_mask (np.ndarray or torch.Tensor) – Shape (N,), N_deghost is the predicted deghosted voxel count

  • last_index (int, default 6) – Indexes where hit-related features start @ 4 + deghost_input_features

  • batch_col (int, default 0) –

Returns

Shape (N_deghost,) contains rescaled charge array for input data. Includes deghosted mask already.

Return type

np.ndarray or torch.Tensor

mlreco.utils.deghosting.adapt_labels_knn(result, label_seg, label_clustering, num_classes=5, batch_column=0, coords_column_range=(1, 4), true_mask=None, use_numpy=False)[source]

Returns new cluster labels that have the same size as the input w/ ghost points. Points predicted as nonghost but that are true ghosts get the cluster label of the closest cluster. Points that are true ghosts and predicted as ghosts get “empty” (-1) values.

Note

Uses GPU version from torch_cluster.knn to speed up the label adaptation computation.

Parameters
  • result (dict) –

  • label_seg (list of torch.Tensor) –

  • label_clustering (list of torch.Tensor) –

  • num_classes (int, default 5) – Semantic classes count.

  • batch_column (int, default 0) –

  • coords_column_range (tuple, default (1, 4)) –

  • true_mask (torch.Tensor, default None) – True nonghost mask. If None, will use the intersection of predicted nonghost and true nonghost. This option is useful to do “cheat ghost predictions” (i.e. mimic deghosting predictions using true ghost mask, to run later stages of the chain independently of the deghosting stage).

Returns

shape: (input w/ ghost points, label_clusters_features)

Return type

np.ndarray

mlreco.utils.deghosting.adapt_labels(*args, **kwargs)[source]

Kept for backward compatibility, to deprecate soon.

mlreco.utils.deghosting.adapt_labels_numpy(*args, **kwargs)[source]

Numpy version of adapt_labels.

mlreco.utils.deghosting.deghost_labels_and_predictions(data_blob, result)[source]

Given dictionaries <data_blob> and <result>, apply deghosting to uresnet predictions and labels for use in later reconstruction stages.

Warning

Modifies in place the input data and result dictionaries.

Note

Used in analysis tools (decorator).

Parameters
  • data_blob (dict) –

  • result (dict) –