IuliiaBaglaeva / TransientAnalyzerUI

Graphical interface for TransientAnalyzer
GNU General Public License v3.0
1 stars 1 forks source link

overflow encountered in double_scalars #1

Open AndreZeug opened 1 year ago

AndreZeug commented 1 year ago

Hi there, I tested the UI with your example file Sarcomere_length_Cagalinec et.al. (2019).xlsx and it worked fine. I used latest version (hotfix) for both, TransientAnalyzer and TransientAnalyzerUI However, when I test my own data, testTrace_res3.xlsx I receive the following error:

(base) D:\Defuser\Downloads\TransientAnalyzerUI-main>python Main.py 2023-03-18 07:14:24.371119: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. WARNING:tensorflow:From C:\Users\DefUser\anaconda3\lib\site-packages\tensorflow\python\autograph\pyct\static_analysis\liveness.py:83: Analyzer.lamba_check (from tensorflow.python.autograph.pyct.static_analysis.liveness) is deprecated and will be removed after 2023-09-23. Instructions for updating: Lambda fuctions will be no more assumed to be used in the statement where they are used, or at least in the same block. https://github.com/tensorflow/tensorflow/issues/56089 C:\Users\DefUser\anaconda3\lib\site-packages\TransientAnalyzer\TransientAnalyzer.py:283: RuntimeWarning: overflow encountered in double_scalars return res res C:\Users\DefUser\anaconda3\lib\site-packages\TransientAnalyzer\TransientAnalyzer.py:317: RuntimeWarning: invalid value encountered in double_scalars dydx = (fr - fl) / (2 dx)

Any guess?

IaBogdi commented 1 year ago

Dear Dr. Andre Zeug,

thank you very much for sharing with your problem of TransientAnalyzerUI usage. This is caused by the too high learning rate (alpha) parameter of heavy ball method. Tbh, we have spotted the similar problem in our data recently, which are also sarcomere contractions and of very low noise. We have just made an update of both TransientAnalyzer and UI versions so that it is now possible to change learning rate (alpha) if this problem appears. For your example trace, we decreased alpha by thousand times and it worked fine afterwards (this is the analysis file, the third sheet is the list of input parameters testTrace_res3_analysis_Gibbs.xlsx). To use the latest version, sync the TransientAnalyzerUI repository and update TransientAnalyzer using pip: pip install --upgrade TransientAnalyzer Hope it solved the issue.

Best Regards, Bogdan and Iuliia

AndreZeug commented 1 year ago

Great, it also works with alpha=0.1! I will play more with the parameters 🤗. Many thanks for immediate support. Andre

AndreZeug commented 1 year ago

Sorry, it is me again. I lost track of your beautiful tool a bit, but now I really want to use your tool for data analysis. Unfortunately I ran into a problem again. When trying to analyse a file 005_Roi1.xlsx with alpha=0.1, the cubic interpolation runs into an error:

Traceback (most recent call last):
  File "D:\Defuser\Downloads\TransientAnalyzerUI-main\Main.py", line 41, in run
    self.Analyzer._FitSingleTransient(i)
  File "C:\Users\DefUser\anaconda3\lib\site-packages\TransientAnalyzer\TransientAnalyzer.py", line 376, in _FitSingleTransient
    baseline_spline = CubicSpline(x_findt0,np.array([self.baselines[idx]] * len(x_findt0)))
  File "C:\Users\DefUser\anaconda3\lib\site-packages\scipy\interpolate\_cubic.py", line 629, in __init__
    x, dx, y, axis, _ = prepare_input(x, y, axis)
  File "C:\Users\DefUser\anaconda3\lib\site-packages\scipy\interpolate\_cubic.py", line 61, in prepare_input
    raise ValueError("`x` must be strictly increasing sequence.")
ValueError: `x` must be strictly increasing sequence.

Playing around with the 'start' parameters (if this helps at all) is a bit time-consuming, as when the error occurs I have to quit the anaconda command window and restart anaconda and TransientAnalyzerUI. A good guess is very welcome though. For other files, it functions very well. 001_Roi2.xlsx

Again, any guess?

Best Regards Andre

IuliiaBaglaeva commented 1 year ago

Dear Dr. Andre Zeug,

Oh, we also had such problem several months ago, when we found out that Transient's sign combobox didn't work, and we fixed it and made an upgrade for TransientAnalyzer UI (please, check, if you have the latest version). In some cases, especially not noisy one, determination of the sign transient doesn't work, in these cases detection usually far away from the place where it should be, like in your case with 005_Roi1.xlsx file. You need to choose "positive" or "negative" (depends on where transients go, above or below of baseline) instead of "automatic". We checked both your files, and it worked.

Best regards, Iuliia and Bogdan

AndreZeug commented 1 year ago

Just great, updating and using "positive" helped and allowed me to process a bunch of files. Can you please help me with some other problem as well?! This file 006_Roi1.xlsx does not really process an error, however it "hangs" while anaysing the second peak. (I reduced "Prominence" to 0.8 to detect peak1 as well.) Do I further have to adjust some other parameter?

Thanks again for your immediate response. Best Regards, Andre

IuliiaBaglaeva commented 1 year ago

Dear @AndreZeug, We played with parameters a bit :-) We attach the file with analysis, and you can find the values of parameters which were used in "Analysis Parameters" sheet. 006_Roi1_analysis.xlsx It was a problem with heavy ball method again, and we had to make alpha still less, in this case it was 0.001.

We plan to make update of TransientAnalyzer on weekend to fix this problem of alpha detection automatically. and also we will try to use Cython to increase the speed of analysis.

Happy to help, Iuliia and Bogdan

AndreZeug commented 1 year ago

Really great! I have also been playing around with the alpha and was successful with 0.01, I did not know how small it could be. For some data it was also useful to reduce "Prominence" and introduce a positive "Shift". So far I have been using your GUI for data analysis, but I am planning to do some script based analysis where an automatic estimation of alpha would certainly help. Thanks a lot for the support! Andre

IaBogdi commented 1 year ago

Dear @AndreZeug , sorry for the latency, were busy with experimental work. We have prepared an update for TransientAnalyzer where we have improved the sign detection and made the adaptive learning rate in Heavy Ball so that it becomes more stable and does not crash.

For the update, just use pip: pip install --upgrade TransientAnalyzer

Best regards, Bogdan and Iuliia

AndreZeug commented 1 year ago

Many thanks for the update and don't worry about the timing!