graintrace.tess_to_gnn#

Parse Neper .tess files into torch_geometric graph representations.

class graintrace.tess_to_gnn.NeperTessToGraphNN(tess_path, geometry_cell_file=None, geometry_face_file=None, device='cpu', dtype=torch.float64)[source]#

Bases: object

Parse a Neper .tess file and build a graph representation (pytorch_geometric Data) with grains as nodes and faces as edges.

install_neper()[source]#

Placeholder hook for installing NEPER (not implemented).

load_geometry_information(cell_file, face_file)[source]#

Placeholder hook for loading precomputed cell/face geometry (not implemented).

run_neper_for_geometry_information(tess_path)[source]#

Placeholder hook for computing geometry via NEPER (not implemented).

parse_tess()[source]#

Parse the Neper .tess file.

validate_topology(verbose=True)[source]#

Validate the graph connectivity: ensure each face belongs to 1 or 2 cells.

Parameters:

verbose (bool)

Return type:

bool

register_default_features()[source]#

Register default node/edge features. Add more as needed.

register_dataframe_features(data, verbose=True)[source]#

Register every column in a pandas DataFrame as a node feature.

Parameters:
Return type:

None

activate_all_registered_features()[source]#

Activate all currently registered node and edge features.

Return type:

None

build_cell_graph()[source]#

Construct a torch_geometric Data graph using selected features.

visualize_graph_2D(graph, node_attr=None, edge_attr=None, cmap='viridis', outpath='graph_2D.png', show_node_labels=True, show_edge_labels=True)[source]#

Render a 2D NetworkX plot of the cell-cell graph and save it to outpath.

visualize_graph_3D(graph, outpath='graph_3D.png', node_attr=None, edge_attr=None, cmap='viridis', show_node_labels=False, show_edge_labels=False)[source]#

3D visualization of the cell-cell graph using centroid positions if available. Falls back to seed positions if centroids are not yet computed.