<source lang="python">
# Python module imports.
import os, stat
# relax module imports.
from specific_analyses.model_free.model pipe_control import determine_model_typepipes
import lib.io
from pipe_control specific_analyses.api import pipesreturn_api
# Read the state with the setup
                chi2 = str(cdp.chi2)
                tm = str(cdp.diff_tensor.tm)
 
                # Get the api to get number of parameters
                api = return_api(pipe_name=pipe_name)
                model_loop = api.model_loop
                model_desc = api.model_desc
                model_statistics = api.model_statistics
 
                for model_info in model_loop():
                    desc = model_desc(model_info)
                    # Num_params_(k)
                    # Num_data_sets_(n)
                    k_glob, n_glob, chi2_glob = model_statistics(model_info, global_stats=True)
                    break
 
                k_glob = str(k_glob)
                n_glob = str(n_glob)
                chi2_glob = str(chi2_glob)
 
                # Append to results
                out_results.append([pipe_name_rnd, model, round_i, cdp_iter, chi2, tm, k_glob, n_glob, chi2_glob])                print("\n# Data:")                print(out_results[-1])
# Change back to original pipe
# Write the file.
headings = ["pipe_name", "model", "round_i", "cdp_iter", "chi2", "tm", "k_glob_Num_params", "n_glob_Num_data_sets", "chi2_glob"]
lib.io.write_data(out=file, headings=headings, data=out_results)
file.close()