CompactionAnalyzer 1.0.2__tar.gz → 1.0.3__tar.gz
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.
- {CompactionAnalyzer-1.0.2 → compactionanalyzer-1.0.3}/CompactionAnalyzer/CompactionFunctions.py +165 -130
- {CompactionAnalyzer-1.0.2 → compactionanalyzer-1.0.3}/CompactionAnalyzer/QtShortCuts.py +527 -58
- {CompactionAnalyzer-1.0.2 → compactionanalyzer-1.0.3}/CompactionAnalyzer/StructureTensor.py +4 -1
- compactionanalyzer-1.0.3/CompactionAnalyzer/__init__.py +7 -0
- {CompactionAnalyzer-1.0.2 → compactionanalyzer-1.0.3}/CompactionAnalyzer/plotting.py +31 -16
- {CompactionAnalyzer-1.0.2 → compactionanalyzer-1.0.3}/CompactionAnalyzer.egg-info/PKG-INFO +11 -1
- {CompactionAnalyzer-1.0.2 → compactionanalyzer-1.0.3}/CompactionAnalyzer.egg-info/SOURCES.txt +1 -1
- compactionanalyzer-1.0.3/CompactionAnalyzer.egg-info/requires.txt +10 -0
- {CompactionAnalyzer-1.0.2 → compactionanalyzer-1.0.3}/PKG-INFO +11 -1
- {CompactionAnalyzer-1.0.2 → compactionanalyzer-1.0.3}/README.md +54 -19
- {CompactionAnalyzer-1.0.2 → compactionanalyzer-1.0.3}/setup.py +7 -4
- CompactionAnalyzer-1.0.2/CompactionAnalyzer/__init__.py +0 -7
- CompactionAnalyzer-1.0.2/CompactionAnalyzer.egg-info/requires.txt +0 -5
- /CompactionAnalyzer-1.0.2/CompactionAnalyzer/GUI.py → /compactionanalyzer-1.0.3/CompactionAnalyzer/GUI_old_use_saenopy_instead.py +0 -0
- {CompactionAnalyzer-1.0.2 → compactionanalyzer-1.0.3}/CompactionAnalyzer/QExtendedGraphicsView.py +0 -0
- {CompactionAnalyzer-1.0.2 → compactionanalyzer-1.0.3}/CompactionAnalyzer/utilities.py +0 -0
- {CompactionAnalyzer-1.0.2 → compactionanalyzer-1.0.3}/CompactionAnalyzer.egg-info/dependency_links.txt +0 -0
- {CompactionAnalyzer-1.0.2 → compactionanalyzer-1.0.3}/CompactionAnalyzer.egg-info/top_level.txt +0 -0
- {CompactionAnalyzer-1.0.2 → compactionanalyzer-1.0.3}/LICENSE +0 -0
- {CompactionAnalyzer-1.0.2 → compactionanalyzer-1.0.3}/setup.cfg +0 -0
{CompactionAnalyzer-1.0.2 → compactionanalyzer-1.0.3}/CompactionAnalyzer/CompactionFunctions.py
RENAMED
|
@@ -2,12 +2,17 @@ import numpy as np
|
|
|
2
2
|
from skimage import io
|
|
3
3
|
from PIL import Image
|
|
4
4
|
from skimage.filters import gaussian, threshold_otsu, threshold_yen
|
|
5
|
-
import scipy.ndimage.morphology as scipy_morph
|
|
6
|
-
import scipy.ndimage.measurements as scipy_meas
|
|
7
5
|
from skimage.morphology import remove_small_objects
|
|
8
6
|
import imageio
|
|
9
7
|
from skimage import color
|
|
10
|
-
|
|
8
|
+
try:
|
|
9
|
+
from scipy.ndimage import distance_transform_edt
|
|
10
|
+
import scipy.ndimage as scipy_morph
|
|
11
|
+
import scipy.ndimage as scipy_meas
|
|
12
|
+
except ImportError:
|
|
13
|
+
from scipy.ndimage.morphology import distance_transform_edt
|
|
14
|
+
import scipy.ndimage.morphology as scipy_morph
|
|
15
|
+
import scipy.ndimage.measurements as scipy_meas
|
|
11
16
|
import matplotlib.pyplot as plt
|
|
12
17
|
import os
|
|
13
18
|
import pandas as pd
|
|
@@ -69,6 +74,15 @@ def custom_mask(img,show_segmentation=True):
|
|
|
69
74
|
dict: Dictionary with keys: mask, radius, centroid (x/y)
|
|
70
75
|
"""
|
|
71
76
|
from roipoly import RoiPoly
|
|
77
|
+
import matplotlib
|
|
78
|
+
|
|
79
|
+
# switch backend for roipoly
|
|
80
|
+
try:
|
|
81
|
+
mpl_backend = matplotlib.get_backend()
|
|
82
|
+
matplotlib.use('Qt5Agg')
|
|
83
|
+
except:
|
|
84
|
+
print ("Switched to Qt5Agg Backend for Roipoly")
|
|
85
|
+
|
|
72
86
|
# need to install RoiPoly package via pip to use this function
|
|
73
87
|
height = img.shape[0]
|
|
74
88
|
width = img.shape[1]
|
|
@@ -93,7 +107,15 @@ def custom_mask(img,show_segmentation=True):
|
|
|
93
107
|
# if show_segmentation:
|
|
94
108
|
# plt.figure()
|
|
95
109
|
# plt.subplot(121), plt.imshow(img)
|
|
96
|
-
# plt.subplot(122), plt.imshow(mask)
|
|
110
|
+
# plt.subplot(122), plt.imshow(mask)
|
|
111
|
+
|
|
112
|
+
# switch to original backend
|
|
113
|
+
try:
|
|
114
|
+
matplotlib.use(mpl_backend)
|
|
115
|
+
print ("Switched Back")
|
|
116
|
+
except:
|
|
117
|
+
print ("Could not switched back")
|
|
118
|
+
|
|
97
119
|
return {'mask': mask, 'radius': radius, 'centroid': (cx, cy)}
|
|
98
120
|
|
|
99
121
|
def regional_maxima(img):
|
|
@@ -204,10 +226,11 @@ def StuctureAnalysisMain(fiber_list,
|
|
|
204
226
|
sigma_tensor = None , # sigma of applied gauss filter / window for structure tensor analysis in px
|
|
205
227
|
# should be in the order of the objects to analyze !!
|
|
206
228
|
# 7 um for collagen
|
|
207
|
-
edge =
|
|
229
|
+
edge = 15 , # Cutt of pixels at the edge since values at the border cannot be trusted
|
|
208
230
|
segmention_thres = 1.0 , # for cell segemetntion, thres 1 equals normal otsu threshold , user also can specify gaus1 + gaus2 in segmentation if needed
|
|
209
231
|
seg_gaus1=0.5, seg_gaus2 = 100 , # 2 gaus filters used as bandpassfilter for local contrast enhancement; For seg_gaus2 = None a single gauss filter is applied
|
|
210
232
|
max_dist = None, # optional: specify the maximal distance around cell center for analysis (in px)
|
|
233
|
+
min_dist = None, # optional: specify the minimals distance around cell center for analysis (in px)
|
|
211
234
|
regional_max_correction = True,# background correction using regional maxima approach
|
|
212
235
|
show_segmentation = False , # display the segmentation output
|
|
213
236
|
sigma_first_blur = 0.5 , # slight first bluring of whole image before appplying the structure tensor
|
|
@@ -219,6 +242,7 @@ def StuctureAnalysisMain(fiber_list,
|
|
|
219
242
|
SaveNumpy = False , # saves numpy arrays for later analysis - can create large data files
|
|
220
243
|
norm1=1,norm2 = 99 , # contrast spreading for input images between norm1- and norm2-percentile; values below norm1-percentile are set to zero and
|
|
221
244
|
# values above norm2-percentile are set to 1
|
|
245
|
+
### use norm1= 0,norm2 = 100 if no contras enhancement desired
|
|
222
246
|
seg_invert=False, # if segmentation is inverted dark objects are detected inseated of bright objects
|
|
223
247
|
seg_iter = 1, # number of repetitions of binary closing, dilation and filling holes steps
|
|
224
248
|
segmention_method="otsu", # use "otsu", "entropy" or "yen" as segmentation method
|
|
@@ -269,7 +293,7 @@ def StuctureAnalysisMain(fiber_list,
|
|
|
269
293
|
'SaveNumpy': [SaveNumpy], 'norm1': [norm1], 'norm2': [norm2],
|
|
270
294
|
'seg_invert': [seg_invert], 'seg_iter': [seg_iter], 'segmention_method': [segmention_method],
|
|
271
295
|
'load_segmentation': [load_segmentation], 'path_seg': [path_seg],
|
|
272
|
-
'max_dist': [max_dist]
|
|
296
|
+
'max_dist': [max_dist], 'min_dist': [min_dist]
|
|
273
297
|
|
|
274
298
|
},
|
|
275
299
|
'Data' : {'fiber_list': [fiber_list], 'cell_list': [cell_list], 'out_list': [out_list]}
|
|
@@ -279,20 +303,20 @@ def StuctureAnalysisMain(fiber_list,
|
|
|
279
303
|
|
|
280
304
|
|
|
281
305
|
# load images
|
|
282
|
-
im_cell = imageio.imread(cell_list[n]) #color.rgb2gray(..)
|
|
283
|
-
im_fiber = imageio.imread(fiber_list[n]) #color.rgb2gray()
|
|
306
|
+
im_cell = imageio.v2.imread(cell_list[n]) #color.rgb2gray(..)
|
|
307
|
+
im_fiber = imageio.v2.imread(fiber_list[n]) #color.rgb2gray()
|
|
284
308
|
|
|
285
309
|
## if 3 channels convert to grey
|
|
286
310
|
if len(im_cell.shape) == 3 :
|
|
287
311
|
im_cell = color.rgb2gray(im_cell)
|
|
288
312
|
if len(im_fiber.shape) == 3 :
|
|
289
313
|
im_fiber = color.rgb2gray(im_fiber)
|
|
290
|
-
|
|
314
|
+
|
|
291
315
|
# # applying normalizing/ contrast spreading
|
|
292
316
|
im_cell_n = normalize(im_cell, norm1, norm2)
|
|
293
317
|
im_fiber_n = normalize(im_fiber, norm1, norm2)
|
|
294
318
|
im_fiber_g = gaussian(im_fiber_n, sigma=sigma_first_blur) # blur fiber image slightly (test with local gauss - similar)
|
|
295
|
-
|
|
319
|
+
|
|
296
320
|
|
|
297
321
|
# segment cell (either manual or automatically)
|
|
298
322
|
if manual_segmention==True:
|
|
@@ -326,10 +350,13 @@ def StuctureAnalysisMain(fiber_list,
|
|
|
326
350
|
# Structure Tensor Orientation
|
|
327
351
|
# get structure tensor
|
|
328
352
|
ori, max_evec, min_evec, max_eval, min_eval = analyze_local(im_fiber_g_forstructure, sigma=sigma_tensor, size=0, filter_type="gaussian")
|
|
353
|
+
|
|
329
354
|
# cut off edges as specified
|
|
330
355
|
if edge != 0:
|
|
331
356
|
ori, max_evec, min_evec, max_eval, min_eval = ori[edge:-edge,edge:-edge], max_evec[edge:-edge,edge:-edge], min_evec[edge:-edge,edge:-edge], \
|
|
332
357
|
max_eval[edge:-edge,edge:-edge], min_eval[edge:-edge,edge:-edge]
|
|
358
|
+
|
|
359
|
+
|
|
333
360
|
"""
|
|
334
361
|
coordinates
|
|
335
362
|
"""
|
|
@@ -342,31 +369,32 @@ def StuctureAnalysisMain(fiber_list,
|
|
|
342
369
|
dx_norm = (dx/distance)
|
|
343
370
|
dy_norm = (dy/distance)
|
|
344
371
|
dist_surface = distance_transform_edt(~segmention["mask"])[edge:-edge,edge:-edge] # dist to surface
|
|
345
|
-
|
|
346
|
-
|
|
372
|
+
# calculate an angle without the deviation/reference to the cell position
|
|
373
|
+
angle_no_reference = np.arctan2(min_evec[:,:,0],min_evec[:,:,1])*360/(2*np.pi)
|
|
374
|
+
|
|
375
|
+
|
|
347
376
|
"""
|
|
348
377
|
total image analysis
|
|
349
378
|
"""
|
|
350
379
|
# Angular deviation from orietation to center vector (projection to only have positive deviation angle values since negative/positive deviation does not matter here)
|
|
351
380
|
angle_dev = np.arccos(np.abs(dx_norm * min_evec[:,:,0] + dy_norm*min_evec[:,:,1])) * 360/(2*np.pi)
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
381
|
+
## compute the orientation
|
|
382
|
+
orientation_dev = 1 - (2 * np.arccos(np.abs(dx_norm * min_evec[:,:,0] + dy_norm*min_evec[:,:,1]))/ (0.5* np.pi))
|
|
383
|
+
|
|
384
|
+
|
|
357
385
|
### set values to nan if max distance is specified
|
|
358
386
|
## for following analysis then only orientation within a certtain distance to the cell are used
|
|
359
387
|
if max_dist:
|
|
360
|
-
angle_dev[distance
|
|
361
|
-
ori[distance
|
|
362
|
-
angle[distance
|
|
388
|
+
angle_dev[distance>max_dist] = np.nan
|
|
389
|
+
ori[distance>max_dist] = np.nan
|
|
390
|
+
angle[distance>max_dist] = np.nan # also for angular evaluation
|
|
363
391
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
392
|
+
if min_dist:
|
|
393
|
+
angle_dev[distance<min_dist] = np.nan
|
|
394
|
+
ori[distance<min_dist] = np.nan
|
|
395
|
+
angle[distance<max_dist] = np.nan # also for angular evaluation
|
|
396
|
+
|
|
397
|
+
|
|
370
398
|
# weighting by coherence and image intensity
|
|
371
399
|
im_fiber_g = im_fiber_g[edge:-edge,edge:-edge]
|
|
372
400
|
# could also use non filtered image
|
|
@@ -374,14 +402,18 @@ def StuctureAnalysisMain(fiber_list,
|
|
|
374
402
|
# use a threshold in the intensity image// only coherence and orientation vectors
|
|
375
403
|
# corresponding to pixels in the intesity iamage above a threshold are considered.
|
|
376
404
|
weight_image = gaussian(im_fiber_g,sigma=15)
|
|
405
|
+
|
|
406
|
+
# construct weighted array so that the mean value of these arrays later
|
|
407
|
+
# result in the weighted average of these
|
|
408
|
+
# weight by coherency
|
|
409
|
+
angle_dev_weighted = (angle_dev * ori) / np.nanmean(ori)
|
|
410
|
+
orientation_dev_weighted = (orientation_dev * ori) / np.nanmean(ori)
|
|
411
|
+
# weight by coherency & intensity
|
|
377
412
|
angle_dev_weighted2 = (angle_dev_weighted *weight_image) / np.nanmean(weight_image)
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
# also weighting the coherency like this
|
|
413
|
+
orientation_dev_weighted2 = (orientation_dev *weight_image*ori) / np.nanmean(weight_image*ori)
|
|
414
|
+
# weighting coherency by intensity
|
|
382
415
|
ori_weight2 = (ori * weight_image) / np.nanmean(weight_image)
|
|
383
|
-
|
|
384
|
-
|
|
416
|
+
|
|
385
417
|
# GRADIENT towards center
|
|
386
418
|
grad_y = np.gradient(im_fiber_g, axis=0)
|
|
387
419
|
grad_x = np.gradient(im_fiber_g, axis=1)
|
|
@@ -402,9 +434,7 @@ def StuctureAnalysisMain(fiber_list,
|
|
|
402
434
|
alpha_dev_total1 = np.nanmean(angle_dev[(~segmention["mask"][edge:-edge,edge:-edge])])
|
|
403
435
|
alpha_dev_total2 = np.nanmean(angle_dev_weighted[(~segmention["mask"][edge:-edge, edge:-edge])])
|
|
404
436
|
alpha_dev_total3 = np.nanmean(angle_dev_weighted2[(~segmention["mask"][edge:-edge, edge:-edge])])
|
|
405
|
-
|
|
406
|
-
# cos_dev_total2 = np.nanmean(np.cos(2*angle_dev_weighted[(~segmention["mask"][edge:-edge, edge:-edge])]*np.pi/180))
|
|
407
|
-
# cos_dev_total3 = np.nanmean(np.cos(2*angle_dev_weighted2[(~segmention["mask"][edge:-edge, edge:-edge])]*np.pi/180))
|
|
437
|
+
|
|
408
438
|
cos_dev_total1 = np.nanmean(orientation_dev[(~segmention["mask"][edge:-edge,edge:-edge]) ])
|
|
409
439
|
cos_dev_total2 = np.nanmean(orientation_dev_weighted[(~segmention["mask"][edge:-edge,edge:-edge]) ])
|
|
410
440
|
cos_dev_total3 = np.nanmean(orientation_dev_weighted2[(~segmention["mask"][edge:-edge,edge:-edge]) ])
|
|
@@ -571,59 +601,32 @@ def StuctureAnalysisMain(fiber_list,
|
|
|
571
601
|
excel_distance = pd.DataFrame.from_dict(results_distance)
|
|
572
602
|
excel_distance.to_excel(os.path.join(out_list[n],"results_distance.xlsx"))
|
|
573
603
|
|
|
574
|
-
|
|
575
|
-
# Halflife values - Leave for now..
|
|
576
|
-
# # Calculate value where ntensity drops 25%
|
|
577
|
-
# distintdrop = np.abs(np.array(results_distance['Intensity Norm (individual)'])-0.75)
|
|
578
|
-
# # distance where int drops to 75%
|
|
579
|
-
# halflife_int = midofshells[np.where(distintdrop == np.nanmin(distintdrop))[1]]
|
|
580
|
-
# # if decrease is not within range (minimum equals last value) then set to nan
|
|
581
|
-
# if halflife_int == midofshells[-1]:
|
|
582
|
-
# halflife_int = np.nan
|
|
583
|
-
# # # Calculate value where orientation drops to 75% within maxorientation(min) to 45° (random) range
|
|
584
|
-
# # difference to 45 degree instead of min-max range
|
|
585
|
-
# # calculate halflife of maximal orientation over distance
|
|
586
|
-
# # difference to 45 degree for all
|
|
587
|
-
# diffdist = np.array(dist_angle_individ)-45
|
|
588
|
-
# # maximal orientation
|
|
589
|
-
# diffmax = np.nanmin(diffdist)
|
|
590
|
-
# diffmax_pos = np.where(diffmax==diffdist)[0][0]
|
|
591
|
-
# # difference angle drops to 75%
|
|
592
|
-
# diff2 = np.abs(diffdist-(0.75*diffmax))
|
|
593
|
-
# diff2[:diffmax_pos] = np.nan # only look at distances on the right side /further out
|
|
594
|
-
# halflife_ori = midofshells[np.where(diff2 == np.nanmin(diff2))]
|
|
595
|
-
# # if decrease is not within range (minimum equals last value) then set to nan
|
|
596
|
-
# if halflife_ori == midofshells[-1]:
|
|
597
|
-
# halflife_ori = np.nan
|
|
598
|
-
# try:
|
|
599
|
-
# np.savetxt(os.path.join(out_list[n],"meanangle_within10shells.txt"), [dist_angle_accum[9]])
|
|
600
|
-
# except:
|
|
601
|
-
# pass
|
|
604
|
+
|
|
602
605
|
|
|
603
606
|
if SaveNumpy:
|
|
604
607
|
#create output folder if not existing
|
|
605
|
-
numpy_out = os.path.join(out_list[n],
|
|
608
|
+
numpy_out = os.path.join(out_list[n], "NumpyArrays" )
|
|
609
|
+
print (numpy_out)
|
|
606
610
|
if not os.path.exists(numpy_out):
|
|
607
611
|
os.makedirs(numpy_out)
|
|
608
612
|
|
|
609
613
|
np.save(os.path.join(numpy_out, "segmention.npy" ),segmention)
|
|
610
|
-
np.save(os.path.join(numpy_out, "
|
|
611
|
-
np.save(os.path.join(numpy_out, "AngleMap(weight_int).npy" ),angle_dev_weighted)
|
|
612
|
-
np.save(os.path.join(numpy_out, "
|
|
614
|
+
np.save(os.path.join(numpy_out, "AngleDeviationMap.npy" ),angle_dev )
|
|
615
|
+
#np.save(os.path.join(numpy_out, "AngleMap(weight_int).npy" ),angle_dev_weighted)
|
|
616
|
+
np.save(os.path.join(numpy_out, "AngleDeviationMap(weight_int_coh).npy"),angle_dev_weighted2 )
|
|
617
|
+
np.save(os.path.join(numpy_out, "AngleMap_NoReference.npy"), angle_no_reference )
|
|
613
618
|
np.save(os.path.join(numpy_out, "OrientationMap.npy" ),orientation_dev )
|
|
614
|
-
np.save(os.path.join(numpy_out, "OrientationMap_weight_int.npy" ),orientation_dev_weighted)
|
|
619
|
+
#np.save(os.path.join(numpy_out, "OrientationMap_weight_int.npy" ),orientation_dev_weighted)
|
|
615
620
|
np.save(os.path.join(numpy_out, "OrientationMap_weight_intcoh.npy" ),orientation_dev_weighted2 )
|
|
616
621
|
np.save(os.path.join(numpy_out, "FiberImageCrop.npy" ),normalize(im_fiber_n[edge:-edge,edge:-edge]) )
|
|
617
622
|
np.save(os.path.join(numpy_out, "CoherencyMap.npy" ),ori )
|
|
618
|
-
np.save(os.path.join(numpy_out, "CoherencyMap(weighted_int).npy" ),ori_weight2)
|
|
623
|
+
#np.save(os.path.join(numpy_out, "CoherencyMap(weighted_int).npy" ),ori_weight2)
|
|
619
624
|
np.save(os.path.join(numpy_out, "Vector_min_ax0.npy"),min_evec[:,:,0])
|
|
620
625
|
np.save(os.path.join(numpy_out, "Vector_min_ax1.npy"),min_evec[:,:,1])
|
|
621
|
-
np.save(os.path.join(numpy_out, "mask_surface_shells.npy"),mask_shells['Mask_shell'])
|
|
622
|
-
np.save(os.path.join(numpy_out, "mask_spherical_shells.npy"),mask_shells['Mask_shell_center'])
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
626
|
+
#np.save(os.path.join(numpy_out, "mask_surface_shells.npy"),mask_shells['Mask_shell'])
|
|
627
|
+
#np.save(os.path.join(numpy_out, "mask_spherical_shells.npy"),mask_shells['Mask_shell_center'])
|
|
628
|
+
|
|
629
|
+
|
|
627
630
|
"""
|
|
628
631
|
Plott results
|
|
629
632
|
"""
|
|
@@ -631,69 +634,103 @@ def StuctureAnalysisMain(fiber_list,
|
|
|
631
634
|
if plotting:
|
|
632
635
|
#create output folder if not existing
|
|
633
636
|
figures = os.path.join(out_list[n],"Figures")
|
|
637
|
+
print (figures)
|
|
634
638
|
if not os.path.exists(figures):
|
|
635
639
|
os.makedirs(figures)
|
|
636
|
-
|
|
640
|
+
|
|
641
|
+
plot_angle_dev(angle_map = orientation_dev, vmin=-1,vmax=1,
|
|
642
|
+
vec0=min_evec[:,:,0] ,vec1=min_evec[:,:,1] ,coherency_map=ori,
|
|
643
|
+
path_png= os.path.join(figures,"Orientation.png"),label="Orientation",dpi=dpi,cmap="coolwarm")
|
|
637
644
|
# plot orientation and angle deviation maps together with orientation structure
|
|
638
|
-
plot_angle_dev(angle_map = angle_dev,
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
#
|
|
652
|
-
|
|
653
|
-
plot_coherency(
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
645
|
+
# plot_angle_dev(angle_map = angle_dev, vmin=0,vmax=90,
|
|
646
|
+
# vec0=min_evec[:,:,0] ,vec1=min_evec[:,:,1] ,coherency_map=ori,
|
|
647
|
+
# path_png= os.path.join(figures,"Angle_deviation.png"),label="Angle Deviation",dpi=dpi,cmap="viridis_r")
|
|
648
|
+
|
|
649
|
+
# # do not show the weighted ones here, as only the mean has the same range again and here angles can be smaller/large
|
|
650
|
+
# plot_angle_dev(angle_map = angle_dev_weighted2,
|
|
651
|
+
# vec0=min_evec[:,:,0] ,vec1=min_evec[:,:,1] ,coherency_map=ori,
|
|
652
|
+
# path_png= os.path.join(figures,"Angle_deviation_weighted.png"),label="Angle Deviation",dpi=dpi,cmap="viridis_r")
|
|
653
|
+
# plot_angle_dev(angle_map = orientation_dev_weighted2 ,
|
|
654
|
+
# vec0=min_evec[:,:,0] ,vec1=min_evec[:,:,1] ,coherency_map=ori,
|
|
655
|
+
# path_png= os.path.join(figures,"Orientation_weighted.png"),label="Orientation",dpi=dpi,cmap="viridis")
|
|
656
|
+
|
|
657
|
+
# # pure coherency and pure orientation
|
|
658
|
+
# plot_coherency(ori,path_png= os.path.join(figures,"coherency_noquiver.png"),
|
|
659
|
+
# label="Coherency",vmin=0,vmax=1,cmap="turbo",dpi=dpi)
|
|
660
|
+
# plot_coherency(orientation_dev,
|
|
661
|
+
# path_png= os.path.join(figures,"Orientation_noquiver.png"),
|
|
662
|
+
# label="Orientation",vmin=-1,vmax=1,cmap="coolwarm",dpi=dpi)
|
|
663
|
+
|
|
657
664
|
|
|
658
665
|
### more fancy overlay plot of cell & fiber & orientation (notweighted)
|
|
659
666
|
plot_fancy_overlay(im_fiber_n[edge:-edge,edge:-edge],
|
|
660
667
|
im_cell_n[edge:-edge,edge:-edge],
|
|
661
|
-
orientation_dev,
|
|
668
|
+
orientation_dev, cmap_angle="coolwarm",
|
|
662
669
|
path_png= os.path.join(figures,"Orientation_overlay.png"),
|
|
663
670
|
label="Orientation",dpi=dpi,
|
|
664
671
|
# ,cmap_cell="Greys_r",cmap_fiber="Greys_r", ### use default values here
|
|
665
672
|
# cmap_angle="viridis", alpha_ori =0.8, alpha_cell = 0.4, alpha_fiber = 0.4,
|
|
666
673
|
omin=-1, omax=1,scale=scale)
|
|
674
|
+
|
|
675
|
+
plot_fancy_overlay(im_fiber_n[edge:-edge,edge:-edge],
|
|
676
|
+
im_cell_n[edge:-edge,edge:-edge],
|
|
677
|
+
ori, cmap_angle="turbo",
|
|
678
|
+
path_png= os.path.join(figures,"Coherency_overlay.png"),
|
|
679
|
+
label="Coherency",dpi=dpi,
|
|
680
|
+
# ,cmap_cell="Greys_r",cmap_fiber="Greys_r", ### use default values here
|
|
681
|
+
# cmap_angle="viridis", alpha_ori =0.8, alpha_cell = 0.4, alpha_fiber = 0.4,
|
|
682
|
+
omin=0, omax=1,scale=scale)
|
|
683
|
+
|
|
684
|
+
plot_fancy_overlay(im_fiber_n[edge:-edge,edge:-edge],
|
|
685
|
+
im_cell_n[edge:-edge,edge:-edge],
|
|
686
|
+
angle_dev, cmap_angle="viridis_r",
|
|
687
|
+
path_png= os.path.join(figures,"Angle_Deviation_overlay.png"),
|
|
688
|
+
label="Angle Deviation",dpi=dpi,
|
|
689
|
+
# ,cmap_cell="Greys_r",cmap_fiber="Greys_r", ### use default values here
|
|
690
|
+
# cmap_angle="viridis", alpha_ori =0.8, alpha_cell = 0.4, alpha_fiber = 0.4,
|
|
691
|
+
omin=0, omax=90,scale=scale)
|
|
692
|
+
|
|
693
|
+
plot_fancy_overlay(im_fiber_n[edge:-edge,edge:-edge],
|
|
694
|
+
im_cell_n[edge:-edge,edge:-edge],
|
|
695
|
+
angle_no_reference, cmap_angle="gist_rainbow",
|
|
696
|
+
path_png= os.path.join(figures,"Angle_NoReference_overlay.png"),
|
|
697
|
+
label="Angle (no reference)",dpi=dpi,
|
|
698
|
+
# ,cmap_cell="Greys_r",cmap_fiber="Greys_r", ### use default values here
|
|
699
|
+
# cmap_angle="viridis", alpha_ori =0.8, alpha_cell = 0.4, alpha_fiber = 0.4,
|
|
700
|
+
omin=-180, omax=180,
|
|
701
|
+
scale=scale)
|
|
702
|
+
|
|
667
703
|
|
|
668
704
|
plt.close("all")
|
|
669
705
|
|
|
670
706
|
|
|
671
|
-
# Polar plots
|
|
672
|
-
plot_polar(results_angle['Angles Plotting'], results_angle['Coherency (weighted by intensity)'],
|
|
673
|
-
path_png= os.path.join(figures,"polar_coherency_weighted.png"), label = "Coherency (weighted)",dpi=dpi)
|
|
674
|
-
|
|
675
|
-
|
|
707
|
+
# Polar plots
|
|
676
708
|
plot_polar(results_angle['Angles Plotting'], results_angle['Coherency (weighted by intensity)'],
|
|
677
709
|
path_png= os.path.join(figures,"polar_coherency_double.png"), label = "Coherency (weighted)",
|
|
678
|
-
something2 = results_angle['Coherency'], label2 = "Coherency",dpi=dpi)
|
|
679
|
-
|
|
680
|
-
plot_polar(results_angle['Angles Plotting'], results_angle['Mean Intensity'],
|
|
681
|
-
path_png= os.path.join(figures,"polar_intensity.png"), label = "Mean Intensity",dpi=dpi)
|
|
710
|
+
something2 = results_angle['Coherency'], label2 = "Coherency",dpi=dpi, vmin=0,vmax=1)
|
|
682
711
|
|
|
683
712
|
plot_polar(results_angle['Angles Plotting'], results_angle['Orientation (weighted by intensity and coherency)'],
|
|
684
|
-
|
|
713
|
+
path_png= os.path.join(figures,"polar_orientation_double.png"), label = "Orientation (weighted)",
|
|
714
|
+
something2 = results_angle['Orientation'], label2 = "Orientation",dpi=dpi, vmin=-1,vmax=1)
|
|
685
715
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
716
|
+
# plot_polar(results_angle['Angles Plotting'], results_angle['Coherency (weighted by intensity)'],
|
|
717
|
+
# path_png= os.path.join(figures,"polar_coherency_weighted.png"), label = "Coherency (weighted)",dpi=dpi)
|
|
718
|
+
|
|
719
|
+
# plot_polar(results_angle['Angles Plotting'], results_angle['Mean Intensity'],
|
|
720
|
+
# path_png= os.path.join(figures,"polar_intensity.png"), label = "Mean Intensity",dpi=dpi)
|
|
721
|
+
|
|
722
|
+
# plot_polar(results_angle['Angles Plotting'], results_angle['Orientation (weighted by intensity and coherency)'],
|
|
723
|
+
# path_png= os.path.join(figures,"Orientation_weighted_polar.png"), label = "Orientation",dpi=dpi)
|
|
724
|
+
|
|
725
|
+
# plot_polar(results_angle['Angles Plotting'], results_angle['Orientation'],
|
|
726
|
+
# path_png= os.path.join(figures,"Orientation_polar.png"), label = "Orientation",dpi=dpi)
|
|
727
|
+
# quiver plots with center overlay
|
|
728
|
+
# quiv_coherency_center(vec0=min_evec[:,:,0] ,vec1=min_evec[:,:,1] ,coherency_map=ori,
|
|
729
|
+
# center0=center_small[0],center1 = center_small[1],
|
|
730
|
+
# path_png= os.path.join(figures,"quiv_coherency_center.png"),dpi=dpi )
|
|
731
|
+
|
|
689
732
|
# summarizing triple plot
|
|
690
733
|
plot_triple(results_angle,results_total , path_png= os.path.join(figures,"Triple_plot.png") ,dpi=dpi)
|
|
691
|
-
|
|
692
|
-
# quiver plots with center overlay
|
|
693
|
-
quiv_coherency_center(vec0=min_evec[:,:,0] ,vec1=min_evec[:,:,1] ,coherency_map=ori,
|
|
694
|
-
center0=center_small[0],center1 = center_small[1],
|
|
695
|
-
path_png= os.path.join(figures,"quiv_coherency_center.png"),dpi=dpi )
|
|
696
|
-
plt.close("all")
|
|
697
734
|
# image fiber + segmention
|
|
698
735
|
plot_fiber_seg(fiber_image=normalize(im_fiber_n[edge:-edge,edge:-edge]) ,
|
|
699
736
|
c0=center_small[0],c1=center_small[1],
|
|
@@ -707,14 +744,12 @@ def StuctureAnalysisMain(fiber_list,
|
|
|
707
744
|
segmention=segmention["mask"][edge:-edge,edge:-edge],
|
|
708
745
|
path_png=os.path.join(figures,"overlay.png"),dpi=dpi ,scale=scale)
|
|
709
746
|
|
|
710
|
-
plot_overlay(fiber_image=normalize(im_fiber_n[edge:-edge,edge:-edge]) ,
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
747
|
+
# plot_overlay(fiber_image=normalize(im_fiber_n[edge:-edge,edge:-edge]) ,
|
|
748
|
+
# c0=center_small[0],c1=center_small[1], vec0=min_evec[:,:,0],
|
|
749
|
+
# vec1=min_evec[:,:,1], coherency_map=ori,show_n=10,
|
|
750
|
+
# segmention=segmention["mask"][edge:-edge,edge:-edge],
|
|
751
|
+
# path_png=os.path.join(figures,"overlay2.png"),dpi=dpi ,scale=scale)
|
|
752
|
+
|
|
718
753
|
plt.close("all")
|
|
719
754
|
### DISTANCE PLOTS
|
|
720
755
|
# plot shells - deactived as it consumes a lot of time
|
|
@@ -726,12 +761,12 @@ def StuctureAnalysisMain(fiber_list,
|
|
|
726
761
|
|
|
727
762
|
plot_distance(results_distance,string_plot = "Intensity Norm (individual)",
|
|
728
763
|
path_png=os.path.join(figures,"Intensity_distance.png"),dpi=dpi)
|
|
729
|
-
|
|
764
|
+
|
|
765
|
+
|
|
730
766
|
# save raw cell image
|
|
731
767
|
plot_cell(im_cell_n, path_png=os.path.join(figures,"cell-raw.png"), scale=scale, dpi=dpi)
|
|
732
768
|
|
|
733
|
-
plt.close("all")
|
|
734
|
-
|
|
769
|
+
plt.close("all")
|
|
735
770
|
|
|
736
771
|
return
|
|
737
772
|
|
|
@@ -758,10 +793,10 @@ def SummarizeResultsTotal(data, output_folder= None):
|
|
|
758
793
|
'Overall weighted Oriantation (std all cells)': []}
|
|
759
794
|
|
|
760
795
|
for i, path in enumerate(list_total):
|
|
761
|
-
results_total_combined['Orientation (weighted by coherency)'].append(float(pd.read_excel(list_total[i])['Orientation (weighted by coherency)']))
|
|
762
|
-
results_total_combined['Orientation (weighted by intensity and coherency)'].append(float(pd.read_excel(list_total[i])['Orientation (weighted by intensity and coherency)']))
|
|
763
|
-
results_total_combined['Mean Angle (weighted by coherency)'].append(float(pd.read_excel(list_total[i])['Mean Angle (weighted by coherency)']))
|
|
764
|
-
results_total_combined['Mean Angle (weighted by intensity and coherency)'].append(float(pd.read_excel(list_total[i])['Mean Angle (weighted by intensity and coherency)']))
|
|
796
|
+
results_total_combined['Orientation (weighted by coherency)'].append(float(pd.read_excel(list_total[i])['Orientation (weighted by coherency)'][0]))
|
|
797
|
+
results_total_combined['Orientation (weighted by intensity and coherency)'].append(float(pd.read_excel(list_total[i])['Orientation (weighted by intensity and coherency)'][0]))
|
|
798
|
+
results_total_combined['Mean Angle (weighted by coherency)'].append(float(pd.read_excel(list_total[i])['Mean Angle (weighted by coherency)'][0]))
|
|
799
|
+
results_total_combined['Mean Angle (weighted by intensity and coherency)'].append(float(pd.read_excel(list_total[i])['Mean Angle (weighted by intensity and coherency)'][0]))
|
|
765
800
|
results_total_combined['Path'].append(str(list_total[i]))
|
|
766
801
|
|
|
767
802
|
ovreall_orientation = np.nanmean(results_total_combined['Orientation (weighted by intensity and coherency)'])
|