pytrax/__RandomWalk__.py
def export_walk(self, image=None, path=None, sub='data', prefix='rw_',
                    sample=1):
        r'''
        Export big image to vti and walker coords to vtu

        Parameters
        ----------
        image: ndarray of int size (Default is None)
            Can be used to export verisons of the image
        path: string (default = None)
            the filepath to save the data, defaults to current working dir
        prefix: string (default = 'rw_)
            a string prefix for all the data
        sample: int (default = 1)
            used to down-sample the number of walkers to export by this factor
        '''
        if path is None:
            path = os.getcwd()
        if sub is not None:
            subdir = os.path.join(path, sub)
            # if it doesn't exist, make it
            if not os.path.exists(subdir):
                os.makedirs(subdir)
            path = subdir
        if image is not None:
            if len(np.shape(image)) == 2:
                image = image[:, :, np.newaxis]
            im_fp = os.path.join(path, prefix+'image')
            imageToVTK(im_fp, cellData={'image_data': image})
        # number of zeros to fill the file index
        zf = np.int(np.ceil(np.log10(self.nt*10)))
        w_id = np.arange(0, self.nw, sample)
        nw = len(w_id)
        time_data = np.ascontiguousarray(np.zeros(nw, dtype=int))
        if self.dim == 2:
            z_coords = np.ascontiguousarray(np.ones(nw, dtype=int))
        coords = self.real_coords
        for t in range(np.shape(coords)[0]):
            st = self.stride*t
            time_data.fill(st)
            x_coords = np.ascontiguousarray(coords[t, w_id, 0])
            y_coords = np.ascontiguousarray(coords[t, w_id, 1])
            if self.dim == 3:
                z_coords = np.ascontiguousarray(coords[t, w_id, 2])
            wc_fp = os.path.join(path, prefix+'coords_'+str(st).zfill(zf))
            pointsToVTK(path=wc_fp,
                        x=x_coords,
                        y=y_coords,
                        z=z_coords,
                        data={'time': time_data})
r'''
        Export big image to vti and walker coords to vtu

        Parameters
        ----------
        image: ndarray of int size (Default is None)
            Can be used to export verisons of the image
        path: string (default = None)
            the filepath to save the data, defaults to current working dir
        prefix: string (default = 'rw_)
            a string prefix for all the data
        sample: int (default = 1)
            used to down-sample the number of walkers to export by this factor
        
r'''
Export big image to vti and walker coords to vtu

Parameters

ndarray of int size (Default is None)
Can be used to export verisons of the image
path: string (default = None)
the filepath to save the data, defaults to current working dir
prefix: string (default = 'rw_)
a string prefix for all the data
sample: int (default = 1)
used to down-sample the number of walkers to export by this factor
r ' ' ' Export big image to vti and walker coords to vtu Parameters ndarray of int size ( Default is None ) Can be used to export verisons of the image path : string ( default = None ) the filepath to save the data defaults to current working dir prefix : string ( default = ' rw_ ) a string prefix for all the data sample : int ( default = 1 ) used to down - sample the number of walkers to export by this factor
def export_walk(self, image=None, path=None, sub='data', prefix='rw_',
                    sample=1):
        if path is None:
            path = os.getcwd()
        if sub is not None:
            subdir = os.path.join(path, sub)
            if not os.path.exists(subdir):
                os.makedirs(subdir)
            path = subdir
        if image is not None:
            if len(np.shape(image)) == 2:
                image = image[:, :, np.newaxis]
            im_fp = os.path.join(path, prefix+'image')
            imageToVTK(im_fp, cellData={'image_data': image})
        zf = np.int(np.ceil(np.log10(self.nt*10)))
        w_id = np.arange(0, self.nw, sample)
        nw = len(w_id)
        time_data = np.ascontiguousarray(np.zeros(nw, dtype=int))
        if self.dim == 2:
            z_coords = np.ascontiguousarray(np.ones(nw, dtype=int))
        coords = self.real_coords
        for t in range(np.shape(coords)[0]):
            st = self.stride*t
            time_data.fill(st)
            x_coords = np.ascontiguousarray(coords[t, w_id, 0])
            y_coords = np.ascontiguousarray(coords[t, w_id, 1])
            if self.dim == 3:
                z_coords = np.ascontiguousarray(coords[t, w_id, 2])
            wc_fp = os.path.join(path, prefix+'coords_'+str(st).zfill(zf))
            pointsToVTK(path=wc_fp,
                        x=x_coords,
                        y=y_coords,
                        z=z_coords,
                        data={'time': time_data})
def export_walk ( self , image = None , path = None , sub = 'data' , prefix = 'rw_' , sample = 1 ) : if path is None : path = os . getcwd ( ) if sub is not None : subdir = os . path . join ( path , sub ) if not os . path . exists ( subdir ) : os . makedirs ( subdir ) path = subdir if image is not None : if len ( np . shape ( image ) ) == 2 : image = image [ : , : , np . newaxis ] im_fp = os . path . join ( path , prefix + 'image' ) imageToVTK ( im_fp , cellData = { 'image_data' : image } ) zf = np . int ( np . ceil ( np . log10 ( self . nt * 10 ) ) ) w_id = np . arange ( 0 , self . nw , sample ) nw = len ( w_id ) time_data = np . ascontiguousarray ( np . zeros ( nw , dtype = int ) ) if self . dim == 2 : z_coords = np . ascontiguousarray ( np . ones ( nw , dtype = int ) ) coords = self . real_coords for t in range ( np . shape ( coords ) [ 0 ] ) : st = self . stride * t time_data . fill ( st ) x_coords = np . ascontiguousarray ( coords [ t , w_id , 0 ] ) y_coords = np . ascontiguousarray ( coords [ t , w_id , 1 ] ) if self . dim == 3 : z_coords = np . ascontiguousarray ( coords [ t , w_id , 2 ] ) wc_fp = os . path . join ( path , prefix + 'coords_' + str ( st ) . zfill ( zf ) ) pointsToVTK ( path = wc_fp , x = x_coords , y = y_coords , z = z_coords , data = { 'time' : time_data } )
r'''
Export big image to vti and walker coords to vtu
r ' ' ' Export big image to vti and walker coords to vtu
r'''
        Export big image to vti and walker coords to vtu

        Parameters
        ----------
        image: ndarray of int size (Default is None)
            Can be used to export verisons of the image
        path: string (default = None)
            the filepath to save the data, defaults to current working dir
        prefix: string (default = 'rw_)
            a string prefix for all the data
        sample: int (default = 1)
            used to down-sample the number of walkers to export by this factor
        ''' # if it doesn't exist, make it # number of zeros to fill the file index
self
image
path
sub
prefix
sample