def getMeanInpCurrents(params, numunits=100,
                       filepattern=os.path.join('simulation_output_default',
                                                'population_input_spikes*')):
    '''return a dict with the per population mean and std synaptic current,
    averaging over numcells recorded units from each population in the
    network
    
    Returned currents are in unit of nA.
    
    '''
    #convolution kernels
    x = np.arange(100) * params.dt
    kernel = np.exp(-x / params.model_params['tau_syn_ex'])


    #number of external inputs:
    K_bg = np.array(sum(params.K_bg, []))

    #compensate for DC CC connections if we're using that
    iDC =  K_bg * params.dc_amplitude * 1E-3 # unit ????
    
    data = {}
    
    #loop over network-populations
    for i, Y in enumerate(params.Y):
        if i % SIZE == RANK:
            #file to open
            fname = glob.glob(filepattern+'*' + Y + '*')[0]
            print fname
            #read in read data and assess units, up to numunits
            rawdata = np.array(helpers.read_gdf(fname))
            units = np.unique(rawdata[:, 0])
            if numunits > units.size:
                numcells = units.size
            else:
                numcells = numunits
            units = units[:numcells]
            
            #churn through data and extract the input currents per cell
            for j, unit in enumerate(units):
                slc = rawdata[:, 0] == unit
                #just the spikes:
                if j == 0:
                    dataslc = rawdata[slc, 2:]
                else:
                    dataslc = np.r_['0,3', dataslc, rawdata[slc, 2:]]
            
            #fix the datatype, it may be object
            dataslc = dataslc.astype(float)
                   
            #fill in data-structure
            data.update({
                Y : {
                    'E' : np.convolve(dataslc[:, :, 0].mean(axis=0),
                                      kernel, 'same')*1E-3 + float(iDC[i]),
                    'I' : np.convolve(dataslc[:, :, 1].mean(axis=0),
                                      kernel, 'same')*1E-3,
                    'tvec' : rawdata[slc, 1],
                    'numunits' : numunits,
                }
            })
    
    
    data = COMM.allgather(data)
    
    return {k: v for d in data for k, v in d.items()}