celldetective 1.3.9.post4__py3-none-any.whl → 1.4.0__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/__init__.py +0 -3
- celldetective/_version.py +1 -1
- celldetective/events.py +2 -4
- celldetective/extra_properties.py +320 -24
- celldetective/gui/InitWindow.py +33 -45
- celldetective/gui/__init__.py +1 -0
- celldetective/gui/about.py +19 -15
- celldetective/gui/analyze_block.py +34 -19
- celldetective/gui/base_components.py +23 -0
- celldetective/gui/btrack_options.py +26 -34
- celldetective/gui/classifier_widget.py +71 -80
- celldetective/gui/configure_new_exp.py +113 -17
- celldetective/gui/control_panel.py +68 -141
- celldetective/gui/generic_signal_plot.py +9 -12
- celldetective/gui/gui_utils.py +49 -21
- celldetective/gui/json_readers.py +5 -4
- celldetective/gui/layouts.py +246 -22
- celldetective/gui/measurement_options.py +32 -17
- celldetective/gui/neighborhood_options.py +10 -13
- celldetective/gui/plot_measurements.py +21 -17
- celldetective/gui/plot_signals_ui.py +131 -75
- celldetective/gui/process_block.py +180 -123
- celldetective/gui/processes/compute_neighborhood.py +594 -0
- celldetective/gui/processes/measure_cells.py +5 -0
- celldetective/gui/processes/segment_cells.py +27 -6
- celldetective/gui/processes/track_cells.py +6 -0
- celldetective/gui/retrain_segmentation_model_options.py +12 -20
- celldetective/gui/retrain_signal_model_options.py +57 -56
- celldetective/gui/seg_model_loader.py +21 -62
- celldetective/gui/signal_annotator.py +139 -72
- celldetective/gui/signal_annotator2.py +431 -635
- celldetective/gui/signal_annotator_options.py +8 -11
- celldetective/gui/survival_ui.py +49 -95
- celldetective/gui/tableUI.py +28 -25
- celldetective/gui/thresholds_gui.py +617 -1221
- celldetective/gui/viewers.py +106 -39
- celldetective/gui/workers.py +9 -3
- celldetective/io.py +73 -27
- celldetective/measure.py +63 -27
- celldetective/neighborhood.py +342 -268
- celldetective/preprocessing.py +25 -17
- celldetective/relative_measurements.py +50 -29
- celldetective/scripts/analyze_signals.py +4 -1
- celldetective/scripts/measure_relative.py +4 -1
- celldetective/scripts/segment_cells.py +0 -6
- celldetective/scripts/track_cells.py +3 -1
- celldetective/scripts/train_segmentation_model.py +7 -4
- celldetective/signals.py +29 -14
- celldetective/tracking.py +7 -2
- celldetective/utils.py +36 -8
- {celldetective-1.3.9.post4.dist-info → celldetective-1.4.0.dist-info}/METADATA +24 -16
- {celldetective-1.3.9.post4.dist-info → celldetective-1.4.0.dist-info}/RECORD +57 -55
- {celldetective-1.3.9.post4.dist-info → celldetective-1.4.0.dist-info}/WHEEL +1 -1
- tests/test_qt.py +21 -21
- {celldetective-1.3.9.post4.dist-info → celldetective-1.4.0.dist-info}/entry_points.txt +0 -0
- {celldetective-1.3.9.post4.dist-info → celldetective-1.4.0.dist-info/licenses}/LICENSE +0 -0
- {celldetective-1.3.9.post4.dist-info → celldetective-1.4.0.dist-info}/top_level.txt +0 -0
celldetective/measure.py
CHANGED
|
@@ -20,13 +20,21 @@ from skimage.feature import blob_dog, blob_log
|
|
|
20
20
|
from celldetective.utils import rename_intensity_column, create_patch_mask, remove_redundant_features, \
|
|
21
21
|
remove_trajectory_measurements, contour_of_instance_segmentation, extract_cols_from_query, step_function, interpolate_nan, _remove_invalid_cols
|
|
22
22
|
from celldetective.preprocessing import field_correction
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
# try:
|
|
25
|
+
# from celldetective.extra_properties import *
|
|
26
|
+
# extra_props = True
|
|
27
|
+
# except Exception as e:
|
|
28
|
+
# print(f"The module extra_properties seems corrupted: {e}... Skip...")
|
|
29
|
+
# extra_props = False
|
|
30
|
+
|
|
24
31
|
from inspect import getmembers, isfunction
|
|
25
32
|
from skimage.morphology import disk
|
|
26
33
|
from scipy.signal import find_peaks, peak_widths
|
|
27
34
|
|
|
28
35
|
from celldetective.segmentation import filter_image
|
|
29
36
|
from celldetective.regionprops import regionprops_table
|
|
37
|
+
from celldetective.utils import pretty_table
|
|
30
38
|
|
|
31
39
|
abs_path = os.sep.join([os.path.split(os.path.dirname(os.path.realpath(__file__)))[0], 'celldetective'])
|
|
32
40
|
|
|
@@ -211,7 +219,7 @@ def measure(stack=None, labels=None, trajectories=None, channel_names=None,
|
|
|
211
219
|
measurements = measurements.sort_values(by=[column_labels['track'],column_labels['time']])
|
|
212
220
|
measurements = measurements.dropna(subset=[column_labels['track']])
|
|
213
221
|
else:
|
|
214
|
-
measurements['ID'] = np.arange(len(
|
|
222
|
+
measurements['ID'] = np.arange(len(measurements))
|
|
215
223
|
|
|
216
224
|
measurements = measurements.reset_index(drop=True)
|
|
217
225
|
measurements = _remove_invalid_cols(measurements)
|
|
@@ -365,26 +373,35 @@ def measure_features(img, label, features=['area', 'intensity_mean'], channels=N
|
|
|
365
373
|
corrected_image = field_correction(img[:,:,ind].copy(), threshold_on_std=norm['threshold_on_std'], operation=norm['operation'], model=norm['model'], clip=norm['clip'])
|
|
366
374
|
img[:, :, ind] = corrected_image
|
|
367
375
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
376
|
+
try:
|
|
377
|
+
import celldetective.extra_properties as extra_props
|
|
378
|
+
extraprops = True
|
|
379
|
+
except Exception as e:
|
|
380
|
+
print(f"The module extra_properties seems corrupted: {e}... Skip...")
|
|
381
|
+
extraprops = False
|
|
382
|
+
|
|
383
|
+
if extraprops:
|
|
384
|
+
extra = getmembers(extra_props, isfunction)
|
|
385
|
+
extra = [extra[i][0] for i in range(len(extra))]
|
|
386
|
+
|
|
387
|
+
extra_props_list = []
|
|
388
|
+
feats = features.copy()
|
|
389
|
+
for f in features:
|
|
390
|
+
if f in extra:
|
|
391
|
+
feats.remove(f)
|
|
392
|
+
extra_props_list.append(getattr(extra_props, f))
|
|
393
|
+
|
|
394
|
+
# Add intensity nan mean if need to measure mean intensities
|
|
395
|
+
if measure_mean_intensities:
|
|
396
|
+
extra_props_list.append(getattr(extra_props, 'intensity_nanmean'))
|
|
397
|
+
|
|
398
|
+
if len(extra_props_list) == 0:
|
|
399
|
+
extra_props_list = None
|
|
400
|
+
else:
|
|
401
|
+
extra_props_list = tuple(extra_props_list)
|
|
386
402
|
else:
|
|
387
|
-
extra_props_list =
|
|
403
|
+
extra_props_list = []
|
|
404
|
+
feats = features.copy()
|
|
388
405
|
|
|
389
406
|
props = regionprops_table(label, intensity_image=img, properties=feats, extra_properties=extra_props_list, channel_names=channels)
|
|
390
407
|
df_props = pd.DataFrame(props)
|
|
@@ -837,17 +854,32 @@ def local_normalisation(image, labels, background_intensity, measurement='intens
|
|
|
837
854
|
|
|
838
855
|
def normalise_by_cell(image, labels, distance=5, model='median', operation='subtract', clip=False):
|
|
839
856
|
|
|
840
|
-
|
|
857
|
+
try:
|
|
858
|
+
import celldetective.extra_properties as extra_props
|
|
859
|
+
extraprops = True
|
|
860
|
+
except Exception as e:
|
|
861
|
+
print(f"The module extra_properties seems corrupted: {e}... Skip...")
|
|
862
|
+
extraprops = False
|
|
841
863
|
|
|
842
864
|
border = contour_of_instance_segmentation(label=labels, distance=distance * (-1))
|
|
843
865
|
if model == 'mean':
|
|
866
|
+
|
|
844
867
|
measurement = 'intensity_nanmean'
|
|
845
|
-
|
|
868
|
+
if extraprops:
|
|
869
|
+
extra_props = [getattr(extra_props, measurement)]
|
|
870
|
+
else:
|
|
871
|
+
extra_props = []
|
|
872
|
+
|
|
846
873
|
background_intensity = regionprops_table(intensity_image=image, label_image=border,
|
|
847
874
|
extra_properties=extra_props)
|
|
848
875
|
elif model == 'median':
|
|
876
|
+
|
|
849
877
|
measurement = 'intensity_median'
|
|
850
|
-
|
|
878
|
+
if extraprops:
|
|
879
|
+
extra_props = [getattr(extra_props, measurement)]
|
|
880
|
+
else:
|
|
881
|
+
extra_props = []
|
|
882
|
+
|
|
851
883
|
background_intensity = regionprops_table(intensity_image=image, label_image=border,
|
|
852
884
|
extra_properties=extra_props)
|
|
853
885
|
|
|
@@ -1250,16 +1282,20 @@ def classify_irreversible_events(data, class_attr, r2_threshold=0.5, percentile_
|
|
|
1250
1282
|
# ambiguity, possible transition, use `unique_state` technique after
|
|
1251
1283
|
df.loc[indices, class_attr] = 2
|
|
1252
1284
|
|
|
1253
|
-
print("
|
|
1285
|
+
print("Number of cells per class after the initial pass: ")
|
|
1286
|
+
pretty_table(df.loc[df['FRAME']==0,class_attr].value_counts().to_dict())
|
|
1254
1287
|
|
|
1255
1288
|
df.loc[df[class_attr]!=2, class_attr.replace('class', 't')] = -1
|
|
1256
1289
|
# Try to fit time on class 2 cells (ambiguous)
|
|
1257
1290
|
df = estimate_time(df, class_attr, model='step_function', class_of_interest=[2], r2_threshold=r2_threshold)
|
|
1258
|
-
|
|
1291
|
+
|
|
1292
|
+
print("Number of cells per class after conditional signal fit: ")
|
|
1293
|
+
pretty_table(df.loc[df['FRAME']==0,class_attr].value_counts().to_dict())
|
|
1259
1294
|
|
|
1260
1295
|
# Revisit class 2 cells to classify as neg/pos with percentile tolerance
|
|
1261
1296
|
df.loc[df[class_attr]==2,:] = classify_unique_states(df.loc[df[class_attr]==2,:].copy(), class_attr, percentile_recovery)
|
|
1262
|
-
print("
|
|
1297
|
+
print("Number of cells per class after recovery pass (median state): ")
|
|
1298
|
+
pretty_table(df.loc[df['FRAME']==0,class_attr].value_counts().to_dict())
|
|
1263
1299
|
|
|
1264
1300
|
return df
|
|
1265
1301
|
|