Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nd2shrink
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
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
nd2shrink
Commits
27fbc7b6
Commit
27fbc7b6
authored
4 years ago
by
Andrey Aristov
Browse files
Options
Downloads
Patches
Plain Diff
assemble container with warnings
parent
43e12d33
No related branches found
No related tags found
1 merge request
!5
fix testing and stuff
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Dockerfile
+7
-9
7 additions, 9 deletions
Dockerfile
droplet_growth/register.py
+103
-0
103 additions, 0 deletions
droplet_growth/register.py
with
110 additions
and
9 deletions
Dockerfile
+
7
−
9
View file @
27fbc7b6
FROM
python:latest
FROM
jupyter/datascience-notebook:latest
WORKDIR
/root
WORKDIR
/home/jovyan
USER
root
COPY
. .
COPY
. .
RUN
apt-get update
RUN
apt-get
install
'ffmpeg'
\
'libsm6'\
'libxext6' -y
RUN
python
-V
&&
\
RUN
python
-V
&&
\
python -m pip install -r requirements.txt &&\
# python -m pip install -r requirements.txt &&\
python setup.py install
pip install -e .
CMD
python -V && jupyter lab
USER
jovyan
\ No newline at end of file
CMD
python -V && jupyter notebook
\ No newline at end of file
This diff is collapsed.
Click to expand it.
droplet_growth/register.py
+
103
−
0
View file @
27fbc7b6
...
@@ -13,6 +13,7 @@ def align_stack(path, template16, mask2, plot=False, binnings=(1,16,2)):
...
@@ -13,6 +13,7 @@ def align_stack(path, template16, mask2, plot=False, binnings=(1,16,2)):
stack should contain two channels: bright field and fluorescence.
stack should contain two channels: bright field and fluorescence.
BF will be binned 8 times and registered with template8 (aligned BF).
BF will be binned 8 times and registered with template8 (aligned BF).
When the transformation verctor will be applied to the original data and stacked with the mask.
When the transformation verctor will be applied to the original data and stacked with the mask.
The output stack is of the same size as mask.
The resulting 3-layer stack will be returned and also saved with suffix
"
.aligned.tif
"
The resulting 3-layer stack will be returned and also saved with suffix
"
.aligned.tif
"
'''
'''
...
@@ -58,6 +59,107 @@ def align_stack(path, template16, mask2, plot=False, binnings=(1,16,2)):
...
@@ -58,6 +59,107 @@ def align_stack(path, template16, mask2, plot=False, binnings=(1,16,2)):
return
aligned_stack
return
aligned_stack
def
align_timelapse
(
bf
,
fluo_stack
,
template16
,
mask2
,
plot
=
False
,
binnings
=
(
4
,
16
,
2
)):
'''
stack should contain two channels: bright field and fluorescence.
BF will be binned 8 times and registered with template8 (aligned BF).
When the transformation verctor will be applied to the original data and stacked with the mask.
The output stack is of the same size as mask.
The resulting 3-layer stack will be returned and also saved with suffix
"
.aligned.tif
"
'''
stack_temp_scale
=
binnings
[
1
]
//
binnings
[
0
]
mask_temp_scale
=
binnings
[
1
]
//
binnings
[
2
]
mask_bf_scale
=
binnings
[
0
]
//
binnings
[
2
]
f_bf
=
filter_by_fft
(
bf
[::
stack_temp_scale
,
::
stack_temp_scale
],
sigma
=
40
,
fix_horizontal_stripes
=
True
,
fix_vertical_stripes
=
True
,
highpass
=
True
)
tvec8
=
get_transform
(
f_bf
,
template16
,
plot
=
plot
)
plt
.
show
()
tvec
=
scale_tvec
(
tvec8
,
stack_temp_scale
)
print
(
tvec
)
mask
=
mask2
[::
mask_bf_scale
,
::
mask_bf_scale
]
aligned_bf
=
unpad
(
transform
(
bf
,
tvec
),
mask
.
shape
)
if
plot
:
plt
.
figure
(
dpi
=
300
)
plt
.
imshow
(
bf
,
cmap
=
'
gray
'
,)
# vmax=aligned_tritc.max()/5)
plt
.
colorbar
()
plt
.
title
(
'
Original image
'
)
plt
.
show
()
plt
.
figure
(
dpi
=
300
)
plt
.
imshow
(
mic
.
segment
.
label2rgb
(
mask
,
to_8bits
(
aligned_bf
),
bg_label
=
0
))
plt
.
title
(
'
Aligned mask over aligned image
'
)
plt
.
show
()
aligned_fluo
=
list
(
map
(
lambda
x
:
unpad
(
transform
(
x
,
tvec
),
mask
.
shape
),
fluo_stack
))
return
(
aligned_bf
,
aligned_fluo
,
mask
)
def
align_mask_to_bf
(
bf_path
,
template16
,
mask2
,
plot
=
False
,
binnings
=
(
4
,
16
,
2
)):
'''
bf_path sould contain tif with bright field.
BF will be binned and used as a template to aligh template8.
When the transformation verctor will be applied to the mask which will be returned
resized to the size of the BF input.
The aligned mask will be saved as
"
mask.aligned.tif
"
'''
bf
=
imread
(
bf_path
)
print
(
bf_path
,
bf
.
shape
)
bf_temp_scale
=
binnings
[
1
]
//
binnings
[
0
]
mask_temp_scale
=
binnings
[
1
]
//
binnings
[
2
]
mask_bf_scale
=
binnings
[
0
]
//
binnings
[
2
]
f_bf
=
filter_by_fft
(
bf
[::
bf_temp_scale
,
::
bf_temp_scale
],
sigma
=
40
,
fix_horizontal_stripes
=
True
,
fix_vertical_stripes
=
True
,
highpass
=
True
)
tvec8
=
get_transform
(
pad
(
template16
,
f_bf
.
shape
),
f_bf
,
plot
=
plot
)
plt
.
show
()
tvec
=
scale_tvec
(
tvec8
,
mask_temp_scale
)
print
(
tvec
)
padded_mask
=
pad
(
mask2
[::
mask_bf_scale
,
::
mask_bf_scale
],
bf
.
shape
)
aligned_mask
=
unpad
(
transform
(
padded_mask
,
tvec
),
bf
.
shape
)
if
plot
:
plt
.
figure
(
dpi
=
300
)
plt
.
imshow
(
bf
,
cmap
=
'
gray
'
,)
# vmax=aligned_tritc.max()/5)
plt
.
colorbar
()
plt
.
title
(
'
Original image
'
)
plt
.
show
()
plt
.
figure
(
dpi
=
300
)
plt
.
imshow
(
tvec8
[
"
timg
"
],
cmap
=
'
gray
'
,)
# vmax=aligned_tritc.max()/5)
plt
.
colorbar
()
plt
.
title
(
'
Aligned template
'
)
plt
.
show
()
plt
.
figure
(
dpi
=
300
)
plt
.
imshow
(
mic
.
segment
.
label2rgb
(
aligned_mask
,
to_8bits
(
bf
),
bg_label
=
0
))
plt
.
title
(
'
Aligned mask over orginal image
'
)
plt
.
show
()
save_path
=
bf_path
.
replace
(
'
.tif
'
,
'
.mask.aligned.tif
'
)
imwrite
(
save_path
,
aligned_mask
)
print
(
f
"
Saved
{
save_path
}
"
)
return
aligned_mask
def
get_transform
(
image
,
template
,
plot
=
True
,
pad_ratio
=
1.2
,
figsize
=
(
10
,
5
),
dpi
=
300
):
def
get_transform
(
image
,
template
,
plot
=
True
,
pad_ratio
=
1.2
,
figsize
=
(
10
,
5
),
dpi
=
300
):
'''
'''
Pads image and template, registers and returns tvec
Pads image and template, registers and returns tvec
...
@@ -176,6 +278,7 @@ def scale_tvec(tvec, scale=8):
...
@@ -176,6 +278,7 @@ def scale_tvec(tvec, scale=8):
def
transform
(
image
,
tvec
):
def
transform
(
image
,
tvec
):
print
(
f
'
input
{
image
.
shape
}
'
)
fluo
=
reg
.
transform_img_dict
(
image
,
tvec
)
fluo
=
reg
.
transform_img_dict
(
image
,
tvec
)
return
fluo
.
astype
(
'
uint
'
)
return
fluo
.
astype
(
'
uint
'
)
...
...
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