'Read a chunk of raw data.'

@verbose
def _read_segment_file(self, data, idx, fi, start, stop, cals, mult):

    nchan = self._raw_extras[fi]['nchan']
    data_left = ((stop - start) * nchan)
    n_sens = self._raw_extras[fi]['n_sens']
    sensor_gain = self._raw_extras[fi]['sensor_gain'].copy()
    sensor_gain[:n_sens] = (sensor_gain[:n_sens] / self._raw_extras[fi]['amp_gain'])
    conv_factor = np.array(((KIT.VOLTAGE_RANGE / self._raw_extras[fi]['DYNAMIC_RANGE']) * sensor_gain))
    n_bytes = 2
    blk_size = min(data_left, (((100000000 // n_bytes) // nchan) * nchan))
    with open(self._filenames[fi], 'rb', buffering=0) as fid:
        data_offset = KIT.RAW_OFFSET
        fid.seek(data_offset)
        data_offset = unpack('i', fid.read(KIT.INT))[0]
        pointer = ((start * nchan) * KIT.SHORT)
        fid.seek((data_offset + pointer))
        stim = self._raw_extras[fi]['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='h', 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[:, np.newaxis]
            if (stim is not None):
                params = self._raw_extras[fi]
                stim_ch = _make_stim_channel(block[stim, :], params['slope'], params['stimthresh'], params['stim_code'], stim)
                block = np.vstack((block, stim_ch))
            _mult_cal_one(data_view, block, idx, None, mult)
