Have a section of code, but it says that my float can't be interpreted as an integer, i don't know how to change this though - anyone have an idea?

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))

Error:

File "", line 1, in runfile('/Users/charlieargent/Extended Report /Analysis/untitled1.py', wdir='/Users/charlieargent/Extended Report /Analysis')

File "/anaconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 786, in runfile execfile(filename, namespace)

File "/anaconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "/Users/charlieargent/Extended Report /Analysis/untitled1.py", line 45, in find_cells = tp.batch( binary_inv_frame(readvid(i)), 21, minmass = 200, invert = False )

File "/anaconda3/lib/python3.7/site-packages/slicerator/init.py", line 687, in process return Pipeline(proc_func, *ancestors)

File "/anaconda3/lib/python3.7/site-packages/slicerator/init.py", line 415, in init self._len = len(ancestors[0])

TypeError: 'float' object cannot be interpreted as an integer

0 Answers