Skip to content

Commit 98ccf0d

Browse files
Gilles86jdkent
authored andcommitted
Revise code according to suggestions @bthirion in issue nilearn#173
1 parent 9291be7 commit 98ccf0d

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

nistats/first_level_model.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import numpy as np
1919
import pandas as pd
2020
from nibabel import Nifti1Image
21+
from nibabel.onetime import setattr_on_read
2122

2223
from sklearn.base import (BaseEstimator,
2324
clone,
@@ -613,15 +614,15 @@ def get_voxelwise_model_attribute_(self, attribute, timeseries=True):
613614
else:
614615
return output
615616

616-
@property
617+
@setattr_on_read
617618
def residuals(self):
618619
return self.get_voxelwise_model_attribute_('resid')
619620

620-
@property
621+
@setattr_on_read
621622
def predicted(self):
622623
return self.get_voxelwise_model_attribute_('predicted')
623624

624-
@property
625+
@setattr_on_read
625626
def rsq(self):
626627
return self.get_voxelwise_model_attribute_('rsq', timeseries=False)
627628

nistats/regression.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,14 @@ def __init__(self, theta, Y, model, wY, wresid, cov=None, dispersion=1.,
278278
self.wresid = wresid
279279
self.wdesign = model.wdesign
280280

281-
@property
281+
@setattr_on_read
282282
def resid(self):
283283
"""
284284
Residuals from the fit.
285285
"""
286286
return self.Y - self.predicted
287287

288-
@property
288+
@setattr_on_read
289289
def norm_resid(self):
290290
"""
291291
Residuals, normalized to have unit length.
@@ -305,7 +305,7 @@ def norm_resid(self):
305305
"""
306306
return self.resid * positive_reciprocal(np.sqrt(self.dispersion))
307307

308-
@property
308+
@setattr_on_read
309309
def predicted(self):
310310
""" Return linear predictor values from a design matrix.
311311
"""
@@ -363,14 +363,12 @@ def logL(self, Y):
363363
"""
364364
raise ValueError('minimize_memory should be set to False to make residuals or predictions.')
365365

366-
@setattr_on_read
367366
def resid(self):
368367
"""
369368
Residuals from the fit.
370369
"""
371370
raise ValueError('minimize_memory should be set to False to make residuals or predictions.')
372371

373-
@setattr_on_read
374372
def norm_resid(self):
375373
raise ValueError("SimpleRegressionResults does not store residuals."
376374
"If needed, use the RegressionResults class.")

0 commit comments

Comments
 (0)