Image copyright AP Image caption Recent attacks, including the mass murder in Nice, have blurred the lines between individual and group acts of terror

With four attacks in southern Germany coming shortly after the mass murder of 84 people in Nice, counter-terrorism officials are struggling to detect a common thread. Is there a single, defining feature to these attacks that could offer clues on how to prevent more of them from happening?

On the surface, the answer would appear to be no. The truck driver in Nice was known to have had psychiatric problems and violent outbursts, yet he had a clear enough head to keep his plans hidden for months.

The mass murder he went on to commit was claimed by the so-called Islamic State (IS). As was the attack by the axe-wielding young Afghan who struck passengers on a German train and Sunday night's suicide bombing at a music festival in Ansbach.

Yet initial suspicions of an IS link to last Friday's shooting rampage in a Munich shopping mall have been replaced by something closer to an individual, non-political grievance by the perpetrator. His killing spree bears a striking similarity to recent gun rampages by disaffected teenagers at US college campuses.

Likewise, investigators have concluded that the killing of a Polish woman by a Syrian refugee in Reutlingen is not connected to terrorism.

'The lock snaps open'

Peter Aylward, who spent much of his career as a detective in the Metropolitan Police, then later as a forensic psychoanalyst at Broadmoor Psychiatric Hospital, says it is possible to find a common thread in the past history of murderers. He believes the clues are all in their dysfunctional backgrounds.

"It is a psychiatric problem," he says, "and such planning [as the Nice or Munich attacks] indicates a disordered personality. With such premeditation there is a desire to enact a form of revenge, and with such intent on causing major terror."

Image caption David Ali Sonboly, who carried out the attack in Munich, was born in city, to Iranian parents

So why do we only see such a relatively small number of killing sprees, compared with the large number of people who suffer from psychiatric disorders and never go on to harm anyone?

"With a detailed look at the history of those perpetrators," says Mr Aylward, "what we see is a sort of combination-lock of numbers that if arranged in the right sequence then the lock snaps open and a murderous attack takes place."

He says far more work needs to be done to identify the signs leading up to such events before they happen.

'Broader cause'

All of this poses a major problem for US and European governments and intelligence agencies trying to stop the next mass killing. Mental health is not usually in their remit.

At a recent meeting of Western counter-terrorism officers in Washington, it was concluded that agencies well-practiced in confronting ideological organisations like IS were ill-equipped to deal with lone individuals bearing murderous personal grievances.

The challenge becomes even harder when a troubled individual with mental problems is cynically recruited by a terrorist organisation, thus blurring the lines between the two.

Gen Michael Hayden, a former director of the CIA and NSA, say the phenomenon "allows the truly troubled and the truly dangerous to reach for a broader cause that gives meaning to their alienation".

The concept of terrorist organisations preying on disturbed people to further their aims is not new. But given the vast scale of recent refugee movements and the enduring conflicts in Syria, Iraq and Afghanistan, it is a pattern likely to be repeated. All the more reason, says Mr Aylward, to help protect those most vulnerable to being exploited.

Seven deadly days

A week of bloody attacks has frayed nerves in Germany, which led the way in accepting asylum seekers from Syria. To date, only the first has been linked to a militant group:

Image copyright Getty Images

18 July: An axe-wielding teenage asylum seeker from Afghanistan is shot dead after injuring five people in an attack on a train. IS claims the attack, releasing a video recorded by the attacker before the incident

22 July: A German teenager of Iranian extraction goes on a shooting rampage in the Bavarian state capital, Munich, killing nine people, most of them migrants, before shooting himself. He is said to have been obsessed with school shootings

24 July: A Syrian asylum seeker is arrested in the town of Reutlingen, Baden-Wuerttemberg, after allegedly killing a Polish woman with a machete and injuring two other people. Police suggest it was probably a "crime of passion"

24 July: A failed Syrian asylum seeker blows himself up outside a music festival in the small Bavarian town of Ansbach, injuring 12 other people. Motive not immediately clear

German media on the attacks