Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Create mosaïc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DISCO Beamline
Create mosaïc
Commits
5ff1b3ed
Commit
5ff1b3ed
authored
Mar 27, 2023
by
Hugo CHAUVET
Browse files
Options
Downloads
Patches
Plain Diff
Allow single image processing
parent
589f99ab
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ImageJ/script_mosaic_telemos.py
+42
-21
42 additions, 21 deletions
ImageJ/script_mosaic_telemos.py
with
42 additions
and
21 deletions
ImageJ/script_mosaic_telemos.py
+
42
−
21
View file @
5ff1b3ed
...
...
@@ -149,7 +149,9 @@ def load_image_tiles_stack(images_dir):
# Test if the format is only PosXXX
directoryPos
=
os
.
path
.
join
(
os
.
path
.
abspath
(
d
),
'
Pos*
'
)
filesPos
=
glob
.
glob
(
directoryPos
)
regex_cpt_roi
=
None
# Test if the format is from MDAQ with only Default folrder in (when multipos is untick)
directoryDefault
=
os
.
path
.
join
(
os
.
path
.
abspath
(
d
),
'
Default
'
)
if
len
(
filesSE
)
>
0
:
format
=
'
SE
'
...
...
@@ -172,6 +174,12 @@ def load_image_tiles_stack(images_dir):
regex_cpt_roi
=
None
name_pattern
=
'
Pos
'
if
os
.
path
.
isdir
(
directoryDefault
):
format
=
'
DEFAULT
'
files
=
[
'
Default
'
]
regex_cpt_roi
=
None
name_pattern
=
'
Default
'
# Save the base directory
base_dir
=
os
.
path
.
abspath
(
d
)
...
...
@@ -217,8 +225,12 @@ def load_image_tiles_stack(images_dir):
if
format
==
'
POS
'
:
IJ
.
log
(
'
Load multi-position format from MACQ
'
)
hstack
,
good_names
=
load_mm_images
(
base_dir
,
roi
=
None
,
tile
=
False
,
pos
=
True
,
return_filenames
=
True
)
metadata
=
load_metadata
(
os
.
path
.
join
(
base_dir
,
good_names
[
0
].
split
(
os
.
path
.
sep
)[
0
],
'
metadata.txt
'
))
if
format
==
'
DEFAULT
'
:
IJ
.
log
(
'
Load single position format from MACQ
'
)
hstack
,
good_names
=
load_mm_images
(
base_dir
,
roi
=
None
,
tile
=
False
,
pos
=
False
,
return_filenames
=
True
)
metadata
=
load_metadata
(
os
.
path
.
join
(
base_dir
,
good_names
[
0
].
split
(
os
.
path
.
sep
)[
0
],
'
metadata.txt
'
))
hstack
.
setTitle
(
"
Data
"
)
return
hstack
,
metadata
,
base_dir
,
selected_roi
,
good_names
...
...
@@ -287,6 +299,7 @@ def process_white(implus_white, implus_darkofwhite, zofwhite, roi=None):
xmax
=
xmin
+
xmax
ymax
=
ymin
+
ymax
else
:
print
(
'
No crop of white
'
)
xmin
=
ymin
=
0
xmax
=
implus_white
.
width
ymax
=
implus_white
.
height
...
...
@@ -309,6 +322,7 @@ def process_white(implus_white, implus_darkofwhite, zofwhite, roi=None):
xmax
=
xmin
+
xmax
ymax
=
ymin
+
ymax
else
:
print
(
'
No crop of dark of white
'
)
xmin
=
ymin
=
0
xmax
=
implus_darkofwhite
.
width
ymax
=
implus_darkofwhite
.
height
...
...
@@ -400,10 +414,12 @@ def process_tiles(implus_tiles_stack, channel, z, implus_white_corr, implus_dark
mmversion
=
getMMversion
(
metadata
)
roi
=
getRoi
(
metadata
,
mmversion
)
if
roi
is
not
None
and
len
(
roi
)
==
4
and
implus_dark_stack
.
width
>
roi
[
2
]
and
implus_dark_stack
.
height
>
roi
[
3
]:
print
(
'
I crop the dark
'
)
xmin
,
ymin
,
xmax
,
ymax
=
roi
xmax
=
xmin
+
xmax
ymax
=
ymin
+
ymax
else
:
print
(
'
No crop of the dark
'
)
xmin
=
ymin
=
0
xmax
=
implus_dark_stack
.
width
ymax
=
implus_dark_stack
.
height
...
...
@@ -434,17 +450,15 @@ def process_tiles(implus_tiles_stack, channel, z, implus_white_corr, implus_dark
if
data
.
numDimensions
()
==
5
:
inter
=
Intervals
.
createMinMax
(
0
,
0
,
channel
,
z
-
1
,
0
,
xLen
-
1
,
yLen
-
1
,
channel
,
z
-
1
,
Ntiles
-
1
)
# Data are x,y,channel,
(t or z)
# Data are x,y,channel,
t
if
data
.
numDimensions
()
==
4
:
if
Ntiles
>
1
:
# x, y, channel, t
inter
=
Intervals
.
createMinMax
(
0
,
0
,
channel
,
0
,
xLen
-
1
,
yLen
-
1
,
channel
,
Ntiles
-
1
)
else
:
# x, y, channel, z
inter
=
Intervals
.
createMinMax
(
0
,
0
,
channel
,
z
-
1
,
xLen
-
1
,
yLen
-
1
,
channel
,
z
-
1
)
# Date are x,y,channel
if
data
.
numDimensions
()
==
3
:
inter
=
Intervals
.
createMinMax
(
0
,
0
,
channel
,
xLen
-
1
,
yLen
-
1
,
channel
)
if
inter
is
not
None
:
data
=
ops
.
transform
().
crop
(
data
,
inter
)
...
...
@@ -519,6 +533,7 @@ def run_processing(channel, zimg, zwhite, run_basic=True, optimizeXY=True, savep
IJ
.
run
(
"
Image Sequence...
"
,
"
format=TIFF name=tile_ start=1 save=[
"
+
procfolder
+
"
]
"
)
# Save the tile position file for the stitching
if
tilesposfile
is
not
None
:
with
open
(
procfolder
+
'
/TileConfiguration.txt
'
,
'
w
'
)
as
f
:
f
.
write
(
tilesposfile
)
...
...
@@ -600,6 +615,9 @@ def run_gui(default_values=None):
if
default_values
is
None
:
default_values
=
{}
default_values
[
'
optimXY
'
]
=
False
if
tilesposfile
is
None
:
default_values
[
'
Basic
'
]
=
False
else
:
default_values
[
'
Basic
'
]
=
True
default_values
[
'
dir
'
]
=
rootdir
+
'
/IJ_roi%s_telemosMosaic
'
%
(
selectedroi
)
default_values
[
'
zimg
'
]
=
0
...
...
@@ -896,7 +914,10 @@ if __name__ in ['__builtin__','__main__']:
# Make a list of tiles names
tilesondisk
=
set
(
os
.
path
.
dirname
(
t
)
for
t
in
file_names
)
if
len
(
tilesondisk
)
>
1
:
tilesposfile
=
extract_tile_positions
(
metadata
,
selectedroi
,
tilesondisk
)
else
:
tilesposfile
=
None
if
fdark
is
not
None
:
darks
=
load_images
(
fdark
,
roi
=
roi
)
...
...
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