Window Fingerprinting for Accessible Textural Properties
Annotate pore-graph windows with element-weighted shell fingerprints; understand Mechanism A vs B failures, accessible-region BFS, and effect on accessible SA / void volume.
Overview
Every connection in a periodic segmentation is a window — a narrow passage between two pore regions. The natural question is: “How wide is that window?” Most tools answer with the local pore-limiting diameter (PLD) along the pocket-to-pocket connection. mofography goes one step further: it attaches a direction-invariant, element-weighted fingerprint of the framework atoms that ring each window centre. Diameter + chemistry give a multi-modal description of each aperture — useful when diameter alone hides important distinctions.
This tutorial covers:
Window shell fingerprints — what the 118-element vector captures and how it is built.
Window fingerprint expansion — a BFS that rescues watershed regions behind slightly sub-probe windows when the local framework shell looks like the rest of the open mouth.
Effect on textural properties — how the bridging changes accessible surface area and void volume on IRMOF-1, and when you should (and should not) turn it on.
Mechanism A / B / C / D failure modes — what each one is, what fingerprinting does (and does not) fix, and where to look when you suspect each. If you have not done so, please complete the Connections and Windows tutorial first — it explains the basic seg['connections'] 5-tuple and the difference between internal and periodic windows. This page assumes that knowledge.
Why fingerprints exist
A single PLD number tells you how wide a window is. It does not tell you what is around it:
Two windows of diameter 3.8 Å may be ringed by different framework chemistry (e.g. Si/Al vs carboxylate pillars).
Two windows of diameter 5.0 Å may sit in different topology contexts (8-ring in a zeolite vs the 4-ring of a MOF).
For percolation at a near-PLD probe radius, this distinction matters more than the absolute size. If a candidate sub-probe window is at a position whose framework shell looks the same as an already-open mouth, the probability that it is the same physical aperture — undercounted by the grid — is high. If the framework shell looks completely different, the throat probably is different too, and the user’s probe should still gate access.
import mofography as mgrfrom ase.io import readimport numpy as npimport networkx as nximport plotly.graph_objects as goimport plotly.express as pximport logging# Quiet the segmentation chatterlogging.getLogger("mofography").setLevel(logging.WARNING)
Step 1: Periodic segmentation with windows
We use IRMOF-1 because it has a tight distribution of window sizes near its PLD — the perfect regime to show the bridging effect.
Show code
atoms = read("IRMOF-1.cif")spacing =0.5# Ådgrid = mgr.dgrid_from_atoms_rust(atoms, spacing=spacing)dgrid_f32 = dgrid.astype(np.float32) # Rust kernel requires float32seg = mgr.do_periodic_segmentation_rust( dgrid_f32, atoms, spacing=spacing, mask_thickness=0.05, h=0.2, min_distance=1.5, threshold_abs=1.5, minimum_window_separation=1.5, wall_thickness=0.05, extra_padding=5, compute_connections=True, # <-- windows come back in seg['connections'] watershed_backend="rust_det", disable_tqdm=True, return_dgrid=True, return_padded_regions=True,)seg["mat_atoms"] = atoms # needed by the fingerprint annotatorprint(f"Pockets (PBC-grouped): {len(seg['maxima_pbc'])}")print(f"Unique regions: {len(seg['unique_regions'])}")print(f"Window connections: {len(seg['connections'])}")
The key point: compute_connections=True (default) makes the same call return the regions, the maxima, and the window list together.
Step 2: Inspect seg['connections']
Each entry of seg['connections'] is a 5-element numpy array:
Index
Meaning
c[0]
The two region labels the window connects
c[1]
Confirmation flag (always True for a detected window)
c[2]
'internal' or 'periodic'
c[3]
Window centroid coordinates, shape (1, 3)
c[4]
Window radius in Å, shape (1,)
The detailed walkthrough of the 5-tuple lives in the Connections and Windows tutorial. Here we just need two things: a connections list with internal and periodic windows, and a unique_regions set that filters out padding artefacts.
Show code
connections = seg["connections"]unique_regions = seg["unique_regions"]# Keep only windows that touch at least one unit-cell regionconnections_trimmed = [ c for c in connectionsif np.any(np.isin(c[0], unique_regions))]internal = [c for c in connections_trimmed if c[2] =="internal"]periodic = [c for c in connections_trimmed if c[2] =="periodic"]print(f"Unit-cell windows: {len(connections_trimmed)} (internal={len(internal)}, periodic={len(periodic)})")
Unit-cell windows: 108 (internal=54, periodic=54)
Each window is essentially a centroid of the touching boundary between two regions. The list already carries a window_radius; what we want to do now is add a shell fingerprint to each one.
Step 3: Build the canonical pore graph
The connections list contains two directed entries per canonical window (one for each traversal direction). The standard pore-graph view collapses these to a networkx.MultiDiGraph keyed by canonical edge identity:
Show code
graph = mgr.make_directed_graph_from_segmentation_results(seg, dgrid=dgrid_f32)print(f"Pore graph: {graph.number_of_nodes()} nodes, {graph.number_of_edges()} edges")# Each edge carries a window_radius (the maximum over periodic images on that canonical edge).wrs =sorted({float(d.get("window_radius", 0.0)) for _, _, d in graph.edges(data=True)})print(f"Window radius range: {wrs[0]:.3f} ... {wrs[-1]:.3f} Å (N unique = {len(wrs)})")
For IRMOF-1 the windows come in a tight 3.68–3.96 Å band — close to the framework’s PLD, which is exactly where the fingerprinting rescue is most useful.
Step 4: Annotate graph edges with shell fingerprints
annotate_graph_edges_with_window_fingerprints walks every graph edge, computes a window centre from the edge data, and stamps an element-weighted vector onto the edge:
a shell of radius shell_radius (default 3.5 Å) around the centre,
weighted by 1 / max(dist, 1e-3) so nearer atoms dominate,
placed into a 118-slot vector (one slot per atomic number 1–118),
L2-normalized so cosine similarity is meaningful.
The result is stored on each edge as window_fp_vec (the tuple) and window_fp_ready (boolean). The window centre in fractional coordinates is also stored as window_frac_pos.
Show code
mgr.annotate_graph_edges_with_window_fingerprints( graph, seg, atoms=atoms, shell_radius=3.5)# Inspect the first few edgesprint(f"{'edge':>14s}{'wr [Å]':>7s}{'ready':>6s}{'nonzero slots (Z)':>30s}")print("-"*65)for u, v, k, data inlist(graph.edges(keys=True, data=True))[:6]: wr =float(data.get("window_radius", 0.0)) ready =bool(data.get("window_fp_ready", False))if ready: v_fp = np.asarray(data["window_fp_vec"]) nz = np.flatnonzero(v_fp) z_list =", ".join(f"Z={int(i+1)}"for i in nz)else: z_list ="(no atoms in shell)"print(f"({u:>2d},{v:>2d},{k:>2d}) {wr:7.3f}{ready!s:>6s}{z_list:>30s}")
For IRMOF-1 every window lands on the same set of non-zero slots — Z=6 (C), Z=8 (O), Z=30 (Zn), Z=1 (H) — which is exactly what we expect: a carboxylate linker + Zn₄O node + benzene ring + terminating H.
Step 5: What the fingerprint actually captures
The vector is direction-invariant: whether you walk the graph edge from u → v or v → u, the centre and the shell are the same, so the fingerprint is the same. That makes cosine similarity a meaningful distance.
Let’s confirm that on IRMOF-1:
Show code
# Cosine between two windows on the same canonical edge (different periodic images# at the same physical throat — fingerprints should be essentially identical).def cosine(a, b): a, b = np.asarray(a), np.asarray(b) denom =float(np.linalg.norm(a) * np.linalg.norm(b))returnfloat(np.dot(a, b) / denom) if denom >1e-12else0.0ready_edges = [ (u, v, k, data["window_fp_vec"], float(data["window_radius"]))for u, v, k, data in graph.edges(keys=True, data=True)if data.get("window_fp_ready")]# Same canonical (u, v), two different periodic images (different keys)pairs = {}for e in ready_edges: pairs.setdefault((e[0], e[1]), []).append(e)canon_with_two =next((grp for grp in pairs.values() iflen(grp) >=2), None)if canon_with_two isnotNone: a, b = canon_with_two[0], canon_with_two[1]print(f"Same canonical edge, two periodic images: "f"({a[0]},{a[1]},{a[2]}) and ({b[0]},{b[1]},{b[2]}); "f"cos = {cosine(a[3], b[3]):.4f}")# Two different edges at the same radiuse0 = ready_edges[0]same_wr = [e for e in ready_edges ifabs(e[4] - e0[4]) <1e-6and e[3] isnot e0[3]]if same_wr: e1 = same_wr[0]print(f"Different edge, same wr={e1[4]:.3f}: cos = {cosine(e0[3], e1[3]):.4f}")# The most different edgedef farthest_cosine(ref, others): ref_v = np.asarray(ref[3])returnmax(others, key=lambda e: 1.0- cosine(ref_v, e[3]))far = farthest_cosine(e0, [e for e in ready_edges if e[3] isnot e0[3]])print(f"Farthest pair: ({e0[0]},{e0[1]},{e0[2]}) wr={e0[4]:.3f} "f"vs ({far[0]},{far[1]},{far[2]}) wr={far[4]:.3f}: cos = {cosine(e0[3], far[3]):.4f}")
Same canonical edge, two periodic images: (2,4,0) and (2,4,1); cos = 0.9998
Different edge, same wr=3.678: cos = 0.9998
Farthest pair: (2,4,0) wr=3.678 vs (5,6,0) wr=3.710: cos = 0.3967
In IRMOF-1 every window fingerprints the same chemistry (Zn, O, C, H) at slightly different distances, so all pairwise cosines are very close to 1. That’s the easy case. On more complex materials — a zeolite with 8-ring and 6-ring windows of similar diameter, or a MOF with carboxylate and pyridyl linkers — the cosine separates the two families cleanly.
Step 6: Percolation at a near-PLD probe
Now the core question: what does fingerprinting actually do at a probe radius near the PLD?
percolating_region_labels_at_probe_winding is the central entry point. It runs the standard winding percolation at probe_radius, then optionally calls _expand_percolating_labels_with_window_fingerprint to add neighbour regions whose connecting window is slightly sub-probe but whose shell matches an open mouth.
Below the smallest window (probe ≪ 3.68 Å): no percolation either way.
Near the PLD (probe ≈ 3.7–3.8 Å): strict percolation drops because the smallest windows are just below the probe, but window FP rescues those regions whose sub-probe throats share a shell with an open mouth.
At/above the largest window (probe ≳ 3.96 Å): every window passes the strict threshold, so the FP expansion has nothing to add.
The window FP does not force a percolation that does not exist — it only bridges sub-probe gaps whose size is within window_fp_subprobe_gap (default 0.5 Å) and whose shell cosine is above window_fp_sim_thresh (default 0.88) of an open mouth. Windows that are too small, or look chemically different, stay closed.
Step 7: Why the expansion fires — walking a single BFS step
The mechanism is concrete. Let’s track one sub-probe edge that gets bridged and confirm the three gates that let it through:
Show code
# Pick a probe in the interesting regimeprobe =3.75subprobe_gap =0.5sim_thresh =0.88ref_tol =0.12# Build the per-edge view used internallypercolating_strict = percolating_labels(seg, probe, fp_on=False)percolating_nodes_strict =set()for node, labels in mgr.build_base_region_labels_from_results(seg).items():ifset(labels).intersection(percolating_strict): percolating_nodes_strict.add(int(node))# Reference edges = those incident on a strict-percolating node whose window_radius >= probe - ref_tolref_edges = []for u, v, k, data in graph.edges(keys=True, data=True):ifint(u) notin percolating_nodes_strict andint(v) notin percolating_nodes_strict:continue wr =float(data.get("window_radius", 0.0))if wr < probe - ref_tol:continueifnot data.get("window_fp_ready"):continue ref_edges.append((int(u), int(v), int(k), data, wr))print(f"Reference edges (strict-percolating, wr >= {probe-ref_tol:.2f}): {len(ref_edges)}")# Candidate edges = sub-probe but within subprobe_gap, that the BFS will considercandidate_count =0bridged = []for u, v, k, data in graph.edges(keys=True, data=True): wr =float(data.get("window_radius", 0.0)) gap = probe - wrif gap <=0or gap > subprobe_gap:continueifnot data.get("window_fp_ready"):continue candidate_count +=1 cvec = np.asarray(data["window_fp_vec"])# match against any reference best =Nonefor _, _, _, ref_data, rwr in ref_edges: rvec = np.asarray(ref_data["window_fp_vec"])if rwr - wr > subprobe_gap:continue cos = cosine(cvec, rvec)if cos >= sim_thresh and (best isNoneor cos > best[1]): best = (rwr, cos)if best isnotNone: bridged.append((u, v, k, wr, best[0], best[1]))print(f"Candidate sub-probe edges: {candidate_count}")print(f" Bridged by FP (cos >= {sim_thresh}): {len(bridged)}")print()print(f"{'edge':>14s}{'wr [Å]':>7s}{'gap':>5s}{'ref_wr [Å]':>10s}{'cosine':>7s}")print("-"*56)for u, v, k, wr, rwr, c in bridged[:8]:print(f"({u:>2d},{v:>2d},{k:>2d}) {wr:7.3f}{probe-wr:5.2f}{rwr:10.3f}{c:7.4f}")
Sub-probe gap — probe − wr ≤ window_fp_subprobe_gap (default 0.5 Å). Windows that are much smaller than the probe stay closed regardless of chemistry.
Reference gap — wr_ref − wr_cand ≤ window_fp_subprobe_gap (one-sided). A candidate window must not be much smaller than a reference open mouth either — this is the Mechanism D guard that stops the FP from over-bridging to genuinely smaller annex apertures.
Shell cosine — cosine(cvec, rvec) ≥ window_fp_sim_thresh (default 0.88). The local framework shell must look like an open mouth.
Together they are the entire fingerprint expansion policy.
Step 8: Effect on accessible void volume and surface area
The standard compute_void_volume_from_results and compute_surface_area_mc / compute_surface_area_mesh entry points accept window_fp_for_accessible and an optional winding_kwargs dict. The defaults are window_fp_for_accessible=True, which is the recommended setting for production runs.
On IRMOF-1 at probe = 3.75 Å, window FP roughly doubles the accessible void volume and surface area. The strict reading misses an entire ring of small-cage regions because the smallest windows are just under the probe; the FP reads them as the same aperture (the cosine is essentially 1) and adds them.
This is the expected behaviour for a Mechanism B failure (defined below): the user’s probe and the grid are slightly mis-aligned, and the FP closes the gap on the user’s behalf.
Numerical note. Because we passed winding_kwargsonly when fp=True, the legacy reader is bit-for-bit comparable — the only difference is whether the FP expansion fires. If you want to compare against the lattice / Zeo++-style definition, use accessibility_method="lattice" (the FP is winding-only).
Step 9: Tweak the parameters and watch the policy change
winding_kwargs is the single dict that controls fingerprint behaviour. Every entry has a default; the table in docs/window_fingerprinting.org lists them. Two are worth playing with interactively:
window_fp_subprobe_gap (default 0.5 Å) — how far below the probe a window can sit and still be bridged. Lower it to make the policy stricter; raise it to be more permissive.
window_fp_sim_thresh (default 0.88) — minimum cosine to a reference open mouth. Lower to be more permissive (less chemistry discrimination); raise to require tighter matches.
Show code
probe =3.75print(f"{'subprobe_gap':>14s}{'sim_thresh':>11s}{'regions':>8s}{'VV':>8s}")print("-"*50)for gap in [0.2, 0.5, 0.8]:for sim in [0.80, 0.88, 0.95]: kwargs = {"window_fp_for_accessible": True,"window_fp_subprobe_gap": gap,"window_fp_sim_thresh": sim, } labels = mgr.percolating_region_labels_at_probe_winding(seg, probe, kwargs=kwargs) result = mgr.compute_void_volume_from_results( seg, atoms, probe_radius=probe, window_fp_for_accessible=True, accessibility_method="winding", winding_kwargs=kwargs, )print(f"{gap:14.2f}{sim:11.2f}{len(labels):8d} "f"{result['accessible_void_volume']:8.4f}")
In this sweep on IRMOF-1 the values stay similar because every window fingerprints the same Zn/O/C/H chemistry. The parameters matter much more on materials where windows have different local framework environments (zeolites, MOFs with mixed linkers).
Step 10: Mechanism A / B / C / D failure modes
The fingerprint expansion is a targeted fix. It is useful for some failure modes and useless for others. The four labelled failure modes in the literature are:
Mechanism A — PLD threshold / no percolation seed (FP cannot help)
MGR PLD is just below the requested probe, so no window opens; no percolating mouth exists.
The BFS in _expand_percolating_labels_with_window_fingerprint returns immediately because percolating_labels is empty.
Policy: do not silently widen the probe. The user-set probe radius stays strict. This is a separate PLD / graph-edge calibration problem.
Show code
# Above the largest window in IRMOF-1, strict winding has no percolation at all,# and the FP expansion has nothing to start from.probe_above_pld =5.0strict = percolating_labels(seg, probe_above_pld, fp_on=False)fp = percolating_labels(seg, probe_above_pld, fp_on=True)print(f"probe {probe_above_pld} Å: strict={len(strict)} regions, +FP={len(fp)} regions (Mechanism A: still zero)")
probe 5.0 Å: strict=0 regions, +FP=0 regions (Mechanism A: still zero)
Mechanism B — watershed / graph window gating (FP helps)
A region is reachable only through a window whose window_radius is slightly below the probe (grid undershoot, watershed placement, mask thickness).
The BFS bridges it when the sub-probe gap ≤ window_fp_subprobe_gap and the shell matches an open mouth.
This is the failure mode the FP expansion is designed to fix. Step 8 above demonstrates it on IRMOF-1.
Mechanism C — dead-end annex pockets (FP does not help)
The annex is reached through a window with window_radius ≈ 0.6–0.8 Å and pocket_radius ≈ 2 Å — much below the probe.
The sub-probe gap exceeds window_fp_subprobe_gap (default 0.5 Å), so the BFS rejects the bridge. The annex is correctly excluded at a 1.2 Å probe — a 1.2 Å sphere cannot pass a 0.7 Å throat even if the annex interior is wide.
Mofography counts void only in regions graph-reachable from percolating mouths. Zeo++ uses a geometric accessibility (every voxel with dgrid > probe on a percolating mask) and includes annex void regardless of whether a probe can fit through.
Policy: treat a large Zeo++ excess with good PLD agreement and intact main-path winding as expected conservative bias, not a Mofography bug. The CoRE-2000 screen documents several UDEMEW-like cases.
Mechanism D — FP over-bridge to annex apertures (FP can hurt; the one-sided gate fixes it)
Before the fix, FP could bridge a candidate whose shell cosine was high but whose window_radius was much smaller than the reference open mouth (an annex throat on the same framework shell but at a different aperture size).
Fix: _window_fp_matches_reference_edges uses a one-sidedwr_ref − wr_cand ≤ window_fp_ref_minus_cand_tol gate (default = subprobe_gap = 0.5 Å). It blocks annex bridges with Δwr ≈ 0.7–0.8 Å while preserving Mechanism B grid undershoot (Δwr ≈ 0.4–0.5 Å). See docs/window_fingerprinting.org for the XALDOE case study.
Step 11: When to use window FP
Scenario
Recommendation
Production accessible SA / void volume
Leave window_fp_for_accessible=True (default). The default tuning is calibrated for CoRE-2000 / typical MOFs.
Strict probe-gated comparison vs Zeo++
Pass window_fp_for_accessible=False. Use this when you want to audit Mofography’s graph-reachable definition explicitly.
LIS (largest included sphere)
FP is off by default for LIS. Enable window_fp_for_lis=True only when validating a specific outlier — it is experimental.
A material with very different window chemistries (e.g. mixed-linker MOF)
Consider raising window_fp_sim_thresh (e.g. 0.95) to require tighter matches.
A material with very small framework atoms (zeolites)
Default shell_radius=3.5 Å is calibrated for organic / metal-organic frameworks. On pure siliceous zeolites the shell often contains only Si/O; cosine between two windows of the same ring is essentially 1 and the gate barely fires.
Step 12: What fingerprinting does not change
annotate_graph_edges_with_window_fingerprints does not change where the windows are or how wide they are. It only adds metadata.
Summary
Concept
What it does
Window shell fingerprint
118-element vector of framework atoms within shell_radius (default 3.5 Å) of a window centre, weighted by 1/d, L2-normalized. Direction-invariant.
annotate_graph_edges_with_window_fingerprints
Stamps window_fp_vec and window_fp_ready onto every edge of the canonical pore graph.
BFS expansion
Adds neighbour regions behind sub-probe windows when (a) probe − wr ≤ window_fp_subprobe_gap, (b) wr_ref − wr_cand ≤ window_fp_ref_minus_cand_tol (one-sided), and (c) cosine(fp_cand, fp_ref) ≥ window_fp_sim_thresh.
Effect on accessible SA / VV
Largest impact at probes just above the smallest window_radius in the structure; no impact when the probe is far from the PLD.
Mechanism A
No percolating mouth exists; FP cannot help.
Mechanism B
Sub-probe window with matching shell; FP can help.
Mechanism C
Annex dead-end with much smaller throat; FP deliberately does not help.
Mechanism D
FP would over-bridge to an annex; the one-sided reference gate prevents it.
Where to go next
Connections and Windows — the basic seg['connections'] walkthrough that this page builds on.
Region Segmentation — the segmentation that produces the regions and the maxima.
Pore Graph (RAG) — the region adjacency graph that the windows live on.