def METHOD_NAME(obj):
    if isinstance(obj, dict) and obj.get('vtkClass', None) == 'vtkImageData':
        data_array = obj['pointData']['arrays'][0]['data']
        pixel_data = bytebuffer_to_numpy(
            data_array['values'], data_array['dataType'])
        extent = obj['extent']
        # numpy indexes in ZYX order, where X varies the fastest
        dims = [
            extent[5] - extent[4] + 1,
            extent[3] - extent[2] + 1,
            extent[1] - extent[0] + 1,
        ]
        direction = np.zeros((3, 3))
        for x in range(3):
            for y in range(3):
                direction[x][y] = obj['direction'][x*3+y]
        itk_image = itk.GetImageFromArray(np.reshape(pixel_data, dims))
        # https://discourse.itk.org/t/set-image-direction-from-numpy-array/844/10
        vnlmat = itk.GetVnlMatrixFromArray(direction)
        itk_image.GetDirection().GetVnlMatrix().copy_in(vnlmat.data_block())
        itk_image.SetOrigin(obj['origin'])
        itk_image.SetSpacing(obj['spacing'])
        return itk_image
    return obj