def conn_links(nodes, links, node_idx):
    """
    Returns the first and last pixels of links connected to node_idx.
    """
    
    link_ids = nodes['conn'][nodes['idx'].index(node_idx)]
    link_pix = []
    for l in link_ids:
        link_pix.extend([links['idx'][l][-1], links['idx'][l][0]])
        
    return link_pix