Skip to content

Commit

Permalink
Merge pull request #210 from amarquand/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
amarquand authored Jun 14, 2024
2 parents 7c6a3b3 + b405303 commit c1b418b
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions pcntoolkit/normative.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,11 @@ def predict(covfile, respfile, maskfile=None, **kwargs):
X = fileio.load(covfile)
if len(X.shape) == 1:
X = X[:, np.newaxis]

if respfile is not None:
Y, maskvol = load_response_vars(respfile, maskfile)
if len(Y.shape) == 1:
Y = Y[:, np.newaxis]

sample_num = X.shape[0]
if models is not None:
feature_num = len(models)
Expand All @@ -817,6 +821,11 @@ def predict(covfile, respfile, maskfile=None, **kwargs):
Xz = scaler_cov[fold].transform(X)
else:
Xz = X
if respfile is not None:
if outscaler in ['standardize', 'minmax', 'robminmax']:
Yz = scaler_resp[fold].transform(Y)
else:
Yz = Y

# estimate the models for all variabels
for i, m in enumerate(models):
Expand All @@ -842,18 +851,10 @@ def predict(covfile, respfile, maskfile=None, **kwargs):
Yhat[:, i] = yhat.squeeze()
S2[:, i] = s2.squeeze()
if respfile is not None:
Y, maskvol = load_response_vars(respfile, maskfile)
Y = Y[:, i:i+1]
if alg == 'hbr':
if outscaler in ['standardize', 'minmax', 'robminmax']:
Yz = scaler_resp[fold].transform(Y)
else:
Yz = Y
Z[:,i] = nm.get_mcmc_zscores(Xz, Yz, **kwargs)
Z[:,i] = nm.get_mcmc_zscores(Xz, Yz[:, i:i+1], **kwargs)
else:
Z[:,i] = (Y - Yhat[:, i]) / np.sqrt(S2[:, i])


Z[:,i] = (Y[:, i] - Yhat[:, i]) / np.sqrt(S2[:, i])

if respfile is None:
save_results(None, Yhat, S2, None, outputsuffix=outputsuffix)
Expand Down

0 comments on commit c1b418b

Please sign in to comment.