FAQ
| This is a
LIVE
service |
Changelog
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
STPT Mosaic Pipeline
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
Service Desk
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Institute of Astronomy
camCEAD
IMAXT
STPT Mosaic Pipeline
Commits
f835dc13
Unverified
Commit
f835dc13
authored
5 years ago
by
Eduardo Gonzalez Solares
Browse files
Options
Downloads
Patches
Plain Diff
Add function to parse mocasic file
parent
323da61a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!3
Dask
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
stpt_pipeline/mosaic_functions.py
+21
-0
21 additions, 0 deletions
stpt_pipeline/mosaic_functions.py
stpt_pipeline/preprocess.py
+7
-7
7 additions, 7 deletions
stpt_pipeline/preprocess.py
with
28 additions
and
7 deletions
stpt_pipeline/mosaic_functions.py
+
21
−
0
View file @
f835dc13
from
os
import
listdir
from
pathlib
import
Path
from
typing
import
Dict
import
dask.array
as
da
import
numpy
as
np
...
...
@@ -111,6 +113,25 @@ def get_mosaic_file(root_dir):
return
''
def
parse_mosaic_file
(
root_dir
:
Path
)
->
Dict
[
str
,
str
]:
"""
Return contents of mosaic file as dictionary.
Parameters
----------
root_dir
Directory containing mosaic file
Returns
-------
dictionary of key, values with mosaic file contents
"""
mosaic_file
=
get_mosaic_file
(
root_dir
)
with
open
(
mosaic_file
)
as
fh
:
items
=
[
item
.
strip
().
split
(
'
:
'
,
1
)
for
item
in
fh
.
readlines
()]
res
=
{
k
[
0
]:
k
[
1
]
for
k
in
items
}
return
res
def
get_img_cube
(
root_dir
,
imgs
,
...
...
This diff is collapsed.
Click to expand it.
stpt_pipeline/preprocess.py
+
7
−
7
View file @
f835dc13
...
...
@@ -8,15 +8,17 @@ import zarr
from
dask
import
delayed
from
distributed
import
Client
,
wait
from
scipy.ndimage
import
geometric_transform
from
zarr
import
blosc
from
imaxt_image.image
import
TiffImage
from
stpt_pipeline.utils
import
get_coords
from
.mosaic_functions
import
get
_mosaic_file
from
.mosaic_functions
import
parse
_mosaic_file
from
.settings
import
Settings
from
.stpt_displacement
import
defringe
,
magic_function
log
=
logging
.
getLogger
(
'
owl.daemon.pipeline
'
)
blosc
.
use_threads
=
False
# TODO: Check if this makes it quicker or slower
def
read_flatfield
(
flat_file
:
Path
):
...
...
@@ -141,14 +143,11 @@ def preprocess(root_dir: Path, flat_file: Path, output_dir: Path):
z
=
zarr
.
group
(
out
,
'
w
'
)
dirs
=
list_directories
(
root_dir
)
for
d
in
dirs
:
for
d
in
dirs
[:
2
]
:
# TODO: All this should be metadata
section
=
re
.
compile
(
r
'
\d\d\d\d$
'
).
search
(
d
.
name
).
group
()
mosaic_file
=
get_mosaic_file
(
d
)
res
=
open
(
d
/
mosaic_file
,
'
r
'
).
read
()
mrows
=
re
.
compile
(
r
'
mrows:(\d+)\n
'
).
search
(
res
).
groups
()[
0
]
mcolumns
=
re
.
compile
(
r
'
mcolumns:(\d+)\n
'
).
search
(
res
).
groups
()[
0
]
mrows
,
mcolumns
=
int
(
mrows
),
int
(
mcolumns
)
mosaic
=
parse_mosaic_file
(
d
)
mrows
,
mcolumns
=
int
(
mosaic
[
'
mrows
'
]),
int
(
mosaic
[
'
mcolumns
'
])
fovs
=
mrows
*
mcolumns
files
=
sorted
(
list
(
d
.
glob
(
'
*.tif
'
)))
files_ch1
=
sorted
(
list
(
d
.
glob
(
'
*_01.tif
'
)))
...
...
@@ -168,6 +167,7 @@ def preprocess(root_dir: Path, flat_file: Path, output_dir: Path):
wait
(
fut
)
# Write metadata
# TODO: Write contents of mosaic file here as well
z
.
attrs
[
'
sections
'
]
=
len
(
dirs
)
# TODO: Read from mosaic file
z
.
attrs
[
'
fovs
'
]
=
fovs
z
.
attrs
[
'
mrows
'
]
=
mrows
...
...
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