Code Monkey home page Code Monkey logo

pyspm's People

Contributors

dineshpinto avatar ns-rse avatar oscholder avatar scholi 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyspm's Issues

TIFF image meta information

Hi Scholi
Thanks for sharing this toolbox.
Can it be used to extract metadata from an SPM tiff image file such as pixel to world distance mapping etc?

collaboration with pycroscopy

Hello @scholi,

First of all, great job on this amazing package! I am a developer on a package similar to PySPM, called pycroscopy. It seems that both packages are aligned towards the same / very similar goals. I thought that it would make sense for us to combine forces and produce something greater than the sum of its parts.

Would you consider collaborating with us on pycroscopy? Looking forward to hearing from you.

Weird topography values

Hi,

The 'Height Sensor' or 'Z sensor' channel values (i.e. the topography), seem to be a bit weird. For example:

scan = PfmFile(filelist[0])

chan = scan.get_channel()
xsize, ysize, unit = scan.get_size() # defined by me

fig, ax = plt.subplots(1,1)

im = ax.imshow(chan.pixels, extent=[0,xsize,0,ysize])
ax.set_title('{0} [{1}]'.format(chan.channel, chan.zscale))

append_colorbar(ax, im, label_size=10) # defined by me

Results in, as compared to Gwyddion:

pySPM Gwyddion
image image

Note that in both cases the minimum of the data has been shifted to zero (but not doing it still shows weird values). The 'nm' label has been produced via chan.zscale so should be consistent. Any ideas?

Cheers,

Edoardo

Calibration of ITM files

Hello,

Thanks for your previous assistance with my questions. I have been using your "reconstruct" function for making SI images from saved ITM (uncalibrated) files from the IonTof instrument. I was wondering if there is anyway to calibrate the raw ITM file. Otherwise, I currently have to compare the calibrated ITA file (calibrated with your spectragui) and the uncalibrated ITM file and try to spot the ion of interest. I was also wondering if you have any advice on making the reconstruct function compile faster. Currently, reconstructing 14 scans of a 512x512 image takes around 5+ minutes.

Thanks so much,
Shohini

"li" variable not defined in ITM.py

When running >>> res = AI.get_raw_spectrum(ROI=[ROI1, ROI2], prog=True, sf=sf, k0=k0)
I get the error that local variable "li" is referenced before assignment.

The code from the file is below. The error arises near the end "for k in li"

