At ten o'clock tonight, lights across the country will be turned off or dimmed for an hour to commemorate the day, 100 years ago, when it was feared "the lamps are going out all over Europe".

Recalling that terrible occasion, Lloyd George wrote that at the hour when Britain declared war on Germany, the striking of Big Ben "echoed in our ears like the hammer of destiny".

The toll of the Great War was obscene, Britain and its empire losing 908,371 men, and Scotland suffering a disproportionate number of deaths. Many died without recognition, and it was Rudyard Kipling who came up with the consoling epitaph for the nameless dead, "Known Unto God".

But as we reflect upon the nobility and sacrifice of those who fought in 1914-18, what of the soldiers whose names are only too clearly recorded, shot after being condemned as cowards? Until recently they were barely mentioned, the stigma of turning tail or refusing orders still a stain on their name. Only those with a fierce disdain for establishment views were sceptical about their disgrace, one such being Lewis Grassic Gibbon. His portrayal in Sunset Song of Ewan Tavendale, court-martialed for trying to get home to his wife and homeland when he was clearly deranged by battle, is a heart-breaking depiction of senseless - but not wholly unheroic - death.

In all, 306 British soldiers were executed for cowardice and desertion in the First World War. The effect such summary justice had upon the firing squad has been little discussed, but in such unenlightened and militaristic times there were many who thought anyone who abandoned their post deserved their fate. One army doctor wrote of a deserter, "I went to trial determined to give him no help, for I detest his type - I really hoped he would be shot."

Fortunately, not all medics were as callous. As war escalated, it was at Craiglockhart War Hospital in Edinburgh that shell shock was first properly treated, by the pioneering psychoanalyst and neurologist Dr W H R Rivers. The poet Robert Graves, who was gassed and badly wounded, suffered shell shock but was never hospitalised. He wrote that, long after the war, "the noise of a car back-firing would send me flat on my face". In 1916, the diffident, stammering, charismatic Rivers was sent to Craiglockhart where, Graves's friends told him, he diagnosed the men in his care "largely through a study of their dream life".

Rivers's radical approach was known as the "talking cure". Such was the buttoned-up culture of the time, it was viewed by some with deep suspicion. Among his most famous patients were Siegfried Sassoon and Wilfred Owen. That Rivers's job was to make such men fit again for the front was the terrible irony of his medical success. That this also enabled them to go on to compose some of the finest war poetry ever written would have been cold comfort.

Rivers's work revolutionised the understanding of post-traumatic stress disorder. Whatever its name, the treatment of soldiers driven insane by what they had endured in the trenches is awful to contemplate, and what their contemporaries viewed as cowardice would today be seen as severe mental illness, to be treated with compassion. That the 306 executed soldiers were finally given a symbolic pardon in 2006 is the least they are owed.

Even so, some persist in considering them guilty as charged, since they had broken the laws of their own time. In my view these hangers and floggers are as heartless as those who signed their death sentences. Of course, no-one doubts the armed forces have their share of chancers, cowards and criminals. But given the hellish conditions of trench warfare - more than 80,000 were diagnosed with shell shock - it is testimony to the troops' extraordinary stoicism that the number is not far higher.

To begrudge a pardon for so-called cowards on the grounds of anachronism is like saying that all those women burned at the stake before the law removed witchcraft from its books also deserved their fate. Just because something was deemed a capital crime does not mean it should have been. Thanks to Rivers and his patients, we now recognise that soldiers shot for cowardice and desertion were as much victims of war as those who fell under enemy fire.