Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SVLT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
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
ALMF
SVLT
Commits
0f5f4bd8
Commit
0f5f4bd8
authored
1 month ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Handling of feature extraction on empty RoiSets
parent
36499d70
No related branches found
Branches containing commit
No related tags found
2 merge requests
!4
Migrate project from rhodes/model_server to grp-almf/svlt
,
!3
Migrate from rhodes/model_server to grp-almf/svlt repo
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
model_server/rois/roiset.py
+5
-1
5 additions, 1 deletion
model_server/rois/roiset.py
tests/rois/test_features.py
+20
-0
20 additions, 0 deletions
tests/rois/test_features.py
tests/rois/test_roiset.py
+6
-0
6 additions, 0 deletions
tests/rois/test_roiset.py
with
31 additions
and
1 deletion
model_server/rois/roiset.py
+
5
−
1
View file @
0f5f4bd8
...
...
@@ -550,6 +550,8 @@ class RoiSet(object):
return
PatchStack
(
list
(
se_ext
))
def
get_patch_obmap_acc
(
self
,
**
kwargs
)
->
Union
[
PatchStack
,
None
]:
if
self
.
count
==
0
:
return
None
labels
=
self
.
df
().
index
.
sort_values
().
to_list
()
acc_masks
=
self
.
get_patch_masks_acc
(
**
kwargs
)
return
PatchStack
([(
acc_masks
.
iat
(
i
).
data
>
0
)
*
labels
[
i
]
for
i
in
range
(
0
,
len
(
labels
))])
...
...
@@ -908,13 +910,15 @@ class RoiSet(object):
:param extractor: function that takes an RoiSet object and returns a DataFrame of features
:param kwargs: variable-length keyword arguments that are passed to feature extractor
"""
if
self
.
count
==
0
:
return
df_features
=
extractor
(
self
,
**
kwargs
)
insert_level
(
df_features
,
'
features
'
)
self
.
_df
=
self
.
_df
.
join
(
df_features
)
def
get_features
(
self
)
->
pd
.
DataFrame
:
return
self
.
df
().
features
return
self
.
df
().
get
(
'
features
'
)
@classmethod
...
...
This diff is collapsed.
Click to expand it.
tests/rois/test_features.py
+
20
−
0
View file @
0f5f4bd8
...
...
@@ -70,3 +70,23 @@ class TestRoiSetMonoProducts(unittest.TestCase):
roiset
.
extract_features
(
regionprops
,
make_3d
=
True
,
channel
=
2
)
self
.
assertTrue
((
'
features
'
,
'
intensity_std-2
'
)
in
roiset
.
df
().
columns
)
self
.
assertTrue
(
'
intensity_std-2
'
in
roiset
.
get_features
())
def
test_empty_roiset_extract_features
(
self
):
import
numpy
as
np
from
model_server.base.accessors
import
InMemoryDataAccessor
arr_mask
=
InMemoryDataAccessor
(
np
.
zeros
([
*
stack
.
hw
,
1
,
stack
.
nz
],
dtype
=
'
uint8
'
))
roiset
=
RoiSet
.
from_binary_mask
(
stack
,
arr_mask
,
params
=
RoiSetMetaParams
(
filters
=
{
'
area
'
:
{
'
min
'
:
1e3
,
'
max
'
:
1e4
}},
expand_box_by
=
(
128
,
2
)
),
allow_3d
=
True
,
)
self
.
assertEqual
(
roiset
.
count
,
0
)
roiset
.
extract_features
(
regionprops
,
make_3d
=
True
,
channel
=
2
)
self
.
assertTrue
((
'
features
'
,
'
intensity_std-2
'
)
not
in
roiset
.
df
().
columns
)
self
.
assertIsNone
(
roiset
.
get_features
())
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/rois/test_roiset.py
+
6
−
0
View file @
0f5f4bd8
...
...
@@ -915,6 +915,12 @@ class TestEmptyRoiSet(unittest.TestCase):
self
.
assertEqual
(
len
(
df_patches
),
0
)
self
.
assertIsNone
(
roiset
.
get_patches_acc
(
make_3d
=
True
))
def
test_get_obmaps
(
self
):
roiset
=
self
.
empty_roiset
self
.
assertEqual
(
roiset
.
count
,
0
)
acc_obmap
=
roiset
.
get_patch_obmap_acc
(
make_3d
=
True
)
self
.
assertIsNone
(
acc_obmap
)
def
test_run_exports
(
self
):
roiset
=
self
.
empty_roiset
export_params
=
RoiSetExportParams
(
**
{
...
...
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