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
047ab19a
There was a problem fetching the pipeline summary.
Commit
047ab19a
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
More trying to reduce memory usage'
parent
0da742af
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/__init__.py
+9
-15
9 additions, 15 deletions
tests/__init__.py
tests/test_atlases.py
+13
-7
13 additions, 7 deletions
tests/test_atlases.py
tests/test_atlases_query.py
+4
-3
4 additions, 3 deletions
tests/test_atlases_query.py
with
26 additions
and
25 deletions
tests/__init__.py
+
9
−
15
View file @
047ab19a
...
@@ -285,21 +285,15 @@ def make_random_mask(filename, shape, xform, premask=None):
...
@@ -285,21 +285,15 @@ def make_random_mask(filename, shape, xform, premask=None):
mask
=
np
.
zeros
(
shape
,
dtype
=
np
.
uint8
)
mask
=
np
.
zeros
(
shape
,
dtype
=
np
.
uint8
)
if
premask
is
None
:
numones
=
np
.
random
.
randint
(
1
,
np
.
prod
(
shape
)
/
100
)
numones
=
np
.
random
.
randint
(
1
,
np
.
prod
(
shape
)
/
100
)
xc
=
np
.
random
.
randint
(
0
,
shape
[
0
],
numones
)
xc
=
np
.
random
.
randint
(
0
,
shape
[
0
],
numones
)
yc
=
np
.
random
.
randint
(
0
,
shape
[
1
],
numones
)
yc
=
np
.
random
.
randint
(
0
,
shape
[
1
],
numones
)
zc
=
np
.
random
.
randint
(
0
,
shape
[
2
],
numones
)
zc
=
np
.
random
.
randint
(
0
,
shape
[
2
],
numones
)
mask
[
xc
,
yc
,
zc
]
=
1
mask
[
xc
,
yc
,
zc
]
=
1
else
:
xc
,
yc
,
zc
=
np
.
where
(
premask
)
if
premask
is
not
None
:
numones
=
np
.
random
.
randint
(
1
,
len
(
xc
))
mask
[
premask
==
0
]
=
0
idxs
=
np
.
random
.
randint
(
1
,
len
(
xc
),
numones
)
xc
=
xc
[
idxs
]
yc
=
yc
[
idxs
]
zc
=
zc
[
idxs
]
mask
[
xc
,
yc
,
zc
]
=
1
img
=
fslimage
.
Image
(
mask
,
xform
=
xform
)
img
=
fslimage
.
Image
(
mask
,
xform
=
xform
)
img
.
save
(
filename
)
img
.
save
(
filename
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_atlases.py
+
13
−
7
View file @
047ab19a
...
@@ -20,7 +20,7 @@ import pytest
...
@@ -20,7 +20,7 @@ import pytest
import
tests
import
tests
import
fsl.utils.transform
as
transform
import
fsl.utils.transform
as
transform
import
fsl.data.atlases
as
atlases
import
fsl.data.atlases
as
atlases
import
fsl.data.image
as
fslimage
import
fsl.data.image
as
fslimage
datadir
=
op
.
join
(
op
.
dirname
(
__file__
),
'
testdata
'
)
datadir
=
op
.
join
(
op
.
dirname
(
__file__
),
'
testdata
'
)
...
@@ -222,7 +222,8 @@ def test_load_atlas():
...
@@ -222,7 +222,8 @@ def test_load_atlas():
reg
=
atlases
.
registry
reg
=
atlases
.
registry
reg
.
rescanAtlases
()
reg
.
rescanAtlases
()
probatlas
=
reg
.
loadAtlas
(
'
harvardoxford-cortical
'
)
probatlas
=
reg
.
loadAtlas
(
'
harvardoxford-cortical
'
,
indexed
=
True
,
calcRange
=
False
,
loadData
=
False
)
probsumatlas
=
reg
.
loadAtlas
(
'
harvardoxford-cortical
'
,
loadSummary
=
True
)
probsumatlas
=
reg
.
loadAtlas
(
'
harvardoxford-cortical
'
,
loadSummary
=
True
)
lblatlas
=
reg
.
loadAtlas
(
'
talairach
'
)
lblatlas
=
reg
.
loadAtlas
(
'
talairach
'
)
...
@@ -236,7 +237,8 @@ def test_find():
...
@@ -236,7 +237,8 @@ def test_find():
reg
=
atlases
.
registry
reg
=
atlases
.
registry
reg
.
rescanAtlases
()
reg
.
rescanAtlases
()
probatlas
=
reg
.
loadAtlas
(
'
harvardoxford-cortical
'
)
probatlas
=
reg
.
loadAtlas
(
'
harvardoxford-cortical
'
,
indexed
=
True
,
calcRange
=
False
,
loadData
=
False
)
probsumatlas
=
reg
.
loadAtlas
(
'
harvardoxford-cortical
'
,
loadSummary
=
True
)
probsumatlas
=
reg
.
loadAtlas
(
'
harvardoxford-cortical
'
,
loadSummary
=
True
)
lblatlas
=
reg
.
loadAtlas
(
'
talairach
'
)
lblatlas
=
reg
.
loadAtlas
(
'
talairach
'
)
...
@@ -268,7 +270,8 @@ def test_prepareMask():
...
@@ -268,7 +270,8 @@ def test_prepareMask():
reg
=
atlases
.
registry
reg
=
atlases
.
registry
reg
.
rescanAtlases
()
reg
.
rescanAtlases
()
probatlas
=
reg
.
loadAtlas
(
'
harvardoxford-cortical
'
)
probatlas
=
reg
.
loadAtlas
(
'
harvardoxford-cortical
'
,
indexed
=
True
,
loadData
=
False
,
calcRange
=
False
)
probsumatlas
=
reg
.
loadAtlas
(
'
harvardoxford-cortical
'
,
loadSummary
=
True
)
probsumatlas
=
reg
.
loadAtlas
(
'
harvardoxford-cortical
'
,
loadSummary
=
True
)
lblatlas
=
reg
.
loadAtlas
(
'
talairach
'
)
lblatlas
=
reg
.
loadAtlas
(
'
talairach
'
)
...
@@ -276,13 +279,16 @@ def test_prepareMask():
...
@@ -276,13 +279,16 @@ def test_prepareMask():
ashape
=
list
(
atlas
.
shape
[:
3
])
ashape
=
list
(
atlas
.
shape
[:
3
])
m2shape
=
[
s
*
1.5
for
s
in
ashape
]
m2shape
=
[
s
*
1.5
for
s
in
ashape
]
goodmask1
=
fslimage
.
Image
(
np
.
random
.
random
(
ashape
),
xform
=
atlas
.
voxToWorldMat
)
goodmask1
=
fslimage
.
Image
(
np
.
array
(
np
.
random
.
random
(
ashape
),
dtype
=
np
.
float32
),
xform
=
atlas
.
voxToWorldMat
)
goodmask2
,
xf
=
goodmask1
.
resample
(
m2shape
)
goodmask2
,
xf
=
goodmask1
.
resample
(
m2shape
)
goodmask2
=
fslimage
.
Image
(
goodmask2
,
xform
=
xf
)
goodmask2
=
fslimage
.
Image
(
goodmask2
,
xform
=
xf
)
wrongdims
=
fslimage
.
Image
(
wrongdims
=
fslimage
.
Image
(
np
.
random
.
random
(
list
(
ashape
)
+
[
10
]))
np
.
random
.
random
(
list
(
ashape
)
+
[
2
]))
wrongspace
=
fslimage
.
Image
(
wrongspace
=
fslimage
.
Image
(
np
.
random
.
random
((
20
,
20
,
20
)),
np
.
random
.
random
((
20
,
20
,
20
)),
xform
=
transform
.
concat
(
atlas
.
voxToWorldMat
,
np
.
diag
([
2
,
2
,
2
,
1
])))
xform
=
transform
.
concat
(
atlas
.
voxToWorldMat
,
np
.
diag
([
2
,
2
,
2
,
1
])))
...
...
This diff is collapsed.
Click to expand it.
tests/test_atlases_query.py
+
4
−
3
View file @
047ab19a
...
@@ -34,11 +34,12 @@ def _repeat(iterator, n):
...
@@ -34,11 +34,12 @@ def _repeat(iterator, n):
yield
elem
yield
elem
_atlases
=
cache
.
Cache
(
maxsize
=
1
)
_atlases
=
cache
.
Cache
()
def
_get_atlas
(
atlasID
,
res
,
summary
=
False
):
def
_get_atlas
(
atlasID
,
res
,
summary
=
False
):
atlas
=
_atlases
.
get
((
atlasID
,
res
,
summary
),
default
=
None
)
atlas
=
_atlases
.
get
((
atlasID
,
res
,
summary
),
default
=
None
)
if
atlas
is
None
:
if
atlas
is
None
:
if
summary
or
atlasID
in
(
'
talairach
'
,
'
striatum-structural
'
,
'
jhu-labels
'
):
if
summary
or
atlasID
in
(
'
talairach
'
,
'
striatum-structural
'
,
'
jhu-labels
'
):
kwargs
=
{}
kwargs
=
{}
else
:
else
:
kwargs
=
{
'
loadData
'
:
False
,
kwargs
=
{
'
loadData
'
:
False
,
...
@@ -66,7 +67,7 @@ def _random_atlas(atype, res, summary=False):
...
@@ -66,7 +67,7 @@ def _random_atlas(atype, res, summary=False):
# Generate a mask which tells us which
# Generate a mask which tells us which
# voxels in the atlas are all zeros
# voxels in the atlas are all zeros
_zero_masks
=
{}
_zero_masks
=
cache
.
Cache
(
maxsize
=
5
)
def
_get_zero_mask
(
aimg
):
def
_get_zero_mask
(
aimg
):
atlasID
=
aimg
.
desc
.
atlasID
atlasID
=
aimg
.
desc
.
atlasID
...
...
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