Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problems with running example files #4

Open
isikfurkan opened this issue Apr 20, 2024 · 4 comments
Open

problems with running example files #4

isikfurkan opened this issue Apr 20, 2024 · 4 comments

Comments

@isikfurkan
Copy link

isikfurkan commented Apr 20, 2024

Hi I am totally new in python, but the stemtool is what I exactly need. I installed it via pip install stemtool. I am trying to play with example files to understand how things work. But I could not make it work, most probably due to my lack of knowledge. For instance when I tried to run afit example I face the error:

Basically, I loaded the image file changing or adding some parts as shown below to the original settings:
from PIL import Image st.tic() stem_image = Image.open('stem_image.tif') stem_image = np.array(stem_image) st.toc() atoms = st.afit.atom_fit(stem_image, float('0.027466'), str('nm'))
Traceback (most recent call last): File "C:\Users\Furkan\Desktop\pythonfiles\tekstemtool\example.py", line 31, in <module> atoms.peaks_vis(0.1, 0.1) File "C:\Users\Furkan\Desktop\pythonfiles\tekstemtool\.venv\lib\site-packages\stemtool\afit\atom_positions.py", line 1083, in peaks_vis data_peaks = skfeat.peak_local_max( TypeError: peak_local_max() got an unexpected keyword argument 'indices'
If I remove the 'indices=False' part then I face:

Choose your points in a clockwise fashion, or else you will get a wrong result Traceback (most recent call last): File "C:\Users\Furkan\Desktop\pythonfiles\tekstemtool\example.py", line 31, in <module> atoms.peaks_vis(0.1, 0.1) File "C:\Users\Furkan\Desktop\pythonfiles\tekstemtool\.venv\lib\site-packages\stemtool\afit\atom_positions.py", line 1091, in peaks_vis self.peaks = (st.afit.remove_close_vals(peaks, pixel_dist)).astype(np.float) File "C:\Users\Furkan\Desktop\pythonfiles\tekstemtool\.venv\lib\site-packages\numpy\__init__.py", line 353, in __getattr__ raise AttributeError(__former_attrs__[attr]) AttributeError: module 'numpy' has no attribute 'float'.np.floatwas a deprecated alias for the builtinfloat. To avoid this error in existing code, use floatby itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, usenp.float64here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
When I replace all the 'np.float' with 'np.float64' or just 'float', I got this:

Choose your points in a clockwise fashion, or else you will get a wrong result Traceback (most recent call last): File "C:\Users\Furkan\Desktop\pythonfiles\tekstemtool\example.py", line 33, in <module> atoms.refine_peaks() File "C:\Users\Furkan\Desktop\pythonfiles\tekstemtool\.venv\lib\site-packages\stemtool\afit\atom_positions.py", line 1109, in refine_peaks st.afit.med_dist(self.peaks[0:test, :]) File "C:\Users\Furkan\Desktop\pythonfiles\tekstemtool\.venv\lib\site-packages\stemtool\afit\atom_positions.py", line 829, in med_dist warnings.filterwarnings("ignore") NameError: name 'warnings' is not defined
So I added to the atom_positions.py file Import warnings

Finally I got these results presented in the attached pdf document.
Atom_Fitting.pdf
the exported jupyter code ad python code in txt form:
atom_fitting.txt

My TEM image in png form is also attached here:
stem_image

And I could not move further, that was the end of my python skills :). And I faced some other problems with other examples aswell and I could not make any of them work
I would be more than appreciated if you could help.
Best!

@isikfurkan isikfurkan changed the title peak_local_max() got an unexpected keyword argument 'indices' problems with running example files Apr 20, 2024
@dxm447
Copy link
Collaborator

dxm447 commented Apr 20, 2024

Hi @isikfurkan ,
Could you share the full code that led to this error?

@isikfurkan
Copy link
Author

Hi I included it in the updated version of my comment

@isikfurkan
Copy link
Author

Alrigt, for this specific example file (Atom_Fitting.ipnby) the problem is scikit-image version related. In the repo, the atom_positions.py file has 1082nd line:
data_peaks = skfeat.peak_local_max(
1083 self.data_thresh, min_distance=int(pixel_dist / 3), indices=False
where current scikit-image package does not support the indices parameter. Removing that part does not solve the problem. Yet installing an old version (via pip install scikit-image==0.18.3) worked.
PS1: You should add "import warnings" to atom_positions.py"
PS2: You should also add hdf5storage, tqdm, nptyping, pyfftw, distributed, zarr and ncempy packages to requirements

@isikfurkan
Copy link
Author

isikfurkan commented Nov 10, 2024

If you want to use current scikit-image package, here is the revised atom_positions.py (ChatGPT rocks)
atom_positions.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants