gbeflow/__init__.py
def make_track_movie(movie,df,c,name):
    '''
    Plots the trajectory of points over time on each frame of 
    an existing movie or array
    
    Parameters
    ----------
    movie : str
        Complete or relative path to the movie file to plot on
    df : pd.DataFrame
        Dataframe of tracks minimally with columns x,y,t
    c : str,color
        Currently only supports single color assignments, 
        but data specific assignments could be possible
    name : str
        Root of filename for output file, without filetype 
        
    Returns
    -------
    Saves a tif stack using path provided by `name`
    '''
    
    # Import specialized plotting functions for non-gui backend
    from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
    from matplotlib.figure import Figure
    
    # If input is a string, import movie from specified path
    if type(movie) == str:
        vimg = load_avi_as_array(movie)
    # If input not a string and not an array, print error message
    elif type(movie) == np.ndarray:
        vimg = movie
    else:
        print('movie input must be a path to avi or a numpy array')
        return()
    
    # Initialize list to save arrays of each frame
    Larr = []
    
    # Generate plot of each frame and save to list
    for t in tqdm.tqdm(range(vimg.shape[0])):
        # Setup figure object and subplot axes
        fig = Figure()
        canvas = FigureCanvas(fig)
        ax = fig.gca()
        
        # Plot image and tracks
        ax.imshow(vimg[t])
        ax.scatter(df[df.t==t].x,df[df.t==t].y,c=c)
        
        # Format figure for output
        fig.tight_layout(pad=0)
        ax.axis('off')
        
        # Draw plot which is required for saving
        canvas.draw()
        
        # Esport plotting figure as a string of rgb values
        rgbstring = canvas.tostring_rgb()
        
        # Load rgb string into a numpy array
        image = np.frombuffer(rgbstring,dtype='uint8')
        
        # Reshape image array to fit dimensions of the original plot
        Larr.append(
            image.reshape(fig.canvas.get_width_height()[::-1]+(3,))
        )
        
    # Compile array list to array and save
    tifffile.imsave(name+'.tif',data=np.array(Larr))

    Plots the trajectory of points over time on each frame of 
    an existing movie or array
    
    Parameters
    ----------
    movie : str
        Complete or relative path to the movie file to plot on
    df : pd.DataFrame
        Dataframe of tracks minimally with columns x,y,t
    c : str,color
        Currently only supports single color assignments, 
        but data specific assignments could be possible
    name : str
        Root of filename for output file, without filetype 
        
    Returns
    -------
    Saves a tif stack using path provided by `name`
    
Plots the trajectory of points over time on each frame of
an existing movie or array

Parameters

movie : str
Complete or relative path to the movie file to plot on
df : pd.DataFrame
Dataframe of tracks minimally with columns x,y,t
c : str,color
Currently only supports single color assignments,
but data specific assignments could be possible
name : str
Root of filename for output file, without filetype

Returns

Saves a tif stack using path provided by `name`
Plots the trajectory of points over time on each frame of an existing movie or array Parameters movie : str Complete or relative path to the movie file to plot on df : pd . DataFrame Dataframe of tracks minimally with columns x y t c : str color Currently only supports single color assignments but data specific assignments could be possible name : str Root of filename for output file without filetype Returns Saves a tif stack using path provided by ` name `
def make_track_movie(movie,df,c,name):
    from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
    from matplotlib.figure import Figure
    if type(movie) == str:
        vimg = load_avi_as_array(movie)
    elif type(movie) == np.ndarray:
        vimg = movie
    else:
        print('movie input must be a path to avi or a numpy array')
        return()
    Larr = []
    for t in tqdm.tqdm(range(vimg.shape[0])):
        fig = Figure()
        canvas = FigureCanvas(fig)
        ax = fig.gca()
        ax.imshow(vimg[t])
        ax.scatter(df[df.t==t].x,df[df.t==t].y,c=c)
        fig.tight_layout(pad=0)
        ax.axis('off')
        canvas.draw()
        rgbstring = canvas.tostring_rgb()
        image = np.frombuffer(rgbstring,dtype='uint8')
        Larr.append(
            image.reshape(fig.canvas.get_width_height()[::-1]+(3,))
        )
    tifffile.imsave(name+'.tif',data=np.array(Larr))
def make_track_movie ( movie , df , c , name ) : from matplotlib . backends . backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib . figure import Figure if type ( movie ) == str : vimg = load_avi_as_array ( movie ) elif type ( movie ) == np . ndarray : vimg = movie else : print ( 'movie input must be a path to avi or a numpy array' ) return ( ) Larr = [ ] for t in tqdm . tqdm ( range ( vimg . shape [ 0 ] ) ) : fig = Figure ( ) canvas = FigureCanvas ( fig ) ax = fig . gca ( ) ax . imshow ( vimg [ t ] ) ax . scatter ( df [ df . t == t ] . x , df [ df . t == t ] . y , c = c ) fig . tight_layout ( pad = 0 ) ax . axis ( 'off' ) canvas . draw ( ) rgbstring = canvas . tostring_rgb ( ) image = np . frombuffer ( rgbstring , dtype = 'uint8' ) Larr . append ( image . reshape ( fig . canvas . get_width_height ( ) [ : : - 1 ] + ( 3 , ) ) ) tifffile . imsave ( name + '.tif' , data = np . array ( Larr ) )
Plots the trajectory of points over time on each frame of
an existing movie or array
Plots the trajectory of points over time on each frame of an existing movie or array
'''
    Plots the trajectory of points over time on each frame of 
    an existing movie or array
    
    Parameters
    ----------
    movie : str
        Complete or relative path to the movie file to plot on
    df : pd.DataFrame
        Dataframe of tracks minimally with columns x,y,t
    c : str,color
        Currently only supports single color assignments, 
        but data specific assignments could be possible
    name : str
        Root of filename for output file, without filetype 
        
    Returns
    -------
    Saves a tif stack using path provided by `name`
    ''' # Import specialized plotting functions for non-gui backend # If input is a string, import movie from specified path # If input not a string and not an array, print error message # Initialize list to save arrays of each frame # Generate plot of each frame and save to list # Setup figure object and subplot axes # Plot image and tracks # Format figure for output # Draw plot which is required for saving # Esport plotting figure as a string of rgb values # Load rgb string into a numpy array # Reshape image array to fit dimensions of the original plot # Compile array list to array and save
movie
df
c
name