def _read_segment_file(self, data, idx, fi, start, stop, cals, mult):
    'Read a chunk of raw data.'
    sqd = self._raw_extras[fi]
    nchan = sqd['nchan']
    data_left = ((stop - start) * nchan)
    conv_factor = sqd['conv_factor']
    n_bytes = sqd['dtype'].itemsize
    assert (n_bytes in (2, 4))
    blk_size = min(data_left, (((100000000 // n_bytes) // nchan) * nchan))
    with open(self._filenames[fi], 'rb', buffering=0) as fid:
        pointer = ((start * nchan) * n_bytes)
        fid.seek((sqd['dirs'][KIT.DIR_INDEX_RAW_DATA]['offset'] + pointer))
        stim = sqd['stim']
        for blk_start in (np.arange(0, data_left, blk_size) // nchan):
            blk_size = min(blk_size, (data_left - (blk_start * nchan)))
            block = np.fromfile(fid, dtype=sqd['dtype'], count=blk_size)
            block = block.reshape(nchan, (- 1), order='F').astype(float)
            blk_stop = (blk_start + block.shape[1])
            data_view = data[:, blk_start:blk_stop]
            block *= conv_factor
            if (stim is not None):
                stim_ch = _make_stim_channel(block[stim, :], sqd['slope'], sqd['stimthresh'], sqd['stim_code'], stim)
                block = np.vstack((block, stim_ch))
            _mult_cal_one(data_view, block, idx, cals, mult)
Read a chunk of raw data.
def _read_segment_file(self, data, idx, fi, start, stop, cals, mult):
    
    sqd = self._raw_extras[fi]
    nchan = sqd['nchan']
    data_left = ((stop - start) * nchan)
    conv_factor = sqd['conv_factor']
    n_bytes = sqd['dtype'].itemsize
    assert (n_bytes in (2, 4))
    blk_size = min(data_left, (((100000000 // n_bytes) // nchan) * nchan))
    with open(self._filenames[fi], 'rb', buffering=0) as fid:
        pointer = ((start * nchan) * n_bytes)
        fid.seek((sqd['dirs'][KIT.DIR_INDEX_RAW_DATA]['offset'] + pointer))
        stim = sqd['stim']
        for blk_start in (np.arange(0, data_left, blk_size) // nchan):
            blk_size = min(blk_size, (data_left - (blk_start * nchan)))
            block = np.fromfile(fid, dtype=sqd['dtype'], count=blk_size)
            block = block.reshape(nchan, (- 1), order='F').astype(float)
            blk_stop = (blk_start + block.shape[1])
            data_view = data[:, blk_start:blk_stop]
            block *= conv_factor
            if (stim is not None):
                stim_ch = _make_stim_channel(block[stim, :], sqd['slope'], sqd['stimthresh'], sqd['stim_code'], stim)
                block = np.vstack((block, stim_ch))
            _mult_cal_one(data_view, block, idx, cals, mult)