Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update calculate_adj.py #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
10 changes: 5 additions & 5 deletions SpaGCN_package/SpaGCN/calculate_adj.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def calculate_adj_matrix(x, y, x_pixel=None, y_pixel=None, image=None, beta=49,
if histology:
assert (x_pixel is not None) & (x_pixel is not None) & (image is not None)
assert (len(x)==len(x_pixel)) & (len(y)==len(y_pixel))
print("Calculateing adj matrix using histology image...")
print("Calculating adj matrix using histology image...")
#beta to control the range of neighbourhood when calculate grey vale for one spot
#alpha to control the color scale
beta_half=round(beta/2)
Expand All @@ -73,7 +73,7 @@ def calculate_adj_matrix(x, y, x_pixel=None, y_pixel=None, image=None, beta=49,
print("Var of x,y,z = ", np.var(x),np.var(y),np.var(z))
X=np.array([x, y, z]).T.astype(np.float32)
else:
print("Calculateing adj matrix using xy only...")
print("Calculating adj matrix using xy only...")
X=np.array([x, y]).T.astype(np.float32)
return pairwise_distance(X)

Expand All @@ -84,7 +84,7 @@ def calculate_adj_matrix(x, y, x_pixel=None, y_pixel=None, image=None, beta=49,
if histology:
assert (x_pixel is not None) & (x_pixel is not None) & (image is not None)
assert (len(x)==len(x_pixel)) & (len(y)==len(y_pixel))
print("Calculateing adj matrix using histology image...")
print("Calculating adj matrix using histology image...")
#beta to control the range of neighbourhood when calculate grey vale for one spot
#alpha to control the color scale
beta_half=round(beta/2)
Expand Down Expand Up @@ -116,12 +116,12 @@ def calculate_adj_matrix(x, y, x_pixel=None, y_pixel=None, image=None, beta=49,
x1,y1,z1,x2,y2,z2=x[i],y[i],z[i],x[j],y[j],z[j]
adj[i][j]=distance((x1,y1,z1),(x2,y2,z2))
else:
print("Calculateing adj matrix using xy only...")
print("Calculating adj matrix using xy only...")
for i in range(len(x)):
if i%50==0:
print("Calculating spot", i)
for j in range(len(x)):
x1,y1,x2,y2=x[i],y[i],x[j],y[j]
adj[i][j]=distance((x1,y1),(x2,y2))
return adj
"""
"""