def cdf_processing(fpath, structure): with suppress_stdout(): # Read CDF dat = ANDI_reader(fpath) # Construct int matrix ~ (n_scan, n_mz) im = build_intensity_matrix_i(dat) # Basic noise and baseline corrections smooth = savitzky_golay_im(im) norm = tophat_im(smooth, struct=structure) return norm
def test_savitzky_golay_intensity_matrix(im, tic): # Use Savitzky-Golay filtering to smooth all IC's in the IM im_smooth = savitzky_golay_im(im) assert isinstance(im_smooth, IntensityMatrix) # find the IC for derivatisation product ion before smoothing ic = im.get_ic_at_index(73) assert isinstance(ic, IonChromatogram) # find the IC for derivatisation product ion after smoothing ic_smooth = im_smooth.get_ic_at_index(73) assert isinstance(ic_smooth, IonChromatogram) # TODO: value assertions savitzky_golay_im(im, degree=5) savitzky_golay_im(im, window=5) # Test Errors for obj in [test_string, *test_numbers, *test_lists, test_dict]: with pytest.raises(TypeError): savitzky_golay_im(obj) # type: ignore for obj in [test_string, test_float, *test_lists, test_dict]: with pytest.raises(TypeError): savitzky_golay_im(im, degree=obj) # type: ignore for obj in [test_float, *test_lists, test_dict]: with pytest.raises(TypeError): savitzky_golay_im(im, window=obj) # type: ignore
"""proc.py """ # This file has been replaced by jupyter/NoiseSmoothing.ipynb from pyms.GCMS.IO.ANDI import ANDI_reader from pyms.IntensityMatrix import build_intensity_matrix from pyms.Noise.SavitzkyGolay import savitzky_golay_im # read the raw data andi_file = "data/gc01_0812_066.cdf" data = ANDI_reader(andi_file) # build an intensity matrix object from the data im = build_intensity_matrix(data) # Use Savitzky-Golay filtering to smooth all IC's in the IM print("Smoothing ...") im_smooth = savitzky_golay_im(im) print("Done") # find the IC for derivatisation product ion before smoothing ic = im.get_ic_at_index(73) # find the IC for derivatisation product ion after smoothing ic_smooth = im_smooth.get_ic_at_index(73) ic.write("output/ic.dat", minutes=True) ic_smooth.write("output/ic_smooth.dat", minutes=True)
"""proc.py """ import sys sys.path.append("/x/PyMS/") from pyms.GCMS.IO.ANDI.Function import ANDI_reader from pyms.GCMS.Function import build_intensity_matrix from pyms.Noise.SavitzkyGolay import savitzky_golay_im # read the raw data andi_file = "/x/PyMS/data/gc01_0812_066.cdf" data = ANDI_reader(andi_file) # build an intensity matrix object from the data im = build_intensity_matrix(data) # Use Savitzky-Golay filtering to smooth all IC's in the IM print "Smoothing ..." im_smooth = savitzky_golay_im(im) print "Done" # find the IC for derivatisation product ion before smoothing ic = im.get_ic_at_index(73) # find the IC for derivatisation product ion after smoothing ic_smooth = im_smooth.get_ic_at_index(73) ic.write("output/ic.dat",minutes=True) ic_smooth.write("output/ic_smooth.dat",minutes=True)