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
d4a505f2
Commit
d4a505f2
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
BF,ENH: ImageWrapper and naninfrange have support for structured
arrays (e.g. RGB data)
parent
424d0e18
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/imagewrapper.py
+4
-2
4 additions, 2 deletions
fsl/data/imagewrapper.py
fsl/utils/naninfrange.py
+6
-0
6 additions, 0 deletions
fsl/utils/naninfrange.py
with
10 additions
and
2 deletions
fsl/data/imagewrapper.py
+
4
−
2
View file @
d4a505f2
...
@@ -303,9 +303,11 @@ class ImageWrapper(notifier.Notifier):
...
@@ -303,9 +303,11 @@ class ImageWrapper(notifier.Notifier):
# data range for each volume/slice/vector
# data range for each volume/slice/vector
#
#
# We use nan as a placeholder, so the
# We use nan as a placeholder, so the
# dtype must be non-integral
# dtype must be non-integral. The
# len(dtype) check takes into account
# structured data (e.g. RGB)
dtype
=
self
.
__image
.
get_data_dtype
()
dtype
=
self
.
__image
.
get_data_dtype
()
if
np
.
issubdtype
(
dtype
,
np
.
integer
):
if
np
.
issubdtype
(
dtype
,
np
.
integer
)
or
len
(
dtype
)
>
0
:
dtype
=
np
.
float32
dtype
=
np
.
float32
self
.
__volRanges
=
np
.
zeros
((
nvols
,
2
),
self
.
__volRanges
=
np
.
zeros
((
nvols
,
2
),
dtype
=
dtype
)
dtype
=
dtype
)
...
...
This diff is collapsed.
Click to expand it.
fsl/utils/naninfrange.py
+
6
−
0
View file @
d4a505f2
...
@@ -23,6 +23,12 @@ def naninfrange(data):
...
@@ -23,6 +23,12 @@ def naninfrange(data):
use an alternate approach to calculating the minimum/maximum.
use an alternate approach to calculating the minimum/maximum.
"""
"""
# For structured arrays, we assume that
# all fields are numeric, and we simply
# take the range across all fields
if
len
(
data
.
dtype
)
>
0
:
data
=
np
.
concatenate
([
data
[
n
]
for
n
in
data
.
dtype
.
names
])
if
not
np
.
issubdtype
(
data
.
dtype
,
np
.
floating
):
if
not
np
.
issubdtype
(
data
.
dtype
,
np
.
floating
):
return
data
.
min
(),
data
.
max
()
return
data
.
min
(),
data
.
max
()
...
...
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