Skip to content

Commit

Permalink
working Mac version
Browse files Browse the repository at this point in the history
  • Loading branch information
bethac07 committed Dec 15, 2023
1 parent 018199d commit f2487c5
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions active_plugins/runilastik.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
import subprocess
import shutil
import uuid
import logging
import sys
import h5py
Expand Down Expand Up @@ -143,9 +144,10 @@ def run(self, workspace):
# preparing the data

# Directory that will be used to pass images to the docker container

# Create a UUID for this run
unique_name = str(uuid.uuid4())

temp_dir = os.path.join(get_default_output_directory(), ".cellprofiler_temp")
temp_dir = os.path.join(get_default_output_directory(), ".cellprofiler_temp", unique_name)

os.makedirs(temp_dir, exist_ok=True)

Expand Down Expand Up @@ -175,10 +177,13 @@ def run(self, workspace):
model_file = self.project_file.value
model_directory = os.path.dirname(os.path.abspath(model_file))

fout_name = f"/data/{os.path.basename(fout.name)}"
fin_name = f"/data/{os.path.basename(fin.name)}"

cmd = [f"{docker_path}", "run", "--rm", "-v", f"{temp_dir}:/data",
"-v", f"{model_directory}:/model",
f"{ILASTIK_DOCKER}", "/opt/ilastik-1.4.0-Linux/run_ilastik.sh", "--headless",
"--project", f"/model/{model_file}"
"--project", f"/model/{os.path.basename(model_file)}"
]

if self.docker_or_local.value == "Local":
Expand All @@ -188,6 +193,9 @@ def run(self, workspace):
else:
executable = self.executable.value

fout_name = fout.name
fin_name = fin.name

cmd = [
executable,
"--headless",
Expand All @@ -202,17 +210,14 @@ def run(self, workspace):
cmd += ["--export_source", "probabilities stage 2"]
#cmd += ["--export_source", "probabilities all stages"]

cmd += [
"--output_filename_format", fout.name,
fin.name
]
cmd += ["--output_filename_format", fout_name, fin_name]

try:
subprocess.check_call(cmd)


with h5py.File(fout.name, "r") as f:
y_data = f["exported_data"].value
y_data = f["exported_data"][()]

y = Image(y_data)

Expand Down

0 comments on commit f2487c5

Please sign in to comment.