if exp.has_pattern(phns):
     s = exp.get_s(path_idx)
     E,edge_feature_row_breaks,\
         edge_orientations= exp.get_edgemap_no_threshold(s)
     phn_times = exp.get_phn_times(path_idx)
     # get the backgrounds for all detection spots
     P,C=exp.get_detection_scores(E,mean_template,
                                  bg_len, 
                                  mean_background,
                                  edge_feature_row_breaks,
                                  edge_orientations)
     scores = P+C
     # select the object
     pattern_times = exp.get_pattern_times(E,phns,phn_times,s)
     # find the maxima
     scores_maxima = ps.get_maxima(scores,5)
     maxima_idx = np.arange(scores.shape[0])[scores_maxima]
     # see if we pick up the patterns 
     for i in xrange(len(pattern_times)):
         pattern_array =np.empty(scores.shape[0],dtype=bool)
         pattern_array[:]=False
         # consider something a detection if its within a third of the template length around the start of the pattern
         pattern_array[pattern_times[i][0]-template_length/3:pattern_times[i][0]+template_length/3] = True
         pattern_maxima = np.logical_and(scores_maxima,pattern_array)
         if pattern_maxima.any():
             true_pos_thresholds.append( np.max(scores[pattern_maxima]))
         else:
             # this was a false negative
             pattern_thresholds.append(-np.inf)
         # remove the maxima that are contained within the pattern radius
         # at end of for loop only maxima left will be related to false positives
     if t < bg_len:
         cur_bgd = mean_background
     else:
         cur_bgd = np.maximum(np.minimum(np.mean(E[:,t-bg_len:t],
                                                 axis=1),
                                         .4),
                              .05)
     E_segment = E[:,t:t+template_length].copy()
     _,edge_thresholds = esp.threshold_edgemap(E_segment,.30,edge_feature_row_breaks,abst_threshold=abst_threshold)
     esp.spread_edgemap(E_segment,edge_feature_row_breaks,edge_orientations,spread_length=spread_length)
     P,C = tt.score_template(template,cur_bgd,E_segment)
     score_vals_edge_thresholds.append((P+C,edge_thresholds))
 patterns = exp.get_patterns(E,phns,phn_times,s)
 bgds = exp.get_pattern_bgds(E,phns,phn_times,s,bg_len)
 # find the maxima
 scores_maxima = ps.get_maxima(scores,maxima_radius)
 maxima_idx = np.arange(scores.shape[0])[scores_maxima]
 # see if we pick up the patterns 
 for i in xrange(len(pattern_times)):
     esp.threshold_edgemap(patterns[i],.30,edge_feature_row_breaks,abst_threshold=abst_threshold)
     esp.spread_edgemap(patterns[i],edge_feature_row_breaks,edge_orientations,spread_length=3)
     esp.threshold_edgemap(bgds[i],.30,edge_feature_row_breaks,abst_threshold=abst_threshold)
     esp.spread_edgemap(bgds[i],edge_feature_row_breaks,edge_orientations,spread_length=spread_length)
     # compute background mean
     bgds[i] = np.mean(bgds[i],axis=1)
     # impose floor and ceiling constraints on values
     bgds[i] = np.maximum(np.minimum(bgds[i],.4),.05)
     registered_example = np.empty((template_height,template_length))
     et._register_template(patterns[i],registered_example,template_height,template_length)
     P_reg,C_reg = tt.score_template_background_section(mean_template,bgds[i],registered_example)        
     pattern_array =np.empty(scores.shape[0],dtype=bool)