elif type(ROI) in [list, tuple]:
            multi_roi = True
           Spectrum = np.zeros((number_channels, len(ROI)), dtype=np.float32)
            for s in T:
                raw = self.get_raw_raw_data(s)
                rawv = struct.unpack('<{}I'.format(len(raw)//4), raw)
                i = 0
                while i < len(rawv):
                    b = rawv[i]
                    if b & 0xc000000000:
                        x = b & 0x0fffffff
                        y = rawv[i+1] & 0x0fffffff
                        dt = dts[x]
                        fp = dt%1
                        ip = int(dt)
                        li = []
                        for k, R in enumerate(ROI):
                            if R[y,x]:
                                li.append(k)
                        i += 3
                    else:
                        for k in li:
                                Spectrum[b-ip, k] += (1-fp)
                                Spectrum[b-ip-1, k] += fp
                        i += 1

Defining regions of interest (ROI)

Hi! I've been reading (and running) the "Introduction to pySPM a python library for ToF-SIMS data analysis" tutorial. When it comes to defining a ROI, the example you provide is by thresholding the SI data. I was wondering if there are other options to define a ROI, for example: drawing a rectangle in the SI intensity image (and then obtain the spectrum from the area inside the rectangle).
Thanks again!

Scaling parts of the spectrum

When using A.ShowSpectrum() is it possible to scale the spectrum to account for differences in intensity. As shown in the image.

Thanks

Normalisation of images

Hi Scholi,

Is it possible to normalise images, either by total count or by another image?

Thanks
Mat

Error while using correct_lines/ correct_slope on .spm- (Bruker-) data with different x-,y-dimension

Describe the bug
A clear and concise description of what the bug is.

When spm data is loaded while using the Bruker and SPM module, the functions correct_lines and correct_slope do not work and return the following Error:

"self.pixels -= np.tile(np.mean(self.pixels, axis=1).T, (self.pixels.shape[0], 1)).T
ValueError: operands could not be broadcast together with shapes (128,1024) (128,128) (128,1024)"

Furthermore, the plot with .show(pixels='False') returns an image with wrong y-dimension: here both axes are shown with the same range of the x axes.

The function works fine if i use an image with same x and y dimension.

To Reproduce
Snippet of code creating the error:

filename = 'testfile.spm'
scan = pySPM.Bruker(filename)
topoB.correct_lines(inline=True)
topoB.show()

topoB = scan.get_channel("Height Sensor")

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Information:

  • OS: [e.g. windows]
  • Python and pySPM version.

Please run the following and attach the result to your issue

import sys
import pySPM
import numpy as np
import scipy
import matplotlib as mpl
print("Python",sys.version)
print("pySPM",pySPM.__version__)
print("numpy",np.__version__)
print("scipy",scipy.__version__)
print("matplotlib", mpl.__version__)

Python 3.9.13 (main, Aug 25 2022, 23:51:50) [MSC v.1916 64 bit (AMD64)]
pySPM 0.2.23
numpy 1.21.5
scipy 1.9.1
matplotlib 3.5.2

Additional context
Add any other context about the problem here.

lower case augment support for get_channel() struct.error: unpack requires a buffer of 369664 bytes

Hi,
I'm not sure whether it was just me. I was intending to load and plot a .sxm file and here's the code:

import pySPM
from matplotlib import pyplot as plt
scan = pySPM.SXM('sxm/unnamed166.sxm')
print(scan.list_channels())
z = scan.get_channel('z')
print(z.pixels)
z.show()
plt.show()

It doesn't work and produce an error: struct.error: unpack requires a buffer of 369664 bytes
It is fixed by changing 'z' to capital 'Z', which is aligned with the channel name Z.

For anyone who gets this error as I did, make sure you use exactly the same channel name as in scan.list_channels().
It couldn't be better if the dev team can make lower case augment work.
Thanks!

reuse file format reader in afmformats

Hi Olivier,

I am the author of afmformats (used by PyJibe) and I was wondering whether it would make sense to incorporate the file-reader functionalities of pySPM in afmformats.

  1. I have previously only worked with force-distance data. Are the file formats you have used here plain image files or do they contain the raw force-distance trace data (i.e. cantilever deflection vs. piezo position)?
  2. What do you think about this? Does it even make sense?
  3. My initial thought was to just make pySPM a dependency of afmformats, but then I saw that pySPM depends on several other packages which I would like to avoid. I see that pySPM is licensed under the Apache 2.0 license which would be compatible with the MIT license (afmformats), as far as I know.

Cross-ref: AFM-analysis/afmformats#18

https://github.com/scholi/pySPM_data. This URL could not be found .

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Snippet of code creating the error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Information:

  • OS: [e.g. windows]
  • Python and pySPM version.

Please run the following and attach the result to your issue

import sys
import pySPM
import numpy as np
import scipy
import matplotlib as mpl
print("Python",sys.version)
print("pySPM",pySPM.__version__)
print("numpy",np.__version__)
print("scipy",scipy.__version__)
print("matplotlib", mpl.__version__)

Additional context
Add any other context about the problem here.

SPM_image.get_extent() fails for a Bruker AFM image

The following:

scan = pySPM.Bruker(filename)
chan = scan.get_channel()
chan.get_extent()

Results in an error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-365-32333116e5f9> in <module>
----> 1 chan.get_extent()

c:\python37\lib\site-packages\pySPM\SPM.py in get_extent(self)
    464         Get the image extent in real data
    465         """
--> 466         W = self.size['recorded']['real']['x']
    467         H = self.size['recorded']['real']['y']
    468         return (0, W, 0, H)

KeyError: 'recorded'

.pixels is upside-down

Hi Olivier,

Thanks again for the package. I just wanted to turn your attention to the artefact I encountered. After loading the .spm file and choosing the channel, when I plot the numpy array I get from .pixels, it is upside-down in respect to the original image that gets shown when using your .show() function. There seems to be an np.flipud missing or something...

Thanks,
Dejan.

Controlling image axix label size font type..etc

Hello

I am quite new to python so some guideline would be nice

I am plotting AFM with the pySPM, everything is good however, I would want to also control the fontsize and type of the label, ticks, axes thickness and unit...etc. For other plots I can use matplotlib.pyplot to control these elements but not here?

Thanks.

Bruker get_channel floating point parsing error

Describe the bug
Hi there 😄

We have been using pySPM for a while now to open Bruker .spm files, and it has been going seamlessly. Today we have noticed that on files that previously definitely loaded properly, it now throws this error. The files are non-square in their aspect ratio.

The issue appears to be the handling of floating point values in the get_channel() method of the Bruker class.

What is weird is that this error happens on both version 0.2.23 and 0.5.1 and manually setting the versions to previous versions does not fix it.

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[9], [line 7](vscode-notebook-cell:?execution_count=9&line=7)
      [3](vscode-notebook-cell:?execution_count=9&line=3) data = pySPM.Bruker(file)
      [5](vscode-notebook-cell:?execution_count=9&line=5) data.list_channels()
----> [7](vscode-notebook-cell:?execution_count=9&line=7) height = data.get_channel('Height')

File [/opt/homebrew/Caskroom/miniforge/base/envs/new/lib/python3.10/site-packages/pySPM/Bruker.py:173](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/new/lib/python3.10/site-packages/pySPM/Bruker.py:173), in Bruker.get_channel(self, channel, backward, corr, debug, encoding, lazy, mfm)
    [171](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/new/lib/python3.10/site-packages/pySPM/Bruker.py:171)     print("xres/yres", xres, yres)
    [172](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/new/lib/python3.10/site-packages/pySPM/Bruker.py:172) scan_size = self.layers[i][b'Scan Size'][0].split()
--> [173](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/new/lib/python3.10/site-packages/pySPM/Bruker.py:173) aspect_ratio = [int(x) for x in self.layers[i][b'Aspect Ratio'][0].split(b":")]
    [174](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/new/lib/python3.10/site-packages/pySPM/Bruker.py:174) if debug:
    [175](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/new/lib/python3.10/site-packages/pySPM/Bruker.py:175)     print("aspect ratio", aspect_ratio)

File [/opt/homebrew/Caskroom/miniforge/base/envs/new/lib/python3.10/site-packages/pySPM/Bruker.py:173](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/new/lib/python3.10/site-packages/pySPM/Bruker.py:173), in <listcomp>(.0)
    [171](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/new/lib/python3.10/site-packages/pySPM/Bruker.py:171)     print("xres/yres", xres, yres)
    [172](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/new/lib/python3.10/site-packages/pySPM/Bruker.py:172) scan_size = self.layers[i][b'Scan Size'][0].split()
--> [173](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/new/lib/python3.10/site-packages/pySPM/Bruker.py:173) aspect_ratio = [int(x) for x in self.layers[i][b'Aspect Ratio'][0].split(b":")]
    [174](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/new/lib/python3.10/site-packages/pySPM/Bruker.py:174) if debug:
    [175](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/new/lib/python3.10/site-packages/pySPM/Bruker.py:175)     print("aspect ratio", aspect_ratio)

ValueError: invalid literal for int() with base 10: b'0.51216'

To Reproduce
file used:
not_working_file.spm.zip

I had to compress it since GitHub won't allow .spm uploads. I hope this doesn't corrupt it.

from pathlib import Path

import pySPM

print("pySPM version: ", pySPM.__version__)

file = Path('/Users/sylvi/Downloads/not_working_file.spm')

data = pySPM.Bruker(file)

data.list_channels()

height = data.get_channel('Height')

Expected behavior
Loading the height channel data as usual.

Screenshots
image

Information:

  • OS: Windows 10 (intel x86), macOS Sonoma (ARM M1 Pro)
  • Python version: 3.10.9
  • PySPM version: 0.5.1

Please run the following and attach the result to your issue

import sys
import pySPM
import numpy as np
import scipy
import matplotlib as mpl
print("Python",sys.version)
print("pySPM",pySPM.__version__)
print("numpy",np.__version__)
print("scipy",scipy.__version__)
print("matplotlib", mpl.__version__)
Python 3.10.9 | packaged by conda-forge | (main, Feb  2 2023, 20:26:08) [Clang 14.0.6 ]
pySPM 0.5.1
numpy 1.26.3
scipy 1.10.1
matplotlib 3.7.1

Unable to read a SXM file from Nanonis

Describe the bug
I tried in the last days to use your package for read .sxm data to python to get an array of the Topo signal of my measurements. By doing that I used your documentation and installed the both .whl datas you need to run your code. I simply tried to copy your section bout reading .sxm file and get always the error:

File c:\users\rbrue\nextcloud\python projekte\read nanonis.py:24
S = pySPM.SXM(filename)

File ~\AppData\Roaming\Python\Python311\site-packages\pySPM\SXM.py:36 in init
self.header[key].append(l.decode('ascii').split())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 11: ordinal not in range(128)

To Reproduce

#import nanonis_load
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl

import os
from IPython import display
import pySPM

from pySPM_data import get_data

filename = get_data('C:\\Users\\rbrue\\Nextcloud\\Data Lab 013\\Sample 09_22\\09_2022\\FeTa110_20220923_CrTip_9935R_4.2K_2.4T_011.sxm')
S = pySPM.SXM(filename)

Expected behavior
Basically I expect that the reading work properly.

Information:

  • Windows 10
  • Python 3.11.3
  • pySPM pyspm-0.3.2-py3-none-any.whl
  • pySPM_data pySPM_data-0.2.4-py3-none-any.whl

Please run the following and attach the result to your issue

numpy 1.25.1
scipy 1.11.1
matplotlib 3.7.2

Additional context
I comment also the line where the version of pySPM is trying to print because there I get this error:

AttributeError: module 'pySPM' has no attribute 'version'

That's also why I don't show the version of pySPM in the last section.
Maybe that problem is linked to the other but I am not sure.

SurfaceLab7 .itax & .itm file support

Hi PySPM Team,

Thank you for this useful approach to analysing SIMS data.

I am a new user of python and surface lab, so I apologise if there are any obvious oversights from me.

The method works great for studying .ita files from SurfaceLab 6 however I am having difficulty opening .itax and .itm files from Surfacelab 7

Error for opening surfacelab7 .itm file
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 39: ordinal not in range(128)

If possible please could you inform me if there is support for IonToF Surfacelab 7 file formats in particular processing of .itax and .itm file formats.

Many thanks,

V

get_channel("Height") issue

One more issue I am running into that not being able to view height channel. I am able to get .list_channels() to work, but .get_channel("Height") is not working. Below is a screen shot of my jupyter notebook showing the error:

height channel error

This file version is v5.15b7 if that helps.

Thank you,

Kurt

Unable to load an approach curve from Bruker Icon

Hi scholi,

Thank you for your very handy library. I have been trying to use it on approach-retract curve for AFM and I've been running into troubles. Is this feature already implemented ?

List of channels empty when importing an approach curve
While the creation of the object works, the library writes down an empty list of channels when loading the spm file of an approach curve of a Bruker Icon Dimension (using the ramp option in the dedicated software.

meas = Bruker(path); meas.list_channels(); data = meas.get_channel();

Expected behavior
I'm trying to recover this kind of data
test_image

Information:
Windows 10 64bits
Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)]
pySPM 0.2.23
numpy 1.20.1
scipy 1.6.2
matplotlib 3.3.4

OperationalError: unable to open database file

Hi Olivier,

I am having trouble loading pySPM into Jupyter Notebook. I have installed successfully pySPM but when i try to 'import pySPM' i get the following error:

OperationalError: unable to open database file

I assume this is something to do with sqlite but, as a python novice, have been unable to troubleshoot it successfully - is there anything I can try? I have all of the prerequisites installed, as well as sqlite3. Apologies if this is issue is trivial.

Many thanks,

Davis

Bruker spm format: request for explanantion of overall scale computation

Hello,
I have great difficulties for understand how is computed the final factor by which is multiplied the raw data (e.g. 32 bits signed integer) to obtain the correct unit (meter in the below example) For example in my actual file I have

\*Ciao image list
\Data offset: 80960
\Data length: 1048576
\Bytes/pixel: 4
\Start context: OL
\Data type: AFM
\Data Type Description: 
\Note: 
\Plane fit: 0 0 0 5
\Frame direction: Down
\Capture start line: 0
\Color Table Index: 12
\Relative frame time: 5091.9
\Invalid Data Flag: None
\Invalid Data Fill: None
\Samps/line: 512
\Number of lines: 512
\Aspect Ratio: 1:1
\Scan Size: 10 10 ~m
\Scan Line: Main
\Line Direction: Retrace
\Highpass: 0
\Lowpass: 0
\Realtime Planefit: Line
\Offline Planefit: None
\Valid data start X: 0
\Valid data start Y: 0
\Valid data len X: 512
\Valid data len Y: 512
\Tip x width correction factor: 1
\Tip y width correction factor: 1
\Tip x width correction factor sigma: 1
\Tip y width correction factor sigma: 1
\@2:Image Data: S [ZSensor] "Height Sensor"
\@Z magnify: C [2:Z scale] 4.14356 
\@2:Z scale: V [Sens. ZsensSens] (0.0000000000370204 V/LSB) 0.159002 V
\@2:Z offset: V [Sens. ZsensSens] (0.0000000000370204 V/LSB) 0.000000 V

I don't manage to recover the actual factor from numbers in the lines

\@Z magnify: C [2:Z scale] 4.14356 
\@2:Z scale: V [Sens. ZsensSens] (0.0000000000370204 V/LSB) 0.159002 V
\@2:Z offset: V [Sens. ZsensSens] (0.0000000000370204 V/LSB) 0.000000 V

Thanks for help.

S.

get_channel does not work for specific afm channel - value error

I am trying to open from my Bruker .spm data some channel (Input 2).

when I write:

Current = ScanB.get_channel(channel='Input2')

it shows me following error message:

"""Current = ScanB.get_channel(channel='Input2')

File ~\AppData\Roaming\Python\Python311\site-packages\pySPM\Bruker.py:165 in get_channel
data = self._get_raw_layer(i, debug=debug) * scale * scale2

File ~\AppData\Roaming\Python\Python311\site-packages\pySPM\Bruker.py:64 in _get_raw_layer
rows = int(self.layers[i][b'Samps/line'][0])

ValueError: invalid literal for int() with base 10: b'0 0' """

Could you please help me to solve this problem? Input2 is getting from cyclic voltammetry. I am saving potential into Input1, and get_channel in this case is working.

Thanks in advance.

Question regarding mass calibration and dealing with iontof image files

Hello,

Thank you for writing this very useful package. I have a few questions regarding the package.

(1) I have been trying to calibrate some ita files from our IONTOF V using your sf, k0 = E.auto_mass_cal(fitting_peaks=["C","CH","CH2", "CHS"]) function and get the following set of errors:. Could you please explain why this is happening? The files I am using can be opened and plotted using your other commands.

MissingBlock Traceback (most recent call last)
in
1 fig, ax = plt.subplots(2, 2, figsize=(21,6))
----> 2 sf, k0 = E.auto_mass_cal(fitting_peaks=["C","CH","CH2","CHS"])
3 E.show_spectrum_around(12, ax=ax[0,1], sf=sf, k0=k0);

c:\users\sen\appdata\local\programs\python\python37\lib\site-packages\pySPM\ITM.py in auto_mass_cal(self, t, S, pos, debug, error, Range, fitting_peaks, apply, **kargs)
410 time_width = 1e10self.root.goto('propend/Instrument.LMIG.Chopper.Width').get_key_value()['float']
411 if t is None or S is None:
--> 412 t, S = self.get_spectrum(time=True)
413 N = np.prod(list(self.size['pixels'].values())) * self.Nscan
414 mask = S > N
0.01/time_width

c:\users\sen\appdata\local\programs\python\python37\lib\site-packages\pySPM\ITM.py in get_spectrum(self, sf, k0, scale, time, error, **kargs)
598 """
599 RAW = zlib.decompress(self.root.goto(
--> 600 'filterdata/TofCorrection/Spectrum/Reduced Data/IITFSpecArray/'+['CorrectedData','Data'][kargs.get('uncorrected',False)]).value)
601 if scale is None:
602 scale = self.scale

c:\users\sen\appdata\local\programs\python\python37\lib\site-packages\pySPM\Block.py in goto(self, path, lazy)
543 p = e['name']
544 idx = e['id']
--> 545 s = s.goto_item(p, idx, lazy=lazy)
546 return s
547

c:\users\sen\appdata\local\programs\python\python37\lib\site-packages\pySPM\Block.py in goto_item(self, name, idx, lazy)
486 name: name of the children's block
487 """
--> 488 Idx = self.get_index(name, idx, lazy=lazy)
489 self.f.seek(Idx)
490 return Block(self.f, parent=self)

c:\users\sen\appdata\local\programs\python\python37\lib\site-packages\pySPM\Block.py in get_index(self, name, idx, lazy)
513 return l['bidx']
514 i+=1
--> 515 raise MissingBlock(self, name, idx)
516
517 def goto(self, path, lazy=False):

MissingBlock: Missing block "root/filterdata" with index 0

(2) Alternatively, is there a different manual method or mass calibration? I have attempted using the spectra tool but the window opens but my file doesn't load. These same files load when using your other commands for plotting the spectra so I am unsure what the issue it. I get errors like this:
Traceback (most recent call last):
File "c:\users\sen\appdata\local\programs\python\python37\lib\site-packages\matplotlib\cbook_init_.py", line 216, in process
func(*args, **kwargs)
File "c:\users\sen\appdata\local\programs\python\python37\lib\site-packages\pySPM\tools\spectra.py", line 223, in on_motion
self.refresh()
File "c:\users\sen\appdata\local\programs\python\python37\lib\site-packages\pySPM\tools\spectra.py", line 62, in refresh
self.yAxisScaleChanged()
File "c:\users\sen\appdata\local\programs\python\python37\lib\site-packages\pySPM\tools\spectra.py", line 116, in yAxisScaleChanged

(3) Lastly, I have many ITA and ITM spectra/image files where I didn't do any creation of peak lists on SurfaceLab. I want to be able to chose peaks and reconstruct the corresponding images. Is there a way to do this using PySPM? Most of your image examples involve files that already had peak lists created.

I am using this package because I currently don't have access to SurfaceLab anymore for data analysis and would very much appreciate your help.

Thank you,
Shohini

Need Engage X and Y Pos info

I'm trying to pull out "Engage X Pos" and "Engage Y Pos" from a bruker file.

parameter lists

I don't see this in the existing list I get from layers:

existing list

Is there another way to get that info from the file? It seems you are mostly only pulling the Ciao image list...not the File List shown in the first image that is a screen shot of nanoscope.

Thanks,

Kurt

Wired z axis values

Hi,

the z scale (height) values from my code seems a bit wired.

filename="CaptureFile.0_00019.spm"
ScanB = pySPM.Bruker(filename)
Height = ScanB.get_channel("Height")
Height2 = Height.correct_plane(inline=False)
fig, ax = plt.subplots(1,1, figsize=(5,5))
p=Height2.zero_min().show(ax=ax, cmap="inferno", title="")
cbar=plt.colorbar(p,fraction=0.046)
cbar.set_label(label=Height2.zscale,rotation=270, labelpad=10)
plt.tight_layout()

This is the result from the code:
Python Code Output

This is the same picture opened through Gwyddion:
Gwyddion Output

This is the source file:
CaptureFile.0_00019.zip

I plotted the same graphs using a file from an other issue (see below). In that file there is a

[ZSensor] "Height Sensor"

and the python plot is identical to the Gwyddion graph.

e17089.0_00001.zip

Cheers

Get Data

Hi scholi,

I'm working through your introduction notebook right now. I just got an error 404 when trying to upload your SPM data package, either from the webpage or using

pip install -U pySPM_data-0.2.4-py3-none-any.whl

Do you have any suggestions?

Ryan

Issue with median of differences correction

Hi,

I noticed a difference in the median difference correction between pySPM and Gwyddion.
The first row shows the each step of the image correction in python, the second one shows the corresponding Gwyddion images. Only the last figures are different even if the are both correceted by the median of differences.

Gwyddion vs Python

Here you can find the source code:

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import pySPM

file="01201542.0_00001"
filename=file+".spm"

ScanB = pySPM.Bruker(filename)
Height = ScanB.get_channel("Height")
Height_corrected = Height.correct_plane(inline=False)

import copy

Height_corrected_1 = copy.deepcopy(Height_corrected) # make deepcopy of object otherwise you will just change the original
Height_corrected_1.correct_median_diff(inline=True)
fig, ax = plt.subplots(1,3,figsize=(15,7))
Height.show(ax=ax[0], title="No corrections", cmap="viridis")
Height_corrected.show(ax=ax[1], title="Plane correction", cmap="viridis");
Height_corrected_1.show(ax=ax[2], title="Plane correction + median of differences", cmap="viridis");
plt.tight_layout()
plt.savefig(file+"comparison.png")

Here you can find the source file:
01201542.0_00001.zip

I'm currently using juyter notebook on windows 10.
These are the versions of the libraries:

Python 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)]
pySPM 0.2.22
numpy 1.19.2
scipy 1.5.2
matplotlib 3.3.2

Cheers

struct.error: unpack requires a buffer of 80 bytes

Hi Scholi,

I have been trying to use spectra on my data (TOFion) and I received the following error

To Reproduce
Snippet of code creating the error
image

  • OS: windows
  • Python 3.7.3 and pySPM version.

Please run the following and attach the result to your issue
`Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]
pySPM 0.2.21
numpy 1.16.4
scipy 1.3.0
matplotlib 3.1.0


Thanks
Ibrahim 

Error when opening an ITM File generated by Surface Lab 7

Dear developer(s),

I was trying to use pySPM for reading ITM files generated by SurfaceLab 7.X. This is the version that creates the .itax files instead of the .ita, but, together with it, the software also prints .itm files, which I hoped could be read by pySPM. Is it incorrect?

In particular, I tried something very simple:

import pySPM
AI = pySPM.ITM("test.itm", readonly=True)

But it raises the following error (if I try removing the readonly option, of course nothing change) :

MissingBlock Traceback (most recent call last)
Input In [3], in <cell line: 6>()
2 path_test = path + "\2022_03_24_non_coated_NMC_spectrometry_positive_01_TL.itm"
4 print(path_test)
----> 6 AI = pySPM.ITM("test.itm", readonly=True)

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pySPM\ITM.py:114, in ITM.init(self, filename, debug, readonly, precond, label)
112 except:
113 self.Nscan = None
--> 114 self.spp = self.root.goto("propend/Registration.Raster.ShotsPerPixel").get_key_value()['int']
115 try:
116 R = [z for z in self.root.goto('MassIntervalList').get_list() if z['name'] == 'mi']

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pySPM\Block.py:545, in Block.goto(self, path, lazy)
543 p = e['name']
544 idx = e['id']
--> 545 s = s.goto_item(p, idx, lazy=lazy)
546 return s

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pySPM\Block.py:488, in Block.goto_item(self, name, idx, lazy)
482 @deprecated("gotoItem")
483 def goto_item(self, name, idx=0, lazy=False):
484 """
485 Return a new Block instance of a child of the current Block
486 name: name of the children's block
487 """
--> 488 Idx = self.get_index(name, idx, lazy=lazy)
489 self.f.seek(Idx)
490 return Block(self.f, parent=self)

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pySPM\Block.py:515, in Block.get_index(self, name, idx, lazy)
513 return l['bidx']
514 i+=1
--> 515 raise MissingBlock(self, name, idx)

MissingBlock: Missing block "/propend/Registration.Raster.ShotsPerPixel" with index 0

Thanks in advance for your help, I am really looking forward for using this library!

Teo Lombardo

Nonsquare scans Bruker files (.spm)

Hello, thank you very much for your work, it is great (and very time efficient) to reopen the Bruker files with python !

I have a little trouble with opening scans that are non square (where the aspect ratio is not 1:1). For example, I have a 2:1 aspect ratio scan, X size is 10 µm and Y size = X size/2 = 5 µm, 256 pixels in X, 128 pixels in Y. When I use pySPM, the scan becomes a 10*10 µm scan...

Thanks in advance,

Guillaume

Support for Bruker version 0x09300201

Hi,

Thanks for the code first of all - very nice! I can read without any issues Bruker files version 0x09010300, but get weird images when opening newer ones of version 0x09300201 -- in the same way I would if I were to open them with say an old Gwyddion release. Any clue what the difference between them is? If you give me some info I could try to add support for the newer version myself.

Cheers!

Question: basic plotting code

Not really a python user and trying to plot a basic SPM image. This is what I did:

from pySPM import *
a = Bruker("./pathTo/file.spm")
a.list_channels() # S [ZSensor] "Height Sensor"

a.get_channel("Height Sensor").show() 
<matplotlib.image.AxesImage object at 0x7fdd15970790>

# but nothing shows

The pixels are logged as an array type of object so I don't know what I am missing here. Would be good to just get some hint.

PD: Also tried plt.show() but it isn't really an image of the data, just a color gradient.

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.