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
27df5ee5
Commit
27df5ee5
authored
8 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Making the imagewrapper.calcExpansion function smarter.
parent
7242680f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/data/imagewrapper.py
+58
-12
58 additions, 12 deletions
fsl/data/imagewrapper.py
with
58 additions
and
12 deletions
fsl/data/imagewrapper.py
+
58
−
12
View file @
27df5ee5
...
@@ -426,7 +426,7 @@ def calcExpansion(slices, coverage):
...
@@ -426,7 +426,7 @@ def calcExpansion(slices, coverage):
lowVol
,
highVol
=
slices
[
numDims
]
lowVol
,
highVol
=
slices
[
numDims
]
expansions
=
[]
expansions
=
[]
volumes
=
list
(
range
(
lowVol
,
highVol
))
volumes
=
[]
# TODO Currently, the returned expansion(s) includes
# TODO Currently, the returned expansion(s) includes
# the current coverage. Remove this duplication;
# the current coverage. Remove this duplication;
...
@@ -435,10 +435,16 @@ def calcExpansion(slices, coverage):
...
@@ -435,10 +435,16 @@ def calcExpansion(slices, coverage):
# one or more expansion slices without
# one or more expansion slices without
# overlapping the existing coverage.
# overlapping the existing coverage.
for
vol
in
volumes
:
for
vol
in
range
(
lowVol
,
highVol
):
expansion
=
[]
# First we'll figure out the index
# range for each dimension that
# needs to be added to the coverage.
# We build a list of required ranges,
# where each entry is a tuple
# containing:
# (dimension, lowIndex, highIndex)
reqRanges
=
[]
for
dim
in
range
(
numDims
):
for
dim
in
range
(
numDims
):
lowCover
,
highCover
=
coverage
[:,
dim
,
vol
]
lowCover
,
highCover
=
coverage
[:,
dim
,
vol
]
...
@@ -447,13 +453,53 @@ def calcExpansion(slices, coverage):
...
@@ -447,13 +453,53 @@ def calcExpansion(slices, coverage):
if
np
.
isnan
(
lowCover
):
lowCover
=
lowSlice
if
np
.
isnan
(
lowCover
):
lowCover
=
lowSlice
if
np
.
isnan
(
highCover
):
highCover
=
highSlice
if
np
.
isnan
(
highCover
):
highCover
=
highSlice
expansion
.
append
((
min
(
lowCover
,
lowSlice
),
# The slice covers a region
max
(
highCover
,
highSlice
)))
# below the current coverage
if
lowCover
-
lowSlice
>
0
:
expansion
.
append
((
vol
,
vol
+
1
))
reqRanges
.
append
((
dim
,
lowSlice
,
lowCover
))
for
i
in
range
(
padDims
):
expansion
.
append
((
0
,
1
))
# The slice covers a region
# above the current coverage
expansions
.
append
(
expansion
)
if
highCover
-
highSlice
<
0
:
reqRanges
.
append
((
dim
,
highCover
,
highSlice
))
# Now we generate an expansion for
# each of those ranges.
for
dimx
,
xlo
,
xhi
in
reqRanges
:
expansion
=
[[
0
,
0
]
for
d
in
range
(
numDims
)]
# The expansion for each
# dimension will span the range
# for that dimension...
expansion
[
dimx
][
0
]
=
xlo
expansion
[
dimx
][
1
]
=
xhi
# And will span the union of
# the range and coverage for
# every other dimension.
for
dimy
,
ylo
,
yhi
in
reqRanges
:
if
dimy
==
dimx
:
continue
# TODO The dimension expansions will
# potentially overlap. Remove
# this duplication.
yLowCover
,
yHighCover
=
coverage
[:,
dimy
,
vol
]
expansion
[
dimy
][
0
]
=
min
((
ylo
,
yLowCover
))
expansion
[
dimy
][
1
]
=
max
((
yhi
,
yHighCover
))
# Finish off this expansion by
# adding indices for the vector/
# slice/volume dimension, and for
# 'padding' dimensions of size 1.
expansion
.
append
((
vol
,
vol
+
1
))
for
i
in
range
(
padDims
):
expansion
.
append
((
0
,
1
))
volumes
.
append
(
vol
)
expansions
.
append
(
expansion
)
return
volumes
,
expansions
return
volumes
,
expansions
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