def export_freq_band(xfreq, bands, filename):
    heading_row_1 = ['Segment index',
                   'Start time',
                   'End time',
                   'Duration',
                   'Stitches',
                   'Stage',
                   'Cycle',
                   'Event type',
                   'Channel',
                   ]
    spacer = [''] * (len(heading_row_1) - 1)
    band_hdr = [str(b1) + '-' + str(b2) for b1, b2 in bands]
    xband = xfreq.copy()
    for seg in xband:
        bandlist = []
        for i, b in enumerate(bands):
            pwr, _ = band_power(seg['data'], b)
            bandlist.append(pwr)
        seg['band'] = bandlist
    as_matrix = asarray([
            [x['band'][y][chan] for y in range(len(x['band']))] \
            for x in xband for chan in x['band'][0].keys()])
    desc = get_descriptives(as_matrix)
    with open(filename, 'w', newline='') as f:
        lg.info('Writing to ' + str(filename))
        csv_file = writer(f)
        csv_file.writerow(['Wonambi v{}'.format(__version__)])
        csv_file.writerow(heading_row_1 + band_hdr)
        csv_file.writerow(['Mean'] + spacer + list(desc['mean']))
        csv_file.writerow(['SD'] + spacer + list(desc['sd']))
        csv_file.writerow(['Mean of ln'] + spacer + list(desc['mean_log']))
        csv_file.writerow(['SD of ln'] + spacer + list(desc['sd_log']))
        idx = 0
        for seg in xband:
            for chan in seg['band'][0].keys():
                idx += 1
                cyc = None
                if seg['cycle'] is not None:
                    cyc = seg['cycle'][2]
                data_row = list(
                        [seg['band'][x][chan] for x in range(
                                len(seg['band']))])
                csv_file.writerow([idx,
                                   seg['start'],
                                   seg['end'],
                                   seg['duration'],
                                   seg['n_stitch'],
                                   seg['stage'],
                                   cyc,
                                   seg['name'],
                                   chan,
                                   ] + data_row)