def do_counting(sorting1, sorting2, delta_tp, unit_map12):
    """
    This count all counting score possible lieke:
      * TP: true positive
      * CL: classification error
      * FN: False negative
      * FP: False positive
      * TOT: 
      * TOT_ST1: 
      * TOT_ST2: 

    Parameters
    ----------
    sorting1: SortingExtractor instance
        The ground truth sorting.
    
    sorting2: SortingExtractor instance
        The tested sorting.
    
    delta_tp: int
        
    unit_map12: dict
        Dict of matching from sorting1 to sorting2.

    Output
    ----------
    
    counts: dict 
        A dict containing all coutning
    
    labels_st1: np.array of str
        Contain label for units of sorting 1
    
    labels_st2: np.array of str
        Contain label for units of sorting 2
    """
    
    unit1_ids = sorting1.get_unit_ids()
    unit2_ids = sorting2.get_unit_ids()
    labels_st1 = dict()
    labels_st2 = dict()
    N1 = len(unit1_ids)
    N2 = len(unit2_ids)

    # copy spike trains for faster access from extractors with memmapped data
    #~ sts1 = []
    #~ for u in sorting1.get_unit_ids():
        #~ sts1.append(sorting1.get_unit_spike_train(u))
    #~ sts2 = []
    #~ for u in sorting2.get_unit_ids():
        #~ sts2.append(sorting2.get_unit_spike_train(u))
    sts1 = {u1: sorting1.get_unit_spike_train(u1) for u1 in unit1_ids}
    sts2 = {u2: sorting2.get_unit_spike_train(u2) for u2 in unit2_ids}
    
    # Evaluate
    for u1 in unit1_ids:
        lab_st1 = np.array(['UNPAIRED'] * len(sts1[u1]))
        labels_st1[u1] = lab_st1
    for u2 in unit2_ids:
        lab_st2 = np.array(['UNPAIRED'] * len(sts2[u2]))
        labels_st2[u2] = lab_st2

    for u1 in unit1_ids:
        u2 = unit_map12[u1]
        if u2 !=-1:
            lab_st1 = labels_st1[u1]
            lab_st2 = labels_st2[u2]
            mapped_st = sorting2.get_unit_spike_train(u2)
            # from gtst: TP, TPO, TPSO, FN, FNO, FNSO
            for sp_i, n_sp in enumerate(sts1[u1]):
                matches = (np.abs(mapped_st.astype(int)-n_sp)<=delta_tp//2)
                if np.sum(matches) > 0:
                    lab_st1[sp_i] = 'TP'
                    lab_st2[np.where(matches)[0][0]] = 'TP'
        else:
            lab_st1 = np.array(['FN'] * len(sts1[u1]))
            labels_st1[u1] = lab_st1

    # find CL-CLO-CLSO
    for u1 in unit1_ids:
        lab_st1 = labels_st1[u1]
        st1 = sts1[u1]
        for l_gt, lab in enumerate(lab_st1):
            if lab == 'UNPAIRED':
                for u2 in unit2_ids:
                    if u2 in unit_map12.values() and unit_map12[u1] != -1:
                        lab_st2 = labels_st2[u2]
                        n_sp = st1[l_gt]
                        mapped_st = sts2[u2]
                        matches = (np.abs(mapped_st.astype(int)-n_sp)<=delta_tp//2) 
                        if np.sum(matches) > 0:
                            lab_st1[l_gt] = 'CL_' + str(u1) + '_' + str(u2)
                            lab_st2[np.where(matches)[0][0]] = 'CL_' + str(u2) + '_' + str(u1)


    for u1 in unit1_ids:
        lab_st1 = labels_st1[u1]
        for l_gt, lab in enumerate(lab_st1):
            if lab == 'UNPAIRED':
                lab_st1[l_gt] = 'FN'

    for u2 in unit2_ids:
        lab_st2 = labels_st2[u2]
        for l_gt, lab in enumerate(lab_st2):
            if lab == 'UNPAIRED':
                lab_st2[l_gt] = 'FP'

    TOT_ST1 = sum([len(sts1[u1]) for u1 in unit1_ids])
    TOT_ST2 = sum([len(sts2[u2]) for u2 in unit2_ids])
    total_spikes = TOT_ST1 + TOT_ST2
    TP = sum([len(np.where('TP' == labels_st1[unit])[0]) for unit in unit1_ids])
    CL = sum([len([i for i, v in enumerate(labels_st1[u1]) if 'CL' in v]) for u1 in unit1_ids])
    FN = sum([len(np.where('FN' == labels_st1[u1])[0]) for u1 in unit1_ids])
    FP = sum([len(np.where('FP' == labels_st2[u2])[0]) for u2 in unit2_ids])
    
    counts = {'TP': TP, 'CL': CL, 'FN': FN, 'FP': FP, 'TOT': total_spikes, 'TOT_ST1': TOT_ST1,
                   'TOT_ST2': TOT_ST2}

    return counts, labels_st1, labels_st2
This count all counting score possible lieke:
      * TP: true positive
      * CL: classification error
      * FN: False negative
      * FP: False positive
      * TOT: 
      * TOT_ST1: 
      * TOT_ST2: 

    Parameters
    ----------
    sorting1: SortingExtractor instance
        The ground truth sorting.
    
    sorting2: SortingExtractor instance
        The tested sorting.
    
    delta_tp: int
        
    unit_map12: dict
        Dict of matching from sorting1 to sorting2.

    Output
    ----------
    
    counts: dict 
        A dict containing all coutning
    
    labels_st1: np.array of str
        Contain label for units of sorting 1
    
    labels_st2: np.array of str
        Contain label for units of sorting 2