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