| Literature DB >> 34875998 |
Zao Liu1,2, Zhiwei Chen3, Kan Song4.
Abstract
BACKGROUND: Software for nuclear magnetic resonance (NMR) spectrometers offer general functionality of instrument control and data processing; these applications are often developed with non-scripting languages. NMR users need to flexibly integrate rapidly developing NMR applications with emerging technologies. Scripting systems offer open environments for NMR users to write custom programs. However, existing scripting systems have limited capabilities for both extending the functionality of NMR software's non-script main program and using advanced native script libraries to support specialized application domains (e.g., biomacromolecules and metabolomics). Therefore, it is essential to design a novel scripting system to address both of these needs. RESULT: Here, a novel NMR scripting system named SpinSPJ is proposed. It works as a plug-in in the Java based NMR spectrometer software SpinStudioJ. In the scripting system, both Java based NMR methods and original CPython based libraries are supported. A module has been developed as a bridge to integrate the runtime environments of Java and CPython. The module works as an extension in the CPython environment and interacts with Java via the Java Native Interface. Leveraging this bridge, Java based instrument control and data processing methods of SpinStudioJ can be called with the CPython style. Compared with traditional scripting systems, SpinSPJ better supports both extending the non-script main program and implementing advanced NMR applications with a rich variety of script libraries. NMR researchers can easily call functions of instrument control and data processing as well as developing complex functionality (such as multivariate statistical analysis, deep learning, etc.) with CPython native libraries.Entities:
Keywords: Artificial intelligence; CPython; Data processing; Instrument control; Java; NMR; Script; Software
Mesh:
Year: 2021 PMID: 34875998 PMCID: PMC8650269 DOI: 10.1186/s12859-021-04492-y
Source DB: PubMed Journal: BMC Bioinformatics ISSN: 1471-2105 Impact factor: 3.169
Fig. 1The relationship between SpinSPJ and SpinStudioJ. SpinStudioJ is a NMR software for spectrometers. It is built with a plugin architecture called Eclipse Rich Client Platform which integrates the functionalities as a plugin style. SpinSPJ works as a plugin in SpinStudioJ. SpinSPJ can call the Java based functions of instrument control and data processing, as well as using the native libraries of CPython
Fig. 2Architecture of the proposed SpinSPJ scripting system. The three components play different roles in the scripting system. Component Java extends the functionality of SpinStudioJ’s main program by the mechanism of OSGi. Component CPython offers the powerful libraries such as Numpy, SciPy, Pandas, Tensorflow, etc. Component C works as a bridge to connect Java and CPython to make their resources accessible to each other
Fig. 3Execution workflow of the proposed SpinSPJ scripting system. The arrows denote the execution flow of script statements in each components. Firstly, by importing the module spinspj, the scripting system installs an importer hook, which defines how to find (“find_module()”) and load (“load_module()”) the module spinspj. Secondly, the fields and methods of module spinspj are wrapped as PyJField and PyJMethod, which enable the Java based fields and methods being called as a conventional CPython style through the JNI
Fig. 4A screenshot of the NMR scripting editor. The scripting editor offers an environment to edit and execute the scripts of SpinSPJ. The script code and output are respectively displayed in the middle and bottom area of the editor’s interface
General functions in the proposed SpinSPJ scripting system
| Function name | Description | Example |
|---|---|---|
| aij(n) | Inject a sample, The sample number is “n” | aij(2) |
| alock() | Lock the field automatically | alock() |
| stm(nucleus) | Automatic tuning and matching | stm('H1') |
| smartmapshim() | Create a gradient shim map and perform the shimming | smartmapshim() |
| smartshim() | Perform the gradient shimming using the existing field map | smartshim() |
| searchshim(algorithm, evaluation, channels, iteration) | Searching for better shim values with an algorithm | searchshim('simplex', 'FIDArea', 'z1-z2', 50) |
| vartemp(target, timeout) | Vary temperature to “target” celsius degree within “timeout” seconds | vartemp(35.5, 240) |
| spin(target, timeout) | Rotate the sample with the spin rate of “target” Hz within “timeout” seconds | spin(20, 200) |
| setshimvalue(channel, value) | Set the shim value of shim coil in “channel” | setshimvalue('z1', 1000) |
| go() | Start the data acquisition | go() |
| setactws(path) | Set the active workspace | setactws('D:/1.nmr') |
| setparam(name, value) | Set the value of parameter of the active workspace | setparam('ns', 4) |
| getfid(path) | Get the FID data of the workspace whose storage path is “path” | getfid('D:/1.nmr') |
| getspec(path) | Get the spectrum data of the workspace whose storage path is “path” | getspec('D:/1.nmr') |
| setspec(path, data) | Set the spectrum data of the workspace whose storage path is “path” | setspec('D:/1.nmr', data) |
| wft() | Perform the data processing with weighting and Fourier transform | wft() |
| np.multiply(a, b) | Matrix multiplication | np.multiply(a, b) |
| np.median(a) | Compute median of an array | np.median(a) |
| plt.plot(x, y) | Draw a curve | plt.plot(x, y) |
| scipy.optimize.curve_fit (func, x, y) | Compute curve fitting | scipy.optimize.curve_fit(func, x, y) |
Fig. 5Searching shimming by FID area and simplex algorithm. As the evaluation of field’s homogeneity, FID area can be acquired and calculated by calling Java based method; the library SciPy of CPython provides the simplex algorithm to optimize the shim values with an iterative style. The homogeneity of the magnetic field is much better after utilizing the searching shimming method
Fig. 6Principal component analysis. After some basic data processing, PCA is easily performed with the help of the CPython library scikit-learn
Fig. 7Non-uniform sampling by deep learning. The original FID data is read by calling the function offered by the main program of SpinStudioJ. The reconstruction method based on deep learning is easily performed with the help of CPython libraries such as Tensorflow, keras, cuDNN, etc.