loki2.preprocess ================ .. py:module:: loki2.preprocess .. autoapi-nested-parse:: Preprocessing utilities for Loki2. This module provides utilities for loading and preprocessing Loki2 outputs, including .pt embeddings and JSON metadata files. Module Contents --------------- .. py:function:: setup_dummy_modules() -> None Sets up dummy modules for 'loki2' and its submodules. This is required to simulate the module structure that the torch model expects when unpickling objects that reference e.g. 'loki2.data.dataclass.cell_graph'. .. py:function:: load_and_print_tensor(file_path: str) -> Any Load a PyTorch object from a given file path. :param file_path: Path to the .pt file. :returns: The loaded Python object (typically a tensor or model state). :rtype: Any .. py:function:: load_sample(base: str, sample_name: str) -> Tuple[numpy.ndarray, numpy.ndarray, List[Dict[str, Any]]] Load a single sample's embeddings, positions, and JSON cell metadata. Expects: - {sample_name}_cells.pt (with attributes `.x` and `.positions`) - {sample_name}_cells.json (list or dict describing cells) :param base: Root directory containing the .pt and .json files. :param sample_name: Sample identifier (without suffix). :returns: - emb: Embeddings array of shape (N, D) from data.x - pos: Positions array from data.positions - cells: List of per-cell dictionaries :rtype: Tuple[np.ndarray, np.ndarray, List[Dict[str, Any]]] :raises TypeError: If JSON structure is not recognized.