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
589a16fb
Commit
589a16fb
authored
Jun 28, 2022
by
Hugo CHAUVET
Browse files
Options
Downloads
Patches
Plain Diff
Replace script_mosaic_telemos.py to allow PosXX format
parent
170d69c7
No related branches found
No related tags found
1 merge request
!3
Dev
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ImageJ/script_mosaic_telemos.py
+61
-26
61 additions, 26 deletions
ImageJ/script_mosaic_telemos.py
with
61 additions
and
26 deletions
ImageJ/script_mosaic_telemos.py
+
61
−
26
View file @
589a16fb
...
@@ -146,6 +146,11 @@ def load_image_tiles_stack(images_dir):
...
@@ -146,6 +146,11 @@ def load_image_tiles_stack(images_dir):
directoryCG
=
os
.
path
.
join
(
os
.
path
.
abspath
(
d
),
'
?-Pos_*
'
)
directoryCG
=
os
.
path
.
join
(
os
.
path
.
abspath
(
d
),
'
?-Pos_*
'
)
filesCG
=
glob
.
glob
(
directoryCG
)
filesCG
=
glob
.
glob
(
directoryCG
)
# Test if the format is only PosXXX
directoryPos
=
os
.
path
.
join
(
os
.
path
.
abspath
(
d
),
'
Pos*
'
)
filesPos
=
glob
.
glob
(
directoryPos
)
regex_cpt_roi
=
None
if
len
(
filesSE
)
>
0
:
if
len
(
filesSE
)
>
0
:
format
=
'
SE
'
format
=
'
SE
'
files
=
filesSE
files
=
filesSE
...
@@ -161,6 +166,16 @@ def load_image_tiles_stack(images_dir):
...
@@ -161,6 +166,16 @@ def load_image_tiles_stack(images_dir):
regex_cpt_roi
=
'
([0-9]*)-Pos_
'
regex_cpt_roi
=
'
([0-9]*)-Pos_
'
name_pattern
=
'
%s-Pos_
'
name_pattern
=
'
%s-Pos_
'
if
len
(
filesPos
)
>
0
:
format
=
'
POS
'
files
=
sorted
(
filesPos
)
regex_cpt_roi
=
None
name_pattern
=
'
Pos
'
# Save the base directory
base_dir
=
os
.
path
.
abspath
(
d
)
if
regex_cpt_roi
is
not
None
:
# Simple regexp to find roi numbers roiXX_tile
# Simple regexp to find roi numbers roiXX_tile
matched
=
re
.
findall
(
regex_cpt_roi
,
'
\n
'
.
join
(
files
))
matched
=
re
.
findall
(
regex_cpt_roi
,
'
\n
'
.
join
(
files
))
# Convert this to python set (this allow to remove duplicate in roinum and sort tilenumber
# Convert this to python set (this allow to remove duplicate in roinum and sort tilenumber
...
@@ -180,15 +195,18 @@ def load_image_tiles_stack(images_dir):
...
@@ -180,15 +195,18 @@ def load_image_tiles_stack(images_dir):
else
:
else
:
selected_roi
=
roinum
[
0
]
selected_roi
=
roinum
[
0
]
# Load all files for the selected ROI
# Load all files for the selected ROI
directory
=
os
.
path
.
join
(
os
.
path
.
abspath
(
d
),
name_pattern
%
(
selected_roi
)
+
'
*
'
)
directory
=
os
.
path
.
join
(
os
.
path
.
abspath
(
d
),
name_pattern
%
(
selected_roi
)
+
'
*
'
)
# files = glob.glob(directory)
# files = glob.glob(directory)
base_dir
=
os
.
path
.
abspath
(
d
)
metadata
=
load_metadata
(
os
.
path
.
join
(
base_dir
,
name_pattern
%
(
selected_roi
)
+
'
1
'
,
'
metadata.txt
'
))
metadata
=
load_metadata
(
os
.
path
.
join
(
base_dir
,
name_pattern
%
(
selected_roi
)
+
'
1
'
,
'
metadata.txt
'
))
# Simple regexp to find tile numbers roi1_tileXX
# Simple regexp to find tile numbers roi1_tileXX
else
:
selected_roi
=
'
0
'
if
format
==
'
SE
'
:
if
format
==
'
SE
'
:
IJ
.
log
(
'
Load a slide-explorer folder format
'
)
# Find the smallest tile number for this roi
# Find the smallest tile number for this roi
hstack
,
good_names
=
load_mm_images
(
base_dir
,
roi
=
selected_roi
,
return_filenames
=
True
)
hstack
,
good_names
=
load_mm_images
(
base_dir
,
roi
=
selected_roi
,
return_filenames
=
True
)
...
@@ -196,6 +214,11 @@ def load_image_tiles_stack(images_dir):
...
@@ -196,6 +214,11 @@ def load_image_tiles_stack(images_dir):
IJ
.
log
(
'
NOT IMPLEMENTED NEED SOME TESTS !!!!!
'
)
IJ
.
log
(
'
NOT IMPLEMENTED NEED SOME TESTS !!!!!
'
)
hstack
,
good_names
=
load_mm_images
(
base_dir
,
roi
=
selected_roi
,
tile
=
False
,
pos
=
True
,
return_filenames
=
True
)
hstack
,
good_names
=
load_mm_images
(
base_dir
,
roi
=
selected_roi
,
tile
=
False
,
pos
=
True
,
return_filenames
=
True
)
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
'
))
hstack
.
setTitle
(
"
Data
"
)
hstack
.
setTitle
(
"
Data
"
)
return
hstack
,
metadata
,
base_dir
,
selected_roi
,
good_names
return
hstack
,
metadata
,
base_dir
,
selected_roi
,
good_names
...
@@ -694,6 +717,7 @@ def getMMtiles(metadata, selected_roi, tilesondisk):
...
@@ -694,6 +717,7 @@ def getMMtiles(metadata, selected_roi, tilesondisk):
yt
=
[
None
]
*
len
(
mmsum
[
'
StagePositions
'
])
yt
=
[
None
]
*
len
(
mmsum
[
'
StagePositions
'
])
test_nameSE
=
'
roi
'
+
selected_roi
test_nameSE
=
'
roi
'
+
selected_roi
test_nameGC
=
'
%s-Pos_
'
%
selected_roi
test_nameGC
=
'
%s-Pos_
'
%
selected_roi
test_namePos
=
'
Pos
'
uniquecols
=
set
(
a
[
'
GridCol
'
]
for
a
in
mmsum
[
'
StagePositions
'
])
uniquecols
=
set
(
a
[
'
GridCol
'
]
for
a
in
mmsum
[
'
StagePositions
'
])
uniquerows
=
set
(
a
[
'
GridRow
'
]
for
a
in
mmsum
[
'
StagePositions
'
])
uniquerows
=
set
(
a
[
'
GridRow
'
]
for
a
in
mmsum
[
'
StagePositions
'
])
...
@@ -714,6 +738,17 @@ def getMMtiles(metadata, selected_roi, tilesondisk):
...
@@ -714,6 +738,17 @@ def getMMtiles(metadata, selected_roi, tilesondisk):
ind
=
c
*
Nrow
+
r
ind
=
c
*
Nrow
+
r
# print(ind, pl['Label'])
# print(ind, pl['Label'])
if
pl
[
'
Label
'
].
startswith
(
test_namePos
):
ind
=
i
# Find the name of the Stage
for
dev
in
pl
[
'
DevicePositions
'
]:
if
dev
[
'
Device
'
]
==
'
XYStage
'
:
xt
[
ind
]
=
dev
[
'
Position_um
'
][
0
]
yt
[
ind
]
=
dev
[
'
Position_um
'
][
1
]
break
else
:
xt
[
ind
]
=
pl
[
'
DevicePositions
'
][
0
][
'
Position_um
'
][
0
]
xt
[
ind
]
=
pl
[
'
DevicePositions
'
][
0
][
'
Position_um
'
][
0
]
yt
[
ind
]
=
pl
[
'
DevicePositions
'
][
0
][
'
Position_um
'
][
1
]
yt
[
ind
]
=
pl
[
'
DevicePositions
'
][
0
][
'
Position_um
'
][
1
]
...
...
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