neurots.generate.algorithms.barcode

Class to collect all TMD related info used in NeuroTS.

Classes

Barcode(ph_angles)

Class to generate the barcode structure.

class neurots.generate.algorithms.barcode.Barcode(ph_angles)

Bases: object

Class to generate the barcode structure.

The barcode structure is essential for the TMD based growth algorithms.

Parameters:

ph_angles (list of lists) –

list of barcodes and angles of 6 elements:

  • either:

    [
        end_point,
        start_point,
        4D_angles
    ]
    
  • or equivalent:

    [
        Termination,
        Bifurcation,
        Angle parent - child (x-y),
        Angle parent - child (z),
        Angle child1 - child2 (x-y),
        Angle child1 - child2 (z)
    ]
    

Returns:

The ph_angles will be decomposed in the following dictionaries:

{
    angles: {ID: 4D_angles}
    bifs: {ID: start_point}
    terms: {ID, end_point}
}

curate_stop_criterion(parent_stop, child_stop)

Checks if the children stop criterion is compatible with parent.

The child bar’s length should be smaller than the current bar’s length. This process ensures that each branch can only generate smaller branches. The criteria to ensure this statement is True are the following:

  • parent_stop.ref <= child_stop.bif <= parent_stop.term or child_stop.bif = inf

  • child_stop.term <= parent_stop.term

  • term(child_stop.bif) <= parent_stop.term

Parameters:
  • parent_stop (TMDStop) – stop criteria of parent section.

  • target_stop (TMDStop) – proposed stop criteria for child.

Returns:

The next bar for which the expected length of the child branch is smaller than current one for both bif and term.

Return type:

TMDStop

get_bar(bar_id)

Returns the pair of (bifurcation, termination) that corresponds to the input index.

The trivial bifurcation of id=0 is not included.

get_persistence_length()

Returns the maximum bar length.

get_term(bar_id)

Returns a termination based on index if the input ID exists of infinity.

If it doesn’t exist the branch will terminate as it gets term = -infinity.

get_term_between(bar_id, above=0.0, below=inf)

Returns a termination based on index.

If the index exists and its value is between the above / below thresholds, the termination is returned. If it doesn’t exist the branch will terminate as it gets term = -infinity.

max_term()

Returns the id and value of the maximum termination.

Termination list cannot be empty. This means the growth should have stopped, and therefore it will results in a ‘StopIteration’ error

min_bif(bif_above=0.0, bif_below=inf)

Returns the id and value of the minimum bifurcation whose value is in threshold range.

If no value is valid, returns infinity (np.inf) and therefore the index is None.

min_term(term_above=0.0, term_below=inf)

Returns the id and value of the minimum termination whose value is in threshold range.

If no value is valid, returns zero, the section will terminate and therefore the index is None.

remove_bif(bar_id)

Remove a bifurcation that has been used if bif_id is not None.

remove_term(bar_id)

Remove a termination that has been used, if term_id is not None.

select_compatible_bif(below_bif, above_bif, below_term, above_term)

Finds a bifurcation within the barcode.

The bifurcation must fulfil both bif and term criteria / boundaries: below_bif <= bif <= above_bif below_term <= term <= above_term

static validate_persistence(ph_angles)

Checks if data are in the expected format.

The input barcodes should follow the rules: 1. Bar: (start, end), end > start