python,麻烦大家帮我看看这个代码!!!

这个是我做设计的老师给我的代码,我们的课题是对心电图进行分析,老师给了三个代码,但是第一个代码的输入有点问题,本人又是个新手小白不知道怎么改,求求大神帮我看看!

import cmath
from abc import ABC, abstractmethod

import numpy as np
import scipy.integrate as integrate
import scipy.interpolate as interpolate
import scipy.signal as signal


class Analysis(ABC):
 def __init__(self, type, leads):
  self.type = type
  self.leads = leads
 @abstractmethod
 def analyse(self):
  pass
# Auto-Correlation Cross-Correlation Integral Squared
class ACIS(Analysis):
 def analyse(self):
  matrix = []
  for i in range(0, len(self.leads)):
   for j in range(0, len(self.leads)):
    if list(np.zeros(len(self.leads[i])))==self.leads[i] or list(np.zeros(len(self.leads[j])))==self.leads[j]:
     matrix.append(0)
     continue
    correlation = correlationFunction(self.leads[i], self.leads[j])
    square = np.square(correlation)
    integral = integrate.simps(square)
    division = np.divide(integral, 1000000)
    if (np.math.isnan(division)):
     matrix.append(0)
    else:
     matrix.append(division)
  return matrix

def correlationFunction(list1, list2):
 x = list1[:]
 y = list2[:]
 # correlation(x,y)/sqrt(x^2 * y^2)
 correlation = np.correlate(x, y, mode='full')[len(x)-1:]
 return np.divide(correlation, np.sqrt(np.multiply(np.var(x), np.var(y))))

class CorrelationFourierTransform(Analysis):
 def analyse(self):
  matrixfttReal = []
  matrixftReal = []
  matrixfttImm = []
  matrixftImm = []
  matrixAmplitude = []
  matrixAmplitudePeaks = []
  for i in range(0, len(self.leads)):
      # print(str(i+1) + "/"+str(len(self.leads)))
     for j in range(0, len(self.leads)):
       if list(np.zeros(len(self.leads[i])))==self.leads[i] or list(np.zeros(len(self.leads[j])))==self.leads[j]:
        matrixfttReal.append(0)
        matrixftReal.append(0)
        matrixfttImm.append(0)
        matrixftImm.append(0)
        matrixAmplitude.append(0)
        matrixAmplitudePeaks.append(0)
        continue
       correlation = correlationFunction(self.leads[i], self.leads[j])
       x = np.linspace(1/500, 10, len(correlation))
       newX, newY = FT.splineFunctionDescaling(x, correlation)
       frequency = np.logspace(-2, 2, 100)
       g1, g2 = FT.doFourier(newX, newY, frequency)
       amplitude = np.sqrt(np.add(np.square(np.real(g1)), np.square(np.imag(g1))))
       integralfttReal = integrate.simps(x=frequency, y=np.abs(np.real(g2)))
       integralfttImmaginary = integrate.simps(x=frequency, y=np.abs(np.imag(g2)))
       integralftReal = integrate.simps(x=frequency, y=np.abs(np.real(g1)))
       integralftImmaginary = integrate.simps(x=frequency, y=np.abs(np.imag(g1)))
       integralAmplitude = integrate.simps(x=frequency, y=amplitude)
       peakSum = 0
       for index in signal.find_peaks(amplitude, threshold=0.05)[0]:
        peakSum += np.multiply(amplitude[index], frequency[index])
       matrixfttReal.append(integralfttReal)
       matrixfttImm.append(integralfttImmaginary)
       matrixftReal.append(integralftReal)
       matrixftImm.append(integralftImmaginary)
       matrixAmplitude.append(integralAmplitude)
       matrixAmplitudePeaks.append(peakSum)
  return (matrixfttReal, matrixfttImm, matrixftReal, matrixftImm, matrixAmplitude,matrixAmplitudePeaks)

class FT:
 j = complex(0, 1)
 i = complex(1, 1)

 @staticmethod
 def ftt(g, g_infinte, w, t, N):
  result = 0
  result = FT.ft(g, g_infinte, w, t, N)*FT.j*w
  return result

 @staticmethod
 def ft(g, g_infinte,w,t,N):
  result = 0
  temp = FT.j * w * g[0] + (1 - cmath.exp(-FT.j * w * t[1]))\
         * ((g[1] - g[0]) / t[1]) + g_infinte * cmath.exp(-FT.j * w * t[N - 1])
  for k in range(2, N):
   result = result + ((g[k] - g[k - 1]) / (t[k] - t[k - 1])) * \
       (cmath.exp(-FT.j * w * t[k - 1]) - cmath.exp(-FT.j * w * t[k]))
  result = (result + temp) / (-(w) * (w))
  return result

 @staticmethod
 def splineFunctionDescaling(x, y):
  spline = interpolate.CubicSpline(x, y)
  splineX = np.logspace(np.log10(x[1]), np.log10(x[-1]), int(len(x) / 4))
  newY = []
  for x in splineX:
   newY.append(spline(x))
  return (splineX, newY)

 @staticmethod
 def doFourier(x, y, frequency):
     timePoints = len(x)
     timeSpace = x
     g_infinite = 0
     g1 = np.zeros(len(frequency)) * FT.i
     g2 = np.zeros(len(frequency)) * FT.i
     for a in range(len(frequency)):
      g1[a] = FT.ft(y, g_infinite, frequency[a], timeSpace, timePoints)
      g2[a] = FT.ftt(y, g_infinite, frequency[a], timeSpace, timePoints)
     return g1, g2

过程结果不重要  主要是输入这边的代码,我下载的数据无法输入我也不知道他的输入是什么意思,求大佬指点啊!!!

老师给了一些数据,格式是asc的

你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,目前超出我们的服务范围,暂时无法为您解答。

首次提问人员可免费体验一次有问必答服务。目前首次提问的问题服务范围为:编程语言、Java开发、python、数据库、前端开发 领域专业技术问题,为您提供问题的解决思路和指导。不提供源码代写、项目文档代写、论文代写、作业代写、安装包资源发送或安装、软件使用指导等服务。

我们后续会持续优化,扩大我们的服务范围,为您带来更好地服务。