'Read a segment of data from a file.'

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

    stop -= 1
    offset = 0
    with _fiff_get_fid(self._filenames[fi]) as fid:
        for this in self._raw_extras[fi]:
            if (this['last'] >= start):
                if ((stop > this['last']) and (start < this['first'])):
                    first_pick = 0
                    last_pick = this['nsamp']
                    logger.debug('W')
                elif (start >= this['first']):
                    first_pick = (start - this['first'])
                    if (stop <= this['last']):
                        last_pick = ((this['nsamp'] + stop) - this['last'])
                        logger.debug('M')
                    else:
                        last_pick = this['nsamp']
                        logger.debug('E')
                else:
                    first_pick = 0
                    last_pick = ((stop - this['first']) + 1)
                    logger.debug('B')
                picksamp = (last_pick - first_pick)
                if (picksamp > 0):
                    if (this['ent'] is not None):
                        one = read_tag(fid, this['ent'].pos, shape=(this['nsamp'], self.info['nchan']), rlims=(first_pick, last_pick)).data
                        one.shape = (picksamp, self.info['nchan'])
                        _mult_cal_one(data[:, offset:(offset + picksamp)], one.T, idx, cals, mult)
                    offset += picksamp
            if (this['last'] >= stop):
                break
