'**SUMMARY**
Do a sliding median filter with a window size equal to size.
**PARAMETERS**
* *sz* - the size of the median filter.
**RETURNS**
The linescan after being passed through the median filter.
The last index where the value occurs or None if none is found.
**EXAMPLE**
>>>> ls = img.getLineScan(x=10)
>>>> ls2 = ls.median(7)
>>>> plt.plot(ls)
>>>> plt.plot(ls2)
>>>> plt.show()'

def median(self, sz=5):

    if ((sz % 2) == 0):
        sz = (sz + 1)
    skip = int(np.floor((sz / 2)))
    out = self[0:skip]
    vsz = len(self)
    for idx in range(skip, (vsz - skip)):
        val = np.median(self[(idx - skip):(idx + skip)])
        out.append(val)
    for pt in self[((-1) * skip):]:
        out.append(pt)
    retVal = LineScan(out, image=self.image, pointLoc=self.pointLoc, pt1=self.pt1, pt2=self.pt2)
    retVal._update(self)
    return retVal
