Giter Club home page Giter Club logo

fcwt's People

Contributors

fastlib avatar felixdollack avatar lschneiderbauer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fcwt's Issues

MacBook M1 "zsh: illegal hardware instruction"

When I try to run the python example code it does not execute and I get the warning: zsh: illegal hardware instruction

Specs:

Mac M1
Ventura 13.4
cmake 3.26.4
numpy 1.24.3
linbomp 16.0.5
clang 14.0.3

Example Code giving Segmentation Fault

Greetings,

I was able to successfully install the fCWT but the example given on the home page was compiled using

$ g++ -mavx2 -fopenmp -lfCWT ./example.cpp

compilation successful but,

$ ./a.out
Segmentation fault (core dumped)

Please help.

OMP dependencies

Hello,

I am interested in fCWT. I noticed an hardcoded path "/usr/local/opt/libomp/lib" using this library on apple computer.
My libomp is installed into : /opt/homebrew/Cellar/libomp/16.0.1

Would you consider providing a customizable variable to twik this hardcoded path and make a smoother path detection.. ?

Template for `double`

I'm guessing there may be a reason linked deeply into the algorithm to use single-precision floats, instead of doubles, which are often the default in many applications and libraries today.

Would it be possible to template the algorithm's fundamental storage type in order to be able to use single- or double-precision floating-point numbers (or perhaps, even some more exotic types should there be a reason for these)?

Thanks

Benchmark against CCWT

Hi, seems like you kind of reinvented CCWT. Same idea: Transform signal to frequency domain using FFT, do a convolution with a wavelet per frequency band via element wise multiplication, and transform each frequency band back using iFFT.

More implementations are nice, and so would be to have a comparison between the two.

Reconstruction from coefficients i.e. inverse fCWT

Hi,
Thanks for the great tool..

Is there anyway to reconstruct the signal from the coefficients ?

For example

        #Initialize
        fs = 1000
        n = fs*100 #100 seconds
        ts = np.arange(n)

        #Generate linear chirp
        signal = np.sin(2*np.pi*((1+(20*ts)/n)*(ts/fs)))
        f0 = 1 #lowest frequency
        f1 = 101 #highest frequency
        fn = 200 #number of frequencies

        #Calculate CWT without plotting...
        freqs, out = fcwt.cwt(signal, fs, f0, f1, fn)
       
        # now reconstruct signal from coeff ?
       signal = fcwt.icwt(freqs,out)...or something along these lines ? 


Wavelet coherence

Dear Authors

I don't see this as an issue, but was wondering if there is a way going about doing coherence analysis with your library (python).

Also, thank you for this great software.

Kind regards
Armand

undefined reference on ubuntu

Unfortunately, when I try to build, I get undefined references (same errors as other people). I have ubuntu 22.10. So far it is not possible to solve these problems, even following the methods that were discussed earlier in closed issues. What other options might be available to solve this problem?

fCWT matlab for window

Hi

I'm trying to build MEX-file from source but I'm stuck on a problem
I installed Cmake and GCC, so I made it through until [$ cmake ../ -DBUILD_MATLAB=ON]
But when I type [make] after that, it says this and I cannot find MEX file
make: *** No targets specified and no makefile found. Stop.

Can you spot the problem in this situation?

image
These are the contents in 'build' file

Frequency to scale conversion

To accommodate wavelets which do not have the basic fs/f conversion from frequency to scale it may be helpful to have a frequencyToScale(fs, f) method in the wavelet and for Scales to be generated with a wavelet parameter to call the wavelet's frequencyToScale method.

Linking problem: undefined reference to log@GLIBC_2.29

After running CMake followed by make, I get the following error:
../libs/libfftw3fl.so undefined reference to 'log@GLIBC_2.29'
I'm on a RHEL 7 machine using RedHat's devtoolset-11 (gcc 11.2)
FFTW3 exists on the system, but I only have libfftw3.so, libfftw3f.so and libfftw3l.so not 'fl'. I'd build that library myself, but there isn't a configure/make that does that. Or perhaps there's an easier solution?

fCWT application question

Hi - I read your paper in Nature, and I'm hoping you might be able to answer a few quick questions about the real-time aspect of fCWT.

  • When calculating the power of specific frequency bands in your EEG data, for example, how did you mimic a real-time, streaming application? Did you use fCWT to analyze chunks of data (i.e. 0.5s) so that the time-resolution of the power spectrum was actually 0.5s? Or did you build the time-frequency analysis in real time by computing the WT on incoming samples?
  • Have you used fCWT for real-time, on-line applications to get instantaneous psd's?

Thanks!

I am not able to run the code in C++

Screenshot 1
Screenshot 2
What should I do after that command? And In what folder I should save C++ Example and it runs easily?
Screenshot 3

Screenshot 4
Screenshot 5
When I run C++ code, the above error shows in visual studio code.

How to extract actual periods or frequencies used in Python version? Normalization?

