Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD 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
FSL
fslpy
Commits
6abd4abf
Commit
6abd4abf
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
RF,BF: Nifti.header is now protected via property setter - Failure in
Image.save was resulting in a Nifti without a header.
parent
1b56bbc5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/data/image.py
+19
-7
19 additions, 7 deletions
fsl/data/image.py
with
19 additions
and
7 deletions
fsl/data/image.py
+
19
−
7
View file @
6abd4abf
...
@@ -254,7 +254,7 @@ class Nifti(notifier.Notifier, meta.Meta):
...
@@ -254,7 +254,7 @@ class Nifti(notifier.Notifier, meta.Meta):
shape
,
shape
,
pixdim
)
pixdim
)
self
.
header
=
header
self
.
__
header
=
header
self
.
__shape
=
shape
self
.
__shape
=
shape
self
.
__origShape
=
origShape
self
.
__origShape
=
origShape
self
.
__pixdim
=
pixdim
self
.
__pixdim
=
pixdim
...
@@ -492,6 +492,24 @@ class Nifti(notifier.Notifier, meta.Meta):
...
@@ -492,6 +492,24 @@ class Nifti(notifier.Notifier, meta.Meta):
return
''
.
join
([
c
for
c
in
val
if
c
in
string
.
printable
]).
strip
()
return
''
.
join
([
c
for
c
in
val
if
c
in
string
.
printable
]).
strip
()
@property
def
header
(
self
):
"""
Return a reference to the ``nibabel`` header object.
"""
return
self
.
__header
@header.setter
def
header
(
self
,
header
):
"""
Replace the ``nibabel`` header object managed by this ``Nifti``
with a new header. The new header must have the same dimensions,
voxel size, and orientation as the old one.
"""
new
=
Nifti
(
header
)
if
not
(
self
.
sameSpace
(
new
)
and
self
.
ndim
==
new
.
ndim
):
raise
ValueError
(
'
Incompatible header
'
)
self
.
__header
=
new
@property
@property
def
niftiVersion
(
self
):
def
niftiVersion
(
self
):
"""
Returns the NIFTI file version:
"""
Returns the NIFTI file version:
...
@@ -1411,12 +1429,6 @@ class Image(Nifti):
...
@@ -1411,12 +1429,6 @@ class Image(Nifti):
nib
.
save
(
self
.
__nibImage
,
tmpfname
)
nib
.
save
(
self
.
__nibImage
,
tmpfname
)
# nibabel should close any old
# file handles when the image/
# header refs are deleted
self
.
__nibImage
=
None
self
.
header
=
None
# Copy to final destination,
# Copy to final destination,
# and reload from there
# and reload from there
imcp
.
imcp
(
tmpfname
,
filename
,
overwrite
=
True
)
imcp
.
imcp
(
tmpfname
,
filename
,
overwrite
=
True
)
...
...
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