def create_rep(num2name, name2num, crefs, lrefs, grefs):
    """
    create a human readable representation of the referencing
    """
    all_defined_check(num2name, crefs)
    if DEBUG:
        print_refs(lrefs, grefs)
    chnames = []
    for num in sorted(num2name.keys()):
        chnames += num2name[num]

    out_str = []
    for name in chnames:
        try:
            chan = name2num[name]
        except KeyError:
            print('Processing {}, but no channel number was '
                  'assigned. Check results carefully!'.format(name))
            continue
        ch_board, ch_board_num = chan_to_board_num(chan)

        local_ref_num = crefs[chan]  # gives the local ref number
        # this is now a local number, so it's in 0..7
        maybe_global = False

        if local_ref_num in grefs:
            ref_board = grefs[local_ref_num]
            if ref_board != ch_board:
                maybe_global = True
            # here, I have to check whether the
            # driving channel is the same number on my local board
            # i.e., if b1_15 is b1_ref_2 and b1_ref_2 is gd
            # and b3_7 has ref_2, then it's global only if b3_15 is b3_ref_2

        else:
            ref_board = ch_board

        ref_num = lrefs[(ref_board, local_ref_num)]
        ref_num2 = lrefs[(ch_board, local_ref_num)]
        add_str = ''
        if maybe_global:
            # print('Special case, global ref {}, local ref {}'
            #     .format(ref_num, lrefs[(ch_board, local_ref_num)]))
            if ref_num2 != 38:
                add_str = ' ?'
                if ref_num != ref_num2:
                    # print(ref_num, lrefs[(ch_board, local_ref_num)])
                    ref_board = ch_board
                    ref_num = ref_num2
                else:
                    add_str = ' ???'
                    ref_board = ch_board
                    ref_num = ref_num2
                    pass
                # print('Using channel 38')

        if ref_board == ch_board:
            board_str = 'local{}'.format(add_str)
        else:
            board_str = 'global{}'.format(add_str)

        if ref_num > 31:
            # these are the reference wires
            if ref_num == 38:
                ref_name = 'board {} Unknown Ground'.format(ref_board)
            elif ref_num == 36:
                ref_name = 'board {} Patient Ground'.format(ref_board)
            else:
                tnum = (ref_num - 32) * 8
                refchan = board_num_to_chan(ref_board, tnum)
                if refchan in num2name:
                    pref_name = num2name[refchan]
                    idx = 0
                    if len(pref_name) == 2:
                        if pref_name[0][0] == 'u':
                            idx = 1
                    ref_name = pref_name[idx][:-1] + ' reference wire'

                else:
                    ref_name = 'board {} head stage {} reference wire'.\
                               format(ref_board, ref_num - 32)
        else:
            global_num = board_num_to_chan(ref_board, ref_num)
            chlist = num2name[global_num]
            if len(chlist):
                ref_name = chlist[0]
            else:
                ref_name = 'UNDEF'

        if name == ref_name:
            board_str += ' ZERO'
        out_str.append(('{:03d}'.format(chan), name, ref_name, board_str))
    return out_str