Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
multichip-snakemake
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Andrey ARISTOV
multichip-snakemake
Commits
e79f04bb
Commit
e79f04bb
authored
2 years ago
by
Andrey Aristov
Browse files
Options
Downloads
Patches
Plain Diff
rotate in the thread
parent
453a8881
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
align.py
+28
-9
28 additions, 9 deletions
align.py
with
28 additions
and
9 deletions
align.py
+
28
−
9
View file @
e79f04bb
...
@@ -16,13 +16,21 @@ from scipy.ndimage import laplace, rotate
...
@@ -16,13 +16,21 @@ from scipy.ndimage import laplace, rotate
import
json
import
json
def
align_multichip
(
BF_TRITC_2D_path
,
out_path
,
concentrations_path
,
template_path
,
labels_path
,
table_path
,
fit_poisson
,
nmax
=
10
):
def
align_multichip
(
BF_TRITC_2D_path
,
out_path
,
concentrations_path
,
template_path
,
labels_path
,
table_path
,
fit_poisson
,
nmax
=
10
):
with
open
(
concentrations_path
,
'
r
'
)
as
f
:
with
open
(
concentrations_path
,
'
r
'
)
as
f
:
concentrations_dct
=
(
yaml
.
safe_load
(
f
))
concentrations_dct
=
(
yaml
.
safe_load
(
f
))
concentrations
=
concentrations_dct
[
'
concentrations
'
]
concentrations
=
concentrations_dct
[
'
concentrations
'
]
if
"
rotation_
templ
at
e
_deg
"
in
concentrations_dct
:
if
"
rotation_
d
at
a
_deg
"
in
concentrations_dct
:
rotat
e_templ
at
e
_deg
=
int
(
concentrations_dct
[
"
rotation_
templ
at
e
_deg
"
])
rotat
ion_d
at
a
_deg
=
int
(
concentrations_dct
[
"
rotation_
d
at
a
_deg
"
])
print
(
f
'
Rotation:
{
rotat
e_templ
at
e
_deg
}
'
)
print
(
f
'
Rotation:
{
rotat
ion_d
at
a
_deg
}
'
)
else
:
else
:
rotate_template_deg
=
0
rotate_template_deg
=
0
print
(
'
concentrations:
'
,
concentrations
)
print
(
'
concentrations:
'
,
concentrations
)
...
@@ -32,9 +40,6 @@ def align_multichip(BF_TRITC_2D_path, out_path, concentrations_path, template_pa
...
@@ -32,9 +40,6 @@ def align_multichip(BF_TRITC_2D_path, out_path, concentrations_path, template_pa
data
=
read_dask
(
BF_TRITC_2D_path
)
data
=
read_dask
(
BF_TRITC_2D_path
)
template16
=
tf
.
imread
(
template_path
)
template16
=
tf
.
imread
(
template_path
)
if
rotate_template_deg
!=
0
:
data
=
da
.
from_array
(
rotate
(
data
,
rotate_template_deg
))
print
(
f
'
Rotated data
{
rotate_template_deg
}
deg
'
)
big_labels
=
tf
.
imread
(
labels_path
)
big_labels
=
tf
.
imread
(
labels_path
)
fun
=
partial
(
fun
=
partial
(
...
@@ -43,7 +48,8 @@ def align_multichip(BF_TRITC_2D_path, out_path, concentrations_path, template_pa
...
@@ -43,7 +48,8 @@ def align_multichip(BF_TRITC_2D_path, out_path, concentrations_path, template_pa
big_labels
=
big_labels
,
big_labels
=
big_labels
,
unit
=
unit
,
unit
=
unit
,
fit_poisson
=
fit_poisson
,
fit_poisson
=
fit_poisson
,
nmax
=
nmax
)
nmax
=
nmax
,
rotation_data_deg
=
rotation_data_deg
)
try
:
try
:
p
=
Pool
(
data
.
shape
[
0
])
p
=
Pool
(
data
.
shape
[
0
])
...
@@ -89,7 +95,16 @@ def align_multichip(BF_TRITC_2D_path, out_path, concentrations_path, template_pa
...
@@ -89,7 +95,16 @@ def align_multichip(BF_TRITC_2D_path, out_path, concentrations_path, template_pa
def
align_parallel
(
args
,
**
kwargs
):
def
align_parallel
(
args
,
**
kwargs
):
return
align2D
(
*
args
,
**
kwargs
)
return
align2D
(
*
args
,
**
kwargs
)
def
align2D
(
stack_dask
,
path_tif
,
ab
,
template16
=
None
,
big_labels
=
None
,
unit
=
'
μg_mL
'
,
fit_poisson
=
True
,
nmax
=
20
):
def
align2D
(
stack_dask
,
path_tif
,
ab
,
template16
=
None
,
big_labels
=
None
,
unit
=
'
μg_mL
'
,
fit_poisson
=
True
,
nmax
=
20
,
rotation_data_deg
=
0
):
print
(
ab
,
unit
)
print
(
ab
,
unit
)
try
:
try
:
aligned
=
tf
.
imread
(
path_tif
)
aligned
=
tf
.
imread
(
path_tif
)
...
@@ -102,6 +117,10 @@ def align2D(stack_dask, path_tif, ab, template16=None, big_labels=None, unit='μ
...
@@ -102,6 +117,10 @@ def align2D(stack_dask, path_tif, ab, template16=None, big_labels=None, unit='μ
print
(
'
Processing...
'
)
print
(
'
Processing...
'
)
data
=
stack_dask
.
compute
()
data
=
stack_dask
.
compute
()
if
rotation_data_deg
!=
0
:
data
=
rotate
(
data
,
rotation_data_deg
)
print
(
f
'
Rotated data
{
rotation_data_deg
}
deg
'
)
aligned
,
tvec
=
register
.
align_stack
(
aligned
,
tvec
=
register
.
align_stack
(
data
,
data
,
path_to_save
=
None
,
path_to_save
=
None
,
...
...
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