import error when using spafe library for feature extraction - python

I ' am working on audio file and need to use spafe library for lfcc, lpc... and i install the library as mentionned in the site : https://spafe.readthedocs.io/en/latest/
But when i try to extract some features , like lfcc, mfcc, lpc, i have import error par example when i use this code :
import scipy.io.wavfile
import spafe.utils.vis as vis
from spafe.features.mfcc import lfcc
i have this error :
ImportError: cannot import name 'lfcc'
I don't undestand because i can import spafe, i have all dependancies the libraries required with the correct versions ( numpy, scipy...).

There seems to be a typo in the docs example (which I guess tou are trying to follow); it should be
from spafe.features.lfcc import lfcc
i.e. lfcc, not mfcc (which mfcc indeed does not have a module lfcc, hence the error).

Related

Error importing numpy in Google co lab using Android

I am trying to import numpy in Google co lab using Android but I am getting error shown in attached snap
As #Michael S. allready mentioned in the comments, Import needs to be lowercase:
import numpy as np
You must write the "I" in lowercase. Like that import numpy as np

The data is already loaded from disk issue from mne

i am following this tutorial
M/EEG analysis with MNE Python
and i have a little errors in this fragment : 01:35:57 Working with BIDS data
i followed all the steps before and also implemented code :
import matplotlib.pyplot as plt
import pathlib
import matplotlib
import mne
import mne_bids
matplotlib.use('Qt5Agg')
directory ='C:/Users/User/mne_data/MNE-sample-data/MEG\sample/sample_audvis_raw.fif'
raw =mne.io.read_raw(directory)
#raw.plot()
#plt.show()
events =mne.find_events(raw)
#print(events)
event_id ={
"Auditory/Left":1,
"Auditory/Right":2,
"Visual/Left":3,
"Visual/Right":4,
"Smiley":5,
"Button":32
}
raw.info['line_freq']=60
raw.load_data()
out_path =pathlib.Path("out_data/sample_bids")
bids_path =mne_bids.BIDSPath(subject='01',session='01',task='audiovisual',run='01',root=out_path)
mne_bids.write_raw_bids(raw,bids_path=bids_path,events_data=events,event_id=event_id,overwrite=True)
but when i am running this code, i am getting issue :
ValueError: The data is already loaded from disk and may be altered. See warning for "allow_preload".
i can't understand reason of this error, how can i fix it?please helo me

Pkl.File import can't be read "ValueError: unsupported pickle protocol: 5"

here the exemplary code:
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import pickle5 as pickle
#Read
output = pd.read_pickle("Energy_data.pkl")
plt.figure()
#print(output)
output.plot()
I am using Python 3.7 and that is probably the reason for the error message, because this .pkl files were created in Python 3.8 . If my colleague runs it (he created the .pkl-Files), it'll work.
I tried to use this solution (maybe I did not do it correctly) shown here, but it did not work anyway. Can someone show me how to import the pkl files using the example above in Python 3.7?
Thank you very much in advance!

Is there any problem with the OpenSlide.read_region function?

I am using the python API of openslide packages to read some ndpi file.When I use the read_region function, sometimes it return a odd image. What problems could have happend?
I have tried to read the full image, and it will be worked well. Therefore, I think there is no problem with the original file.
from openslide import OpenSlide
import cv2
import numpy as np
slide = OpenSlide('/Users/xiaoying/django/ndpi-rest-api/slide/read/21814102D-PAS - 2018-05-28 17.18.24.ndpi')
image = slide.read_region((1, 0),6, (780, 960))
image.save('image1.png')
The output is strange output
As the read_region documentation says, the x and y parameters are always in the coordinate space of level 0. For the behavior you want, you'll need to multiply those parameters by the downsample of the level you're reading.
This appears to be a version-realted bug, see also
https://github.com/openslide/openslide/issues/291#issuecomment-722935212
The problem seems to relate to libpixman verions 0.38.x . There is a Workaround section written by GunnarFarneback suggesting to load a different version first e.g.
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libpixman-1.so.0.34.0
upadte easier solution is:
We are using Python 3.6.8+ and this did the trick for us: conda install pixman=0.36.0

Python 2.7 Anaconda Spyder IDE Scitools Movie encoder='html' Not Working

Right now, I'm trying to create a movie in the Anaconda Spyder IDE (running Python 2.7). I have the following import statement at the top of my program:
from scitools.std import cos, exp, linspace, plot, movie
import time, glob, sys, os
After creating plots to make a movie from, I use the call:
movie('tmp_*.png', encoder='html', output_file='tmp_heatwave.html')
to try and create a movie in .html format. After running my program, I get the error:
ValueError: encoder must be ['mencoder', 'ffmpeg', 'mpeg_encode', 'ppmtompeg',
'mpeg2enc', 'convert'], not 'html'
Why is this happening? According to my textbook, A Primer on Scientific Programming with Python, "The HTML format can always be made and played. Hence, this format is the natural choice if problems with other formats occur."
Thanks!
Which version of scitools are you using? 0.9.0?
In the source code of movie class, html is in the legal encoder.
...
_legal_encoders = 'convert mencoder ffmpeg mpeg_encode ppmtompeg '\
'mpeg2enc html'.split()
_legal_file_types = 'png gif jpg ps eps bmp tif tga pnm'.split()
...
EDIT:
check version of scitools.
>>> import scitools
>>> scitools.__version__
'0.9.0'
>>>

Categories

Resources