Ugandan activist and academic Stella Nyanzi has been sentenced to 18 months in prison after she was found guilty of cyber harassment for a Facebook post that insulted the late mother of President Yoweri Museveni.

She attended Friday's sentencing via video link, against her will, and exposed her breasts in protest.

Activists condemned the court's decision, saying that it goes against Uganda's obligation to allow freedom of expression.

Nyanzi's conviction relates to a post she published on Facebook in September 2018, in which she made several references to the president's late mother's private parts and said she wished that she had died at birth.

She was facing two charges of cyber harassment and offensive communication, but was not found guilty of the latter.

On Thursday, after the guilty verdict was read out, Nyanzi responded with a passionate speech, accompanied by cheers from her supporters and other activists.

She later said she would have loved to have been found guilty of offensive communication because she had indeed planned to offend the president.

Nyanzi has previously been arrested for another Facebook post, in which she referred to the president as a "pair of buttocks". She is still on trial in that case.

Nyanzi is an accomplished social researcher and academic, and, before her troubles began, was a lecturer at the country's oldest public university, Makerere.