print("Warning: NaN\"s detected in confound regressor file. Filling these with mean values, but the "
"regressor file should be checked manually.")
confounds_nonan = confounds.apply(lambda x: x.fillna(x.mean()), axis=0)
conf_corr = dir_path + "/confounds_mean_corrected_" + str(random.randint(1, 1000)) + ".tsv"
confounds_nonan.to_csv(conf_corr, sep="\t")
clust_est.fit(func_img, confounds=conf_corr)
else:
After Change
if confounds.isnull().values.any():
import uuid
from time import strftime
run_uuid = "%s_%s" % (strftime("%Y%m%d-%H%M%S"), uuid.uuid4())
print("Warning: NaN\"s detected in confound regressor file. Filling these with mean values, but the "
"regressor file should be checked manually.")
confounds_nonan = confounds.apply(lambda x: x.fillna(x.mean()), axis=0)
conf_corr = "/tmp/confounds_mean_corrected_" + str(run_uuid) + ".tsv"