analysis.classes.particle module¶
-
analysis.classes.particle.matrix_counts(particles_x, particles_y)[source]¶ Function for computing the M x N overlap matrix by counts.
- Parameters
particles_x (List[Particle]) – List of N particles to match with <particles_y>
particles_y (List[Particle]) – List of M particles to match with <particles_x>
the correspondence particles_x -> N and particles_y -> M. (Note) –
- Returns
overlap_matrix
- Return type
(M, N) np.array of ints
-
analysis.classes.particle.matrix_iou(particles_x, particles_y)[source]¶ Function for computing the M x N overlap matrix by IoU.
Here IoU refers to Intersection-over-Union metric.
- Parameters
particles_x (List[Particle]) – List of N particles to match with <particles_y>
particles_y (List[Particle]) – List of M particles to match with <particles_x>
the correspondence particles_x -> N and particles_y -> M. (Note) –
- Returns
overlap_matrix
- Return type
(M, N) np.float array, with range [0, 1]
-
analysis.classes.particle.match_particles_fn(particles_from: Union[List[analysis.classes.Particle.Particle], List[analysis.classes.TruthParticle.TruthParticle]], particles_to: Union[List[analysis.classes.Particle.Particle], List[analysis.classes.TruthParticle.TruthParticle]], min_overlap=0, num_classes=5, verbose=False, overlap_mode='iou')[source]¶ Match each Particle in <pred_particles> to <truth_particles> The number of matches will be equal to the length of <pred_particles>.
- Parameters
particles_from (List[Particle] or List[TruthParticle]) – List of particles to loop over during matching procedure.
particles_to (List[Particle] or List[TruthParticle]) – List of particles to match a given particle from <particles_from>.
min_overlap (int, float, or List[int]/List[float]) –
Minimum required overlap value (float for IoU, int for counts) for a valid particle-particle match pair.
If min_overlap is a list with same length as <num_classes>, a minimum overlap value will be applied separately for different classes.
Example
- match_particles_fn(parts_from, parts_to,
min_overlap=[0.9, 0.9, 0.99, 0.99], num_classes=4)
-> This applies a minimum overlap cut of 0.9 IoU for class labels 0 and 1, and a cut of 0.99 IoU for class labels 2 and 3.
num_classes (int) – Total number of semantic classes (or any other label). This is used for setting <min_overlap> to differ across different semantic labels, for example.
verbose (bool) – If True, print a message when a given particle has no match.
overlap_mode (str) –
Supported modes:
’iou’: overlap matrix is constructed from computing the intersection-over-union metric.
’counts’: overlap matrix is constructed from counting the number of shared voxels.
- Returns
matches (List[Tuple[Particle, Particle]]) – List of tuples, indicating the matched particles. In case of no valid matches, a particle is matched with None
idx (np.array of ints) – Index of matched particles
intersections (np.array of floats/ints) – IoU/Count information for each matches.
-
analysis.classes.particle.match_interactions_fn(ints_from: List[analysis.classes.Interaction.Interaction], ints_to: List[analysis.classes.Interaction.Interaction], min_overlap=0, verbose=False, overlap_mode='iou')[source]¶ Same as <match_particles_fn>, but for lists of interactions.
-
analysis.classes.particle.group_particles_to_interactions_fn(particles: List[analysis.classes.Particle.Particle], get_nu_id=False, mode='pred')[source]¶ Function for grouping particles to its parent interactions.
- Parameters
particles (List[Particle]) – List of Particle instances to construct Interaction instances from.
get_nu_id (bool) – Option to retrieve neutrino_id (unused)
mode (str) –
Supported modes: ‘pred’: output list will contain <Interaction> instances ‘truth’: output list will contain <TruthInteraction> instances.
Do not mix predicted interactions with TruthInteractions and interactions constructed from using labels with Interactions.