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.

def getMeanVoltages(params, numunits=100,
                   filepattern=os.path.join('simulation_output_default',
                                            'voltages')):
    '''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.
    
    '''    
    data = {}
    
    #loop over network-populations
    for i, Y in enumerate(params.Y):
        if i % SIZE == RANK:
            #read in read data and assess units, up to numunits
            fname = glob.glob(filepattern+'*' + Y + '*')[0]
            print fname
            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 per cell voltages
            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 : {
                    'data' : dataslc[:, :, 0].mean(axis=0),
                    'std' : dataslc[:, :, 0].std(axis=0),
                    'sample' : dataslc[0, :, 0],
                    'tvec' : rawdata[slc, 1],
                    'numunits' : numunits,
                }
            })
            
    
    data = COMM.allgather(data)
    
    return {k: v for d in data for k, v in d.items()}