Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
model_server
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
Christopher Randolph Rhodes
model_server
Commits
bbe44945
Commit
bbe44945
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Open issue with axis flipping
parent
91091b3d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/ilastik3d.py
+2
-0
2 additions, 0 deletions
examples/ilastik3d.py
model_server/image.py
+4
-4
4 additions, 4 deletions
model_server/image.py
tests/test_image.py
+22
-3
22 additions, 3 deletions
tests/test_image.py
with
28 additions
and
7 deletions
examples/ilastik3d.py
+
2
−
0
View file @
bbe44945
...
...
@@ -65,4 +65,6 @@ if __name__ == '__main__':
resp_models
=
requests
.
get
(
uri
+
'
models
'
)
raise
Exception
(
'
x, y axes are currently flipped in pixelmap
'
)
server_process
.
terminate
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
model_server/image.py
+
4
−
4
View file @
bbe44945
...
...
@@ -81,14 +81,14 @@ class CziImageFileAccessor(GenericImageFileAccessor):
if
(
sd
.
get
(
'
S
'
)
and
(
sd
[
'
S
'
]
>
1
))
or
(
sd
.
get
(
'
T
'
)
and
(
sd
[
'
T
'
]
>
1
)):
raise
DataShapeError
(
f
'
Cannot handle image with multiple positions or time points:
{
sd
}
'
)
idx
=
{
k
:
sd
[
k
]
for
k
in
[
'
X
'
,
'
Y
'
,
'
C
'
,
'
Z
'
]}
x
ycz
=
np
.
moveaxis
(
idx
=
{
k
:
sd
[
k
]
for
k
in
[
'
Y
'
,
'
X
'
,
'
C
'
,
'
Z
'
]}
y
x
cz
=
np
.
moveaxis
(
cf
.
asarray
(),
[
cf
.
axes
.
index
(
ch
)
for
ch
in
idx
],
[
0
,
1
,
2
,
3
]
)
self
.
_data
=
self
.
conform_data
(
x
ycz
.
reshape
(
x
ycz
.
shape
[
0
:
4
]))
self
.
_data
=
self
.
conform_data
(
y
x
cz
.
reshape
(
y
x
cz
.
shape
[
0
:
4
]))
def
__del__
(
self
):
self
.
czifile
.
close
()
...
...
@@ -98,7 +98,7 @@ def write_accessor_data_to_file(fpath: Path, accessor: GenericImageDataAccessor)
try
:
zcxy
=
np
.
moveaxis
(
accessor
.
data
,
[
3
,
2
,
0
,
1
],
[
3
,
2
,
1
,
0
],
[
0
,
1
,
2
,
3
]
)
tifffile
.
imwrite
(
fpath
,
zcxy
,
imagej
=
True
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_image.py
+
22
−
3
View file @
bbe44945
...
...
@@ -26,9 +26,9 @@ class TestCziImageFileAccess(unittest.TestCase):
nc
=
4
nz
=
11
c
=
3
cf
=
InMemoryDataAccessor
(
np
.
random
.
rand
(
w
,
h
,
nc
,
nz
))
cf
=
InMemoryDataAccessor
(
np
.
random
.
rand
(
h
,
w
,
nc
,
nz
))
sc
=
cf
.
get_one_channel_data
(
c
)
self
.
assertEqual
(
sc
.
shape
,
(
w
,
h
,
1
,
nz
))
self
.
assertEqual
(
sc
.
shape
,
(
h
,
w
,
1
,
nz
))
def
test_write_single_channel_tif
(
self
):
ch
=
4
...
...
@@ -58,4 +58,23 @@ class TestCziImageFileAccess(unittest.TestCase):
def
test_conform_data_longer_than_xycz
(
self
):
data
=
np
.
random
.
rand
(
256
,
512
,
12
,
8
,
3
)
with
self
.
assertRaises
(
DataShapeError
):
acc
=
InMemoryDataAccessor
(
data
)
\ No newline at end of file
acc
=
InMemoryDataAccessor
(
data
)
def
test_write_multichannel_image_preserves_axes
(
self
):
h
=
256
w
=
512
c
=
3
nz
=
10
yxcz
=
(
2
**
8
*
np
.
random
.
rand
(
h
,
w
,
c
,
nz
)).
astype
(
'
uint8
'
)
acc
=
InMemoryDataAccessor
(
yxcz
)
self
.
assertTrue
(
write_accessor_data_to_file
(
output_path
/
f
'
rand3d.tif
'
,
acc
)
)
# need to sort out x,y flipping since np convention yxcz flips axes in 3d tif
self
.
assertEqual
(
acc
.
shape_dict
[
'
X
'
],
w
,
acc
.
shape_dict
)
self
.
assertEqual
(
acc
.
shape_dict
[
'
Y
'
],
h
,
acc
.
shape_dict
)
\ 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