-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New IlastikPretrainedProbability filter #1740
Conversation
992a4dc
to
7063b29
Compare
8a63ef8
to
c0d7f4f
Compare
7063b29
to
b35f97e
Compare
Codecov Report
@@ Coverage Diff @@
## master #1740 +/- ##
==========================================
- Coverage 90.09% 89.94% -0.15%
==========================================
Files 248 252 +4
Lines 9186 9579 +393
==========================================
+ Hits 8276 8616 +340
- Misses 910 963 +53
Continue to review full report at Codecov.
|
c0d7f4f
to
054dd28
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test plan: So I tested everything locally but not sure how to write a unit test without having to install ilastick on travis...
Is that a hard thing to do?
""" | ||
|
||
def __init__(self, ilastik_executable: Union[Path, str], ilastik_project: Union[Path, str]): | ||
ilastik_executable = ilastik_executable \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the assignment extends to multiple lines, I don’t see much of a point to doing x = y if cond else z
(vs the traditional if statement)
|
||
def __init__(self, ilastik_executable: Union[Path, str], ilastik_project: Union[Path, str]): | ||
ilastik_executable = ilastik_executable \ | ||
if isinstance(ilastik_executable, Path) else Path(ilastik_executable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think Path(path) works if path is already a Path. So you might as well do:
x = Path(x)
But you may want to check that.
@@ -5,6 +5,7 @@ | |||
python-dateutil < 2.8.1 | |||
click | |||
dataclasses==0.6 | |||
h5py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a big dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nah it's not crazy just an interface between HDF5 and python
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't that require sucking in a huge HDF5 library? Although we might already have that by virtue of xarray -> netcdf...
stack : ImageStack | ||
Dapi image to be run through ilastik. | ||
in_place : bool | ||
N/A |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "this parameter is ignored for this filter"?
np.save(dapi_file, stack.xarray.values.squeeze()) | ||
|
||
# env {} is needed to fix the weird virtualenv stuff | ||
subprocess.run( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you want subprocess.check_call
? or you can pass check=True
to subprocess.run
probability_images = h5["exported_data"][:] | ||
h5.close() | ||
cell_probabilities, _ = probability_images[:, :, 0], probability_images[:, :, 1] | ||
cell_threshold = threshold_otsu(cell_probabilities) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait, I thought we were going to leave the thresholding to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errr good question. This was how @ambrosejcarr and @dganguli loaded in the cell_probabilities in their notebook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok talked with deep, will delete the thresholding bit
b35f97e
to
be32e23
Compare
be32e23
to
632a0aa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comments, lgtm otherwise.
f"{stack.num_rounds}") | ||
if stack.num_chs != 1: | ||
raise ValueError( | ||
f"{IlastikPretrainedProbability.__name__} given an image with more than one channel" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f"{IlastikPretrainedProbability.__name__} given an image with more than one channel" | |
f"{IlastikPretrainedProbability.__name__} given an image with more than one channel " |
f"{stack.num_chs}") | ||
|
||
# temp files | ||
temp_dir = tempfile.TemporaryDirectory() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
temp_dir = tempfile.TemporaryDirectory() | |
with tempfile.TemporaryDirectory() as temp_dir: |
this will ensure cleanup.
|
||
# temp files | ||
temp_dir = tempfile.TemporaryDirectory() | ||
dapi_file = f"{temp_dir.name}_dapi.npy" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dapi_file = f"{temp_dir.name}_dapi.npy" | |
dapi_file = os.path.join(temp_dir.name, "dapi.npy") |
# temp files | ||
temp_dir = tempfile.TemporaryDirectory() | ||
dapi_file = f"{temp_dir.name}_dapi.npy" | ||
output_file = f"{temp_dir.name}_dapi_Probabilities.h5" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
output_file = f"{temp_dir.name}_dapi_Probabilities.h5" | |
output_file = os.path.join(temp_dir.name, "dapi_Probabilities.h5") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gives me a "Directory not found error"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's something wrong then, you're not creating the temporary files in the right place.
632a0aa
to
29edcd4
Compare
🎉 |
#1740 added h5py but not to the pinned requirements files. That resulted in unhappy travis runs (e.g., https://travis-ci.com/spacetx/starfish/builds/146897038) Test plan: none
#1740 added h5py but not to the pinned requirements files. That resulted in unhappy travis runs (e.g., https://travis-ci.com/spacetx/starfish/builds/146897038) Test plan: none
Creates a IlastikPretrainedProbability that takes in the path to an ilastick executable file, and ilastick project file and an Imagestack and runs ilastick headless to apply the pretrained prediction model to the Imagestack. The output of ilastik is then loaded back in as an ImageStack.
Test plan: So I tested everything locally but not sure how to write a unit test without having to install ilastick on travis...
fixes: #1499