Skip to content

Commit

Permalink
Add an overlay plot of Orientation field & cell image & fiber image t…
Browse files Browse the repository at this point in the history
…o analysis
  • Loading branch information
davidbhr committed Apr 27, 2022
1 parent 4c3a99d commit 3952ad0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
17 changes: 17 additions & 0 deletions CompactionAnalyzer/CompactionFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,20 @@ def StuctureAnalysisMain(fiber_list,
path_png= os.path.join(figures,"Orientation_weighted_noquiver.png"),
label="Orientation",dpi=dpi)
plt.close("all")

### more fancy overlay plot of cell & fiber & orientation (notweighted)
plot_fancy_overlay(im_fiber_n[edge:-edge,edge:-edge],
im_cell_n[edge:-edge,edge:-edge],
orientation_dev,
path_png= os.path.join(figures,"Orientation_overlay.png"),
label="Orientation",dpi=dpi,
# ,cmap_cell="Greys_r",cmap_fiber="Greys_r", ### use default values here
# cmap_angle="viridis", alpha_ori =0.8, alpha_cell = 0.4, alpha_fiber = 0.4,
omin=-1, omax=1,scale=scale)

plt.close("all")


# Polar plots
plot_polar(results_angle['Angles Plotting'], results_angle['Coherency (weighted by intensity)'],
path_png= os.path.join(figures,"polar_coherency_weighted.png"), label = "Coherency (weighted)",dpi=dpi)
Expand Down Expand Up @@ -698,6 +712,9 @@ def StuctureAnalysisMain(fiber_list,
vec1=min_evec[:,:,1], coherency_map=ori,show_n=10,
segmention=segmention["mask"][edge:-edge,edge:-edge],
path_png=os.path.join(figures,"overlay2.png"),dpi=dpi ,scale=scale)
##


plt.close("all")
### DISTANCE PLOTS
# plot shells - deactived as it consumes a lot of time
Expand Down
20 changes: 20 additions & 0 deletions CompactionAnalyzer/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,26 @@ def plot_coherency(coherency,path_png,label="Coherency",dpi=300):
plt.axis('off'); cbar.set_label(label,fontsize=12)
plt.savefig(path_png, dpi=dpi, bbox_inches='tight', pad_inches=0); plt.tight_layout()
return fig


def plot_fancy_overlay(fiber, cell, field,path_png,label="field",dpi=300,cmap_cell="Greys_r",cmap_fiber="Greys_r",
cmap_angle="viridis", alpha_ori =0.8, alpha_cell = 0.4, alpha_fiber = 0.4, # example cmaps: viridis/inferno/coolwarm
omin=-1, omax=1, scale=None):
fig =plt.figure()
plt.imshow(field,cmap=cmap_angle,vmin=omin,vmax=omax,alpha=alpha_ori);cbar =plt.colorbar()
plt.imshow(fiber, cmap=cmap_fiber,alpha=alpha_fiber)
plt.imshow(cell, cmap=cmap_cell,alpha=alpha_cell)
plt.axis('off');
cbar.set_label(label,fontsize=12)
if scale is not None:
scalebar = ScaleBar(scale, "um", length_fraction=0.1, location="lower right", box_alpha=0 ,
color="k")
plt.gca().add_artist(scalebar)
plt.tight_layout()
plt.savefig(path_png, dpi=dpi, bbox_inches='tight', pad_inches=0)
return fig



def plot_polar(angle_plotting, something, path_png,label="something",dpi=300,
something2 = None, something3 = None, label2 = None, label3 =None):
Expand Down

0 comments on commit 3952ad0

Please sign in to comment.