By Lori Grannis

MISSOULA, Montana (Reuters) - A Montana man who shot and killed a German exchange student last month is set to be arraigned before a district court on Wednesday morning.

Missoula homeowner Markus Kaarma, 29, is charged with deliberate homicide in last month's slaying of 17-year-old Diren Dede of Hamburg in a high-profile case that is expected to test Montana's version of the "castle doctrine" self-defense law.

Defense attorney Paul Ryan has said Kaarma will plead not guilty by invoking a defense in line with Montana's version of the 'castle doctrine,' which allows homeowners to exercise force if there is reasonable belief of impending harm or a threat to life.

According to court documents, Dede was visiting Montana for a single school term and staying with a host family two houses away. A witness said he entered Kaarma's open garage as part of a popular local high school prank called "garage hopping," and was unarmed.

Kaarma, a former U.S. Forest Service firefighter whose house had recently been burglarized, was alerted to Dede's presence by motion sensors and a video monitor installed after the burglaries.

Prosecutors say he walked outside and fired a shotgun into his darkened garage, killing Dede.

Attorney Ryan said last week that a 2009 amendment to the law shifts the burden of proof from homeowners to prosecutors as to whether a homeowner was in fear for his life when exercising lethal force.

(Editing by Chris Michaud)

[A smoking 12 bore shotgun having ejected spent a cartridge by Max Earey via Shutterstock]