nelpy / ghost

Spectral analysis tools for neuroscience data
MIT License
10 stars 1 forks source link

scipy: if _is_safe_size(n): #5

Open jeremyNG-lab opened 3 years ago

jeremyNG-lab commented 3 years ago

Hi, This is my code with Accz and Time are array of float:

cwt = ContinuousWaveletTransform(wavelet= morse.Morse()) CPEF=cwt.transform(data =Accz, fs =1000, timestamps =Time, freq_limits =[0,300])

And the answer:

File ".......\lib\site-packages\scipy\fftpack\basic.py", line 87, in fft if _is_safe_size(n):

TypeError: c2c() missing 1 required keyword-only argument: 'plan'

jchutrue commented 3 years ago

Hello,

What version of scipy are you using, and do you have a full traceback of the issue when you run the code?

jeremyNG-lab commented 3 years ago

I use scipy 1.3.0 but I had lot of problem with scipy like No module named.... What version you use?

jchutrue commented 3 years ago

I've been using pyfftw for the FFT backend. For scipy, if you have the full traceback of all your issues, I can take a look. Right now I'm not sure what the specific problems are.

jeremyNG-lab commented 3 years ago

So at the bigging I use the last scipy (1.6.0)

from . import morlet File "......\anaconda3\lib\site-packages\ghost\wave\morlet.py", line 5, in from scipy.misc import logsumexp ImportError: cannot import name 'logsumexp' from 'scipy.misc' (C:\Users\jerem\anaconda3\lib\site-packages\scipy\misc__init__.py)

I changed in the file scipy.misc by scipy.special

_from .fourier import clean_scipy_cache File ".....\anaconda3\lib\site-packages\ghost\sigtools\fourier.py", line 5, in import scipy.fftpack._fftpack as sff ModuleNotFoundError: No module named 'scipy.fftpack.fftpack'

I changed by from scipy.fftpack import fft as sff

And I saw your last message that you use pyfftw so i installed this package and it works. I think that pyfftw must be installed for a good work .

jchutrue commented 3 years ago

The issue with scipy is that they removed some functions in later versions. I'll get around to fixing that today so that you can still use scipy as the fft backend if you want. But in general I do prefer to use pyfftw.

ckemere commented 3 years ago

I think the two pull requests I proposed will fix these issues. But you should update the home page example to also import pyfftw so that people do this by default.

jchutrue commented 3 years ago

@jeremyNG-lab The errors should be gone now--let us know how it looks on your system

jeremyNG-lab commented 3 years ago

Without the FFT backend I have the same issu:

_File "....\anaconda3\lib\site-packages\ghost\sigtools\fourier.py", line 11, in clean_scipy_cache sff.destroy_zfft_cache() AttributeError: 'function' object has no attribute 'destroy_zfftcache'

ckemere commented 3 years ago

The master branch has been changed. Make sure you pip install it again?

jeremyNG-lab commented 3 years ago

I redownload and reinstall the package. But with scipy it didn't work, the same issue.

jchutrue commented 3 years ago

This might have something to do with scipy's legacy code. Try it now?

EDIT: i.e. run pip install again

jeremyNG-lab commented 3 years ago

INFO:ghost:'timestamps' not passed in; generating from data WARNING:root:Module 'pyfftw' not found, using scipy backend Traceback (most recent call last):

File "", line 2, in cwt.transform(data =Accz, fs =10000, voices_per_octaveint=48) #, ,freqs=frevoices_per_octaveint=48 timestamps =Time, freq_limits =[10,401] ,

File "......\anaconda3\lib\site-packages\ghost\formats\preprocessing.py", line 187, in wrap_function return function(*args, **kwargs)

File "......\anaconda3\lib\site-packages\ghost\wave\transforms.py", line 224, in transform wavelet_conv((ii, freq, length))

File ".......\anaconda3\lib\site-packages\ghost\wave\transforms.py", line 203, in wavelet_conv res = convfun(input_asarray[..., start:stop], kernel)

File ".....\anaconda3\lib\site-packages\ghost\sigtools\convolution.py", line 81, in fastconv_scipy clean_scipy_cache()

File ".....\anaconda3\lib\site-packages\ghost\sigtools\fourier.py", line 11, in clean_scipy_cache sff.destroy_zfft_cache()

AttributeError: 'function' object has no attribute 'destroy_zfft_cache'

jchutrue commented 3 years ago
File ".....\anaconda3\lib\site-packages\ghost\sigtools\convolution.py", line 81, in fastconv_scipy
clean_scipy_cache()

File ".....\anaconda3\lib\site-packages\ghost\sigtools\fourier.py", line 11, in clean_scipy_cache
sff.destroy_zfft_cache()

AttributeError: 'function' object has no attribute 'destroy_zfft_cache'

Those two lines above no longer exist. You need to git pull to update to the latest code and then run pip install again.

jeremyNG-lab commented 3 years ago

(base) C:....>pip3 install git+https://github.com/nelpy/ghost.git Collecting git+https://github.com/nelpy/ghost.git Cloning https://github.com/nelpy/ghost.git to c:\users\jerem\appdata\local\temp\pip-req-build-syyxcccr Requirement already satisfied: numpy>=1.15.0 in c:\users\jerem\anaconda3\lib\site-packages (from ghost==0.0.0) (1.19.2) Requirement already satisfied: scipy>=1.0 in c:\users\jerem\anaconda3\lib\site-packages (from ghost==0.0.0) (1.6.0) Requirement already satisfied: matplotlib>=3.0 in c:\users\jerem\anaconda3\lib\site-packages (from ghost==0.0.0) (3.3.4) Requirement already satisfied: python-dateutil>=2.1 in c:\users\jerem\anaconda3\lib\site-packages (from matplotlib>=3.0->ghost==0.0.0) (2.8.1) Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\jerem\anaconda3\lib\site-packages (from matplotlib>=3.0->ghost==0.0.0) (1.3.1) Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in c:\users\jerem\anaconda3\lib\site-packages (from matplotlib>=3.0->ghost==0.0.0) (2.4.7) Requirement already satisfied: cycler>=0.10 in c:\users\jerem\anaconda3\lib\site-packages (from matplotlib>=3.0->ghost==0.0.0) (0.10.0) Requirement already satisfied: pillow>=6.2.0 in c:\users\jerem\anaconda3\lib\site-packages (from matplotlib>=3.0->ghost==0.0.0) (8.1.0) Requirement already satisfied: six in c:\users\jerem\anaconda3\lib\site-packages (from cycler>=0.10->matplotlib>=3.0->ghost==0.0.0) (1.15.0)

I did it

I launched the script and I have the same error

jchutrue commented 3 years ago

If you instead install like so:

  1. pip3 uninstall ghost
  2. Navigate to the directory you want to place the cloned repo in.
  3. git clone https://github.com/nelpy/ghost.git
  4. cd ghost
  5. pip3 install .

and run your script, do you get the same error?

If you still have the error, try exporting your environment by running conda env export > environment.yml. Then upload that file here and I'll try to reproduce the error on my machine.

jeremyNG-lab commented 3 years ago

Yes it works. Really Thanks

But with pyfftw it works everytime

jchutrue commented 3 years ago

Great! It should work fine on either scipy or fftw now. Let me know if you run into any further issues. If there aren't any related ones in the next couple of days, I'll close this one out.