Closed rmadhura-iit closed 1 year ago
This looks like the result of the NaN policy change. Although lmfit ignores the NaNs now during fitting, they still cause errors later in processing, so there may not be an easy way around the error.
If possible, could you send your full settings for processing that led to this error? Otherwise we can try to reproduce this in a meeting.
So I saw this error for the BrainScan data on lethocerus. You can see the path for the images on the firtst line of the error message. I am using default R-min and R-max settings, because even if I change these settings, I am not able to retrieve them afterwards, so there is no way to fix them across multiple trials. So I figured default is better.
Will change the nan_policy in lmfit calls from 'omit' to 'propagate'.
This is the first time I have seen this error message. I am reworking the brain scan with 1.14.10, and got this error message:
Image: 150612_injured_8_28_fineScan_0365.tif
/media/Data_1/rama/BrainScan/150612_injured_8_28_fineScan_0365.tif is being processed ... 2D integration has been calculated. === Partial Integration Method is being processed... Selected peaks = [24, 76, 97, 133, 156, 181, 225, 256, 294, 345, 386, 421, 437, 465, 499, 533, 552, 612, 673] === Central Difference Method is being processed... Selected peaks = [4, 26] === Merging rings ... Merged rings = [25, 76, 97, 133, 156, 181, 225, 256, 294, 345, 386, 421, 437, 465, 499, 533, 552, 612, 673] === Fitting model ... {'g6_fwhm': 26.32897580892859, 'g18_center': 612.0, 'g17_height': 3.9193893646966993, 'g19_fwhm': 35.3223, 'g11_sigma': 15.0, 'g12_height': 4.677777510716623, 'g16_sigma': 12.984255616297078, 'g6_amplitude': 26.29125064592861, 'g9_sigma': 15.0, 'g2_sigma': 6.852801575267902, 'g5_center': 156.0, 'g15_height': 4.059051944411719, 'g12_fwhm': 35.3223, 'g15_amplitude': 152.61800808331375, 'g1_fwhm': 6.7945744023041525, 'g11_height': 1.9303089950064534, 'g7_amplitude': 77.63448079955442, 'g14_fwhm': 35.3223, 'g4_sigma': 15.0, 'g9_height': 5.097935893451757, 'g14_height': 4.527639591904043, 'g12_sigma': 15.0, 'g18_height': 4.185400737921853, 'g10_sigma': 15.0, 'g7_height': 2.0647785552986724, 'g5_height': 3.720427307842836, 'g7_fwhm': 35.3223, 'g2_height': 0.9663787453497791, 'g6_center': 181.0, 'g12_amplitude': 175.88173192150677, 'g8_fwhm': 10.191861603456228, 'g19_center': 673.0, 'g19_sigma': 15.0, 'g17_sigma': 15.0, 'g4_fwhm': 35.3223, 'g4_height': 0.4208455921233666, 'g14_center': 465.0, 'g16_center': 533.0, 'g3_amplitude': 16.808307178727993, 'g16_amplitude': 18.27706016559614, 'g10_fwhm': 35.3223, 'g14_sigma': 15.0, 'g3_center': 97.0, 'g8_amplitude': 10.11596362716562, 'g13_center': 437.0, 'g3_sigma': 14.426950684774532, 'g2_amplitude': 16.59989875337457, 'g13_fwhm': 35.3223, 'g7_center': 225.0, 'g18_sigma': 15.0, 'g13_height': 5.006480759167776, 'g19_amplitude': 31.464297574295824, 'g2_fwhm': 16.13711420547236, 'g18_fwhm': 35.3223, 'g17_amplitude': 147.36677577296388, 'g4_amplitude': 15.823551129700958, 'g19_height': 0.8368292828115999, 'g10_center': 345.0, 'g6_sigma': 11.180886780700261, 'g12_center': 421.0, 'g9_fwhm': 35.3223, 'g16_fwhm': 30.57558481036869, 'g1_amplitude': 62.83630596637839, 'g8_height': 0.9324413925752753, 'g15_center': 499.0, 'g4_center': 133.0, 'g11_fwhm': 35.3223, 'g13_sigma': 15.0, 'g6_height': 0.9380912452014237, 'g17_fwhm': 35.3223, 'g8_center': 256.0, 'g18_amplitude': 157.36864972410243, 'g2_center': 76.0, 'g10_amplitude': 58.21298198063412, 'g1_sigma': 2.885390136954906, 'g7_sigma': 15.0, 'g11_center': 386.0, 'g1_height': 8.687927536962567, 'g3_fwhm': 33.972872011520764, 'g5_sigma': 15.0, 'g5_amplitude': 139.88591738114144, 'g5_fwhm': 35.3223, 'g10_height': 1.5482413947475153, 'g15_fwhm': 35.3223, 'g14_amplitude': 170.23663291298175, 'g15_sigma': 15.0, 'g13_amplitude': 188.2407841623128, 'g1_center': 25.0, 'g9_center': 294.0, 'g16_height': 0.5615641462379599, 'g3_height': 0.46479293313624115, 'g8_sigma': 4.328085205432359, 'g9_amplitude': 191.67944437523005, 'g17_center': 552.0, 'g11_amplitude': 72.57850301935092} Fitting Results = {'alpha9': 191.67944437523005, 'alpha15': 152.61800808331375, 'alpha18': 157.36864972410243, 'alpha10': 58.21298198063412, 'sigmad8': 4.328085205432359, 'sigmad9': 15.0, 'alpha11': 72.57850301935092, 'sigmad2': 6.852801575267902, 'sigmad3': 14.426950684774532, 'alpha12': 175.88173192150677, 'sigmad1': 2.885390136954906, 'sigmad6': 11.180886780700261, 'sigmad7': 15.0, 'sigmad4': 15.0, 'sigmad5': 15.0, 'alpha2': 16.59989875337457, 'alpha3': 16.808307178727993, 'alpha1': 62.83630596637839, 'alpha6': 26.29125064592861, 'alpha7': 77.63448079955442, 'alpha4': 15.823551129700958, 'alpha5': 139.88591738114144, 'u5': 156.0, 'u4': 133.0, 'u7': 225.0, 'u6': 181.0, 'u1': 25.0, 'u3': 97.0, 'u2': 76.0, 'u19': 673.0, 'u18': 612.0, 'alpha16': 18.27706016559614, 'u11': 386.0, 'u10': 345.0, 'u13': 437.0, 'u12': 421.0, 'u15': 499.0, 'u14': 465.0, 'u17': 552.0, 'u16': 533.0, 'alpha17': 147.36677577296388, 'alpha13': 188.2407841623128, 'u9': 294.0, 'u8': 256.0, 'sigmad18': 15.0, 'sigmad19': 15.0, 'alpha14': 170.23663291298175, 'alpha19': 31.464297574295824, 'sigmad14': 15.0, 'sigmad15': 15.0, 'sigmad16': 12.984255616297078, 'sigmad17': 15.0, 'sigmad10': 15.0, 'sigmad11': 15.0, 'sigmad12': 15.0, 'sigmad13': 15.0, 'alpha8': 10.11596362716562} Error for method leastsq = 0.018633377566949272 Time for method leastsq = 0.632801055908 Selected Fitting Method = leastsq === Rings information is being processed ... Peaks to check = [25, 76, 97, 133, 156, 181, 225, 256, 294, 345, 386, 421, 437, 465, 499, 533, 552, 612, 673] /usr/local/lib/python2.7/dist-packages/musclex/modules/ScanningDiffraction.py:1051: RuntimeWarning: invalid value encountered in divide weights = errs / errs.mean() + 1 /usr/local/lib/python2.7/dist-packages/musclex/modules/ScanningDiffraction.py:1052: RuntimeWarning: invalid value encountered in greater weights[weights > 3.] = 0 Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/musclex/ui/CPImageWindow.py", line 878, in batchProcBtnToggled self.processFolder() File "/usr/local/lib/python2.7/dist-packages/musclex/ui/CPImageWindow.py", line 953, in processFolder self.nextImage() File "/usr/local/lib/python2.7/dist-packages/musclex/ui/CPImageWindow.py", line 1136, in nextImage self.onImageChanged() File "/usr/local/lib/python2.7/dist-packages/musclex/ui/CPImageWindow.py", line 1046, in onImageChanged self.processImage(True) File "/usr/local/lib/python2.7/dist-packages/musclex/ui/CPImageWindow.py", line 1054, in processImage self.cirProj.process(flags) File "/usr/local/lib/python2.7/dist-packages/musclex/modules/ScanningDiffraction.py", line 108, in process self.processRings() File "/usr/local/lib/python2.7/dist-packages/musclex/modules/ScanningDiffraction.py", line 410, in processRings self.processOrientation2(model='GMM3') File "/usr/local/lib/python2.7/dist-packages/musclex/modules/ScanningDiffraction.py", line 1129, in processOrientation2 model_dict[i] = self.get_ring_model2([x, hist]) File "/usr/local/lib/python2.7/dist-packages/musclex/modules/ScanningDiffraction.py", line 1053, in get_ring_model2 result = model.fit(data=hist[1], x=x, params=result.params, weights=weights, nan_policy='omit') File "/usr/local/lib/python2.7/dist-packages/lmfit/model.py", line 1007, in fit output.fit(data=data, weights=weights) File "/usr/local/lib/python2.7/dist-packages/lmfit/model.py", line 1355, in fit _ret = self.minimize(method=self.method) File "/usr/local/lib/python2.7/dist-packages/lmfit/minimizer.py", line 1949, in minimize return function(**kwargs) File "/usr/local/lib/python2.7/dist-packages/lmfit/minimizer.py", line 1492, in leastsq lsout = scipy_leastsq(self.__residual, variables, **lskws) File "/usr/local/lib/python2.7/dist-packages/scipy/optimize/minpack.py", line 387, in leastsq raise TypeError('Improper input: N=%s must not exceed M=%s' % (n, m)) TypeError: Improper input: N=4 must not exceed M=0