1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """The module for the relaxation curve fitting parameter list object."""
24
25
26 from numpy import average
27
28
29 from lib.mathematics import round_to_next_order
30 from specific_analyses.parameter_object import Param_list
31
32
34 """Determine the scaling factor for the peak intensities.
35
36 This is for the scaling of the I0 and Iinf parameters during optimisation. The maximum intensity will be used to scale all values.
37
38
39 @keyword model_info: The spin container and the spin ID string from the _model_loop_spin() specific API method.
40 @type model_info: SpinContainer instance, str
41 @return: The average peak intensity of the first time point.
42 @rtype: float
43 """
44
45
46 spin, spin_id = model_info
47
48
49 return round_to_next_order(max(spin.peak_intensity.values()))
50
51
52 -def i0_upper(incs=None, model_info=None):
53 """Find the upper bound for the I0 parameter.
54
55 @keyword incs: The number of grid search increments.
56 @type incs: int
57 @keyword model_info: The spin container and the spin ID string from the _model_loop_spin() specific API method.
58 @type model_info: SpinContainer instance, str
59 @return: The average peak intensity of the first time point.
60 @rtype: float
61 """
62
63
64 spin, spin_id = model_info
65
66
67 upper = max(spin.peak_intensity.values())
68
69
70 return round_to_next_order(upper * 2.0)
71
72
74 """Find the average intensity of the last time point.
75
76 This is for the grid search upper bound for the Iinf parameter.
77
78
79 @keyword incs: The number of grid search increments.
80 @type incs: int
81 @keyword model_info: The spin container and the spin ID string from the _model_loop_spin() specific API method.
82 @type model_info: SpinContainer instance, str
83 @return: The average peak intensity of the last time point.
84 @rtype: float
85 """
86
87
88 spin, spin_id = model_info
89
90
91 max_time = max(cdp.relax_times.values())
92 for key in cdp.relax_times:
93 if cdp.relax_times[key] == max_time:
94 id = key
95 break
96
97
98 upper = average(spin.peak_intensity[id])
99
100
101 return round_to_next_order(upper * 2.0)
102
103
104
106 """The relaxation curve fitting parameter list singleton."""
107
108
109 _instance = None
110
112 """Define all the parameters of the analysis."""
113
114
115 if self._initialised: return
116
117
118 Param_list.__init__(self)
119
120
121 self._add_peak_intensity()
122
123
124 self._add_sn_ratio()
125
126
127 self._add(
128 'relax_times',
129 scope = 'spin',
130 py_type = dict,
131 grace_string = '\\qRelaxation time period (s)\\Q'
132 )
133
134
135 self._add_model_info(model_flag=False)
136
137
138 self._add(
139 'rx',
140 scope = 'spin',
141 default = 8.0,
142 units = 'rad.s^-1',
143 desc = 'Either the R1 or R2 relaxation rate',
144 set = 'params',
145 py_type = float,
146 scaling = 1.0,
147 grid_lower = 0.0,
148 grid_upper = 20.0,
149 grace_string = '\\qR\\sx\\Q',
150 err = True,
151 sim = True
152 )
153 self._add(
154 'i0',
155 scope = 'spin',
156 default = 10000.0,
157 desc = 'The initial intensity',
158 py_type = float,
159 set = 'params',
160 scaling = i_scaling,
161 grid_lower = 0.0,
162 grid_upper = i0_upper,
163 grace_string = '\\qI\\s0\\Q',
164 err = True,
165 sim = True
166 )
167 self._add(
168 'iinf',
169 scope = 'spin',
170 default = 0.0,
171 desc = 'The intensity at infinity',
172 py_type = float,
173 set = 'params',
174 scaling = i_scaling,
175 grid_lower = 0.0,
176 grid_upper = iinf_upper,
177 grace_string = '\\qI\\sinf\\Q',
178 err = True,
179 sim = True
180 )
181
182
183 self._add_min_data(min_stats_global=False, min_stats_spin=True)
184
185
186 self._set_uf_title("Relaxation curve fitting parameters")
187 self._uf_param_table(label="table: curve-fit parameters", caption="Relaxation curve fitting parameters.")
188 self._uf_param_table(label="table: curve-fit parameters and min stats", caption="Relaxation curve fitting parameters and minimisation statistics.", sets=['params', 'fixed', 'min'])
189 self._uf_param_table(label="table: curve-fit parameter value setting", caption="Relaxation curve fitting parameters.")
190 self._uf_param_table(label="table: curve-fit parameter value setting with defaults", caption="Relaxation curve fitting parameter value setting.", default=True)
191