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
97fb4b59
Commit
97fb4b59
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
imagewrapper.canonicalShape moved to image module
parent
cc702436
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/image.py
+26
-2
26 additions, 2 deletions
fsl/data/image.py
fsl/data/imagewrapper.py
+6
-20
6 additions, 20 deletions
fsl/data/imagewrapper.py
with
32 additions
and
22 deletions
fsl/data/image.py
+
26
−
2
View file @
97fb4b59
...
@@ -22,6 +22,7 @@ and file names:
...
@@ -22,6 +22,7 @@ and file names:
.. autosummary::
.. autosummary::
:nosignatures:
:nosignatures:
canonicalShape
looksLikeImage
looksLikeImage
addExt
addExt
splitExt
splitExt
...
@@ -311,10 +312,10 @@ class Nifti(notifier.Notifier, meta.Meta):
...
@@ -311,10 +312,10 @@ class Nifti(notifier.Notifier, meta.Meta):
- A sequence/tuple containing the zooms/pixdims.
- A sequence/tuple containing the zooms/pixdims.
"""
"""
# The canonicalShape
method
figures out
# The canonicalShape
function
figures out
# the data shape that we should use.
# the data shape that we should use.
origShape
=
list
(
header
.
get_data_shape
())
origShape
=
list
(
header
.
get_data_shape
())
shape
=
imagewrapper
.
canonicalShape
(
origShape
)
shape
=
canonicalShape
(
origShape
)
pixdims
=
list
(
header
.
get_zooms
())
pixdims
=
list
(
header
.
get_zooms
())
# if get_zooms() doesn't return at
# if get_zooms() doesn't return at
...
@@ -1318,6 +1319,29 @@ class Image(Nifti):
...
@@ -1318,6 +1319,29 @@ class Image(Nifti):
self
.
notify
(
topic
=
'
dataRange
'
)
self
.
notify
(
topic
=
'
dataRange
'
)
def
canonicalShape
(
shape
):
"""
Calculates a *canonical* shape, how the given ``shape`` should
be presented. The shape is forced to be at least three dimensions,
with any other trailing dimensions of length 1 ignored.
"""
shape
=
list
(
shape
)
# Squeeze out empty dimensions, as
# 3D image can sometimes be listed
# as having 4 or more dimensions
for
i
in
reversed
(
range
(
len
(
shape
))):
if
shape
[
i
]
==
1
:
shape
=
shape
[:
i
]
else
:
break
# But make sure the shape
# has at 3 least dimensions
if
len
(
shape
)
<
3
:
shape
=
shape
+
[
1
]
*
(
3
-
len
(
shape
))
return
shape
def
looksLikeImage
(
filename
,
allowedExts
=
None
):
def
looksLikeImage
(
filename
,
allowedExts
=
None
):
"""
Returns ``True`` if the given file looks like a NIFTI image, ``False``
"""
Returns ``True`` if the given file looks like a NIFTI image, ``False``
otherwise.
otherwise.
...
...
This diff is collapsed.
Click to expand it.
fsl/data/imagewrapper.py
+
6
−
20
View file @
97fb4b59
...
@@ -766,27 +766,13 @@ def canonicalSliceObj(sliceobj, shape):
...
@@ -766,27 +766,13 @@ def canonicalSliceObj(sliceobj, shape):
return
nib
.
fileslice
.
canonical_slicers
(
sliceobj
,
shape
)
return
nib
.
fileslice
.
canonical_slicers
(
sliceobj
,
shape
)
@deprecation.deprecated
(
deprecated_in
=
'
1.7.0
'
,
removed_in
=
'
2.0.0
'
,
details
=
'
moved to the fsl.data.image module
'
)
def
canonicalShape
(
shape
):
def
canonicalShape
(
shape
):
"""
Calculates a *canonical* shape, how the given ``shape`` should
"""
Deprecated - moved to the :mod:`fsl.data.image` module.
"""
be presented. The shape is forced to be at least three dimensions,
from
fsl.data.image
import
canonicalShape
with any other trailing dimensions of length 1 ignored.
return
canonicalShape
(
shape
)
"""
shape
=
list
(
shape
)
# Squeeze out empty dimensions, as
# 3D image can sometimes be listed
# as having 4 or more dimensions
for
i
in
reversed
(
range
(
len
(
shape
))):
if
shape
[
i
]
==
1
:
shape
=
shape
[:
i
]
else
:
break
# But make sure the shape
# has at 3 least dimensions
if
len
(
shape
)
<
3
:
shape
=
shape
+
[
1
]
*
(
3
-
len
(
shape
))
return
shape
def
expectedShape
(
sliceobj
,
shape
):
def
expectedShape
(
sliceobj
,
shape
):
...
...
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