Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michiel Cottaar
fslpy
Commits
8c832aad
Commit
8c832aad
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Plain Diff
Merge branch 'rf/image_save' into 'master'
Rf/image save See merge request fsl/fslpy!188
parents
1e7ac7d1
686cde3a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
COPYRIGHT
+1
-1
1 addition, 1 deletion
COPYRIGHT
LICENSE
+1
-1
1 addition, 1 deletion
LICENSE
fsl/data/image.py
+4
-0
4 additions, 0 deletions
fsl/data/image.py
tests/test_image_advanced.py
+14
-19
14 additions, 19 deletions
tests/test_image_advanced.py
with
20 additions
and
21 deletions
COPYRIGHT
+
1
−
1
View file @
8c832aad
Copyright 2016-20
19
University of Oxford, Oxford, UK
Copyright 2016-20
20
University of Oxford, Oxford, UK
This diff is collapsed.
Click to expand it.
LICENSE
+
1
−
1
View file @
8c832aad
The fslpy library
Copyright 2016-20
19
University of Oxford, Oxford, UK.
Copyright 2016-20
20
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.
...
...
This diff is collapsed.
Click to expand it.
fsl/data/image.py
+
4
−
0
View file @
8c832aad
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
tests/test_image_advanced.py
+
14
−
19
View file @
8c832aad
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment