Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
qim3d
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
QIM
Tools
qim3d
Commits
d3bac131
Commit
d3bac131
authored
9 months ago
by
fima
Browse files
Options
Downloads
Patches
Plain Diff
Zarr update to supoort data from Dask
parent
a96611b1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
qim3d/io/saving.py
+16
-10
16 additions, 10 deletions
qim3d/io/saving.py
with
16 additions
and
10 deletions
qim3d/io/saving.py
+
16
−
10
View file @
d3bac131
...
@@ -24,7 +24,6 @@ Example:
...
@@ -24,7 +24,6 @@ Example:
import
datetime
import
datetime
import
os
import
os
import
dask.array
as
da
import
dask.array
as
da
import
h5py
import
h5py
import
nibabel
as
nib
import
nibabel
as
nib
...
@@ -269,14 +268,21 @@ class DataSaver:
...
@@ -269,14 +268,21 @@ class DataSaver:
zarr.core.Array: The Zarr array saved on disk.
zarr.core.Array: The Zarr array saved on disk.
"""
"""
# Old version that is using dask
if
isinstance
(
data
,
da
.
Array
):
# If the data is a Dask array, save using dask
# assert isinstance(data, da.Array), 'data must be a dask array'
if
self
.
chunk_shape
:
log
.
info
(
"
Rechunking data to shape %s
"
,
self
.
chunk_shape
)
data
=
data
.
rechunk
(
self
.
chunk_shape
)
log
.
info
(
"
Saving Dask array to Zarr array on disk
"
)
da
.
to_zarr
(
data
,
path
,
overwrite
=
self
.
replace
)
# # forces compute when saving to zarr
else
:
# da.to_zarr(data, path, compute=True, overwrite=self.replace, compressor=zarr.Blosc(cname='zstd', clevel=3, shuffle=2))
zarr_array
=
zarr
.
open
(
zarr_array
=
zarr
.
open
(
path
,
mode
=
"
w
"
,
shape
=
data
.
shape
,
chunks
=
self
.
chunk_shape
,
dtype
=
data
.
dtype
path
,
mode
=
"
w
"
,
shape
=
data
.
shape
,
chunks
=
self
.
chunk_shape
,
dtype
=
data
.
dtype
,
)
)
zarr_array
[:]
=
data
zarr_array
[:]
=
data
...
...
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