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
99f15a72
Commit
99f15a72
authored
1 year ago
by
Christian Kento Rasmussen
Browse files
Options
Downloads
Patches
Plain Diff
added control logit for tiff stacks
parent
2679ae2e
Branches
Branches containing commit
No related tags found
1 merge request
!102
Conv zarr tiff folders
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
qim3d/io/convert.py
+12
-1
12 additions, 1 deletion
qim3d/io/convert.py
with
12 additions
and
1 deletion
qim3d/io/convert.py
+
12
−
1
View file @
99f15a72
...
@@ -21,6 +21,7 @@ class Convert:
...
@@ -21,6 +21,7 @@ class Convert:
chunk_shape (tuple, optional): chunk size for the zarr file. Defaults to (64, 64, 64).
chunk_shape (tuple, optional): chunk size for the zarr file. Defaults to (64, 64, 64).
"""
"""
self
.
chunk_shape
=
kwargs
.
get
(
"
chunk_shape
"
,
(
64
,
64
,
64
))
self
.
chunk_shape
=
kwargs
.
get
(
"
chunk_shape
"
,
(
64
,
64
,
64
))
self
.
base_name
=
kwargs
.
get
(
"
base_name
"
,
None
)
def
convert
(
self
,
input_path
,
output_path
):
def
convert
(
self
,
input_path
,
output_path
):
def
get_file_extension
(
file_path
):
def
get_file_extension
(
file_path
):
...
@@ -36,7 +37,7 @@ class Convert:
...
@@ -36,7 +37,7 @@ class Convert:
output_ext
=
get_file_extension
(
output_path
)
output_ext
=
get_file_extension
(
output_path
)
output_path
=
stringify_path
(
output_path
)
output_path
=
stringify_path
(
output_path
)
if
os
.
path
.
isfile
(
input_path
):
if
os
.
path
.
isfile
(
input_path
)
and
os
.
path
.
isfile
(
output_path
)
:
match
input_ext
,
output_ext
:
match
input_ext
,
output_ext
:
case
(
"
.tif
"
,
"
.zarr
"
)
|
(
"
.tiff
"
,
"
.zarr
"
):
case
(
"
.tif
"
,
"
.zarr
"
)
|
(
"
.tiff
"
,
"
.zarr
"
):
return
self
.
convert_tif_to_zarr
(
input_path
,
output_path
)
return
self
.
convert_tif_to_zarr
(
input_path
,
output_path
)
...
@@ -44,6 +45,11 @@ class Convert:
...
@@ -44,6 +45,11 @@ class Convert:
return
self
.
convert_nifti_to_zarr
(
input_path
,
output_path
)
return
self
.
convert_nifti_to_zarr
(
input_path
,
output_path
)
case
_
:
case
_
:
raise
ValueError
(
"
Unsupported file format
"
)
raise
ValueError
(
"
Unsupported file format
"
)
elif
os
.
path
.
isfile
(
input_path
)
and
os
.
path
.
isdir
(
output_path
):
if
input_ext
==
"
.zarr
"
and
not
output_ext
:
return
self
.
convert_zarr_to_tiff_stack
(
input_path
,
output_path
)
else
:
raise
ValueError
(
"
Unsupported file format
"
)
# Load a directory
# Load a directory
elif
os
.
path
.
isdir
(
input_path
):
elif
os
.
path
.
isdir
(
input_path
):
match
input_ext
,
output_ext
:
match
input_ext
,
output_ext
:
...
@@ -55,6 +61,11 @@ class Convert:
...
@@ -55,6 +61,11 @@ class Convert:
return
self
.
convert_zarr_to_nifti
(
input_path
,
output_path
,
compression
=
True
)
return
self
.
convert_zarr_to_nifti
(
input_path
,
output_path
,
compression
=
True
)
case
_
:
case
_
:
raise
ValueError
(
"
Unsupported file format
"
)
raise
ValueError
(
"
Unsupported file format
"
)
elif
os
.
path
.
isdir
(
input_path
)
and
os
.
path
.
isfile
(
output_path
):
if
not
input_ext
and
output_ext
==
"
.zarr
"
:
return
self
.
convert_tiff_stack_to_zarr
(
input_path
,
output_path
)
else
:
raise
ValueError
(
"
Unsupported file format
"
)
# Fail
# Fail
else
:
else
:
# Find the closest matching path to warn the user
# Find the closest matching path to warn the user
...
...
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