arboretum/utils.py
def load_hdf(filename: str,
             filter_by: str = 'area>=100',
             load_segmentation: bool = True,
             load_objects: bool = True,
             color_segmentation: bool = True):

    """ load data from an HDF file """
    with ArboretumHDFHandler(filename) as h:
        h._f_expr = filter_by

        if 'segmentation' in h._hdf and load_segmentation:
            seg = _color_segmentation_by_state(h, color_segmentation)
            seg = seg.astype(np.uint8)
        else:
            seg = None

        # get the objects and strip out the data
        if 'objects' in h._hdf and load_objects:
            obj = h.filtered_objects(f_expr=filter_by)
            loc = np.stack([[o.t, o.x, o.y, o.z, o.label] for o in obj], axis=0)
            loc = loc.astype(np.uint16)
        else:
            loc = np.empty((0,3))

        # get the tracks
        if 'tracks' in h._hdf:
            tracks = h.tracks
        else:
            tracks = []

        # correct files originating from earlier versions of the tracker
        for trk_set in tracks:
            for trk in trk_set:
                if trk.is_root and trk.root == 0:
                    trk.root = trk.ID

    return seg, loc, tracks
 load data from an HDF file 
load data from an HDF file
load data from an HDF file
def load_hdf(filename: str,
             filter_by: str = 'area>=100',
             load_segmentation: bool = True,
             load_objects: bool = True,
             color_segmentation: bool = True):
    with ArboretumHDFHandler(filename) as h:
        h._f_expr = filter_by
        if 'segmentation' in h._hdf and load_segmentation:
            seg = _color_segmentation_by_state(h, color_segmentation)
            seg = seg.astype(np.uint8)
        else:
            seg = None
        if 'objects' in h._hdf and load_objects:
            obj = h.filtered_objects(f_expr=filter_by)
            loc = np.stack([[o.t, o.x, o.y, o.z, o.label] for o in obj], axis=0)
            loc = loc.astype(np.uint16)
        else:
            loc = np.empty((0,3))
        if 'tracks' in h._hdf:
            tracks = h.tracks
        else:
            tracks = []
        for trk_set in tracks:
            for trk in trk_set:
                if trk.is_root and trk.root == 0:
                    trk.root = trk.ID
    return seg, loc, tracks
def load_hdf ( filename : str , filter_by : str = 'area>=100' , load_segmentation : bool = True , load_objects : bool = True , color_segmentation : bool = True ) : with ArboretumHDFHandler ( filename ) as h : h . _f_expr = filter_by if 'segmentation' in h . _hdf and load_segmentation : seg = _color_segmentation_by_state ( h , color_segmentation ) seg = seg . astype ( np . uint8 ) else : seg = None if 'objects' in h . _hdf and load_objects : obj = h . filtered_objects ( f_expr = filter_by ) loc = np . stack ( [ [ o . t , o . x , o . y , o . z , o . label ] for o in obj ] , axis = 0 ) loc = loc . astype ( np . uint16 ) else : loc = np . empty ( ( 0 , 3 ) ) if 'tracks' in h . _hdf : tracks = h . tracks else : tracks = [ ] for trk_set in tracks : for trk in trk_set : if trk . is_root and trk . root == 0 : trk . root = trk . ID return seg , loc , tracks
load data from an HDF file
load data from an HDF file
""" load data from an HDF file """ # get the objects and strip out the data # get the tracks # correct files originating from earlier versions of the tracker
filename
str
filter_by
str
load_segmentation
bool
load_objects
bool
color_segmentation
bool