def _from_hdf_data(h5, name, xfmname=None, **kwargs):
    """Decodes a __hash named node from an HDF file into the 
    constituent Vertex or Volume object"""
    dnode = h5.get("/data/%s"%name)
    if dnode is None:
        dnode = h5.get(name)

    subj = dnode.attrs['subject']
    #support old style xfmname saving as attribute
    if xfmname is None and 'xfmname' in dnode.attrs:
        xfmname = dnode.attrs['xfmname']

    mask = None
    if "mask" in dnode.attrs:
        if dnode.attrs['mask'].startswith("__"):
            mask = h5['/subjects/%s/transforms/%s/masks/%s'%(dnode.attrs['subject'], xfmname, dnode.attrs['mask'])].value
        else:
            mask = dnode.attrs['mask']

    #support old style RGB volumes
    if dnode.dtype == np.uint8 and dnode.shape[-1] in (3, 4):
        alpha = None
        if dnode.shape[-1] == 4:
            alpha = dnode[..., 3]

        if xfmname is None:
            return VertexRGB(dnode[...,0], dnode[...,1], dnode[...,2], subj, 
                alpha=alpha, **kwargs)

        return VolumeRGB(dnode[...,0], dnode[...,1], dnode[...,2], subj, xfmname, 
            alpha=alpha, mask=mask, **kwargs)

    if xfmname is None:
        return Vertex(dnode, subj, **kwargs)
    
    return Volume(dnode, subj, xfmname, mask=mask, **kwargs)
dataset/ETHPy150Open gallantlab/pycortex/cortex/dataset/views.py/_from_hdf_data/original