Esempio n. 1
0
def test_serialization_with_header_fields():

    image_data = common.create_random_array((128, 128), dtype=np.float32)
    image = ismrmrd.Image.from_array(image_data, **common.create_random_image_properties())

    read_image = ismrmrd.Image.from_bytes(image.to_bytes())

    assert image == read_image
Esempio n. 2
0
def test_initialization_with_array_and_header_properties():

    properties = common.create_random_image_properties()
    image_data = common.create_random_array((256, 512), dtype=np.float32)

    image = ismrmrd.Image.from_array(image_data, **properties)

    for field in properties:
        try:
            assert all(map(lambda a, b: a == b,
                           properties.get(field),
                           getattr(image, field))), \
                "Image property doesn't match initialization value: " + field
        except TypeError:
            assert properties.get(field) == getattr(image, field), \
                "Image property doesn't match initialization value: " + field