Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion synapse_net/inference/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .mitochondria import segment_mitochondria
from .ribbon_synapse import segment_ribbon_synapse_structures
from .vesicles import segment_vesicles
from .cristae import segment_cristae
from .util import get_device
from ..file_utils import get_cache_dir

Expand All @@ -25,6 +26,7 @@ def _get_model_registry():
"compartments": "527983720f9eb215c45c4f4493851fd6551810361eda7b79f185a0d304274ee1",
"mitochondria": "24625018a5968b36f39fa9d73b121a32e8f66d0f2c0540d3df2e1e39b3d58186",
"mitochondria2": "553decafaff4838fff6cc8347f22c8db3dee5bcbeffc34ffaec152f8449af673",
"cristae": "f96c90484f4ea92ac0515a06e389cc117580f02c2aacdc44b5828820cf38c3c3",
"ribbon": "7c947f0ddfabe51a41d9d05c0a6ca7d6b238f43df2af8fffed5552d09bb075a9",
"vesicles_2d": "eb0b74f7000a0e6a25b626078e76a9452019f2d1ea6cf2033073656f4f055df1",
"vesicles_3d": "b329ec1f57f305099c984fbb3d7f6ae4b0ff51ec2fa0fa586df52dad6b84cf29",
Expand All @@ -35,6 +37,7 @@ def _get_model_registry():
"compartments": "https://owncloud.gwdg.de/index.php/s/DnFDeTmDDmZrDDX/download",
"mitochondria": "https://owncloud.gwdg.de/index.php/s/1T542uvzfuruahD/download",
"mitochondria2": "https://owncloud.gwdg.de/index.php/s/GZghrXagc54FFXd/download",
"cristae": "https://owncloud.gwdg.de/index.php/s/Df7OUOyQ1Kc2eEO/download",
"ribbon": "https://owncloud.gwdg.de/index.php/s/S3b5l0liPP1XPYA/download",
"vesicles_2d": "https://owncloud.gwdg.de/index.php/s/d72QIvdX6LsgXip/download",
"vesicles_3d": "https://owncloud.gwdg.de/index.php/s/A425mkAOSqePDhx/download",
Expand Down Expand Up @@ -214,14 +217,16 @@ def run_segmentation(
"""
if model_type.startswith("vesicles"):
segmentation = segment_vesicles(image, model=model, tiling=tiling, scale=scale, verbose=verbose, **kwargs)
elif model_type == "mitochondria":
elif model_type == "mitochondria" or model_type == "mitochondria2":
segmentation = segment_mitochondria(image, model=model, tiling=tiling, scale=scale, verbose=verbose, **kwargs)
elif model_type == "active_zone":
segmentation = segment_active_zone(image, model=model, tiling=tiling, scale=scale, verbose=verbose, **kwargs)
elif model_type == "compartments":
segmentation = segment_compartments(image, model=model, tiling=tiling, scale=scale, verbose=verbose, **kwargs)
elif model_type == "ribbon":
segmentation = _segment_ribbon_AZ(image, model=model, tiling=tiling, scale=scale, verbose=verbose, **kwargs)
elif model_type == "cristae":
segmentation = segment_cristae(image, model=model, tiling=tiling, scale=scale, verbose=verbose, **kwargs)
else:
raise ValueError(f"Unknown model type: {model_type}")
return segmentation
2 changes: 1 addition & 1 deletion synapse_net/inference/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def get_prediction(
# If we have channels then the standardization is done independently per channel.
if with_channels:
# TODO Check that this is the correct axis.
input_volume = torch_em.transform.raw.standardize(input_volume, axis=(1, 2, 3))
input_volume = np.stack([torch_em.transform.raw.normalize(input_volume[0]), input_volume[1]], axis=0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you assume that we never want to normalize the first channel, and you assume that we always have only two channels. I don't think we should make such a general assumption.

else:
input_volume = torch_em.transform.raw.standardize(input_volume)

Expand Down
3 changes: 3 additions & 0 deletions synapse_net/tools/segmentation_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ def on_predict(self):
if model_type == "ribbon": # Currently only the ribbon model needs the extra seg.
extra_seg = self._get_layer_selector_data(self.extra_seg_selector_name)
kwargs = {"extra_segmentation": extra_seg}
elif model_type == "cristae": # Cristae model expects 2 3D volumes
image = np.stack([image, self._get_layer_selector_data(self.extra_seg_selector_name)], axis=0)
kwargs = {}
else:
kwargs = {}
segmentation = run_segmentation(
Expand Down