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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
QIM
Tools
qim3d
Commits
b2fa4120
Commit
b2fa4120
authored
11 months ago
by
Christian Kento Rasmussen
Browse files
Options
Downloads
Patches
Plain Diff
created function to save to zarr
parent
e78615ef
No related branches found
No related tags found
4 merge requests
!102
Conv zarr tiff folders
,
!100
Conv zarr nifti
,
!99
Zarr cli
,
!96
Zarr loading and converting
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
qim3d/io/saving.py
+19
-0
19 additions, 0 deletions
qim3d/io/saving.py
with
19 additions
and
0 deletions
qim3d/io/saving.py
+
19
−
0
View file @
b2fa4120
...
...
@@ -24,12 +24,14 @@ Example:
import
datetime
import
os
import
dask.array
as
da
import
h5py
import
nibabel
as
nib
import
numpy
as
np
import
PIL
import
pydicom
import
tifffile
import
zarr
from
pydicom.dataset
import
FileDataset
,
FileMetaDataset
from
pydicom.uid
import
UID
...
...
@@ -234,6 +236,21 @@ class DataSaver:
ds
.
PixelData
=
data_bytes
ds
.
save_as
(
path
)
def
save_to_zarr
(
self
,
path
,
data
):
"""
Saves a Dask array to a Zarr array on disk.
Args:
path (str): The path to the Zarr array on disk.
data (dask.array): The Dask array to be saved to disk.
Returns:
zarr.core.Array: The Zarr array saved on disk.
"""
assert
isinstance
(
data
,
da
.
Array
),
'
data must be a dask array
'
# forces compute when saving to zarr
da
.
to_zarr
(
data
,
path
,
compute
=
True
,
overwrite
=
self
.
replace
,
compressor
=
zarr
.
Blosc
(
cname
=
'
zstd
'
,
clevel
=
3
,
shuffle
=
2
))
def
save_PIL
(
self
,
path
,
data
):
...
...
@@ -330,6 +347,8 @@ class DataSaver:
return
self
.
save_vol
(
path
,
data
)
elif
path
.
endswith
((
"
.dcm
"
,
"
.DCM
"
)):
return
self
.
save_dicom
(
path
,
data
)
elif
path
.
endswith
((
"
.zarr
"
)):
return
self
.
save_to_zarr
(
path
,
data
)
elif
path
.
endswith
((
"
.jpeg
"
,
"
.jpg
"
,
"
.png
"
)):
return
self
.
save_PIL
(
path
,
data
)
else
:
...
...
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