I'm in the midst of trying to create my own radon transform function, for which I need to rotate the simple image I've created. According to the documentation, the function is in scipy.misc.
However,
from scipy.misc import imrotate
gives me "could not import name imrotate"
and
import scipy.misc
scipy.misc.imrotate(myImage,theta)
says that scipy.misc does not have a module named 'imrotate' when I try to call the function.
I've tried removing the '--pylab inline' arguments from my launch, and I've made sure the PIL/Image libraries aren't imported, because I've heard that there were problems with that in other threads, but nothing seems to make it work.
I've gotten around it for now by using a different suite, the scikit-image library, but I'd prefer to use the scipy version if I can, because it's more commonly used.
scipy.misc.imrotate requires the library PIL and I guess that is your problem. Ether it is not installed at all or not installed correctly.
You can use scipy.ndimage.interpolation.rotate instead.
Related
I have a script in Matlab, which accesses a DLL and allows me to utilize the methods to import and analyse data programmatically. However, I would like to convert it to python. I have looked at using pythonnet, but I cannot get it to work. Can anyone suggest a way of replicating this behaviour in python?
Ths example is specific to Delsys and their EMGWorks software.
%locate HPF DLL within EMGworks install folder
path = ['C:\Program Files (x86)\pathtoDLL\HPF.dll'];
%make HPF assembly visible to MATLAB
NET.addAssembly(path);
%locate target HPF file
curFile = 'C:\TestFiles\MyTestFile.hpf';
%construct HPF reader
myHPFreader = HPF.HPFReader(curFile);
%invoke “GetAllSampleRates” method on HPF reader object “myHPFreader”
mySampleRates = myHPFreader.GetAllSampleRates;
Thanks Tim!
I made one small change to the great example you provided!
channel_names = emg_file.GetAllChannelNames()
The emg_file change matched the variable.
The key it seems is knowing the structure of the dll so you can instantiate the class. I looked at the Matlab docs to work this out.
1. Install Python.net
pip install pythonnet
2. Import package and make package available to Python
import clr
clr.AddReference('C:\Program Files (x86)\Delsys, Inc\EMGworks\Matlab Conversion Library \HPF.dll')
3. Instantiate class object
This was initially confusing for me. But it seems that the name of the DLL will be the name of the package. In my case the .dll is HPF.dll so my package name is HPF.
from HPF import HPFReader
emg_file = HPFReader(<filename>)
4. Utilise methods from table in matlab docs to get file info and print it out
channel_names = data.GetAllChannelNames()
for channel in channel_names:
print(channel)
When I'm in ipython and try to import keras, I get the error No space left on device: /home/username/.keras. How can I change this so that Keras does not use my HOME directory, and instead use /data/username/? I did the same for the directory ~/.ipython. I moved it to the desired location and then did export IPYTHONDIR=/data/username/.ipython, can I do something similar with Keras? More generally, how can I do this for any app that wants to use HOME?
Note: Please don't give answers like "you can clean your home" etc. I am asking this for a reason. Thanks!
I don't think keras is the only problem. If you are using theano as a backend, it will create $HOME/.theano/ as well.
One dirty trick is to export HOME=/data/username/, but other program than keras or ipython will also treat /data/username/ as $HONE. To avoid that, you can do this locally by calling HOME=/data/username/ ipython or HOME=/data/username/ python kerasProgram.py.
Probably a basic mistake, but the cause is eluding me. I am trying to import a package, but I get an error saying it cannot be found or imported.
First I set the current directory to the parent directory of the package, and this does not work.
Second, the docs say that the parent folder of the package must be added to the matlab path. I tried this, and still no luck.
It is not due to using plot as the package name as I get the same error when trying to import analysis.
What I can do is to import using: import plot.* or import analyse.* and then go on to use the functions in the packages, but I want to use the namespaces (i.e. not use .*).
Edit
I'm having this problem on both versions I have installed: 2015b and 2016a.
The answer is that, somewhat counterintuitively, you don't need to call import at all. The docs state that
The parent of the top-level package folder must be on the MATLAB path.
Which is what your addpath(pwd) does and then state that (emphasis is mine):
All references to packages, functions, and classes in the package must
use the package name prefix, unless you import the package.
Meaning at this stage you should be able to call
analyse.testFunc
If you were to import analyse.testFunc you would then be able to call testFunc without prefacing it with the namespace but since you want to retain the namespace the answer is to not call import at all.
I'm playing around with most recent Haskell platform (2013.2.0.0) on Windows trying to create a simple but fast concurrent socket server. I'm trying to base my work on examples here: http://www.haskell.org/haskellwiki/Simple_Servers
That sample, however, doesn't not compile complaining that it
Could not find module `System.Event'
After some googling I've found out that all declarations from that module were moved to GHC.Event, which has a remark in its documentation about being 'GHC internal'. Indeed, when i try to import GHC.Event I get the same error
Could not find module `GHC.Event'
How should I be supposed to import useful functions such as registerFd and friends? Is there anything I'm missing in my cabal file? I've got the following:
build-depends: base ==4.6.*, hslogger == 1.2.3, time == 1.4.0.*, old-locale, network == 2.4.1.2
I come with the background in languages like Java or Python where modular programming is enabled by packaging system and import directive (aka namespace aliasing). Historically MATLAB's approach to resolve problems like naming conflicts boils down to setting/playing with MATLABPATH, renaming/extending identifiers with prefixes, etc. So far I have been successfully playing with native MATLAB packaging by prepending plus sign "+" before the folder name (MATLAB notation for package also see here). Obviously they are very long to type ;-) Basically I am back to the similar problem as discussed here with no solution. So let me paraphrased for my particular angle:
Assume I have folder +mypackage defined containing file myfun.m with the function code of the same name.
How to achieve aliasing for MATLAB function inside the user (non-java) package as illustrated by the following python code:
from mypackage import myfun
?
[EDIT] Please note that AFAIK import keyword works only for java classes (with jvm attached to MATLAB process). No, import is working perfectly fine for both functions and aliases for objects and function of both Java and MATLAB origin.
Possibly related but not the same.
[EDIT2]
python's
from mypackage import myfun as anotherfun
is equivalent to MATLAB's
anotherfun = #mypackage.myfun
Doesn't
import mypackage.myfun
work?
link to documentation