I'd like to be able to plot the actual frequencies or actual periods on my scaleograms. I'm using code based on the advanced Python examples so that I can use the optimization. But fcwt returns scales as a SWIG object and I'm not sure what to do with that. (<fcwt.fcwt.Scales; proxy of <Swig Object of type 'Scales *' at 0x000002154D2B70F0> >) Is there a way get to some approximation of the actual periods or frequencies used?

Also what does the normalization option do? Normalized to what?

Included libfftw3.a and libewavelet.a static libs are macOS only

libfftw3.a and libwavelet.a are Mach-O objects, so practically only compatible with MacOS and not UNIX... Probably worth noting this in the readme and adding links to the source (+hash for reproducibility).

fCWT/src/libwavelib on ξ‚  main [!] via C v12.2.0-gcc πŸ”‹βš‘ο–‚ 42% ❯ ar x libwavelib.a 

fCWT/src/libwavelib on ξ‚  main [!?] via C v12.2.0-gcc πŸ”‹βš‘ο–‚ 42% ❯ ls
conv.o  cwt.o  cwtmath.o  hsfft.o  libwavelib.a  real.o  wavefilt.o  wavefunc.o  wavelib.h  wavelib.lib  wavelib.o  wtmath.o

fCWT/src/libwavelib on ξ‚  main [!?] via C v12.2.0-gcc πŸ”‹βš‘ο–‚ 42% ❯ file *.o
conv.o:     Mach-O 64-bit x86_64 object, flags:<|SUBSECTIONS_VIA_SYMBOLS>
cwt.o:      Mach-O 64-bit x86_64 object, flags:<|SUBSECTIONS_VIA_SYMBOLS>
cwtmath.o:  Mach-O 64-bit x86_64 object, flags:<|SUBSECTIONS_VIA_SYMBOLS>
hsfft.o:    Mach-O 64-bit x86_64 object, flags:<|SUBSECTIONS_VIA_SYMBOLS>
real.o:     Mach-O 64-bit x86_64 object, flags:<|SUBSECTIONS_VIA_SYMBOLS>
wavefilt.o: Mach-O 64-bit x86_64 object, flags:<|SUBSECTIONS_VIA_SYMBOLS>
wavefunc.o: Mach-O 64-bit x86_64 object, flags:<|SUBSECTIONS_VIA_SYMBOLS>
wavelib.o:  Mach-O 64-bit x86_64 object, flags:<|SUBSECTIONS_VIA_SYMBOLS>
wtmath.o:   Mach-O 64-bit x86_64 object, flags:<|SUBSECTIONS_VIA_SYMBOLS>

Can not run with numpy 1.22.4

environment: win11 numpy installed with mambaforge, numpy version 1.22.4

RuntimeError Traceback (most recent call last)
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf . Check the section C-API incompatibility at the Troubleshooting ImportError section at https://numpy.org/devdocs/user/troubleshooting-importerror.html#c-api-incompatibility for indications on how to solve this problem .


ImportError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_29484\3900396640.py in
----> 1 import fcwt

c:\Users\Administrator\mambaforge\lib\site-packages\fcwt_init_.py in
----> 1 from .fcwt import Morlet, Scales, FCWT, FCWT_LINSCALES, FCWT_LOGSCALES, FCWT_LINFREQS
2 from .boilerplate import cwt, plot
3

c:\Users\Administrator\mambaforge\lib\site-packages\fcwt\fcwt.py in
11 # Import the low-level C/C++ module
12 if package or "." in name:
---> 13 from . import _fcwt
14 else:
15 import _fcwt

ImportError: numpy.core.multiarray failed to import

can you please update the API version?

Does this work on m1 processor too?

I am working with m1 iMac.
When I run the python example code, I get the following error:

"Process finished with exit code 132 (interrupted by signal 4: SIGILL)"

Here are the specs and package versions I'm working on:

  • M1 iMac, Ventura 13.1
  • cmake 3.26.3
  • gcc(clang) 14.0.0
  • numpy 1.23
  • python 3.9.13
  • conda 22.9.0

Thank you.

Error installing on Ubuntu 20.04

Hello and thank you for sharing the package.
I just edited the CMakelist line 43 as follows:

set(CMAKE_C_COMPILER "gcc-9")
set(CMAKE_CXX_COMPILER "g++-9")

and I got the following error for making :

