def rawMassLynx_MS_load(path=None, inputFile='output.1dMZ', normalize=True, **kwargs): datapath = os.path.join(path, inputFile) # Load data into array msData = np.fromfile(datapath, dtype=np.float32) msDataClean = msData[2:(-1)] numberOfRows = int(len(msDataClean) / 2) msDataReshape = msDataClean.reshape((2, numberOfRows), order='F') # Extract MS data msX = msDataReshape[1] msY = msDataReshape[0] # clean-up MS file firstBad = strictly_increasing(msX) if firstBad == True: pass else: firstBadIdx = np.where(msX == firstBad) try: msX = msX[0:(firstBadIdx[0][0] - 1)] msY = msY[0:(firstBadIdx[0][0] - 1)] except IndexError: pass # clean-up filepath try: clean_up(datapath) except: pass # Normalize MS data if normalize: msY = msY / max(msY) return msX, msY
def rawMassLynx_2DT_load(path=None, inputFile='output.2dRTDT', normalize=False, **kwargs): datapath = os.path.join(path, inputFile) imsData = np.fromfile(datapath, dtype=np.int32) imsDataClean = imsData[3::] numberOfRows = imsData[1] imsDataReshape = imsDataClean.reshape((200, numberOfRows), order='F') # Reshapes the list to 2D array imsDataSplit = np.hsplit(imsDataReshape, int(numberOfRows / 5)) # Splits the array into [scans,200,5] array imsDataSplit = np.sum(imsDataSplit, axis=2).T # Sums each 5 RT scans together """ There is a bug - sometimes when extracting, the last column values go way outside of range and make the plot look terrible. Hacky way round this is to check that any values fall outside the range and if so, set the last column to 0s... """ # Test to ensure all values are above 0 or below 1E8 for value in imsDataSplit[:, -1]: if value < 0: imsDataSplit[:, -1] = 0 elif value > 10000000: imsDataSplit[:, -1] = 0 # clean-up filepath try: clean_up(datapath) except: pass if normalize: imsDataSplitNorm = normalize(imsDataSplit.astype(np.float64), axis=0, norm='max') # Norm to 1 return imsDataSplit, imsDataSplitNorm else: return imsDataSplit
def rawMassLynx_MZDT_load(path=None, inputFile='output.2dDTMZ', normalize=False, **kwargs): datapath = os.path.join(path, inputFile) imsData = np.fromfile(datapath, dtype=np.int32) imsDataClean = imsData[3::] numberOfBins = imsData[0] imsDataSplit = imsDataClean.reshape((200, numberOfBins), order='C') # Reshapes the list to 2D array # clean-up filepath try: clean_up(datapath) except: pass if normalize: imsDataSplitNorm = normalize(imsDataSplit.astype(np.float64), axis=0, norm='max') # Norm to 1 return imsDataSplit, imsDataSplitNorm else: return imsDataSplit
def rawMassLynx_RT_load(path=None, inputFile='output.1dRT', normalize=False, **kwargs): datapath = os.path.join(path, inputFile) rtData = np.fromfile(datapath, dtype=np.int32) rtDataClean = rtData[3::] nScans = rtData[1] rtDataReshape = rtDataClean.reshape((nScans, 2), order='C') rtData1D = rtDataReshape[:, 1] # clean-up filepath try: clean_up(datapath) except: pass if normalize: rtData1DNorm = rtData1D.astype(np.float64) / max(rtData1D) return rtData1D, rtData1DNorm else: return rtData1D
def rawMassLynx_DT_load(path=None, inputFile='output.1dDT', normalize=False, **kwargs): """ Load data for 1D IM-MS data """ datapath = os.path.join(path, inputFile) imsData = np.fromfile(datapath, dtype=np.int32) imsDataClean = imsData[3::] imsDataReshape = imsDataClean.reshape((200, 2), order='C') imsData1D = imsDataReshape[:, 1] # clean-up filepath try: clean_up(datapath) except: pass if normalize: imsData1DNorm = imsData1D.astype(np.float64) / max(imsData1D) return imsData1DNorm else: return imsData1D