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
ae3d65d9
Commit
ae3d65d9
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Ummm. Why did I ever restrict to 4D?
parent
95f51d5e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fsl/data/image.py
+11
-11
11 additions, 11 deletions
fsl/data/image.py
fsl/data/melodicimage.py
+1
-1
1 addition, 1 deletion
fsl/data/melodicimage.py
with
12 additions
and
12 deletions
fsl/data/image.py
+
11
−
11
View file @
ae3d65d9
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
#
"""
This module provides the :class:`Nifti` and :class:`Image` classes, for
"""
This module provides the :class:`Nifti` and :class:`Image` classes, for
representing
3D/4D
NIFTI1 and NIFTI2 images. The ``nibabel`` package is used
representing NIFTI1 and NIFTI2 images. The ``nibabel`` package is used
for file I/O.
for file I/O.
...
@@ -187,9 +187,6 @@ class Nifti(notifier.Notifier):
...
@@ -187,9 +187,6 @@ class Nifti(notifier.Notifier):
header
=
header
header
=
header
origShape
,
shape
,
pixdim
=
self
.
__determineShape
(
header
)
origShape
,
shape
,
pixdim
=
self
.
__determineShape
(
header
)
if
len
(
shape
)
<
3
or
len
(
shape
)
>
4
:
raise
RuntimeError
(
'
Only 3D or 4D images are supported
'
)
voxToWorldMat
=
self
.
__determineTransform
(
header
)
voxToWorldMat
=
self
.
__determineTransform
(
header
)
worldToVoxMat
=
transform
.
invert
(
voxToWorldMat
)
worldToVoxMat
=
transform
.
invert
(
voxToWorldMat
)
...
@@ -451,10 +448,14 @@ class Nifti(notifier.Notifier):
...
@@ -451,10 +448,14 @@ class Nifti(notifier.Notifier):
return
fileslice
.
canonical_slicers
(
sliceobj
,
self
.
__origShape
)
return
fileslice
.
canonical_slicers
(
sliceobj
,
self
.
__origShape
)
# TODO: Remove this method, and use the shape attribute directly
@property
def
is4DImage
(
self
):
def
ndims
(
self
):
"""
Returns ``True`` if this image is 4D, ``False`` otherwise.
"""
"""
Returns the number of dimensions in this image. This number may not
return
len
(
self
.
__shape
)
>
3
and
self
.
__shape
[
3
]
>
1
match the number of dimensions specified in the NIFTI header, as
trailing dimensions of length 1 are ignored. But it is guaranteed to be
at least 3.
"""
return
len
(
self
.
__shape
)
def
getXFormCode
(
self
,
code
=
None
):
def
getXFormCode
(
self
,
code
=
None
):
...
@@ -626,7 +627,7 @@ class Nifti(notifier.Notifier):
...
@@ -626,7 +627,7 @@ class Nifti(notifier.Notifier):
class
Image
(
Nifti
):
class
Image
(
Nifti
):
"""
Class which represents a
3D/4D
NIFTI image. Internally, the image is
"""
Class which represents a NIFTI image. Internally, the image is
loaded/stored using a :mod:`nibabel.nifti1.Nifti1Image` or
loaded/stored using a :mod:`nibabel.nifti1.Nifti1Image` or
:mod:`nibabel.nifti2.Nifti2Image`, and data access managed by a
:mod:`nibabel.nifti2.Nifti2Image`, and data access managed by a
:class:`.ImageWrapper`.
:class:`.ImageWrapper`.
...
@@ -1001,8 +1002,7 @@ class Image(Nifti):
...
@@ -1001,8 +1002,7 @@ class Image(Nifti):
# Otherwise if the number of values in the
# Otherwise if the number of values in the
# image is bigger than the size threshold,
# image is bigger than the size threshold,
# we'll calculate the range from a sample:
# we'll calculate the range from a sample:
if
len
(
self
.
shape
)
==
3
:
self
.
__imageWrapper
[:,
:,
0
]
self
.
__imageWrapper
[...,
0
]
else
:
self
.
__imageWrapper
[:,
:,
:,
0
]
def
loadData
(
self
):
def
loadData
(
self
):
...
...
This diff is collapsed.
Click to expand it.
fsl/data/melodicimage.py
+
1
−
1
View file @
ae3d65d9
...
@@ -77,7 +77,7 @@ class MelodicImage(fslimage.Image):
...
@@ -77,7 +77,7 @@ class MelodicImage(fslimage.Image):
dataImage
=
fslimage
.
Image
(
dataFile
,
dataImage
=
fslimage
.
Image
(
dataFile
,
loadData
=
False
,
loadData
=
False
,
calcRange
=
False
)
calcRange
=
False
)
if
dataImage
.
is4DImage
()
:
if
dataImage
.
ndims
>=
4
:
self
.
__tr
=
dataImage
.
pixdim
[
3
]
self
.
__tr
=
dataImage
.
pixdim
[
3
]
...
...
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