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
bc1efa7e
Commit
bc1efa7e
authored
8 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Some fixes to Image class
parent
aff196f2
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
-1
19 additions, 1 deletion
fsl/data/image.py
with
19 additions
and
1 deletion
fsl/data/image.py
+
19
−
1
View file @
bc1efa7e
...
@@ -144,7 +144,7 @@ class Nifti(notifier.Notifier):
...
@@ -144,7 +144,7 @@ class Nifti(notifier.Notifier):
if
not
isinstance
(
header
,
nib
.
analyze
.
AnalyzeHeader
):
if
not
isinstance
(
header
,
nib
.
analyze
.
AnalyzeHeader
):
raise
ValueError
(
'
Unrecognised header: {}
'
.
format
(
header
))
raise
ValueError
(
'
Unrecognised header: {}
'
.
format
(
header
))
header
=
header
.
copy
()
header
=
header
origShape
,
shape
,
pixdim
=
self
.
__determineShape
(
header
)
origShape
,
shape
,
pixdim
=
self
.
__determineShape
(
header
)
if
len
(
shape
)
<
3
or
len
(
shape
)
>
4
:
if
len
(
shape
)
<
3
or
len
(
shape
)
>
4
:
...
@@ -765,6 +765,23 @@ class Image(Nifti):
...
@@ -765,6 +765,23 @@ class Image(Nifti):
coords
=
[
0
]
*
len
(
self
.
__nibImage
.
shape
)
coords
=
[
0
]
*
len
(
self
.
__nibImage
.
shape
)
return
self
.
__nibImage
.
dataobj
[
tuple
(
coords
)].
dtype
return
self
.
__nibImage
.
dataobj
[
tuple
(
coords
)].
dtype
@Nifti.voxToWorldMat.setter
def
voxToWorldMat
(
self
,
xform
):
"""
Overrides the :meth:`Nifti.voxToWorldMat` property setter.
In ``nibabel``, the header and image affines can easily get
out of sync when they are modified. The ``Nifti`` implementation
updates the header, and this implementation makes sure the
image is also updated.
"""
Nifti
.
voxToWorldMat
.
fset
(
self
,
xform
)
xform
=
self
.
voxToWorldMat
self
.
__nibImage
.
set_sform
(
xform
)
self
.
__nibImage
.
set_qform
(
xform
)
def
__transformChanged
(
self
,
*
args
,
**
kwargs
):
def
__transformChanged
(
self
,
*
args
,
**
kwargs
):
"""
Called when the ``voxToWorldMat`` of this :class:`Nifti` instance
"""
Called when the ``voxToWorldMat`` of this :class:`Nifti` instance
...
@@ -871,6 +888,7 @@ class Image(Nifti):
...
@@ -871,6 +888,7 @@ class Image(Nifti):
nib
.
save
(
self
.
__nibImage
,
filename
)
nib
.
save
(
self
.
__nibImage
,
filename
)
self
.
__fileobj
.
close
()
self
.
__fileobj
.
close
()
self
.
__nibImage
,
self
.
__fileobj
=
loadIndexedImageFile
(
filename
)
self
.
__nibImage
,
self
.
__fileobj
=
loadIndexedImageFile
(
filename
)
self
.
header
=
self
.
__nibImage
.
get_header
()
self
.
__dataSource
=
filename
self
.
__dataSource
=
filename
self
.
__saveState
=
True
self
.
__saveState
=
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