Creates a pymatgen PhononBandStructure object from the dictionary
    extracted by the band.yaml file produced by phonopy. The labels
    will be extracted from the dictionary, if present. If the 'eigenvector'
    key is found the eigendisplacements will be calculated according to the 
    formula::
        
        exp(2*pi*i*(frac_coords \\dot q) / sqrt(mass) * v
    
    and added to the object.

    Args:
        bands_dict: the dictionary extracted from the band.yaml file
        has_nac: True if the data have been obtained with the option
            --nac option. Default False.
        labels_dict: dict that links a qpoint in frac coords to a label.
            Its value will replace the data contained in the band.yaml.

def get_ph_bs_symm_line_from_dict(bands_dict, has_nac=False, labels_dict=None):
    """
    Creates a pymatgen PhononBandStructure object from the dictionary
    extracted by the band.yaml file produced by phonopy. The labels
    will be extracted from the dictionary, if present. If the 'eigenvector'
    key is found the eigendisplacements will be calculated according to the 
    formula::
        
        exp(2*pi*i*(frac_coords \\dot q) / sqrt(mass) * v
    
    and added to the object.

    Args:
        bands_dict: the dictionary extracted from the band.yaml file
        has_nac: True if the data have been obtained with the option
            --nac option. Default False.
        labels_dict: dict that links a qpoint in frac coords to a label.
            Its value will replace the data contained in the band.yaml.
    """

    structure = get_structure_from_dict(bands_dict)

    qpts = []
    frequencies = []
    eigendisplacements = []
    phonopy_labels_dict = {}
    for p in bands_dict['phonon']:
        q = p['q-position']
        qpts.append(q)
        bands = []
        eig_q = []
        for b in p['band']:
            bands.append(b['frequency'])
            if 'eigenvector' in b:
                eig_b = []
                for i, eig_a in enumerate(b['eigenvector']):
                    v = np.zeros(3, np.complex)
                    for x in range(3):
                        v[x] = eig_a[x][0] + eig_a[x][1]*1j
                    eig_b.append(eigvec_to_eigdispl(
                        v, q, structure[i].frac_coords,
                        structure.site_properties['phonopy_masses'][i]))
                eig_q.append(eig_b)
        frequencies.append(bands)
        if 'label' in p:
            phonopy_labels_dict[p['label']] = p['q-position']
        if eig_q:
            eigendisplacements.append(eig_q)

    qpts = np.array(qpts)
    # transpose to match the convention in PhononBandStructure
    frequencies = np.transpose(frequencies)
    if eigendisplacements:
        eigendisplacements = np.transpose(eigendisplacements, (1, 0, 2, 3))

    rec_latt = Lattice(bands_dict['reciprocal_lattice'])

    labels_dict = labels_dict or phonopy_labels_dict

    ph_bs = PhononBandStructureSymmLine(
        qpts, frequencies, rec_latt, has_nac=has_nac, labels_dict=labels_dict,
        structure=structure, eigendisplacements=eigendisplacements)

    return ph_bs