Author: bugman Date: Fri May 31 18:40:11 2013 New Revision: 19836 URL: http://svn.gna.org/viewcvs/relax?rev=19836&view=rev Log: Added the model for no chemical exchange relaxation to the dispersion analysis. Modified: branches/relax_disp/gui/analyses/auto_relax_disp.py branches/relax_disp/specific_analyses/relax_disp/__init__.py branches/relax_disp/specific_analyses/relax_disp/variables.py branches/relax_disp/target_functions/relax_disp.py branches/relax_disp/user_functions/relax_disp.py Modified: branches/relax_disp/gui/analyses/auto_relax_disp.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/gui/analyses/auto_relax_disp.py?rev=19836&r1=19835&r2=19836&view=diff ============================================================================== --- branches/relax_disp/gui/analyses/auto_relax_disp.py (original) +++ branches/relax_disp/gui/analyses/auto_relax_disp.py Fri May 31 18:40:11 2013 @@ -44,7 +44,7 @@ from pipe_control.mol_res_spin import exists_mol_res_spin_data from pipe_control.pipes import has_bundle, has_pipe from specific_analyses.relax_disp import VAR_TIME_EXP -from specific_analyses.relax_disp.variables import MODEL_R2EFF, MODEL_LM63, MODEL_CR72 +from specific_analyses.relax_disp.variables import MODEL_CR72, MODEL_LIST_FULL, MODEL_LM63, MODEL_NOREX, MODEL_R2EFF from status import Status; status = Status() @@ -117,7 +117,7 @@ ds.relax_gui.analyses[data_index].grid_inc = None ds.relax_gui.analyses[data_index].mc_sim_num = None ds.relax_gui.analyses[data_index].save_dir = self.gui.launch_dir - ds.relax_gui.analyses[data_index].disp_models = [MODEL_R2EFF, MODEL_LM63, MODEL_CR72] + ds.relax_gui.analyses[data_index].disp_models = MODEL_LIST_FULL # Error checking. if ds.relax_gui.analyses[data_index].pipe_bundle == None: @@ -447,13 +447,15 @@ desc = "Relaxation dispersion models:" models = [ MODEL_R2EFF, + MODEL_NOREX, MODEL_LM63, MODEL_CR72 ] params = [ u"{R2eff, I\u2080}", - u"{R\u2082, phi_ex, kex}", - u"{R\u2082, R2a, kA, d\u03C9}" + u"{R\u2082, ...}", + u"{R\u2082, ..., phi_ex, kex}", + u"{R\u2082, ..., R2a, kA, d\u03C9}" ] tooltip = "The list of all relaxation dispersion models to be optimised as part of the protocol." tooltip_button = "Open the model list selector window." Modified: branches/relax_disp/specific_analyses/relax_disp/__init__.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp/__init__.py?rev=19836&r1=19835&r2=19836&view=diff ============================================================================== --- branches/relax_disp/specific_analyses/relax_disp/__init__.py (original) +++ branches/relax_disp/specific_analyses/relax_disp/__init__.py Fri May 31 18:40:11 2013 @@ -59,7 +59,7 @@ from specific_analyses.api_common import API_common from specific_analyses.relax_disp.disp_data import average_intensity, find_intensity_keys, loop_cluster, loop_frq, loop_frq_point, loop_frq_point_key, loop_frq_point_time, loop_point, loop_time, relax_time, return_cpmg_frqs, return_index_from_disp_point, return_index_from_frq, return_key_from_disp_point_index, return_param_key_from_data, return_r2eff_arrays, return_spin_lock_nu1 from specific_analyses.relax_disp.parameters import assemble_param_vector, assemble_scaling_matrix, disassemble_param_vector, linear_constraints, param_index_to_param_info, param_num -from specific_analyses.relax_disp.variables import CPMG_EXP, FIXED_TIME_EXP, MODEL_R2EFF, MODEL_LM63, MODEL_CR72, R1RHO_EXP, VAR_TIME_EXP +from specific_analyses.relax_disp.variables import CPMG_EXP, FIXED_TIME_EXP, MODEL_LM63, MODEL_CR72, MODEL_NOREX, MODEL_R2EFF, R1RHO_EXP, VAR_TIME_EXP from target_functions.relax_disp import Dispersion from user_functions.data import Uf_tables; uf_tables = Uf_tables() from user_functions.objects import Desc_container @@ -782,7 +782,7 @@ def _select_model(self, model=MODEL_R2EFF): """Set up the model for the relaxation dispersion analysis. - @keyword model: The relaxation dispersion analysis type. This can be one of 'R2eff', 'LM63', 'CR72'. + @keyword model: The relaxation dispersion analysis type. This can be one of 'R2eff', 'No Rex', 'LM63', 'CR72'. @type model: str """ @@ -810,6 +810,13 @@ if model == MODEL_R2EFF: print("R2eff/R1rho value and error determination.") params = ['r2eff', 'i0'] + + # The model for no chemical exchange relaxation. + elif model == MODEL_NOREX: + print("The model for no chemical exchange relaxation.") + params = [] + for i in range(cdp.spectrometer_frq_count): + params.append('r2') # LM63 model. elif model == MODEL_LM63: Modified: branches/relax_disp/specific_analyses/relax_disp/variables.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp/variables.py?rev=19836&r1=19835&r2=19836&view=diff ============================================================================== --- branches/relax_disp/specific_analyses/relax_disp/variables.py (original) +++ branches/relax_disp/specific_analyses/relax_disp/variables.py Fri May 31 18:40:11 2013 @@ -41,8 +41,17 @@ MODEL_R2EFF = 'R2eff' """The model for determining the R2eff/R1rho values from peak intensities.""" +MODEL_NOREX = 'No Rex' +"""The model for no chemical exchange relaxation.""" + MODEL_LM63 = 'LM63' """The Luz and Meiboom (1963) 2-site fast exchange model.""" MODEL_CR72 = 'CR72' """The Carver and Richards (1972) 2-site model for all time scales.""" + +MODEL_LIST_DISP = [MODEL_NOREX, MODEL_LM63, MODEL_CR72] +"""The list of all dispersion models (excluding the R2eff model).""" + +MODEL_LIST_FULL = [MODEL_R2EFF, MODEL_NOREX, MODEL_LM63, MODEL_CR72] +"""The list of the R2eff model together with all dispersion models.""" Modified: branches/relax_disp/target_functions/relax_disp.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/target_functions/relax_disp.py?rev=19836&r1=19835&r2=19836&view=diff ============================================================================== --- branches/relax_disp/target_functions/relax_disp.py (original) +++ branches/relax_disp/target_functions/relax_disp.py Fri May 31 18:40:11 2013 @@ -31,7 +31,7 @@ from lib.dispersion.lm63 import r2eff_LM63 from lib.errors import RelaxError from target_functions.chi2 import chi2 -from specific_analyses.relax_disp.variables import MODEL_CR72, MODEL_LM63, MODEL_R2EFF +from specific_analyses.relax_disp.variables import MODEL_CR72, MODEL_LIST_FULL, MODEL_LM63, MODEL_NOREX, MODEL_R2EFF class Dispersion: @@ -43,6 +43,7 @@ The following models are currently supported: + - 'No Rex': The model for no chemical exchange relaxation. - 'LM63': The Luz and Meiboom (1963) 2-site fast exchange model. - 'CR72': The Carver and Richards (1972) 2-site model for all time scales. @@ -74,7 +75,7 @@ """ # Check the args. - if model not in [MODEL_R2EFF, MODEL_LM63, MODEL_CR72]: + if model not in MODEL_LIST_FULL: raise RelaxError("The model '%s' is unknown." % model) if values == None: raise RelaxError("No values have been supplied to the target function.") @@ -105,6 +106,8 @@ self.back_calc = zeros((num_spins, num_frq, num_disp_points), float64) # Set up the model. + if model == MODEL_NOREX: + self.func = self.func_NOREX if model == MODEL_LM63: self.func = self.func_LM63 if model == MODEL_CR72: @@ -201,3 +204,42 @@ # Return the total chi-squared value. return chi2_sum + + + def func_NOREX(self, params): + """Target function for no exchange. + + @param params: The vector of parameter values. + @type params: numpy rank-1 float array + @return: The chi-squared value. + @rtype: float + """ + + # Scaling. + if self.scaling_flag: + params = dot(params, self.scaling_matrix) + + # Unpack the parameter values. + R20 = params + + # Initialise. + chi2_sum = 0.0 + + # Loop over the spins. + for spin_index in range(self.num_spins): + # Loop over the spectrometer frequencies. + for frq_index in range(self.num_frq): + # The R2eff values as R20 values. + for i in range(self.num_disp_points): + self.back_calc[spin_index, frq_index, i] = R20[frq_index] + + # For all missing data points, set the back-calculated value to the measured values so that it has no effect on the chi-squared value. + for point_index in range(self.num_disp_points): + if self.missing[spin_index, frq_index, point_index]: + self.back_calc[spin_index, frq_index, point_index] = self.values[spin_index, frq_index, point_index] + + # Calculate and return the chi-squared value. + chi2_sum += chi2(self.values[spin_index, frq_index], self.back_calc[spin_index, frq_index], self.errors[spin_index, frq_index]) + + # Return the total chi-squared value. + return chi2_sum Modified: branches/relax_disp/user_functions/relax_disp.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/user_functions/relax_disp.py?rev=19836&r1=19835&r2=19836&view=diff ============================================================================== --- branches/relax_disp/user_functions/relax_disp.py (original) +++ branches/relax_disp/user_functions/relax_disp.py Fri May 31 18:40:11 2013 @@ -39,7 +39,7 @@ from specific_analyses.relax_disp.disp_data import cpmg_frq, relax_time, spin_lock_field from specific_analyses.relax_disp.nessy import nessy_input from specific_analyses.relax_disp.sherekhan import sherekhan_input -from specific_analyses.relax_disp.variables import MODEL_CR72, MODEL_LM63, MODEL_R2EFF +from specific_analyses.relax_disp.variables import MODEL_CR72, MODEL_LM63, MODEL_NOREX, MODEL_R2EFF from specific_analyses.setup import relax_disp_obj from user_functions.data import Uf_info; uf_info = Uf_info() from user_functions.objects import Desc_container @@ -461,11 +461,13 @@ wiz_element_type = "combo", wiz_combo_choices = [ "%s: {R2eff/R1rho, I0}" % MODEL_R2EFF, - "%s: {R20, phi_ex, kex}" % MODEL_LM63, - "%s: {R20, pA, dw, kex}" % MODEL_CR72 + "%s: {R20, ...}" % MODEL_NOREX, + "%s: {R20, ..., phi_ex, kex}" % MODEL_LM63, + "%s: {R20, ..., pA, dw, kex}" % MODEL_CR72 ], wiz_combo_data = [ MODEL_R2EFF, + MODEL_NOREX, MODEL_LM63, MODEL_CR72 ], @@ -475,12 +477,14 @@ uf.desc.append(Desc_container()) uf.desc[-1].add_paragraph("A number of different dispersion models are supported. These models are dependent upon whether the data originates from a CPMG-type or R1rho-type experiment. For the CPMG-type experiments, the models currently supported are:") uf.desc[-1].add_item_list_element("'%s'" % MODEL_R2EFF, "This is the model used to determine the R2eff values and errors required as the base data for all other models,") +uf.desc[-1].add_item_list_element("'%s'" % MODEL_NOREX, "This is the model for no chemical exchange being present,") uf.desc[-1].add_item_list_element("'%s'" % MODEL_LM63, "The original Luz and Meiboom (1963) 2-site fast exchange equation with parameters {R20, phi_ex, kex},") uf.desc[-1].add_item_list_element("'%s'" % MODEL_CR72, "The Carver and Richards (1972) 2-site equation for all time scales with parameters {R2A, kA, dw}.") uf.desc[-1].add_paragraph("For the R1rho-type experiment, the currently supported models are:") uf.desc[-1].add_item_list_element("'%s'" % MODEL_R2EFF, "This is the same model model as for the CPMG-type experiments except that the R1rho and not R2eff values are determined.") +uf.desc[-1].add_item_list_element("'%s'" % MODEL_NOREX, "This is the model for no chemical exchange being present,") uf.desc[-1].add_paragraph("Except for '%s', these CPMG and R1rho models are fit to clusterings of spins, or spin blocks. The models are described in more detail below." % MODEL_R2EFF) -# Exp-fit model. +# R2eff model. uf.desc.append(Desc_container("The R2eff model")) uf.desc[-1].add_paragraph("This is the simplest of all models in that the dispersion part is not modelled. It is used to determine the R2eff or R1rho values and errors which are required as the base data for all other models. It can be selected by setting the model to '%s'. Depending on the experiment type, this model will be handled differently. The R2eff/R1rho values determined can be later copied to the data pipes of the other dispersion models using the appropriate value user function." % MODEL_R2EFF) uf.desc[-1].add_paragraph("For the fixed relaxation time period CPMG-type experiments, the R2eff values are determined by direct calculation using the formula:") @@ -503,6 +507,9 @@ """) uf.desc[-1].add_paragraph("where I1 is the peak intensity in a spectrum for a given spin-lock field strength nu1.") uf.desc[-1].add_paragraph("For the variable relaxation time period type experiments, the R2eff/R1rho values are determined by fitting to the simple two parameter exponential as in a R1 or R2 analyses. Both R2eff/R1rho and the initial peak intensity I0 are optimised using the minimise user function for each exponential curve separately. Monte Carlo simulations are used to obtain the parameter errors.") +# The no exchange model. +uf.desc.append(Desc_container("The model for no chemical exchange relaxation")) +uf.desc[-1].add_paragraph("This model is provided for model selection purposes. In combination with frequentist methods such as AIC or Bayesian methods, it can show if the presence of chemical exchange is statistically significant. Optimisation is still required as one R20 value per magnetic field strength will be fit to the measured data for each spin system. It is selected by setting the model to '%s'." % MODEL_NOREX) # LM63 model. uf.desc.append(Desc_container("The LM63 2-site fast exchange CPMG model")) uf.desc[-1].add_paragraph("This is the original model for 2-site fast exchange for CPMG-type experiments. It is selected by setting the model to '%s', here named after Luz and Meiboom 1963. The equation for the exchange process is:" % MODEL_LM63)