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
f2ce0ed9
Commit
f2ce0ed9
authored
4 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
RF: Better support for nifti1/2 + FSLOUTPUTTYPE
parent
a33a8492
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fsl/data/image.py
+13
-8
13 additions, 8 deletions
fsl/data/image.py
tests/test_image.py
+14
-8
14 additions, 8 deletions
tests/test_image.py
with
27 additions
and
16 deletions
fsl/data/image.py
+
13
−
8
View file @
f2ce0ed9
...
...
@@ -39,7 +39,6 @@ import json
import
string
import
logging
import
tempfile
import
warnings
import
six
import
numpy
as
np
...
...
@@ -1099,11 +1098,12 @@ class Image(Nifti):
if
header
is
not
None
:
xform
=
header
.
get_best_affine
()
else
:
xform
=
np
.
identity
(
4
)
# We default to NIFTI1 and not
# NIFTI2, because the rest of
# FSL is not yet NIFTI2 compatible.
# default to NIFTI1 if FSLOUTPUTTYPE
# is not set, just to be safe.
if
header
is
None
:
ctr
=
nib
.
nifti1
.
Nifti1Image
outputType
=
os
.
environ
.
get
(
'
FSLOUTPUTTYPE
'
,
'
NIFTI_GZ
'
)
if
'
NIFTI2
'
in
outputType
:
ctr
=
nib
.
Nifti2Image
else
:
ctr
=
nib
.
Nifti1Image
# make sure that the data type is correct,
# in case this header was passed in from
...
...
@@ -1648,9 +1648,14 @@ def defaultExt():
# TODO: Add analyze support.
options
=
{
'
NIFTI
'
:
'
.nii
'
,
'
NIFTI_PAIR
'
:
'
.img
'
,
'
NIFTI_GZ
'
:
'
.nii.gz
'
,
'
NIFTI
'
:
'
.nii
'
,
'
NIFTI2
'
:
'
.nii
'
,
'
NIFTI_GZ
'
:
'
.nii.gz
'
,
'
NIFTI2_GZ
'
:
'
.nii.gz
'
,
'
NIFTI_PAIR
'
:
'
.img
'
,
'
NIFTI2_PAIR
'
:
'
.img
'
,
'
NIFTI_PAIR_GZ
'
:
'
.img.gz
'
,
'
NIFTI2_PAIR_GZ
'
:
'
.img.gz
'
,
}
outputType
=
os
.
environ
.
get
(
'
FSLOUTPUTTYPE
'
,
'
NIFTI_GZ
'
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_image.py
+
14
−
8
View file @
f2ce0ed9
...
...
@@ -246,6 +246,11 @@ def _test_Image_atts(imgtype):
allowedExts
=
fslimage
.
ALLOWED_EXTENSIONS
fileGroups
=
fslimage
.
FILE_GROUPS
typeMap
=
{
np
.
uint8
:
constants
.
NIFTI_DT_UINT8
,
np
.
int16
:
constants
.
NIFTI_DT_INT16
,
np
.
int32
:
constants
.
NIFTI_DT_INT32
,
np
.
float32
:
constants
.
NIFTI_DT_FLOAT32
,
np
.
float64
:
constants
.
NIFTI_DT_FLOAT64
}
# (file, dims, pixdims, dtype)
dtypes
=
[
np
.
uint8
,
np
.
int16
,
np
.
int32
,
np
.
float32
,
np
.
double
]
...
...
@@ -307,14 +312,15 @@ def _test_Image_atts(imgtype):
assert
tuple
(
i
.
nibImage
.
shape
)
==
tuple
(
dims
)
assert
tuple
(
i
.
nibImage
.
header
.
get_zooms
())
==
tuple
(
pixdims
)
assert
i
.
nvals
==
1
assert
i
.
ndim
==
expndims
assert
i
.
dtype
==
dtype
assert
i
.
name
==
op
.
basename
(
path
)
assert
i
.
dataSource
==
fslpath
.
addExt
(
path
,
allowedExts
=
allowedExts
,
mustExist
=
True
,
fileGroups
=
fileGroups
)
assert
i
.
nvals
==
1
assert
i
.
ndim
==
expndims
assert
i
.
dtype
==
dtype
assert
i
.
niftiDataType
==
typeMap
[
dtype
]
assert
i
.
name
==
op
.
basename
(
path
)
assert
i
.
dataSource
==
fslpath
.
addExt
(
path
,
allowedExts
=
allowedExts
,
mustExist
=
True
,
fileGroups
=
fileGroups
)
i
=
None
...
...
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