Example #1
0
    def test_generate_frames(self, fpath, rpath, fixes):
        """Test pixel_array returns correct values."""
        ds = dcmread(fpath)
        frame_generator = generate_frames(ds)
        ref = dcmread(rpath).pixel_array

        nr_frames = getattr(ds, 'NumberOfFrames', 1)
        for ii in range(nr_frames):
            arr = next(frame_generator)

            if nr_frames > 1:
                assert np.array_equal(arr, ref[ii, ...])
            else:
                assert np.array_equal(arr, ref)

        with pytest.raises(StopIteration):
            next(frame_generator)
Example #2
0
    def test_generate_frames(self, fpath, rpath, val, tol):
        """Test pixel_array returns correct values."""
        ds = dcmread(fpath)
        frame_generator = generate_frames(ds)
        ref = dcmread(rpath).pixel_array

        nr_frames = getattr(ds, 'NumberOfFrames', 1)
        for ii in range(nr_frames):
            arr = next(frame_generator)
            if 'YBR' in ds.PhotometricInterpretation:
                arr = convert_color_space(arr, ds.PhotometricInterpretation,
                                          'RGB')

            if nr_frames > 1:
                assert np.allclose(arr, ref[ii, ...], atol=tol)
            else:
                assert np.allclose(arr, ref, atol=tol)

        with pytest.raises(StopIteration):
            next(frame_generator)