[ 12%] Building CXX object CMakeFiles/fCWT_example.dir/src/fcwt.cpp.o
[ 25%] Building CXX object CMakeFiles/fCWT_example.dir/src/main.cpp.o
[ 37%] Building CXX object CMakeFiles/fCWT_example.dir/src/rwave.cpp.o
[ 50%] Building CXX object CMakeFiles/fCWT_example.dir/src/wavelib.cpp.o
[ 62%] Linking CXX executable fCWT_example
/usr/bin/ld: CMakeFiles/fCWT_example.dir/src/fcwt.cpp.o: in function `fcwt::create_optimization_schemes(int, int, int)':
fcwt.cpp:(.text+0x303): undefined reference to `fftwf_init_threads'
/usr/bin/ld: fcwt.cpp:(.text+0x30f): undefined reference to `fftwf_plan_with_nthreads'
/usr/bin/ld: fcwt.cpp:(.text+0x3a2): undefined reference to `fftwf_plan_dft_r2c_1d'
/usr/bin/ld: fcwt.cpp:(.text+0x418): undefined reference to `fftwf_plan_dft_1d'
/usr/bin/ld: fcwt.cpp:(.text+0x420): undefined reference to `fftwf_export_wisdom_to_filename'
/usr/bin/ld: fcwt.cpp:(.text+0x430): undefined reference to `fftwf_free'
/usr/bin/ld: fcwt.cpp:(.text+0x438): undefined reference to `fftwf_free'
/usr/bin/ld: fcwt.cpp:(.text+0x4e3): undefined reference to `fftwf_alloc_complex'
/usr/bin/ld: fcwt.cpp:(.text+0x4ee): undefined reference to `fftwf_alloc_complex'
/usr/bin/ld: CMakeFiles/fCWT_example.dir/src/fcwt.cpp.o: in function `fcwt::load_optimization_schemes(bool, int, int)':
fcwt.cpp:(.text+0x76e): undefined reference to `fftwf_import_wisdom_from_filename'
/usr/bin/ld: CMakeFiles/fCWT_example.dir/src/fcwt.cpp.o: in function `fcwt::main(float*, float*, int*, int*, int*, int*, float*, int, bool)':
fcwt.cpp:(.text.startup+0xcf): undefined reference to `fftwf_alloc_complex'
/usr/bin/ld: fcwt.cpp:(.text.startup+0xdf): undefined reference to `fftwf_alloc_complex'
/usr/bin/ld: fcwt.cpp:(.text.startup+0x139): undefined reference to `fftwf_init_threads'
/usr/bin/ld: fcwt.cpp:(.text.startup+0x145): undefined reference to `fftwf_plan_with_nthreads'
/usr/bin/ld: fcwt.cpp:(.text.startup+0x16a): undefined reference to `fftwf_plan_dft_r2c_1d'
/usr/bin/ld: fcwt.cpp:(.text.startup+0x176): undefined reference to `fftwf_execute'
/usr/bin/ld: fcwt.cpp:(.text.startup+0x17f): undefined reference to `fftwf_destroy_plan'
/usr/bin/ld: fcwt.cpp:(.text.startup+0x198): undefined reference to `fftwf_plan_dft_1d'
/usr/bin/ld: fcwt.cpp:(.text.startup+0x2e1): undefined reference to `fftwf_execute_dft'
/usr/bin/ld: fcwt.cpp:(.text.startup+0x329): undefined reference to `fftwf_destroy_plan'
/usr/bin/ld: fcwt.cpp:(.text.startup+0x331): undefined reference to `fftwf_free'
/usr/bin/ld: fcwt.cpp:(.text.startup+0x339): undefined reference to `fftwf_free'
/usr/bin/ld: fcwt.cpp:(.text.startup+0x33e): undefined reference to `fftwf_cleanup_threads'
/usr/bin/ld: CMakeFiles/fCWT_example.dir/src/wavelib.cpp.o: in function `wavelib::cwt(double*, int, int, int)':
wavelib.cpp:(.text+0x2e): undefined reference to `cwt_init'
/usr/bin/ld: wavelib.cpp:(.text+0x61): undefined reference to `setCWTScales'
/usr/bin/ld: wavelib.cpp:(.text+0x6c): undefined reference to `cwt'
/usr/bin/ld: wavelib.cpp:(.text+0x78): undefined reference to `cwt_free'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/fCWT_example.dir/build.make:132: fCWT_example] Error 1
make[1]: *** [CMakeFiles/Makefile2:106: CMakeFiles/fCWT_example.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Do I need to use gcc 10?

Complex morelet wavelet of the eeg experiment in the article

Hi @fastlib @felixdollack @lschneiderbauer

I am a newbie in signal processing. Based on the article, the cwt and fcwt in the eeg experiments are using complex morlet wavelet with a sigma value of 20 and I understand that the sigma parameters or number of cycles of a morlet wavelet is used to tune the time-frequency resolution tradeoff. Therefore, im currently trying to tune the parameters of sigma for morlet wavelet in CWT. However, i found that the cwt function in matlab 2023b only support the default analytical morelet wavelet "amor" and is unable to tune the sigma value. Hence, would like to ask how did u guys tune the sigma parameters of the morlet wavelet in cwt function of matlab and how do i set the fCWT in matlab to use complex morelet wavelet.

Could you show me the Matlab code of the eeg experiment in the article if possible?

Thanks in advance and sorry if this is a dumb quetion

Scalograms generation

I have recently downloaded this library to use it, I would like to know how would be the implementation in c++ for image generation based on color maps with time, frequency and abs(coefficients).

_mm256_mul_ps segfaults w/ linker options -Wl,-O1 -Wl,--as-needed

Hi,

I have no idea why this is happening, but when compiling your code w/ the linker options -Wl,-O1 -Wl,--as-needed the program segfaults when executing line 85 in fcwt.cpp:
O8[q4] = _mm256_mul_ps(I8[q4],tmp[0]);.

When omitting those options the code runs fine.

I am on linux 5.15, using gcc 12.2; fftw version 3.3.10.
Any idea what's going on here?

fCWT matlab crash on Mac

Dear fastlib

Hi,
I try to do fCWT on matlab, but it crashed at line 55 in the following picture sentence.

Mac PC spec is here,
processor: 2.3 GHz 8core Intel Core i9
memory: 32 GB 2667 MHz DDR4
macOS 13.1(22C65οΌ‰

Are there any solution ?
I would be happy if you could solve it by adding some code.

Thank you.

problem

FR: Benchmarking against IRCAM "wavelet" Library

Personally, I'm almost exclusively looking to do online time-frequency space conversions - as such the situation is a bit different from optimising performing a whole transformation in one go on (assumed) previously-unseen data.

I have just come across this repository by the Institute for Research and Coordination in Acoustics/Music that provides an implementation of the CWT suitable for online use (but that can also be used for offline processing). It seems that each sample is pushed back, and so the transform is updated one sample at a time.

I think this would be good to add to the implementations against which fCWT is benchmarked - especially interesting would be how it compares in online/offline use.

Python Import Errors

I installed fCWT using pip, but when I try to run the tutorial Jupyter notebook I get an import error. This is on Python 3.10.4.

image

Linking problem while doing make

Greetings,

I am unable to compile the code. After CMake if I do the Make then I am getting following errors [OpenSuse Tumbleweed, g++11]. Please help to get is started. I already modified the CMakeList.txt file to include g++11.

[ 14%] Building CXX object CMakeFiles/fCWT.dir/src/fcwt.cpp.o
[ 28%] Linking CXX shared library libfCWT.so
[ 28%] Built target fCWT
[ 42%] Building CXX object CMakeFiles/fCWT_example.dir/src/fcwt.cpp.o
[ 57%] Building CXX object CMakeFiles/fCWT_example.dir/src/main.cpp.o
[ 71%] Building CXX object CMakeFiles/fCWT_example.dir/src/rwave.cpp.o
[ 85%] Building CXX object CMakeFiles/fCWT_example.dir/src/wavelib.cpp.o
[100%] Linking CXX executable fCWT_example
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: CMakeFiles/fCWT_example.dir/src/fcwt.cpp.o: in function fcwt::create_optimization_schemes(int, int, int)': fcwt.cpp:(.text+0x2b5): undefined reference to fftwf_init_threads'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text+0x2c1): undefined reference to fftwf_plan_with_nthreads' /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text+0x341): undefined reference to fftwf_plan_dft_r2c_1d'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text+0x3b1): undefined reference to fftwf_plan_dft_1d' /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text+0x3bb): undefined reference to fftwf_export_wisdom_to_filename'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text+0x3cb): undefined reference to fftwf_free' /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text+0x3d3): undefined reference to fftwf_free'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text+0x476): undefined reference to fftwf_alloc_complex' /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text+0x481): undefined reference to fftwf_alloc_complex'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: CMakeFiles/fCWT_example.dir/src/fcwt.cpp.o: in function fcwt::load_optimization_schemes(bool, int, int)': fcwt.cpp:(.text+0x6b4): undefined reference to fftwf_import_wisdom_from_filename'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: CMakeFiles/fCWT_example.dir/src/fcwt.cpp.o: in function fcwt::main(float*, float*, int*, int*, int*, int*, float*, int, bool)': fcwt.cpp:(.text.startup+0xc1): undefined reference to fftwf_alloc_complex'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text.startup+0xce): undefined reference to fftwf_alloc_complex' /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text.startup+0x121): undefined reference to fftwf_init_threads'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text.startup+0x12d): undefined reference to fftwf_plan_with_nthreads' /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text.startup+0x15b): undefined reference to fftwf_plan_dft_r2c_1d'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text.startup+0x166): undefined reference to fftwf_execute' /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text.startup+0x16e): undefined reference to fftwf_destroy_plan'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text.startup+0x18c): undefined reference to fftwf_plan_dft_1d' /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text.startup+0x2a8): undefined reference to fftwf_execute_dft'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text.startup+0x2e4): undefined reference to fftwf_destroy_plan' /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text.startup+0x2ec): undefined reference to fftwf_free'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text.startup+0x2f4): undefined reference to fftwf_free' /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: fcwt.cpp:(.text.startup+0x2f9): undefined reference to fftwf_cleanup_threads'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: CMakeFiles/fCWT_example.dir/src/wavelib.cpp.o: in function wavelib::cwt(double*, int, int, int)': wavelib.cpp:(.text+0x28): undefined reference to cwt_init'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: wavelib.cpp:(.text+0x59): undefined reference to setCWTScales' /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: wavelib.cpp:(.text+0x64): undefined reference to cwt'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: wavelib.cpp:(.text+0x70): undefined reference to `cwt_free'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/fCWT_example.dir/build.make:148: fCWT_example] Error 1
make[1]: *** [CMakeFiles/Makefile2:112: CMakeFiles/fCWT_example.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

libomp ubuntu build issues

While building fcwt, I encountered OPENMP issues, I installed libomp-dev using apt but is shows fopenmp version 4.5 in every tag present on the ubuntu libomp package list

#9 0.144 Cloning into 'fCWT'...                                                                                               
#9 2.066 Build type is Release                                                                                                
#9 2.101 -- The C compiler identification is GNU 11.4.0                                                                       
#9 2.143 -- The CXX compiler identification is GNU 11.4.0
#9 2.148 -- Detecting C compiler ABI info
#9 2.203 -- Detecting C compiler ABI info - done
#9 2.208 -- Check for working C compiler: /usr/bin/cc - skipped
#9 2.208 -- Detecting C compile features
#9 2.208 -- Detecting C compile features - done
#9 2.210 -- Detecting CXX compiler ABI info
#9 2.272 -- Detecting CXX compiler ABI info - done
#9 2.277 -- Check for working CXX compiler: /usr/bin/c++ - skipped
#9 2.277 -- Detecting CXX compile features
#9 2.278 -- Detecting CXX compile features - done
#9 2.278 Building of shared library is enabled.
#9 2.410 -- Found OpenMP_C: -fopenmp (found version "4.5") 
#9 2.410 CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
#9 2.410   Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
#9 2.410 Call Stack (most recent call first):
#9 2.410   /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
#9 2.410   /usr/share/cmake-3.22/Modules/FindOpenMP.cmake:544 (find_package_handle_standard_args)
#9 2.410   CMakeLists.txt:141 (find_package)
#9 2.410 
#9 2.410 
#9 2.410 -- Configuring incomplete, errors occurred!
#9 2.410 See also "/app/fCWT/build/CMakeFiles/CMakeOutput.log".
#9 2.410 See also "/app/fCWT/build/CMakeFiles/CMakeError.log".
------
executor failed running [/bin/sh -c git clone https://github.com/fastlib/fCWT.git &&     cd fCWT &&     mkdir -p build && cd build &&     cmake .. && make && make install]: exit code: 1

(using ubuntu:latest)
How should I go about fixing this?

Morlet wavelets with fixed temporal window length

Hello!
Thank you for the implementation!

I'm working with EEG data and want to replace method from mne library with your implementation to speed up my computations

With mne I perform CWT with following code:

freqs = np.arange(1, 40.01, 0.1)
power_spectrum = mne.time_frequency.tfr_array_morlet(
        samples,  # samples.shape = [number_of_samples, number_of_eeg_channels, temporal_dim]
        sfreq=128,
        freqs=freqs,
        n_cycles=freqs,
        output='power',
        n_jobs=-1
)

I tried to implement the exact same behaviour with fCWT but failed:

morl = fcwt.Morlet(2.0)  # The problem is here I suppose

scales = fcwt.Scales(
        morl,
        fcwt.FCWT_LINFREQS,
        fs=int(raw_data.info['sfreq']),
        f0=freqs[0],
        f1=freqs[-1],
       fn=len(freqs),
)

nthreads = 4
use_optimization_plan = False
use_normalization = False
fcwt_obj = fcwt.FCWT(morl, nthreads, use_optimization_plan, use_normalization)

signal = samples[0, 0]  # for example
output = np.zeros((len(freqs), signal.size), dtype=np.complex64)
fcwt_obj.cwt(
        signal,
        scales,
        output,
)
power = np.abs(output) ** 2

Could you give some recommendations on how to choose the right sigma parameter of fcwt.Morlet to create Morlet wavelets with temporal window with fixed length? Is it possible to get the same behaviour as mne with the current implementation of fCWT?

C interface

@fastlib do you have plans on providing (or accepting contributions for) a C interface?
I am trying to embed this project as library but since the header file is written in c++ I am getting a lot of compile errors.

building for python

fyi i had to add 'libs' to library_dirs and include_dirs in setup.py in order for this to build for python.

#!/usr/bin/env python

"""
setup.py file for SWIG
"""

from setuptools import Extension, setup, find_packages
import distutils.command.build
import sysconfig
import numpy
import os
import shutil


# Obtain the numpy include directory.  This logic works across numpy versions.
try:
   numpy_include = numpy.get_include()
except AttributeError:
   numpy_include = numpy.get_numpy_include()

libraries = ['fftw3f']
comp_args = ["/arch:AVX", "/O2", "/openmp"]
link_args = []
files2 = ["omp.h",
          "fftw3.h",
          "fftw3f.dll",
          "fftw3f.lib",
          "libfftw3fmac.a",
          "libfftw3f_ompmac.a",
          "libfftw3fl.so",
          "libfftw3f_ompl.so",
          "libomp.a"
          ]
files = [
    "fcwt.h",
    "fcwt.cpp"
]

files = files + files2

if "macosx" in sysconfig.get_platform() or "darwin" in sysconfig.get_platform():
   libraries = ['fftw3fmac', 'fftw3f_ompmac']
   comp_args = ["-mavx", "-O3"]
   link_args = ["-lomp"]

if "linux" in sysconfig.get_platform():
   libraries = ['fftw3fl', 'fftw3f_ompl']
   comp_args = ["-mavx", "-O3"]
   link_args = ["-lomp"]


setup(ext_modules=[
    Extension('fcwt._fcwt',
              sources=[
                  'src/fcwt/fcwt.cpp',
                  'src/fcwt/fcwt_wrap.cxx'
              ],
              library_dirs=['src/fcwt', 'src', 'libs'],
              include_dirs=['src/fcwt', 'src', 'libs', numpy_include],
              libraries=libraries,
              extra_compile_args=comp_args,
              extra_link_args=link_args
              )
],
    packages=find_packages(where='src'),
    package_dir={'fcwt': 'src/fcwt'},
    package_data={'fcwt': files}
)

Installation issues on Apple M1

I tried installation using pip, but resulted in the following error

root ➜ /com.docker.devenvironments.code $ pip install fcwt
Collecting fcwt
  Downloading fCWT-0.1.18.tar.gz (4.6 MB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 4.6 MB 4.6 MB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
    Preparing wheel metadata ... done
Collecting numpy>=1.14.5
  Using cached numpy-1.26.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (14.2 MB)
Building wheels for collected packages: fcwt
  Building wheel for fcwt (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 /tmp/tmpusb54r2k_in_process.py build_wheel /tmp/tmpkufqj71t
       cwd: /tmp/pip-install-4d9xmcij/fcwt_7b0325aac4424ab2bb629c22b7a61965
  Complete output (37 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-aarch64-cpython-39
  creating build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/fcwt.py -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/boilerplate.py -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/__init__.py -> build/lib.linux-aarch64-cpython-39/fcwt
  running egg_info
  writing fCWT.egg-info/PKG-INFO
  writing dependency_links to fCWT.egg-info/dependency_links.txt
  writing requirements to fCWT.egg-info/requires.txt
  writing top-level names to fCWT.egg-info/top_level.txt
  reading manifest file 'fCWT.egg-info/SOURCES.txt'
  adding license file 'LICENSE.txt'
  writing manifest file 'fCWT.egg-info/SOURCES.txt'
  copying src/fcwt/fcwt.cpp -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/fcwt.h -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/fcwt_wrap.cxx -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/fftw3.h -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/fftw3f.dll -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/fftw3f.lib -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/libfftw3f_ompl.so -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/libfftw3f_ompmac.a -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/libfftw3fl.so -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/libfftw3fmac.a -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/libomp.a -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/omp.h -> build/lib.linux-aarch64-cpython-39/fcwt
  running build_ext
  building 'fcwt._fcwt' extension
  creating build/temp.linux-aarch64-cpython-39
  creating build/temp.linux-aarch64-cpython-39/src
  creating build/temp.linux-aarch64-cpython-39/src/fcwt
  aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-PN012d/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Isrc/fcwt -Isrc -Ilibs -I/tmp/pip-build-env-supkdnf8/overlay/lib/python3.9/site-packages/numpy/core/include -I/usr/include/python3.9 -c src/fcwt/fcwt.cpp -o build/temp.linux-aarch64-cpython-39/src/fcwt/fcwt.o -std=c++17 -mavx -O3
  aarch64-linux-gnu-gcc: error: unrecognized command-line option β€˜-mavx’
  error: command '/usr/bin/aarch64-linux-gnu-gcc' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for fcwt
Failed to build fcwt
ERROR: Could not build wheels for fcwt which use PEP 517 and cannot be installed directly

I added some changes in the cmake file
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -march=native -O2")
instead of "-mavx"

And I tried to install and use the C++ endpoint but I am getting segmentation faults on FCWT::cwt.

int main(){
    std::cout << "The server started." << std::endl;
    
    std::string filepath = "../static/sample.csv";
    int nchannels = 6;

    std::vector<std::vector<float>> data = readCSV(filepath, 6); // this part will be replaced with an active socket connection received
    std::cout << "File read successfully. Size " << data.size() <<","<<data[0].size() << std::endl;

    int sampling_rate = 44100;
    int nframe = 128;
    int nsamples = data[0].size();
    int fstart = 1, fend = 64;


    Morlet morlet(2.0f);
    Wavelet *wavelet = &morlet;
    int nthreads = 8;

    FCWT fcwt(wavelet, nthreads, true, false);

    Scales scales(wavelet,  FCWT_LOGSCALES, sampling_rate, fstart, fend, nframe);


    std::vector<MatrixXcf> spectrum(nframe, MatrixXcf::Zero(nchannels, nsamples));

    std::cout << nchannels << std::endl;
    std::vector<complex<float>> spec(data.size()*data[0].size() + 5, 0);
    std::cout << spec[0] << std::endl;

    for (int i = 0; i < nchannels; i++)
    {
        std::cout << i << std::endl;
        fcwt.cwt(&data[i][0], nsamples, &spec[0], &scales);
        std::cout << "good" << std::endl;
        std::cout << spec[0] << std::endl;
    }
    

}
[100%] Linking CXX executable server
[100%] Built target server
The server started.
File read successfully. Size 6,8000
6
(0,0)
0
WARNING: Optimization scheme 'n8192_t8.wis' was not found, fallback to calculation without optimization.
Segmentation fault

How should I rectify this?

Sample frequency limitation

The README states:
Real-time CWT for signals having sample frequencies of up to 200kHz

Does this just mean higher sample frequencies won't run in real-time? Is there any indication of how bad it might get for RF frequencies, e.g., 10-50 MHz? I'm assuming (hoping) this is a complex-valued sample rate, i.e., the BW is the sample rate vs half.

Generate fCWT for a short signal to be used as feature

Hello,
At present, I'm using MFCC as a feature in my CNN project. I'm also trying several other features to improve the prediction
factor. The input data is a mono, 16Hz wave file. The data is extracted for 0.1 seconds.

signal, sr = librosa.load("test.wav", sr=None)
fs = 1600
f0 = 1 # lowest frequency
f1 = 101 # highest frequency
fn = 20 # number of frequencies
# Calculate CWT without plotting...
freqs, out = fcwt.cwt(signal[0:1600], fs, f0, f1, fn)
print(freqs)

The above code is generating freqs with 20 points but I'm a bit confused about fs, f0, and f1. The plot looks blurry and I believe that I haven't used correct values. How do I improve the freqs to have good noise for better predictions?

Optimization scheme 'n2048_t1.wis' was not found

I installed fCWT via pypi -> pip install fcwt and I get the following warning when 'fast' is enabled (true). I am on Ubuntu 22.04.

WARNING: Optimization scheme 'n2048_t1.wis' was not found, fallback to calculation without optimization.

I am dealing with some data that could benefit a great deal from optimization and speed. How can I fix this issue?

Thanks very much in advance.

If fCWT suppose 2D wavelet?

I'm going to use fCWT to process picture. But I don't know if fCWT suppose 2D wavelet. Can you give me a suggestion?

fCWT in C++

This error comes when we run C++ code of fCWT.
Screenshot 2023-06-23 001013

How to get the output time–frequency array?

Hi, your work is excellent. I have some questions about how to get the output time-frequency arrays? Because I want to plot the time-frequency plot obtained by fCWT. Can you give me some specific advice or specific examples? Thanks.

can't compiled the .mexwin64 (WIN) files

Hi:
I change the 'BUILD_MATLAB' = ON in 'CMakeCache.txt',I get fCWT_example.exe.But nothing has changed in the Matlab folder.May I ask what adjustments I need to make to get .mexwin64 (WIN) files.

fCWT vs STFT in CNN-based EEG emotion recognition

          Understood. Thanks a lot for the clarification. Furthermore, I have a few more confusion that I would also like to ask for your expert opinions, 

Currently, I'm trying to build CNN-based eeg emotion recognition model with CWT, STFT, and fCWT respectively, and compare the performance of each model with different methods. However, I found that the performance of STFT is better than CWT (the parameters of both methods have been tuned to the highest performance on CNN). Therefore, would like to ask, if it is possible that using STFT on a narrow band frequency signal such as the Alpha band of an eeg signal will provide better performance than CWT ?

Originally posted by @whip123 in #40 (comment)

Other mother wavelets

Hi,

Great repository and speed. This is a request, not an issue.

Is there any way to add other wavelet types? For instance, a Gaussian wavelet where we can define a variance is quite common in spectroscopy.

AG.

CMake function find_package() does not find fCWT-config.cmake configuration files

Thanks to the authors for the opportunity to use this library!

I have a little problem: i installed the fCWT library following the instructions from this official repository, And in the Ubuntu default path /usr/local/share/fcwt/cmake the configuration files fCWT-config.cmake and fCWT-config-release.cmake are present. However, when using the find_package(fCWT REQUIRED)` function in a QT Creator build together with CMakeLists.txt, CMake gives an error:

CMakeLists.txt:14: error: By not providing "FindfCWT.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "fCWT", but CMake did not find one. Could not find a package configuration file provided by "fCWT" with any of the following names:

fCWTConfig.cmake
fcwt-config.cmake

Add the installation prefix of "fCWT" to CMAKE_PREFIX_PATH or set "fCWT_DIR" to a directory containing one of the above files. If "fCWT" provides a separate development package or SDK, be sure it has been installed.

I've tried specifying the path to the configuration files using CMake commands but they don't bring success:

set (CMAKE_MODULE_PATH fCWT-config.cmake REQUIRED)
set (CMAKE_PREFIX_PATH /usr/local/share/fcwt/cmake/fCWT-config.cmake REQUIRED)
set (fCWT-config.cmake_DIR = /usr/local/share/fcwt/cmake/ REQUIRED)
list(APPEND CMAKE_SYSTEM_PREFIX_PATH /usr/local/share/fcwt/cmake)

listing them before find_package(fCWT REQUIRED)

This seems strange to me because it finds the other library (GSL) I use in my small project. My CMakeLists.txt looks like this:

cmake_minimum_required(VERSION 3.22)

project(fft LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(GSL REQUIRED)
find_package(fCWT REQUIRED)

include_directories(${GSL_INCLUDE_DIR})
include_directories(${fCWT_INCLUDE_DIR})
include_directories(/lib/include)
include_directories(/usr/local/include)

add_executable(fft main.cpp)
target_link_libraries(fft PRIVATE ${GSL_LIBRARY})
target_link_libraries(fft PRIVATE ${fCWT_LIBRARY})

Thank you for paying attention to my question. I will be glad to receive any advice on how to fix this error.

Questions about the library

Hi ! Thanks for taking the time on doing this!

I would like to ask if I can calculate the coeffs and frequency of a signal, like I do with the CWT pywavelets lib : https://pywavelets.readthedocs.io/en/latest/ref/cwt.html

I have been doing experiments with this library but now I need to do CWT on a signal real time, or at least attempt to efficiently calculate this signal and get coeffs / frequency opposed to doing it with Python which has problems saturating a single thread and cumbersome multiproc.

If you could kindly answer to my questions I'd very much appreciated

Thank you !

I can't install fCWT

I want to install fCWT in Ubuntu 20.04 for C++, but when I "make" the library, I get

[ 60%] Linking CXX executable fCWT_example
/usr/bin/ld: attempted static link of dynamic object `../libs/libfftw3fl.so'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/fCWT_example.dir/build.make:101: fCWT_example] Error 1
make[1]: *** [CMakeFiles/Makefile2:78: CMakeFiles/fCWT_example.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

The file "../libs/libfftw3fl.so" exists, so I am clueless about this.

Thank you for writing this library!

installing the fCWT on python

Dear @felixdollack

I hope you're doing well. When I try to install the package with pip command I get the following error. Should I download the 17 GB software?!

Best regards,
Mohammad

Screenshot 2023-08-30 110750

Reducing artefacts for short time spans

The integer truncation of the index into the mother wavelet causes some artefacts for short time spans. Those can be reduced without performance penalty by generating the mother data at a multiple of size for sizes below some threshold and passing that multiple to the daughter wavelet multiplication to scale the step.

how to use fCWT to generate pictures for EEG

I tried to run some cwt generating code but it took me 7 days to finish, too slow, I want to use fCWT instead, although installed, I didn't see specific examples for how to use fCWT to generate pictures just as cwt does, I affiliated the cwt MATLAB code, I'm not so sure how to use fCWT, I will be very grateful if you can help me out, thank you
final_cwt.txt
.

Dose it can be used for real-time application in processing low frequency signal?

First, I would like to express my sincere gratitude and respect for the contributions of the authors of this project.

Below is my question.

When I tried to use the output of fcwt input to my model, I found that to obtain a clear spectrum on low frequency, the signal input to fcwt should long enough. For example, if the target frequency is 20 Hz, the duration of the input signal should larger than 1/20Hz=0.05 s. Otherwise, lower frequency spectrum will blur. Dose this means that the conflict between frequency resolution and time resolution still exist?

Or is that mean, for the processing low frequency(f) signal, the input segment duration delta_t should always satisfy that delta_t>1/f. And the high efficient of fcwt only ensure real time processing of with frequency satisfy f>1/delta_t. (Because Heisenberg uncertainty principle?). From what I know, one of the advantage of cwt above stft is it high frequency resolution at low frequency, if limitation of Heisenberg uncertainty still hold, what the advantage of fcwt above stft for real-time using, especially for the processing of low frequency signal.

My question may seems weird, but it is what confuse me now. Any one familiar with are welcome to share your opinion.

Support for Custom Frequency Array Input

Currently, your interfaces in both C and Python only support creating scales using an f0, f1, and either log or linear scaling. However, for some applications, it would be much easier if the user could simply specify an array of frequencies they would like to generate waveforms for. In my case, I would like to analyze specifically the frequencies that correspond to notes on the piano, so a linear or log step isn't practical.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.