Relation between metal electronic structure and morphology of metal compounds inside carbon nanotubes