Diagonalizing the Hamiltonian, Transiesta, sisl

I have read the Hamiltonian matrix from a TSHS file, using sisl.
How could I extract a sub-hamiltonian corresponding to the basis functions on the molecular atoms for its diagonalization?

The discussion here https://github.com/zerothi/sisl/issues/129 has a solution.
In particular https://github.com/zerothi/sisl/issues/129#issuecomment-498601413 top lines has the solution to your problem.