有一段代码,但是它说我的浮点数不能解释为整数,但是我也不知道如何更改它-任何人都有想法吗?
import numpy as np
import matplotlib.pyplot as plt
from pandas import DataFrame # to build our table of data from the video. import glob import pims # to import the video. from pims import pipeline # a decorator to allow dynamic loading of videos
import scipy.ndimage as nd # for Gaussian filter.
import trackpy as tp # for object tracking functions.
crop = (slice(100, 1000), slice(500, 1250), 0)
thresh = 130
x = glob.glob('/Users/charlieargent/Extended Report /Potassium nitrate 1 hour//')
def readvid(x):
frames = pims.Video(x)
return(frames)
@pipeline
def crop_frame(frame):
return frame[crop]
@pipeline
def filter_frame(frame):
return nd.filters.gaussian_filter( crop_frame(frame), [2, 2] )
@pipeline
def binary_inv_frame(frame):
return ( (255 - filter_frame(frame) > thresh)*255 ).astype('uint8')
for i in x:
find_cells = tp.batch( binary_inv_frame(readvid(i)), 21, minmass = 200, invert = False )
tracks = tp.link_df( find_cells, 25, memory = 0 )
tracks_long = tp.filter_stubs( tracks, 5 )
msds = tp.imsd( tracks_long, 1, 25 )
y = i.split("/")[-3], i.split("/")[-2], i.split("/")[-1]
msds.to_csv("{}.csv".format(y))
错误:
文件“”,第1行,在 runfile('/ Users / charlieargent / Extended Report /Analysis/untitled1.py',wdir ='/ Users / charlieargent / Extended Report / Analysis')
文件“ /anaconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py”,行786,在运行文件中 execfile(文件名,命名空间)
execfile中的文件“ /anaconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py”,第110行 exec(compile(f.read(),文件名,'exec'),命名空间)
文件“ / Users / charlieargent /扩展报告/Analysis/untitled1.py”,第45行,在 find_cells = tp.batch(binary_inv_frame(readvid(i)),21,minmass = 200,invert = False)
文件“ /anaconda3/lib/python3.7/site-packages/slicerator/init.py”,第687行,正在处理中 返回管道(proc_func,*祖先)
文件“ /anaconda3/lib/python3.7/site-packages/slicerator/init.py”,第415行,位于 init 中 self._len = len(祖先[0])
TypeError:“ float”对象不能解释为整数