Skip to content
Snippets Groups Projects
Commit d56402b4 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Tweaks to FEAT model fitting

parent 52a63bd8
No related branches found
No related tags found
No related merge requests found
...@@ -309,6 +309,17 @@ class FEATImage(fslimage.Image): ...@@ -309,6 +309,17 @@ class FEATImage(fslimage.Image):
if self.__design is None: if self.__design is None:
raise RuntimeError('No design') raise RuntimeError('No design')
# Here we are basically trying to
# replicate the behaviour of tsplot.
# There are some differences though -
# by default, tsplot weights the
# data by Z statistics. We're not
# doing that here.
# If we are not plotting a full model fit,
# normalise the contrast vector to unit
# length. Why? Because that's what tsplot
# does.
if not fullmodel: if not fullmodel:
contrast = np.array(contrast) contrast = np.array(contrast)
contrast = contrast / np.sqrt((contrast ** 2).sum()) contrast = contrast / np.sqrt((contrast ** 2).sum())
...@@ -318,17 +329,21 @@ class FEATImage(fslimage.Image): ...@@ -318,17 +329,21 @@ class FEATImage(fslimage.Image):
if len(contrast) != numEVs: if len(contrast) != numEVs:
raise ValueError('Contrast is wrong length') raise ValueError('Contrast is wrong length')
X = self.__design.getDesign(xyz) X = self.__design.getDesign(xyz)
data = self[x, y, z, :] data = self[x, y, z, :]
modelfit = np.zeros(len(data)) modelfit = np.zeros(len(data))
for i in range(numEVs): for i in range(numEVs):
ev = X[:, i]
pe = self.getPE(i)[x, y, z] pe = self.getPE(i)[x, y, z]
modelfit += X[:, i] * pe * contrast[i] modelfit += ev * pe * contrast[i]
return modelfit + data.mean() # Make sure the full model fit
# has the same mean as the data
if fullmodel: return modelfit - modelfit.mean() + data.mean()
else: return modelfit
def partialFit(self, contrast, xyz, fullmodel=False): def partialFit(self, contrast, xyz, fullmodel=False):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment