SALEM, Mass. -- A teenage student whose trial in the murder of his teacher begins this week allegedly said "I became the teacher" to investigators after the 2013 slaying at his Massachusetts high school.

Danvers High School teacher Colleen Ritzer is seen in this undated picture provided by Ritzer's family. AP Photo/Courtesy of Dale Webster via the Lawrence Eagle-Tribune

However, prosecutors won't be allowed to tell the jury about the confession Philip Chism, then 14, allegedly gave to Danvers police. Judge David Lowy ruled that Chism did not fully understand his constitutional rights before he spoke to them.

In the videotaped interview after the attack, Chism told police that teacher Colleen Ritzer provoked the attack with a "trigger" word, which he would not disclose.

"After she insulted me, that's when I became the teacher," Chism said, according to a description Lowy gave in his written ruling.

Get Breaking News Delivered to Your Inbox

Jury selection in the case is scheduled to begin Wednesday in Essex Superior Court in Salem.

The day of the October, 2013 murder, Ritzer had asked Chism, on of her 9th-grade algebra students, to stay after school. Hours later, the body of the popular 24-year-old teacher was found in nearby woods, partly covered by leaves. Authorities say she had been raped and her throat had been slit with a box cutter. Near her body was a note reading, "I hate you all."

Chism was charged in her killing, shocking students and teachers who knew Ritzer as a bubbly, enthusiastic teacher and Chism as a quiet boy and standout soccer player who had recently moved to Massachusetts from Tennessee.

Two years later, Chism is headed to trial as an adult on rape, robbery and murder charges.

Chism's lawyers plan to use a mental health defense, although they have not revealed specifics. His mother told police her son had been under stress following her divorce from his father and their move from Clarksville, Tennessee, to Danvers, a town of 26,000 about 25 miles north of Boston.

A student who was in Ritzer's class with Chism said he was drawing in a notebook instead of taking notes on Oct. 22, 2013.

"She came over and said, 'I didn't know you draw,' and he said, 'yes.' Then later on, she said, 'Can you stay after with me?,'" student Rania Rhaddaoui said, two days after Ritzer's body was found.

Another student who was in the classroom after school that day said she heard Ritzer and Chism talking. The student, whose name was blocked out in court documents, told police that when Ritzer mentioned Tennessee, Chism appeared "visibly upset." When Ritzer noticed his reaction, she changed the subject, but the student said Chism then began talking to himself.

Chism's lawyers have retained Dr. Richard Dudley Jr., a well-known forensic psychiatrist, to testify as an expert. Dudley has testified for a collection of high-profile defendants, including Joshua Komisarjevsky, one of two men convicted in the 2007 murders of Connecticut woman Jennifer Hawke-Petit and her two daughters; Brian Nichols, the Georgia man who killed a judge and three other people after escaping during his 2005 rape trial; and Colin Ferguson, the Long Island railroad shooter who killed six people and wounded 19 others in 1993.

Insanity defenses rarely succeed in Massachusetts, but some legal observers say Chism's youth might make some jurors more willing to consider a mental health defense.

"I would really think that youth is going to be a huge factor. Part of the argument would be that Chism couldn't control whatever disease or defect he had," said Daniel Medwed, a law professor at Northeastern University.

"I assume the defense will tie it into research on adolescent brain development, in particular, adolescents have a difficult time calculating the future and having a sense of the ramifications on their future lives."

Prosecutors are expected to show the jury school surveillance video in which they say Chism is seen following Ritzer into a school bathroom, wearing gloves and a hood, then walking out of the bathroom alone 12 minutes later.

The video also shows Chism pulling a recycling barrel through the school and outside, according to search warrant documents filed in court. The barrel was found near Ritzer's body. Authorities said she was sexually assaulted twice.

Chism was found hours later, walking along Route 1 in neighboring Topsfield. Police there found a box cutter with blood on it inside Chism's backpack. During a pretrial hearing, an officer testified that when Chism was asked whose blood it was, he replied, "It's the girl's."

Chism also had Ritzer's identification, credit cards and a pair of women's underwear in his backpack.

Prosecutors are expected to present that evidence at trial, along with some statements Chism made to Topsfield police, but not his taped confession at the Danvers police station.