def _rdsignal(fp, file_size, header_size, n_sig, bit_width, is_signed, cut_end):
    """
    Read the signal

    Parameters
    ----------
    cut_end : bool, optional
        If True, enables reading the end of files which appear to terminate
        with the incorrect number of samples (ie. sample not present for all channels),
        by checking and skipping the reading the end of such files.
        Checking this option makes reading slower.
    """
    # Cannot initially figure out signal length because there
    # are escape sequences.
    fp.seek(header_size)
    signal_size = file_size - header_size
    byte_width = int(bit_width / 8)
    # numpy dtype
    dtype = str(byte_width)
    if is_signed:
        dtype = 'i' + dtype
    else:
        dtype = 'u' + dtype
    # big endian
    dtype = '>' + dtype
    # The maximum possible samples given the file size
    # All channels must be present
    max_samples = int(signal_size / byte_width)
    max_samples = max_samples - max_samples % n_sig
    # Output information
    signal = np.empty(max_samples, dtype=dtype)
    markers = []
    triggers = []
    # Number of (total) samples read
    sample_num = 0

    # Read one sample for all channels at a time
    if cut_end:
        stop_byte = file_size - n_sig * byte_width + 1
        while fp.tell() < stop_byte:
            chunk = fp.read(2)
            sample_num = _get_sample(fp, chunk, n_sig, dtype, signal, markers, triggers, sample_num)
    else:
        while True:
            chunk = fp.read(2)
            if not chunk:
                break
            sample_num = _get_sample(fp, chunk, n_sig, dtype, signal, markers, triggers, sample_num)

    # No more bytes to read. Reshape output arguments.
    signal = signal[:sample_num]
    signal = signal.reshape((-1, n_sig))
    markers = np.array(markers, dtype='int')
    triggers = np.array(triggers, dtype='int')
    return signal, markers, triggers
def _rdsignal ( fp , file_size , header_size , n_sig , bit_width , is_signed , cut_end ) : fp . seek ( header_size ) signal_size = file_size - header_size byte_width = int ( bit_width / 8 ) dtype = str ( byte_width ) if is_signed : dtype = 'i' + dtype else : dtype = 'u' + dtype dtype = '>' + dtype max_samples = int ( signal_size / byte_width ) max_samples = max_samples - max_samples % n_sig signal = np . empty ( max_samples , dtype = dtype ) markers = [ ] triggers = [ ] sample_num = 0 if cut_end : stop_byte = file_size - n_sig * byte_width + 1 while fp . tell ( ) < stop_byte : chunk = fp . read ( 2 ) sample_num = _get_sample ( fp , chunk , n_sig , dtype , signal , markers , triggers , sample_num ) else : while True : chunk = fp . read ( 2 ) if not chunk : break sample_num = _get_sample ( fp , chunk , n_sig , dtype , signal , markers , triggers , sample_num ) signal = signal [ : sample_num ] signal = signal . reshape ( ( - 1 , n_sig ) ) markers = np . array ( markers , dtype = 'int' ) triggers = np . array ( triggers , dtype = 'int' ) return signal , markers , triggers
Read the signal

    Parameters
    ----------
    cut_end : bool, optional
        If True, enables reading the end of files which appear to terminate
        with the incorrect number of samples (ie. sample not present for all channels),
        by checking and skipping the reading the end of such files.
        Checking this option makes reading slower.