Lawyers for Boy B wanted to introduce evidence from a clinical psychologist that the boy was suffering from post traumatic stress disorder after witnessing the assault on Ana Kriégel, and that there was an explanation for his lies.
It also emerged that the boy gave the psychologist further details of the attack on Ana that he had not disclosed to gardaí.
After hearing the psychologist's evidence, in the absence of the jury, Mr Justice Paul McDermott ruled it was not admissible.
He said it was for the jury to decide why the boy lied.
Boy A and Boy B guilty of murdering Ana Kriégel
Evidence gave brief glimpse of Ana, a 'unique' girl 'full of fun'
The 'overwhelming' forensic case against Boy A
Hours of garda interviews that revealed Boy B's devious lies
Watch: The route taken to Glenwood House
Defence counsel Damien Colgan told the court he wanted to introduce evidence from clinical psychologist Dr Colm Humphries to inform the jury about why his client had "certain reactions".
The gardaí may believe he told lies, Mr Colgan said, but there was an explanation.
Dr Humphries could assist the jury as to why Boy B reacted in the way he did, and how trauma would affect a young person like him.
The doctor told the court he met Boy B seven times over three weeks. He had not reviewed the DVDs of the boy's 16 hours of interviews with gardaí before completing his report, due to a lack of time.
But he said he had watched them before coming to give evidence, although he had not critically analysed them.
The doctor described Boy B as an apparently articulate, "well able guy" who was brighter than most people his age. But he said the boy was very socially naive and "didn't seem to know when to stay quiet".
The doctor said he had a very "concrete" way of describing things and he suggested there might be a language difficulty in the way he communicated. He said the boy preferred the company of younger children as they were "less demanding".
He also said the boy was "incredibly impulsive".
Dr Humphries said when recalling the events around Ana's death, the boy's language became "avoidant" in style, "disconnected and unclear". His way of holding his body went from ease to discomfort and he appeared disconnected as if elsewhere.
The doctor said he was exhibiting behaviour frequently seen in symptoms of post traumatic stress disorder.
The doctor said that children aged between 11 and 13 lied a lot, in order to get out of situations and sometimes, they couldn't get out of the lie.
He said Boy B didn't have a habit of seeking help.
And he urged the court to consider the boy's developmental age as an explanation for why he lied. He said the boy was suffering from "post traumatic reactivity" in the aftermath of the incident and was absolutely gripped by terror and trauma.
Looking at the garda interviews, the doctor said he considered Boy B had shut down and withdrawn into himself and hadn't made much sense at all of what was happening during those "very high intensity verbal situations".
The doctor remarked that the boy's current sexuality and feelings were "quite stunted". He said the boy had been "excited" that Boy A and Ana were "going snogging", as he thought.
But now when something was pleasurable sexually, the boy felt bad, because it reminded him of what had happened. He said the boy's mood was down, his sleep was disturbed and he spent much of his time "trying to avoid".
Dr Humphries said Boy B had told him he didn't want to be Boy A's friend, that he was afraid of him and needed to do what Boy A said. He also said Boy A gave Boy B "kudos" as he was different and doing things with Boy A made him a bigger presence.
The doctor said the boy's first experience of confinement was when he was detained after being arrested for murder. He was the only child ever to request Lego in the detention centre.
The boy knew he could end up in jail, Dr Humphries said, and that "terrified him". He had a "very naive belief" that the story would get him through.
Overall, Dr Humphries said the boy met the criteria for post traumatic stress disorder.
He said the boy had come up with a series of explanations not intended as lies but intended to give an account showing he had no part in what happened while also avoiding the memory of what had occurred.
The court heard the boy had given a different account to the doctor in his meetings with him earlier this year to the version of events he had described to the gardaí as "the truth" in July 2018.
In the new account he described Ana gasping and struggling before "everything stopped".
He described seeing her clothes being ripped and seeing Boy A stand up with his pants open at the crotch.
The doctor said he had found no evidence of the boy having knowledge of a plan for murder.
He claimed very few people murdered others randomly and he found no association between Boy A and Ana to explain murder. He also said he found no signs of a personality disorder or of psychopathy and no overt interest in violence.
He said he discussed the "satanist club" the boy had referred to in a copy book to be sure nothing sinister was going on there. He said the boy had been appalled by his questions and couldn't believe people would believe in "demonic presences and such things".
Dr Humphries was vigorously cross-examined by prosecution counsel, Brendan Grehan, who suggested the doctor had not engaged with the facts of what happened in the boy's interviews with gardaí.
He suggested the doctor had put forward an innocent explanation for the boy's lies.
But there appeared to be no consideration of the possibility that the boy might have "set out on a strategy of lying" in order to avoid being brought to account for doing a bad thing.
The judge ruled out his proposed evidence out in its entirety.
He said the account given by the boy to the doctor, interspersed with comments from the doctor, such as "this is honest" could not be allowed to be given in evidence.
It was the jury's function to assess the lies the prosecution relied on he said. The boy had given the gardai reasons why he had told lies, and had maintained those reasons.
Mr Justice McDermott said the jurors had all experienced teenage years, some may have children and most would have come into contact with teenagers. This common life experience did not need to be the subject of an expert report by a psychologist.
He said the differences between what the boy told gardaí and what he told the psychologist, did not appear to have been explored with him.
Alternative options to the boy's truthfulness, did not appear to have been rigorously explored and there was no critical analysis of the DVDs of the garda interviews.
The doctor's testimony that Boy B was likely to be telling the truth was not admissible he said. And he didn't accept the jury required a psychologist's report to understand that a 13- year-old could be shocked by witnessing a murder.
There were many reasons why people lied, he said, and it was for the jury to assess the boy's explanations based on their human experience.