Can I convert sprites to a texture 2D

Im trying to assign them in code and it doesn’t allow me to assign the sprite image to the brush.
Is there a way to assign a sprite to a brush through code.
Thanks for the help!
Dom