code: def getCSD (lfps,sampr,minf=0.05,maxf=300,norm=True,vaknin=False,spacing=1.0):
    
    datband = getbandpass(lfps,sampr,minf,maxf)
    if datband.shape[0] > datband.shape[1]: # take CSD along smaller dimension
      ax = 1
    else:
      ax = 0
    # can change default to run Vaknin on bandpass filtered LFPs before calculating CSD, that
    # way would have same number of channels in CSD and LFP (but not critical, and would take more RAM);
    if vaknin: datband = Vaknin(datband)
    if norm: removemean(datband,ax=ax)
    # NB: when drawing CSD make sure that negative values (depolarizing intracellular current) drawn in red,
    # and positive values (hyperpolarizing intracellular current) drawn in blue
    CSD = -numpy.diff(datband,n=2,axis=ax) / spacing**2 # now each column (or row) is an electrode -- CSD along electrodes
    return CSD
docs: get current source density approximation using set of local field potentials with equidistant spacing
     first performs a lowpass filter
     lfps is a list or numpy array of LFPs arranged spatially by column
     spacing is in microns