Yousif Badri, 29, is accused of being involved in conduct "with the intention of committing acts of terrorism".
He denies charges under the Terrorism Act at the High Court in Glasgow.
Mr Badri told the court: "I was arrested by police officers in Sainsbury's."
The accused said he was due to graduate on 5 July, 2013, but did not due to his arrest the month before.
The court heard that Mr Badri had wanted to be a doctor ever since he did work experience at a GP surgery.
When asked how he had been coping, Mr Badri said he tried to keep busy and added: "I try not to feel too dark about what's happening and see my friends."
He agreed that he had a wide circle of friends in Aberdeen across all communities.
He told defence QC Murdo Macleod: "I am interested in religion, politics, philosophy and polemics."
Asked about alleged terrorist articles found on his computer hard drive, Mr Badri said: "There are passages of the Koran that have been used to justify crimes and the only way to have a rebuttal of this is to read these articles and pull them apart."
The trial, before judge Lord Turnbull, continues.
A man accused of terrorism offences in Aberdeen has told a court he was arrested at a supermarket the day after sitting his finals for a medical degree.