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
9fd9e62d
Commit
9fd9e62d
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Fixes for nifti units, and to image initialisation
parent
654999ba
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fsl/data/constants.py
+13
-0
13 additions, 0 deletions
fsl/data/constants.py
fsl/data/image.py
+23
-4
23 additions, 4 deletions
fsl/data/image.py
with
36 additions
and
4 deletions
fsl/data/constants.py
+
13
−
0
View file @
9fd9e62d
...
...
@@ -85,6 +85,19 @@ NIFTI_XFORM_ANALYZE = 5
"""
Code which indicates that this is an ANALYZE image, not a NIFTI image.
"""
# NIFTI unit codes
NIFTI_UNITS_UNKNOWN
=
0
NIFTI_UNITS_METER
=
1
NIFTI_UNITS_MM
=
2
NIFTI_UNITS_MICRON
=
3
NIFTI_UNITS_SEC
=
8
NIFTI_UNITS_MSEC
=
16
NIFTI_UNITS_USEC
=
24
NIFTI_UNITS_HZ
=
32
NIFTI_UNITS_PPM
=
40
NIFTI_UNITS_RADS
=
48
# NIFTI file intent codes
NIFTI_INTENT_NONE
=
0
NIFTI_INTENT_CORREL
=
2
...
...
This diff is collapsed.
Click to expand it.
fsl/data/image.py
+
23
−
4
View file @
9fd9e62d
...
...
@@ -332,6 +332,10 @@ class Nifti(notifier.Notifier):
def
xyzUnits
(
self
):
"""
Returns the NIFTI XYZ dimension unit code.
"""
# analyze images have no unit field
if
self
.
niftiVersion
==
0
:
return
constants
.
NIFTI_UNITS_MM
# The nibabel get_xyzt_units returns labels,
# but we want the NIFTI codes. So we use
# the (undocumented) nifti1.unit_codes field
...
...
@@ -345,6 +349,10 @@ class Nifti(notifier.Notifier):
def
timeUnits
(
self
):
"""
Returns the NIFTI time dimension unit code.
"""
# analyze images have no unit field
if
self
.
niftiVersion
==
0
:
return
constants
.
NIFTI_UNITS_SEC
# See xyzUnits
units
=
self
.
header
.
get_xyzt_units
()[
1
]
units
=
nib
.
nifti1
.
unit_codes
[
units
]
...
...
@@ -742,10 +750,20 @@ class Image(Nifti):
# We default to NIFTI1 and not
# NIFTI2, because the rest of
# FSL is not yet NIFTI2 compatible.
nibImage
=
nib
.
nifti1
.
Nifti1Image
(
image
,
xform
,
header
=
header
)
# FSL is not yet NIFTI2 compatible.
if
header
is
None
:
ctr
=
nib
.
nifti1
.
Nifti1Image
# But if a nibabel header has been provided,
# we use the corresponding image type
if
isinstance
(
header
,
nib
.
nifti2
.
Nifti2Header
):
ctr
=
nib
.
nifti2
.
Nifti2Image
elif
isinstance
(
header
,
nib
.
nifti1
.
Nifti1Header
):
ctr
=
nib
.
nifti1
.
Nifti1Image
elif
isinstance
(
header
,
nib
.
analyze
.
AnalyzeHeader
):
ctr
=
nib
.
analyze
.
AnalyzeImage
nibImage
=
ctr
(
image
,
xform
,
header
=
header
)
# otherwise, we assume that it is a nibabel image
else
:
...
...
@@ -1026,6 +1044,7 @@ class Image(Nifti):
.. note:: Modifying image data will force the entire image to be
loaded into memory if it has not already been loaded.
"""
values
=
np
.
array
(
values
)
log
.
debug
(
'
{}: __setitem__ [{} = {}]
'
.
format
(
self
.
name
,
sliceobj
,
...
...
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