-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from ilastik/export-import-refactoring
Import/export command refactoring
- Loading branch information
Showing
31 changed files
with
499 additions
and
1,188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Lines that start with "//" are comments. | ||
|
||
// Lines that start with "#@" declare input parameters that interactively ask the user for values. | ||
// If you want to run a macro in batch or headless mode, remove those lines and set input parameters explicitly. | ||
|
||
#@ File (label = "Input file", style = "file") input | ||
// input = "/absolute/path/to/some/directory/src/test/resources/2d_cells_apoptotic.tif"; | ||
|
||
#@ File (label = "Output file", style = "save") exportPath | ||
// exportPath = "/path/to/some/directory/output.h5"; | ||
|
||
datasetName = "/data"; | ||
compressionLevel = 0; | ||
|
||
run("Export HDF5", "input=[" + input + "] datasetname=[" + datasetName + "] compressionlevel=[" + compressionLevel + "] exportpath=[" + exportPath + "]"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#@ File (label = "Input file", style = "file") input | ||
// input = "/absolute/path/to/some/directory/src/test/resources/2d_cells_apoptotic_1channel.h5"; | ||
|
||
datasetname = "/data"; | ||
axisorder = "tzyxc"; | ||
|
||
run("Import HDF5", "select=[" + input + "] datasetname=[" + datasetname + "] axisorder=[" + axisorder + "]"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#@ File (label = "Project file", style = "file") project | ||
// project = "/absolute/path/to/some/directory/obj_class_2d_cells_apoptotic.ilp"; | ||
|
||
#@ File (label = "Input file", style = "file") input | ||
// input = "/absolute/path/to/some/directory/2d_cells_apoptotic.tif"; | ||
|
||
#@ File (label = "Second input file", style = "file") secondInput | ||
// secondInput = "/absolute/path/to/some/directory/2d_cells_apoptotic_1channel-data_Probabilities.tif"; | ||
|
||
type = "Probabilities"; | ||
|
||
open(input); | ||
run("Run Object Classification Prediction", "projectfilename=[" + project + "] input=[" + input + "] inputproborsegimage=[" + secondInput + "] secondinputtype=[" + type + "]"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
project = "src/test/resources/pixel_class_2d_cells_apoptotic.ilp"; | ||
input = "2d_cells_apoptotic.tif"; | ||
#@ File (label = "Project file", style = "file") project | ||
// project = "/absolute/path/to/some/directory/pixel_class_2d_cells_apoptotic.ilp"; | ||
|
||
#@ File (label = "Input file", style = "file") input | ||
// input = "/absolute/path/to/some/directory/2d_cells_apoptotic.tif"; | ||
|
||
type = "Probabilities"; | ||
|
||
open(input); | ||
run("Run Pixel Classification Prediction", "projectfilename=" + project + " input=" + input + " pixelclassificationtype=Probabilities"); | ||
run("Run Pixel Classification Prediction", "projectfilename=[" + project + "] input=[" + input + "] pixelclassificationtype=[" + type + "]"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env python3 | ||
|
||
"""Build the project and copy plugin to Fiji.""" | ||
|
||
import argparse | ||
import shutil | ||
import subprocess | ||
import sys | ||
from pathlib import Path | ||
|
||
|
||
def main(): | ||
ap = argparse.ArgumentParser(description=__doc__) | ||
ap.add_argument("fiji", type=Path, help="Path to Fiji directory") | ||
args = ap.parse_args() | ||
|
||
if not shutil.which("mvn"): | ||
sys.exit("error: maven not found in system path") | ||
|
||
print("cleaning project") | ||
subprocess.run(["mvn", "clean"], check=True) | ||
|
||
print("building project") | ||
subprocess.run(["mvn", "package", "-DskipTests=true"], check=True) | ||
|
||
jars = list(Path("target").glob("ilastik4ij-*-SNAPSHOT.jar")) | ||
if len(jars) != 1: | ||
sys.exit(f"error: expected exactly one jar, found {jars}") | ||
jar = jars[0] | ||
|
||
for subdir in ("plugins", "jars"): | ||
for old_jar in (args.fiji / subdir).glob("ilastik4ij*.jar"): | ||
print(f"removing {old_jar}") | ||
old_jar.unlink() | ||
|
||
plugins_dir = args.fiji / "plugins" | ||
print(f"copying {jar} to {plugins_dir}") | ||
shutil.copy(jar, plugins_dir) | ||
|
||
|
||
if __name__ == "__main__": | ||
try: | ||
main() | ||
except KeyboardInterrupt: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env python3 | ||
|
||
"""Print all datasets in an HDF5 file.""" | ||
|
||
import argparse | ||
import json | ||
|
||
import numpy | ||
import h5py | ||
|
||
|
||
def to_str(seq): | ||
return "[" + ",".join(map(to_str, seq)) + "]" if isinstance(seq, list) else str(seq) | ||
|
||
|
||
def main(): | ||
ap = argparse.ArgumentParser(description=__doc__) | ||
ap.add_argument("hdf5", type=str, help="Path to HDF5 file") | ||
args = ap.parse_args() | ||
|
||
datasets = {} | ||
|
||
def visit(name, obj): | ||
attrs = {} | ||
for k, v in obj.attrs.items(): | ||
if isinstance(v, bytes): | ||
v = v.decode("utf-8") | ||
elif isinstance(v, numpy.ndarray): | ||
v = to_str(v.tolist()) | ||
attrs[k] = v | ||
|
||
if isinstance(obj, h5py.Dataset): | ||
name = "/" + name.removeprefix("/") | ||
datasets[name] = { | ||
"dtype": obj.dtype.name, | ||
"shape": ",".join(map(str, obj.shape)), | ||
} | ||
if attrs: | ||
datasets[name]["attrs"] = {k: attrs[k] for k in sorted(attrs)} | ||
|
||
|
||
with h5py.File(args.hdf5, "r") as f: | ||
f.visititems(visit) | ||
|
||
datasets = {k: datasets[k] for k in sorted(datasets)} | ||
print(json.dumps(datasets, indent=2)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
src/main/java/org/ilastik/ilastik4ij/hdf5/DatasetEntryProvider.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.