Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-imcflibs
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This project is archived. Its data is
read-only
.
Show more breadcrumbs
imcf
python-imcflibs
Commits
d24887a2
Commit
d24887a2
authored
Jan 7, 2019
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Add 'overwrite' switch to export() and export_using_orig_name()
parent
d39f2d2b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/imcflibs/imagej/bioformats.py
+13
-3
13 additions, 3 deletions
src/imcflibs/imagej/bioformats.py
with
13 additions
and
3 deletions
src/imcflibs/imagej/bioformats.py
+
13
−
3
View file @
d24887a2
...
@@ -57,7 +57,7 @@ def import_image(filename,
...
@@ -57,7 +57,7 @@ def import_image(filename,
return
orig_imps
return
orig_imps
def
export
(
imp
,
filename
):
def
export
(
imp
,
filename
,
overwrite
=
False
):
"""
Simple wrapper to export an image to a given file.
"""
Simple wrapper to export an image to a given file.
Parameters
Parameters
...
@@ -66,13 +66,21 @@ def export(imp, filename):
...
@@ -66,13 +66,21 @@ def export(imp, filename):
The ImagePlus object to be exported by Bio-Formats.
The ImagePlus object to be exported by Bio-Formats.
filename : str
filename : str
The output filename, may include a full path.
The output filename, may include a full path.
overwrite : bool
A switch to indicate existing files should be overwritten. Default is to
keep existing files, in this case an IOError is raised.
"""
"""
# log.info("Exporting to [%s]" % out_file)
# log.info("Exporting to [%s]" % out_file)
if
os
.
path
.
exists
(
filename
):
if
not
overwrite
:
raise
IOError
(
'
file [%s] already exists!
'
%
filename
)
os
.
remove
(
filename
)
IJ
.
run
(
imp
,
"
Bio-Formats Exporter
"
,
"
save=[
"
+
filename
+
"
]
"
)
IJ
.
run
(
imp
,
"
Bio-Formats Exporter
"
,
"
save=[
"
+
filename
+
"
]
"
)
# log.debug("Exporting finished.")
# log.debug("Exporting finished.")
def
export_using_orig_name
(
imp
,
path
,
orig_name
,
tag
,
suffix
):
def
export_using_orig_name
(
imp
,
path
,
orig_name
,
tag
,
suffix
,
overwrite
=
False
):
"""
Export an image to a given path, deriving the name from the input file.
"""
Export an image to a given path, deriving the name from the input file.
The input filename is stripped to its pure file name, without any path or
The input filename is stripped to its pure file name, without any path or
...
@@ -92,6 +100,8 @@ def export_using_orig_name(imp, path, orig_name, tag, suffix):
...
@@ -92,6 +100,8 @@ def export_using_orig_name(imp, path, orig_name, tag, suffix):
to denote information like
"
-avg
"
for an average projection image.
to denote information like
"
-avg
"
for an average projection image.
suffix : str
suffix : str
The new file name suffix, which also sets the file format for BF.
The new file name suffix, which also sets the file format for BF.
overwrite : bool
A switch to indicate existing files should be overwritten.
Returns
Returns
-------
-------
...
@@ -99,5 +109,5 @@ def export_using_orig_name(imp, path, orig_name, tag, suffix):
...
@@ -99,5 +109,5 @@ def export_using_orig_name(imp, path, orig_name, tag, suffix):
The full name of the exported file.
The full name of the exported file.
"""
"""
out_file
=
os
.
path
.
join
(
path
,
image_basename
(
orig_name
)
+
tag
+
suffix
)
out_file
=
os
.
path
.
join
(
path
,
image_basename
(
orig_name
)
+
tag
+
suffix
)
export
(
imp
,
out_file
)
export
(
imp
,
out_file
,
overwrite
)
return
out_file
return
out_file
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
sign in
to comment