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
677d1402
Commit
677d1402
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Used more universal meta field for pixel scale, now a dict
parent
60a3e66e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
model_server/accessors.py
+7
-10
7 additions, 10 deletions
model_server/accessors.py
tests/test_accessors.py
+2
-1
2 additions, 1 deletion
tests/test_accessors.py
with
9 additions
and
11 deletions
model_server/accessors.py
+
7
−
10
View file @
677d1402
...
...
@@ -48,7 +48,7 @@ class GenericImageDataAccessor(ABC):
@property
def
pixel_scale_in_micrometers
(
self
):
return
None
return
{}
@property
def
dtype
(
self
):
...
...
@@ -176,15 +176,12 @@ class CziImageFileAccessor(GenericImageFileAccessor):
@property
def
pixel_scale_in_micrometers
(
self
):
meta_sc_str
=
self
.
czifile
.
metadata
(
raw
=
False
)[
'
ImageDocument
'
][
'
Metadata
'
][
'
ImageScaling
'
][
'
ImagePixelSize
'
]
meta_mags
=
self
.
czifile
.
metadata
(
raw
=
False
)[
'
ImageDocument
'
][
'
Metadata
'
][
'
ImageScaling
'
][
'
ScalingComponent
'
]
sc_xy
=
list
(
map
(
float
,
meta_sc_str
.
split
(
'
,
'
)
))
assert
sc_xy
[
0
]
==
sc_xy
[
1
]
mags
=
[
float
(
m
[
'
Magnification
'
])
for
m
in
meta_mags
]
return
sc_xy
[
0
]
/
np
.
product
(
mags
)
scale_meta
=
self
.
czifile
.
metadata
(
raw
=
False
)[
'
ImageDocument
'
][
'
Metadata
'
][
'
Scaling
'
][
'
Items
'
][
'
Distance
'
]
sc
=
{}
for
m
in
scale_meta
:
if
m
[
'
DefaultUnitFormat
'
].
encode
()
==
b
'
\xc2\xb5
m
'
and
m
[
'
Id
'
]
in
self
.
shape_dict
.
keys
():
# literal mu-m
sc
[
m
[
'
Id
'
]]
=
m
[
'
Value
'
]
*
1e6
return
sc
def
write_accessor_data_to_file
(
fpath
:
Path
,
accessor
:
GenericImageDataAccessor
,
mkdir
=
True
)
->
bool
:
...
...
This diff is collapsed.
Click to expand it.
tests/test_accessors.py
+
2
−
1
View file @
677d1402
...
...
@@ -114,4 +114,5 @@ class TestCziImageFileAccess(unittest.TestCase):
def
test_read_in_pixel_scale_from_czi
(
self
):
cf
=
CziImageFileAccessor
(
czifile
[
'
path
'
])
self
.
assertAlmostEqual
(
cf
.
pixel_scale_in_micrometers
,
czifile
[
'
um_per_pixel
'
],
places
=
3
)
\ No newline at end of file
pxs
=
cf
.
pixel_scale_in_micrometers
self
.
assertAlmostEqual
(
pxs
[
'
X
'
],
czifile
[
'
um_per_pixel
'
],
places
=
3
)
\ No newline at end of file
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