Good way to detect pulse with known width with background noise?
For peak detection a nice method is the following: apply a maximal filter to the data and find the places where the filtered data equals to the original one.

A maximal filter is simply sliding through the data and selecting the maximal element from the sliding window. Formally:

$$g_w[x] = \max\left(f[x-w], f[x-w+1], \dots , f[x+w-1], f[x+w]\right)$$

where $f[x]$ is the original data, $w$ is the half of the window size and $g_w[x]$ is the filtered data. Selecting places where $g_w[x] = f[x]$ are either the local maxima of $f$ or plateaus of local maxima. Obviously we don't want to have plateaus, a single point per peak would be desirable.

The first trick we can do is to apply a minimal filter to the data, select the local minima, then choose places where we detected local maximum (based on the maximal filter) but not a local minimum. This will eliminate long plateaus.

The other thing we can do is to select 'up edges' so places where a non local maximum is followed by a maximum.

To make it clear I generated numeric data from the image you presented and wrote a short code. It uses two constants, one is the window size, the other is the minimum jump we require from a peak. 



import numpy as np
from matplotlib import pyplot as plt
from skimage import feature
from scipy.ndimage.filters import maximum_filter

# put your data here
#data = np.array([0, 79, 75, 69, 69, 7, ...])

filter_win_size = 12
peak_intensity_threshold = 10

max_data = maximum_filter(data, filter_win_size)
min_data = -maximum_filter(-data, filter_win_size)

# select places where we detect maximum but not minimum -&gt; we dont want long plateaus
peak_mask = np.logical_and(max_data == data, min_data != data)
# select peaks where we have enough elevation
peak_mask = np.logical_and(peak_mask, max_data - min_data &gt; peak_intensity_threshold)
# a trick to convert True to 1, False to -1
peak_mask = peak_mask * 2 - 1
# select only the up edges to eliminate multiple maximas in a single peak
peak_mask = np.correlate(peak_mask, [-1, 1], mode='same') == 2

max_places = np.where(peak_mask)[0]

fig, ax = plt.subplots()
r = range(data.shape[0])
ax.plot(r, data, 'k')
ax.plot(max_places, data[max_places], 'xr')
ax.grid()
ax.axis((0, 409, 0, 130))
plt.show()