I am facing same problem with CASTEP. I think you have to use OptaDOS for post-processing the output codes of band structure. But if you are using Material Studio platform for running CASTEP then I am still unaware of the solution. please see the links for details: https://docs.matador.science/en/latest/tutorials/run3_spectral.html