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
6623319f
Commit
6623319f
authored
10 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
transform.axisBounds allows the bounds for multiple axes to be
calculated in one call.
parent
d67dd693
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/fslview/displaycontext.py
+18
-5
18 additions, 5 deletions
fsl/fslview/displaycontext.py
fsl/utils/transform.py
+16
-5
16 additions, 5 deletions
fsl/utils/transform.py
with
34 additions
and
10 deletions
fsl/fslview/displaycontext.py
+
18
−
5
View file @
6623319f
...
...
@@ -271,6 +271,21 @@ class ImageDisplay(props.SyncableHasProperties):
'
imageType
'
])
def
getDisplayBounds
(
self
):
"""
Calculates and returns the min/max values of a 3D bounding box,
in the display coordinate system, which is big enough to contain
the image associated with this :class:`ImageDisplay` instance.
The coordinate system in which the bounding box is defined is
determined by the current value of the :attr:`transform` property.
A tuple containing two values is returned, with the first value
a sequence of three low bounds, and the second value a sequence
of three high bounds.
"""
return
transform
.
axisBounds
(
self
.
image
.
shape
[:
3
],
self
.
voxToDisplayMat
)
def
_transformChanged
(
self
,
*
a
):
"""
Called when the :attr:`transform` property is changed.
...
...
@@ -615,14 +630,12 @@ class DisplayContext(props.SyncableHasProperties):
for
img
in
self
.
_imageList
.
images
:
display
=
self
.
_imageDisplays
[
img
]
xform
=
display
.
voxTo
Display
Mat
lo
,
hi
=
display
.
get
Display
Bounds
()
for
ax
in
range
(
3
):
lo
,
hi
=
transform
.
axisBounds
(
img
.
shape
[:
3
],
xform
,
ax
)
if
lo
<
minBounds
[
ax
]:
minBounds
[
ax
]
=
lo
if
hi
>
maxBounds
[
ax
]:
maxBounds
[
ax
]
=
hi
if
lo
[
ax
]
<
minBounds
[
ax
]:
minBounds
[
ax
]
=
lo
[
ax
]
if
hi
[
ax
]
>
maxBounds
[
ax
]:
maxBounds
[
ax
]
=
hi
[
ax
]
self
.
bounds
[:]
=
[
minBounds
[
0
],
maxBounds
[
0
],
minBounds
[
1
],
maxBounds
[
1
],
...
...
This diff is collapsed.
Click to expand it.
fsl/utils/transform.py
+
16
−
5
View file @
6623319f
...
...
@@ -23,8 +23,18 @@ def concat(x1, x2):
return
np
.
dot
(
x1
,
x2
)
def
axisBounds
(
shape
,
xform
,
axis
):
"""
Returns the (lo, hi) bounds of the specified axis.
"""
def
axisBounds
(
shape
,
xform
,
axes
=
None
):
"""
Returns the (lo, hi) bounds of the specified axis/axes.
"""
scalar
=
False
if
axes
is
None
:
axes
=
[
0
,
1
,
2
]
elif
not
isinstance
(
axes
,
collections
.
Iterable
):
scalar
=
True
axes
=
[
axes
]
x
,
y
,
z
=
shape
[:
3
]
x
-=
0.5
...
...
@@ -44,10 +54,11 @@ def axisBounds(shape, xform, axis):
tx
=
transform
(
points
,
xform
)
lo
=
tx
[:,
ax
i
s
].
min
()
hi
=
tx
[:,
ax
i
s
].
max
()
lo
=
tx
[:,
ax
e
s
].
min
(
axis
=
0
)
hi
=
tx
[:,
ax
e
s
].
max
(
axis
=
0
)
return
(
lo
,
hi
)
if
scalar
:
return
(
lo
[
0
],
hi
[
0
])
else
:
return
(
lo
,
hi
)
def
axisLength
(
shape
,
xform
,
axis
):
...
...
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