Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
ToolBox
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
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
SCS
ToolBox
Commits
85e535e0
Commit
85e535e0
authored
2 years ago
by
Loïc Le Guyader
Browse files
Options
Downloads
Patches
Plain Diff
Adds function to split rois in two left-right
parent
4a15d598
Branches
CHEM-BOZ
No related tags found
1 merge request
!244
WIP: BOZ for CHEM
Pipeline
#96783
passed
2 years ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/toolbox_scs/routines/boz.py
+53
-16
53 additions, 16 deletions
src/toolbox_scs/routines/boz.py
with
53 additions
and
16 deletions
src/toolbox_scs/routines/boz.py
+
53
−
16
View file @
85e535e0
...
...
@@ -32,6 +32,7 @@ __all__ = [
'
inspect_histogram
'
,
'
find_rois
'
,
'
find_rois_from_params
'
,
'
rois_split_lr
'
,
'
inspect_rois
'
,
'
compute_flat_field_correction
'
,
'
inspect_flat_field_domain
'
,
...
...
@@ -665,6 +666,41 @@ def find_rois_from_params(params):
return
find_rois
(
data_mean
,
threshold
)
def
rois_split_lr
(
rois
,
left_fraction
,
gap
):
"""
Split
'
n
'
,
'
0
'
and
'
p
'
ROIs in left and right.
Inputs
------
rois: dictionnary of rois
left_fraction: float between 0 and 1, fraction of the initial
roi width to go to the left roi
gap: in pixel, gap to insert between the left and right rois
Returns
-------
modified dictionary with additional
'
n_l
'
,
'
n_r
'
,
'
0_l
'
,
'
0_r
'
,
'
p_l
'
,
'
p_r
'
rois
"""
for
k
in
[
'
n
'
,
'
0
'
,
'
p
'
]:
width
=
rois
[
k
][
'
xh
'
]
-
rois
[
k
][
'
xl
'
]
rois
[
k
+
'
_l
'
]
=
{
'
xl
'
:
rois
[
k
][
'
xl
'
],
'
xh
'
:
rois
[
k
][
'
xl
'
]
+
int
(
width
*
left_fraction
-
gap
/
2
),
'
yl
'
:
rois
[
k
][
'
yl
'
],
'
yh
'
:
rois
[
k
][
'
yh
'
]}
rois
[
k
+
'
_r
'
]
=
{
'
xl
'
:
rois
[
k
][
'
xl
'
]
+
int
(
width
*
left_fraction
+
gap
/
2
),
'
xh
'
:
rois
[
k
][
'
xh
'
],
'
yl
'
:
rois
[
k
][
'
yl
'
],
'
yh
'
:
rois
[
k
][
'
yh
'
]}
return
rois
def
_plot_roi
(
ax
,
roi
,
alpha
,
color
):
"""
Plot one ROIs
"""
from
matplotlib.patches
import
Rectangle
ax
.
add_patch
(
Rectangle
((
roi
[
'
xl
'
],
128
-
roi
[
'
yh
'
]),
roi
[
'
xh
'
]
-
roi
[
'
xl
'
],
roi
[
'
yh
'
]
-
roi
[
'
yl
'
],
alpha
=
alpha
,
color
=
color
))
def
inspect_rois
(
data_mean
,
rois
,
threshold
=
None
,
allrois
=
False
):
"""
Find rois from 3 beams configuration from mean module image.
...
...
@@ -705,22 +741,23 @@ def inspect_rois(data_mean, rois, threshold=None, allrois=False):
vmax
=
np
.
percentile
(
data_mean
[:,
:
256
],
99
))
main_ax
.
set_aspect
(
'
equal
'
)
from
matplotlib.patches
import
Rectangle
roi
=
rois
[
'
n
'
]
main_ax
.
add_patch
(
Rectangle
((
roi
[
'
xl
'
],
128
-
roi
[
'
yh
'
]),
roi
[
'
xh
'
]
-
roi
[
'
xl
'
],
roi
[
'
yh
'
]
-
roi
[
'
yl
'
],
alpha
=
0.3
,
color
=
'
b
'
))
roi
=
rois
[
'
0
'
]
main_ax
.
add_patch
(
Rectangle
((
roi
[
'
xl
'
],
128
-
roi
[
'
yh
'
]),
roi
[
'
xh
'
]
-
roi
[
'
xl
'
],
roi
[
'
yh
'
]
-
roi
[
'
yl
'
],
alpha
=
0.3
,
color
=
'
g
'
))
roi
=
rois
[
'
p
'
]
main_ax
.
add_patch
(
Rectangle
((
roi
[
'
xl
'
],
128
-
roi
[
'
yh
'
]),
roi
[
'
xh
'
]
-
roi
[
'
xl
'
],
roi
[
'
yh
'
]
-
roi
[
'
yl
'
],
alpha
=
0.3
,
color
=
'
r
'
))
if
'
n_l
'
in
rois
:
_plot_roi
(
main_ax
,
rois
[
'
n_l
'
],
0.3
,
'
b
'
)
_plot_roi
(
main_ax
,
rois
[
'
n_r
'
],
0.3
,
'
b
'
)
else
:
_plot_roi
(
main_ax
,
rois
[
'
n
'
],
0.3
,
'
b
'
)
if
'
0_l
'
in
rois
:
_plot_roi
(
main_ax
,
rois
[
'
0_l
'
],
0.3
,
'
g
'
)
_plot_roi
(
main_ax
,
rois
[
'
0_r
'
],
0.3
,
'
g
'
)
else
:
_plot_roi
(
main_ax
,
rois
[
'
0
'
],
0.3
,
'
g
'
)
if
'
p_l
'
in
rois
:
_plot_roi
(
main_ax
,
rois
[
'
p_l
'
],
0.3
,
'
r
'
)
_plot_roi
(
main_ax
,
rois
[
'
p_r
'
],
0.3
,
'
r
'
)
else
:
_plot_roi
(
main_ax
,
rois
[
'
p
'
],
0.3
,
'
r
'
)
x
.
plot
(
Xs
,
pX
)
x
.
invert_yaxis
()
...
...
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