R = imageio.read(fname, 'DICOM', 'I') if n == 1: assert len(R) > 10 else: assert len(R) == 20 + 25 assert isinstance(R.get_meta_data(), dict) assert isinstance(R.get_meta_data(0), dict) # Test volread() R = imageio.read(fname, 'DICOM', 'v') assert len(R) == n # we ask for one, but get an honest number assert isinstance(R.get_meta_data(), dict) assert isinstance(R.get_meta_data(0), dict) # Test mvolread() R = imageio.read(fname, 'DICOM', 'V') assert len(R) == n assert isinstance(R.get_meta_data(), dict) assert isinstance(R.get_meta_data(0), dict) # Touch DicomSeries objects assert repr(R._series[0]) assert R._series[0].description assert len(R._series[0].sampling) == 3 R = imageio.read(fname, 'DICOM', '?') raises(RuntimeError, R.get_length) run_tests_if_main()
filename1 = os.path.join(test_dir, "test_tiff.tiff") # One image imageio.imsave(filename1, im2, "itk") im = imageio.imread(filename1, "itk") print(im.shape) ims = imageio.mimread(filename1, "itk") print(im2.shape) assert (im == im2).all() assert len(ims) == 1 # Mixed W = imageio.save(filename1, "itk") raises(RuntimeError, W.set_meta_data, 1) assert W.format.name == "ITK" W.append_data(im2) W.append_data(im2) W.close() # R = imageio.read(filename1, "itk") assert R.format.name == "ITK" ims = list(R) # == [im for im in R] assert (ims[0] == im2).all() # Fail raises(IndexError, R.get_data, -1) raises(IndexError, R.get_data, 3) raises(RuntimeError, R.get_meta_data) run_tests_if_main()
for i in range(10): mean = reader.get_next_data().mean() assert mean > 100 and mean < 115 def test_stream(): with raises(IOError): imageio.read(get_remote_file('images/cockatoo.mp4'), stream=5) def test_invalidfile(): filename = test_dir+'/empty.mp4' with open(filename, 'w'): pass with raises(IOError): imageio.read(filename) def show(): reader = imageio.read(get_remote_file('images/cockatoo.mp4')) for i in range(10): reader.get_next_data() import pylab pylab.ion() pylab.show(reader.get_next_data()) run_tests_if_main(1)