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
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
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/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):
# data range for each volume/slice/vector
#
# 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
()
if
np
.
issubdtype
(
dtype
,
np
.
integer
):
if
np
.
issubdtype
(
dtype
,
np
.
integer
)
or
len
(
dtype
)
>
0
:
dtype
=
np
.
float32
self
.
__volRanges
=
np
.
zeros
((
nvols
,
2
),
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):
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
):
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