'putData(D) -- writes samples that must be given as a NUMPY array,
samples x channels. The type of the samples (D) and the number of
channels must match the corresponding quantities in the FieldTrip
buffer.'

def putData(self, D):

    if ((not isinstance(D, numpy.ndarray)) or (len(D.shape) != 2)):
        raise ValueError('Data    must    be    given    as    a    NUMPY    array    (samples    x    channels)')
    nSamp = D.shape[0]
    nChan = D.shape[1]
    (dataType, dataBuf) = serialize(D)
    dataBufSize = len(dataBuf)
    request = struct.pack('HHI', VERSION, PUT_DAT, (16 + dataBufSize))
    dataDef = struct.pack('IIII', nChan, nSamp, dataType, dataBufSize)
    self.sendRaw(((request + dataDef) + dataBuf))
    (status, bufsize, resp_buf) = self.receiveResponse()
    if (status != PUT_OK):
        raise IOError('Samples    could    not    be    written.')
