diff --git a/COPYRIGHT b/COPYRIGHT index c777b532954ad8402670f27a9699a85fd996cc4a..2b9a3c28bd9d162848efdb59e6ce0ea744c83a85 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -1 +1 @@ -Copyright 2016-2019 University of Oxford, Oxford, UK +Copyright 2016-2020 University of Oxford, Oxford, UK diff --git a/LICENSE b/LICENSE index acc27ef8c17068c5949cdc5d5f39a42b063089b9..611fcba5618c84542bbea51bb0329fd035ff3724 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The fslpy library -Copyright 2016-2019 University of Oxford, Oxford, UK. +Copyright 2016-2020 University of Oxford, Oxford, UK. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/fsl/data/image.py b/fsl/data/image.py index 46fb47f813b3dbca90888a45a3a01245f635a350..b65f28105668b76867f41f6d3f0c7a0fa8100c44 100644 --- a/fsl/data/image.py +++ b/fsl/data/image.py @@ -1362,6 +1362,10 @@ class Image(Nifti): def save(self, filename=None): """Saves this ``Image`` to the specifed file, or the :attr:`dataSource` if ``filename`` is ``None``. + + Note that calling ``save`` on an image with modified data will cause + the entire image data to be loaded into memory if it has not already + been loaded. """ import fsl.utils.imcp as imcp diff --git a/tests/test_image_advanced.py b/tests/test_image_advanced.py index 2be8678b603a9d716dc461f770ae65acd89c9173..fd7f64359d9bc071b33689ff95a8697170c247d0 100644 --- a/tests/test_image_advanced.py +++ b/tests/test_image_advanced.py @@ -187,6 +187,15 @@ def _test_image_indexed_save(threaded): # make sure the data range is correct assert img.dataRange == (0, 40) + # Save the image to a different + # location (no changes to data though) + filename = op.join(testdir, 'image2.nii.gz') + img.save(filename) + + # known data range + # should not have changed + assert img.dataRange == (0, 40) + # change some data data = np.zeros((100, 100, 100)) data[:] = 45 @@ -195,35 +204,21 @@ def _test_image_indexed_save(threaded): if threaded: img.getImageWrapper().getTaskThread().waitUntilIdle() - # save the image + # save the image - this will + # cause the image data to be + # loaded into memory img.save() - assert img.dataRange == (0, 45) - - # access the data - index should - # get rebuilt to this point - img[..., 0] - img[..., 40] - if threaded: img.getImageWrapper().getTaskThread().waitUntilIdle() - # make sure we got the modified data - assert img.dataRange == (0, 45) - - img[..., 49] - - if threaded: - img.getImageWrapper().getTaskThread().waitUntilIdle() - - # make sure we got the modified data assert img.dataRange == (0, 49) - + assert np.all(img[..., 40] == data) # Finally, reload, and verify the change img = fslimage.Image(filename) - assert np.all(img[..., 40] == 45) + assert np.all(img[..., 40] == data) @pytest.mark.longtest