celldetective 1.3.7.post1__py3-none-any.whl → 1.3.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- celldetective/_version.py +1 -1
- celldetective/gui/btrack_options.py +8 -8
- celldetective/gui/classifier_widget.py +8 -0
- celldetective/gui/configure_new_exp.py +1 -1
- celldetective/gui/json_readers.py +2 -4
- celldetective/gui/plot_signals_ui.py +38 -29
- celldetective/gui/process_block.py +1 -0
- celldetective/gui/processes/downloader.py +108 -0
- celldetective/gui/processes/measure_cells.py +346 -0
- celldetective/gui/processes/segment_cells.py +354 -0
- celldetective/gui/processes/track_cells.py +298 -0
- celldetective/gui/processes/train_segmentation_model.py +270 -0
- celldetective/gui/processes/train_signal_model.py +108 -0
- celldetective/gui/seg_model_loader.py +71 -25
- celldetective/gui/signal_annotator2.py +10 -7
- celldetective/gui/signal_annotator_options.py +1 -1
- celldetective/gui/tableUI.py +252 -20
- celldetective/gui/viewers.py +1 -1
- celldetective/io.py +53 -20
- celldetective/measure.py +12 -144
- celldetective/relative_measurements.py +40 -43
- celldetective/segmentation.py +48 -1
- celldetective/signals.py +84 -305
- celldetective/tracking.py +23 -24
- celldetective/utils.py +1 -1
- {celldetective-1.3.7.post1.dist-info → celldetective-1.3.8.dist-info}/METADATA +11 -2
- {celldetective-1.3.7.post1.dist-info → celldetective-1.3.8.dist-info}/RECORD +31 -25
- {celldetective-1.3.7.post1.dist-info → celldetective-1.3.8.dist-info}/WHEEL +1 -1
- {celldetective-1.3.7.post1.dist-info → celldetective-1.3.8.dist-info}/LICENSE +0 -0
- {celldetective-1.3.7.post1.dist-info → celldetective-1.3.8.dist-info}/entry_points.txt +0 -0
- {celldetective-1.3.7.post1.dist-info → celldetective-1.3.8.dist-info}/top_level.txt +0 -0
celldetective/segmentation.py
CHANGED
|
@@ -8,10 +8,12 @@ from .utils import _estimate_scale_factor, _extract_channel_indices
|
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
from tqdm import tqdm
|
|
10
10
|
import numpy as np
|
|
11
|
-
from celldetective.io import _view_on_napari, locate_labels, locate_stack, _view_on_napari, _check_label_dims
|
|
11
|
+
from celldetective.io import _view_on_napari, locate_labels, locate_stack, _view_on_napari, _check_label_dims, auto_correct_masks
|
|
12
12
|
from celldetective.filters import * #rework this to give a name
|
|
13
13
|
from celldetective.utils import interpolate_nan_multichannel,_rearrange_multichannel_frame, _fix_no_contrast, zoom_multiframes, _rescale_labels, rename_intensity_column, mask_edges, _prep_stardist_model, _prep_cellpose_model, estimate_unreliable_edge,_get_normalize_kwargs_from_config, _segment_image_with_stardist_model, _segment_image_with_cellpose_model
|
|
14
14
|
from stardist import fill_label_holes
|
|
15
|
+
from stardist.matching import matching
|
|
16
|
+
|
|
15
17
|
import scipy.ndimage as ndi
|
|
16
18
|
from skimage.segmentation import watershed
|
|
17
19
|
from skimage.feature import peak_local_max
|
|
@@ -717,5 +719,50 @@ def train_segmentation_model(config, use_gpu=True):
|
|
|
717
719
|
cmd = f'python "{script_path}" --config "{config}" --use_gpu "{use_gpu}"'
|
|
718
720
|
subprocess.call(cmd, shell=True)
|
|
719
721
|
|
|
722
|
+
|
|
723
|
+
def merge_instance_segmentation(labels, iou_matching_threshold=0.05, mode='OR'):
|
|
724
|
+
|
|
725
|
+
label_reference = labels[0]
|
|
726
|
+
for i in range(1,len(labels)):
|
|
727
|
+
|
|
728
|
+
label_to_merge = labels[i]
|
|
729
|
+
pairs = matching(label_reference,label_to_merge, thresh=0.5, criterion='iou', report_matches=True).matched_pairs
|
|
730
|
+
scores = matching(label_reference,label_to_merge, thresh=0.5, criterion='iou', report_matches=True).matched_scores
|
|
731
|
+
|
|
732
|
+
accepted_pairs = []
|
|
733
|
+
for k,p in enumerate(pairs):
|
|
734
|
+
s = scores[k]
|
|
735
|
+
if s > iou_matching_threshold:
|
|
736
|
+
accepted_pairs.append(p)
|
|
737
|
+
|
|
738
|
+
merge = np.copy(label_reference)
|
|
739
|
+
|
|
740
|
+
for p in accepted_pairs:
|
|
741
|
+
merge[np.where(merge==p[0])] = 0.
|
|
742
|
+
cdt1 = label_reference==p[0]
|
|
743
|
+
cdt2 = label_to_merge==p[1]
|
|
744
|
+
if mode=='OR':
|
|
745
|
+
cdt = np.logical_or(cdt1, cdt2)
|
|
746
|
+
elif mode=='AND':
|
|
747
|
+
cdt = np.logical_and(cdt1, cdt2)
|
|
748
|
+
elif mode=='XOR':
|
|
749
|
+
cdt = np.logical_xor(cdt1,cdt2)
|
|
750
|
+
loc_i, loc_j = np.where(cdt)
|
|
751
|
+
merge[loc_i, loc_j] = p[0]
|
|
752
|
+
|
|
753
|
+
cells_to_ignore = [p[1] for p in accepted_pairs]
|
|
754
|
+
for c in cells_to_ignore:
|
|
755
|
+
label_to_merge[label_to_merge==c] = 0
|
|
756
|
+
|
|
757
|
+
label_to_merge[label_to_merge!=0] = label_to_merge[label_to_merge!=0] + int(np.amax(label_reference))
|
|
758
|
+
merge[label_to_merge!=0] = label_to_merge[label_to_merge!=0]
|
|
759
|
+
|
|
760
|
+
label_reference = merge
|
|
761
|
+
|
|
762
|
+
merge = auto_correct_masks(merge)
|
|
763
|
+
|
|
764
|
+
return merge
|
|
765
|
+
|
|
766
|
+
|
|
720
767
|
if __name__ == "__main__":
|
|
721
768
|
print(segment(None,'test'))
|