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
e3e80e05
Commit
e3e80e05
authored
6 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Merged in changes with accessor convenience methods
parent
b8382eca
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
model_server/base/accessors.py
+27
-5
27 additions, 5 deletions
model_server/base/accessors.py
with
27 additions
and
5 deletions
model_server/base/accessors.py
+
27
−
5
View file @
e3e80e05
...
@@ -51,6 +51,9 @@ class GenericImageDataAccessor(ABC):
...
@@ -51,6 +51,9 @@ class GenericImageDataAccessor(ABC):
def
get_zi
(
self
,
zi
:
int
):
def
get_zi
(
self
,
zi
:
int
):
"""
Return a new accessor of a specific z-coordinate
"""
return
self
.
_derived_accessor
(
return
self
.
_derived_accessor
(
self
.
data
.
take
(
self
.
data
.
take
(
indices
=
[
zi
],
indices
=
[
zi
],
...
@@ -58,8 +61,14 @@ class GenericImageDataAccessor(ABC):
...
@@ -58,8 +61,14 @@ class GenericImageDataAccessor(ABC):
)
)
)
)
def
get_mip
(
self
):
"""
Return a new accessor of maximum intensity projection (MIP) along z-axis
"""
return
self
.
apply
(
lambda
x
:
x
.
max
(
axis
=
self
.
_ga
(
'
Z
'
),
keepdims
=
True
))
def
get_mono
(
self
,
channel
:
int
,
mip
:
bool
=
False
,
squeeze
=
False
):
def
get_mono
(
self
,
channel
:
int
,
mip
:
bool
=
False
):
return
self
.
get_channels
([
channel
],
mip
=
mip
)
return
self
.
get_channels
([
channel
],
mip
=
mip
)
@property
@property
...
@@ -79,7 +88,7 @@ class GenericImageDataAccessor(ABC):
...
@@ -79,7 +88,7 @@ class GenericImageDataAccessor(ABC):
def
_gc
(
self
,
channels
):
def
_gc
(
self
,
channels
):
return
self
.
get_channels
(
list
(
channels
))
return
self
.
get_channels
(
list
(
channels
))
def
_
unique
(
self
):
def
unique
(
self
):
return
np
.
unique
(
self
.
data
,
return_counts
=
True
)
return
np
.
unique
(
self
.
data
,
return_counts
=
True
)
@property
@property
...
@@ -153,6 +162,14 @@ class GenericImageDataAccessor(ABC):
...
@@ -153,6 +162,14 @@ class GenericImageDataAccessor(ABC):
func
(
self
.
data
)
func
(
self
.
data
)
)
)
@property
def
info
(
self
):
return
{
'
shape_dict
'
:
self
.
shape_dict
,
'
dtype
'
:
str
(
self
.
dtype
),
'
filepath
'
:
''
,
}
class
InMemoryDataAccessor
(
GenericImageDataAccessor
):
class
InMemoryDataAccessor
(
GenericImageDataAccessor
):
def
__init__
(
self
,
data
):
def
__init__
(
self
,
data
):
self
.
_data
=
self
.
conform_data
(
data
)
self
.
_data
=
self
.
conform_data
(
data
)
...
@@ -172,6 +189,12 @@ class GenericImageFileAccessor(GenericImageDataAccessor): # image data is loaded
...
@@ -172,6 +189,12 @@ class GenericImageFileAccessor(GenericImageDataAccessor): # image data is loaded
def
read
(
fp
:
Path
):
def
read
(
fp
:
Path
):
return
generate_file_accessor
(
fp
)
return
generate_file_accessor
(
fp
)
@property
def
info
(
self
):
d
=
super
().
info
d
[
'
filepath
'
]
=
self
.
fpath
.
__str__
()
return
d
class
TifSingleSeriesFileAccessor
(
GenericImageFileAccessor
):
class
TifSingleSeriesFileAccessor
(
GenericImageFileAccessor
):
def
__init__
(
self
,
fpath
:
Path
):
def
__init__
(
self
,
fpath
:
Path
):
super
().
__init__
(
fpath
)
super
().
__init__
(
fpath
)
...
@@ -273,7 +296,7 @@ class CziImageFileAccessor(GenericImageFileAccessor):
...
@@ -273,7 +296,7 @@ class CziImageFileAccessor(GenericImageFileAccessor):
def
write_accessor_data_to_file
(
fpath
:
Path
,
acc
:
GenericImageDataAccessor
,
mkdir
=
True
)
->
bool
:
def
write_accessor_data_to_file
(
fpath
:
Path
,
acc
:
GenericImageDataAccessor
,
mkdir
=
True
)
->
bool
:
"""
"""
Export an image accessor to file
.
Export an image accessor to file
:param fpath: complete path including filename and extension
:param fpath: complete path including filename and extension
:param acc: image accessor to be written
:param acc: image accessor to be written
:param mkdir: create any needed subdirectories in fpath if True
:param mkdir: create any needed subdirectories in fpath if True
...
@@ -320,7 +343,7 @@ def write_accessor_data_to_file(fpath: Path, acc: GenericImageDataAccessor, mkdi
...
@@ -320,7 +343,7 @@ def write_accessor_data_to_file(fpath: Path, acc: GenericImageDataAccessor, mkdi
def
generate_file_accessor
(
fpath
):
def
generate_file_accessor
(
fpath
):
"""
"""
Given an image file path, return an image accessor, assuming the file is a supported format and represents
Given an image file path, return an image accessor, assuming the file is a supported format and represents
a single position array, which may be single or multi
-
channel, single plane or z-stack.
a single position array, which may be single or multichannel, single plane or z-stack.
"""
"""
if
str
(
fpath
).
upper
().
endswith
(
'
.TIF
'
)
or
str
(
fpath
).
upper
().
endswith
(
'
.TIFF
'
):
if
str
(
fpath
).
upper
().
endswith
(
'
.TIF
'
)
or
str
(
fpath
).
upper
().
endswith
(
'
.TIFF
'
):
return
TifSingleSeriesFileAccessor
(
fpath
)
return
TifSingleSeriesFileAccessor
(
fpath
)
...
@@ -470,7 +493,6 @@ def make_patch_stack_from_file(fpath): # interpret t-dimension as patch positio
...
@@ -470,7 +493,6 @@ def make_patch_stack_from_file(fpath): # interpret t-dimension as patch positio
return
PatchStack
(
pyxcz
)
return
PatchStack
(
pyxcz
)
class
Error
(
Exception
):
class
Error
(
Exception
):
pass
pass
...
...
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