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
0961c41a
Commit
0961c41a
authored
3 years ago
by
Andrey Aristov
Browse files
Options
Downloads
Patches
Plain Diff
rm zarr tools
parent
f9f381d6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
zarr_tools/__init__.py
+0
-0
0 additions, 0 deletions
zarr_tools/__init__.py
zarr_tools/__main__.py
+0
-22
0 additions, 22 deletions
zarr_tools/__main__.py
zarr_tools/convert.py
+0
-59
0 additions, 59 deletions
zarr_tools/convert.py
with
0 additions
and
81 deletions
zarr_tools/__init__.py
deleted
100644 → 0
+
0
−
0
View file @
f9f381d6
This diff is collapsed.
Click to expand it.
zarr_tools/__main__.py
deleted
100644 → 0
+
0
−
22
View file @
f9f381d6
from
calendar
import
c
from
.convert
import
to_zarr
import
fire
import
nd2
import
os
def
main
(
nd2_path
:
str
,
output
:
str
=
None
,
channel_axis
:
int
=
1
,
steps
:
int
=
6
,
dry_run
=
False
):
data
=
(
d
:
=
nd2
.
ND2File
(
nd2_path
)).
to_dask
().
rechunk
()
print
(
d
.
sizes
)
try
:
channel_axis
=
list
(
d
.
sizes
.
keys
()).
index
(
'
C
'
)
except
ValueError
:
channel_axis
=
None
if
output
is
None
:
output
=
nd2_path
.
replace
(
'
.nd2
'
,
'
.zarr
'
)
out
=
to_zarr
(
data
,
output
,
steps
=
steps
,
dry_run
=
dry_run
,
channel_axis
=
channel_axis
)
assert
os
.
path
.
exists
(
out
),
"
Failed...
"
exit
(
0
)
if
__name__
==
"
__main__
"
:
fire
.
Fire
(
main
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
zarr_tools/convert.py
deleted
100644 → 0
+
0
−
59
View file @
f9f381d6
import
zarr
import
dask.array
as
da
import
os
import
nd2
def
nd2_to_zarr
(
path_nd2
,
out
=
None
,
steps
=
6
,
dry_run
=
False
):
'''
Converts nd2 to zarr, multiscale
'''
data
=
nd2
.
ND2File
(
path_nd2
)
print
(
sizes
:
=
data
.
sizes
)
channel_axis
=
list
(
sizes
.
keys
()).
index
(
'
C
'
)
out
=
(
path_nd2
.
replace
(
'
.nd2
'
,
'
.zarr
'
)
if
out
is
None
else
path_nd2
)
dask_input
=
data
.
to_dask
()
_
=
to_zarr
(
dask_input
=
dask_input
,
path
=
out
,
steps
=
steps
,
channel_axis
=
channel_axis
,
dry_run
=
dry_run
)
def
to_zarr
(
dask_input
:
da
.
Array
,
path
:
str
=
None
,
steps
=
3
,
channel_axis
=
1
,
dry_run
=
False
):
store
=
zarr
.
DirectoryStore
(
baseurl
:
=
path
.
replace
(
'
.nd2
'
,
'
.zarr
'
)
if
path
is
None
else
path
)
grp
=
zarr
.
group
(
store
)
grp
.
attrs
[
'
multiscales
'
]
=
{
"
multiscales
"
:
[
{
"
datasets
"
:
[
{
"
path
"
:
str
(
i
)
}
for
i
in
range
(
steps
)
],
"
name
"
:
os
.
path
.
basename
(
baseurl
),
"
type
"
:
"
nd2
"
,
"
channel_axis
"
:
channel_axis
,
"
version
"
:
"
0.1
"
},
]
}
print
(
baseurl
)
for
i
in
range
(
steps
):
data
=
dask_input
[...,::
2
**
i
,::
2
**
i
]
try
:
data
=
data
.
rechunk
()
print
(
data
.
chunksize
,
data
.
shape
)
if
not
dry_run
:
data
.
to_zarr
(
ppp
:
=
os
.
path
.
join
(
baseurl
,
str
(
i
)))
print
(
f
'
saved
{
ppp
}
'
)
else
:
print
(
f
'
dry-run `to save to`
{
os
.
path
.
join
(
baseurl
,
str
(
i
))
}
'
)
except
Exception
as
e
:
print
(
e
.
args
)
return
baseurl
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