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
c88aa793
Commit
c88aa793
authored
1 year ago
by
s204159
Committed by
fima
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Zarr cli
parent
4ce4e024
No related branches found
No related tags found
1 merge request
!99
Zarr cli
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
qim3d/io/convert.py
+2
-1
2 additions, 1 deletion
qim3d/io/convert.py
qim3d/utils/cli.py
+35
-5
35 additions, 5 deletions
qim3d/utils/cli.py
with
37 additions
and
6 deletions
qim3d/io/convert.py
+
2
−
1
View file @
c88aa793
...
...
@@ -20,6 +20,7 @@ class Convert:
"""
self
.
chunk_shape
=
kwargs
.
get
(
"
chunk_shape
"
,
(
64
,
64
,
64
))
def
convert
(
self
,
input_path
,
output_path
):
# Stringify path in case it is not already a string
input_path
=
stringify_path
(
input_path
)
...
...
@@ -30,7 +31,7 @@ class Convert:
if
os
.
path
.
isfile
(
input_path
):
match
input_ext
,
output_ext
:
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
,
chunks
=
self
.
chunk_shape
)
case
_
:
raise
ValueError
(
"
Unsupported file format
"
)
# Load a directory
...
...
This diff is collapsed.
Click to expand it.
qim3d/utils/cli.py
+
35
−
5
View file @
c88aa793
import
argparse
import
webbrowser
import
outputformat
as
ouf
from
qim3d.gui
import
annotation_tool
,
data_explorer
,
iso3d
,
local_thickness
from
qim3d.io.loading
import
DataLoader
from
qim3d.utils
import
image_preview
from
qim3d
import
__version__
as
version
import
outputformat
as
ouf
import
qim3d
import
qim3d.io
QIM_TITLE
=
ouf
.
rainbow
(
f
"
\n
_ _____ __
\n
____ _(_)___ ___ |__ /____/ /
\n
/ __ `/ / __ `__ \ /_ </ __ /
\n
/ /_/ / / / / / / /__/ / /_/ /
\n
\__, /_/_/ /_/ /_/____/\__,_/
\n
/_/ v
{
version
}
\n\n
"
,
...
...
@@ -14,6 +14,9 @@ QIM_TITLE = ouf.rainbow(
cmap
=
"
hot
"
,
)
def
parse_tuple
(
arg
):
# Remove parentheses if they are included and split by comma
return
tuple
(
map
(
int
,
arg
.
strip
(
'
()
'
).
split
(
'
,
'
)))
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
"
Qim3d command-line interface.
"
)
...
...
@@ -87,6 +90,30 @@ def main():
help
=
"
By default set the maximum value to be 255 so the contrast is strong. This turns it off.
"
,
)
# File Convert
convert_parser
=
subparsers
.
add_parser
(
"
convert
"
,
help
=
"
Convert files to different formats without loading the entire file into memory
"
,
)
convert_parser
.
add_argument
(
"
input_path
"
,
type
=
str
,
metavar
=
"
Input path
"
,
help
=
"
Path to image that will be converted
"
,
)
convert_parser
.
add_argument
(
"
output_path
"
,
type
=
str
,
metavar
=
"
Output path
"
,
help
=
"
Path to save converted image
"
,
)
convert_parser
.
add_argument
(
"
--chunks
"
,
type
=
parse_tuple
,
metavar
=
"
Chunk shape
"
,
default
=
(
64
,
64
,
64
),
help
=
"
Chunk size for the zarr file. Defaults to (64, 64, 64).
"
,
)
args
=
parser
.
parse_args
()
if
args
.
subcommand
==
"
gui
"
:
...
...
@@ -118,7 +145,6 @@ def main():
interface
=
local_thickness
.
Interface
()
interface
.
launch
(
inbrowser
=
inbrowser
,
force_light_mode
=
False
)
elif
args
.
subcommand
==
"
viz
"
:
if
not
args
.
source
:
print
(
"
Please specify a source file using the argument --source
"
)
...
...
@@ -139,6 +165,7 @@ def main():
elif
args
.
subcommand
==
"
preview
"
:
image
=
DataLoader
().
load
(
args
.
filename
)
image_preview
(
image
,
image_width
=
args
.
resolution
,
...
...
@@ -147,6 +174,9 @@ def main():
relative_intensity
=
args
.
absolute_values
,
)
elif
args
.
subcommand
==
"
convert
"
:
qim3d
.
io
.
convert
(
args
.
input_path
,
args
.
output_path
,
chunk_shape
=
args
.
chunks
)
elif
args
.
subcommand
is
None
:
print
(
QIM_TITLE
)
welcome_text
=
(
...
...
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