Loading data
To start analysis with ILTpy, you would need the experimental or synthetic data and the input sampling information (e.g. timings or delays in magnetic resonance experiments).
The data and input sampling is provided using the
data
andt
arguments respectively.Before importing to ILTpy, you may need to apply any applicable data processing steps and prepare the data by,
For inversion, ILTpy expects data which has Gaussian identically distributed noise with a variance of 1. Most experimental datasets need to be scaled with the noise level in order to fulfill this condition. See setting the noise variance to unity in ILTpy FAQs.
The size of the data and the output sampling vector (size of distribution) affects the time and computational resources needed for the inversion. See data reduction in ILTpy FAQs.
You can also consult Examples for data preparation strategies.
The main data loading function in ILTpy is
iltload
which accepts the argumentsdata
andt
and returns anIltData
object (IltData structure).To load data using
iltload
, data should be provided as numpy arrays as described below.
1. From NumPy arrays
NumPy Arrays (numpy.ndarray) containing processed data (e.g. NMR data after routine processing steps) can be passed directly to iltload
and is the recommended way to load data.
Text files can be read using NumPy to get numpy arrays as shown below.
import numpy as np
# Assuming data and input sampling vector is stored in the text files data.txt and t1.txt respectively
data1D = np.loadtxt('data.txt')
t1 = np.loadtxt('t1.txt')
More information about loading data from text files using NumPy can be found here.
Once you have the data and input sampling as numpy arrays, pass it to iltload
by using the data
and t
keyword arguments.
1D inversions :
import iltpy as ilt
# Assuming data1D and t1 are numpy arrays with the data and the sampling vector.
data1D_ILT = ilt.iltload(data=data1D,t=t1)
See an example for 1D inversion.
Multi-dimensional inversions (all dimensions are inverted):
# For 2D inversions, provide the input sampling vectors corresponding to each dimension as a list
# Assuming data2D is a 2D numpy array containing processed data and
# t1,t2 are numpy arrays with sampling vectors corresponding to each dimension.
data2D_ILT = ilt.iltload(data=data2D,t=[t1,t2])
# The same scheme can be used for nD inversion, by specifying the n input sampling vectors as a list.
# e.g in case of 3D data:
# data3D_ILT = ilt.iltload(data=data3D,t=[t1,t2,t3])
This scheme extends naturally to higher dimensions by supplying a list of sampling vectors matching the number of dimensions. See an example for 2D inversion or 3D inversion where all dimensions are inverted.
Multi-dimensional inversions (only some dimensions are inverted):
If only certain dimensions are inverted, you need to provide input sampling vectors only for those dimensions. For the remaining dimensions, ILTpy will internally create unit-spaced sampling arrays with lengths equal to the size of the non-inverted dimensions.
# Assuming data2D is a 2D numpy array where only the first dimension needs to be inverted.
# t1 is a numpy array with sampling vector corresponding to first dimension.
# in this case, the input sampling vector is generated internally and
# corresponds to a 1D numpy array with unity spacing and length equal to the size of uninverted dimension.
data2D_ILT = ilt.iltload(data=data2D,t=t1)
See an example for a 2D inversion where only the first dimension is inverted or a 3D inversion where only the first two dimensions are inverted.
Attention
For multi-dimensional datasets:
All inverted dimensions must appear first in the data array. If necessary, transpose or reorder the data so that the inverted dimensions come before the non-inverted ones.
If no sampling vector is provided for a dimension, a unit-spaced array is used by default.
If a kernel other than the identity kernel is specified for a dimension, you must explicitly provide its input sampling vector. Otherwise, initialization will raise an error.
2. From text files (up to 2D data)
Data with dimensionality up to 2 can be optionally loaded from files in .txt format. If using this method, processed data must be present in the specified folder path in a file named ‘data.txt’. Input sampling vectors for each dimension must be present in the same folder as files named as dim1.txt,dim2.txt.
# Assuming 'TXT_data' is a folder containing data.txt and at least dim1.txt
data_TXT_ILT = ilt.iltload(data_path='TXT_data')
Attention
Files corresponding to each dimension (or axis), even if the dimension is not inverted, must be provided when loading data using this method.