<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Practical model fitting
Someone has given you  text file with concentration-time curves measured in an artery and in tumor tissue. This notebook demonstrates how such data can be analyzed with the compartment models library.
First, we need to import some libraries
Step1:  We can then load the data from the text file and store each of the three columns as a vector
Step2:  This is not very enlightening. Of course, we can do better and plot the two curves.
Step3:  This looks like  a pretty arterial input function (left) and a tissue curve (right).
Tracer-kinetic analysis
To further analyze this data, we need a library for model fitting. Here, we use
https
Step4:  Experience tells that this curve needs to be fitted with a two-compartment exchange model
Step5:  Let us examine the model fit
Step6:  This fit produced the following parameters
<ASSISTANT_TASK:>
Python Code:
import numpy as np
# plotting and graphics settings
import matplotlib.pyplot as plt
%pylab inline
try:
    import seaborn as sns # pretty graphics. not strictly necessary.
    sns.set_context("notebook")
    sns.set_style("whitegrid")
except:
    pass # with less pretty graphics  
Explanation: Practical model fitting
Someone has given you  text file with concentration-time curves measured in an artery and in tumor tissue. This notebook demonstrates how such data can be analyzed with the compartment models library.
First, we need to import some libraries:
End of explanation
time, curve, aif = np.loadtxt('tests/tumor.csv', delimiter=',', unpack=True, comments='#')
print time[0:5]
print curve[0:5]
print aif[0:5]
Explanation: We can then load the data from the text file and store each of the three columns as a vector:
End of explanation
f, (a1,a2)=plt.subplots(1,2)
a1.plot(time, aif, label='AIF')
a2.plot(time,curve, label='Tissue curve')
Explanation: This is not very enlightening. Of course, we can do better and plot the two curves.
End of explanation
import compartmentmodels.compartmentmodels as CM
Explanation: This looks like  a pretty arterial input function (left) and a tissue curve (right).
Tracer-kinetic analysis
To further analyze this data, we need a library for model fitting. Here, we use
https://github.com/michimichi/compartmentmodels. This particular library is currently under development, but in a usable status.
End of explanation
twocx = CM.TwoCXModel(time, curve, aif, 
                      startdict={'Fp':20.0, 'vp': 5.5, 'PS':0.1, 've':9.1})
twocx.fit_model()
Explanation: Experience tells that this curve needs to be fitted with a two-compartment exchange model:
End of explanation
f, a = plt.subplots(1,1)
a.plot(time, curve, label='Tissue curve')
a.plot(time, twocx.fit, label='Model fit')
plt.legend(loc=4)
Explanation: Let us examine the model fit:
End of explanation
print twocx.phys_parameters
Explanation: This fit produced the following parameters:
End of explanation
<END_TASK>