scholi / pySPM

Python library to handle Scanning Probe Microscopy Images. Can read nanoscan .xml data, Bruker AFM images, Nanonis SXM files as well as iontof images(ITA, ITM and ITS).
Apache License 2.0
62 stars 33 forks source link

Question regarding mass calibration and dealing with iontof image files #11

Closed sbrtn closed 5 years ago

sbrtn commented 5 years ago

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 = 1e10*self.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
scholi commented 5 years ago

Hi Shohini, ① Some ITA files differs in the content. This is specially true if you use the latest version of iontof. This might the reason why some data are not found by the library. If you can send me the data, then I can see what is wrong. Otherwise it will be tricky for me to guess what is the exact problem.

You can nevertheless do the calibration yourself. You can retrieve the time and intensity and perform the calibration yourself. For this purpose, use the method get_spectrum. You can provide a sf and k0 arguments which are the mass calibration parameters. You can also retrieve the time instead of the mass with time=True. Then look for the times of known peaks, such as H, C, CH, CH₂, CH₃, ... and perform a least square in order to find the exact mass calibrations parameters. You will find more details on the mass calibration on the wiki: https://github.com/scholi/pySPM/wiki/Mass-calibration

② Your error seems to be related to matplotlib. Which version do you have?

import matplotlib
print(matplotlib.__version__)

I use 2.1.0. If you have a lower version, try to upgrade it. WIth pip for ex.:

pip install --upgrade matplotlib

③ Yes you can reconstruct the data. Did you have look at the doc ? : https://nbviewer.jupyter.org/github/scholi/pySPM/blob/master/doc/pySPM%20Documentation.ipynb#SI-image-reconstruction

For that you need the ITM file (not the ITA) and then give the list of peaks with lower, upper mass given as a tuple. You should also pass the mass calibration parameters: sf and k0 as argument.

Let me know if this works.