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

Question on the expected behavior for RAGGraphBuilder #46

Open
snibbor opened this issue Mar 1, 2023 · 0 comments
Open

Question on the expected behavior for RAGGraphBuilder #46

snibbor opened this issue Mar 1, 2023 · 0 comments

Comments

@snibbor
Copy link

snibbor commented Mar 1, 2023

Hello,

Thank you for your work, this package has been very useful and I enjoy learning from your source code.

I was preparing a dataset using the RAGGraphBuilder and noticed that all my tissue graphs had edges that connected all the "background" or 0 instance map valued nodes in the graph.

Original RAG graph:

before_RAG_fix

I noticed in the adjacency graph that the nth row and column correspond to the 0 instance map node, and that you can remove these edges by modifying the _build_topology method to:
for instance_id in np.arange(1, len(instance_ids) + 1):
mask = (instance_map == instance_id).astype(np.uint8)
dilation = cv2.dilate(mask, kernel, iterations=1)
boundary = dilation - mask
idx = pd.unique(instance_map[boundary.astype(bool)])
instance_id -= 1 # because instance_map id starts from 1
idx -= 1 # because instance_map id starts from 1
idx = idx[idx >= 0] # remove background idx and prevents "end" node -1 from making edges
adjacency[instance_id, idx] = 1

Modified RAG graph:

after_RAG_fix

I am new to learning about GNNs and am not familiar with the pros or cons of having the graph connected this way originally or disconnected. I would think that having a connected graph with the "background" nodes connected by edges would allow the GNN to perform message passing through those edges, so the original method may be desirable.

More importantly, I was wondering if these edges between the 0 instance map nodes was the expected behavior for the method.

Thank you again!
Jack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant