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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Evan Edmond
fslpy
Commits
9c4ce29a
Commit
9c4ce29a
authored
8 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Image.calcRange thresholding is done on bytes, not voxels.
parent
0e37bd43
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
+23
-10
23 additions, 10 deletions
fsl/data/image.py
fsl/data/imagewrapper.py
+2
-0
2 additions, 0 deletions
fsl/data/imagewrapper.py
with
25 additions
and
10 deletions
fsl/data/image.py
+
23
−
10
View file @
9c4ce29a
...
@@ -531,31 +531,44 @@ class Image(Nifti1, notifier.Notifier):
...
@@ -531,31 +531,44 @@ class Image(Nifti1, notifier.Notifier):
"""
Forces calculation of the image data range.
"""
Forces calculation of the image data range.
:arg sizethres: If not ``None``, specifies an image size threshold
:arg sizethres: If not ``None``, specifies an image size threshold
(t
hreshold on the
number of
valu
es). If the number
(t
otal
number of
byt
es). If the number
of bytes in
of values in
the image is greater than this threshold,
the image is greater than this threshold,
the range
the range
is calculated on a sample (the first volume
is calculated on a sample (the first volume
for a
for a
4D image, or slice for a 3D image).
4D image, or slice for a 3D image).
"""
"""
# The ImageWrapper automatically calculates
# The ImageWrapper automatically calculates
# the range of the specified slice, whenever
# the range of the specified slice, whenever
# it gets indexed. All we have to do is
# it gets indexed. All we have to do is
# access a portion of the data to trigger the
# access a portion of the data to trigger the
# range calculation.
# range calculation.
nbytes
=
np
.
prod
(
self
.
shape
)
*
self
.
dtype
.
itemsize
# If an image size threshold has not been specified,
# If an image size threshold has not been specified,
# then we'll calculate the full data range right now.
# then we'll calculate the full data range right now.
if
sizethres
is
None
:
if
sizethres
is
None
or
nbytes
<
sizethres
:
log
.
debug
(
'
{}: Forcing calculation of full
'
'
data range
'
.
format
(
self
.
name
))
self
.
__imageWrapper
[:]
self
.
__imageWrapper
[:]
else
:
log
.
debug
(
'
{}: Calculating data range
'
'
from sample
'
.
format
(
self
.
name
))
# 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:
elif
np
.
prod
(
self
.
shape
)
<
sizethres
:
if
len
(
self
.
shape
)
==
3
:
self
.
__imageWrapper
[:,
:,
0
]
if
len
(
self
.
shape
)
==
3
:
self
.
__imageWrapper
[:,
:,
0
]
else
:
self
.
__imageWrapper
[:,
:,
:,
0
]
else
:
self
.
__imageWrapper
[:,
:,
:,
0
]
def
loadData
(
self
):
"""
Makes sure that the image data is loaded into memory.
See :meth:`.ImageWrapper.loadData`.
"""
self
.
__imageWrapper
.
loadData
()
def
__getitem__
(
self
,
sliceobj
):
def
__getitem__
(
self
,
sliceobj
):
"""
Access the image data with the specified ``sliceobj``.
"""
Access the image data with the specified ``sliceobj``.
...
...
This diff is collapsed.
Click to expand it.
fsl/data/imagewrapper.py
+
2
−
0
View file @
9c4ce29a
...
@@ -224,6 +224,8 @@ class ImageWrapper(notifier.Notifier):
...
@@ -224,6 +224,8 @@ class ImageWrapper(notifier.Notifier):
:arg sliceobj: Something which can slice the image data.
:arg sliceobj: Something which can slice the image data.
"""
"""
log
.
debug
(
'
Getting image data: {}
'
.
format
(
sliceobj
))
sliceobj
=
nib
.
fileslice
.
canonical_slicers
(
sliceobj
=
nib
.
fileslice
.
canonical_slicers
(
sliceobj
,
self
.
__image
.
shape
)
sliceobj
,
self
.
__image
.
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