@@ -672,19 +672,40 @@ def _decompose_projective_matrix(
672672
673673
674674def _get_filename_prefix (path : Path , dataset_id : str | None ) -> tuple [str , str ]:
675+ """Determine the filename prefix and dataset ID for Visium HD files.
676+
677+ The returned ``filename_prefix`` is used to locate files on disk (e.g., ``{prefix}feature_slice.h5``),
678+ while ``dataset_id`` is used to name elements in the ``SpatialData`` object.
679+
680+ Parameters
681+ ----------
682+ path
683+ Path to the Visium HD output directory.
684+ dataset_id
685+ Optional identifier for naming elements. If ``None``, inferred from prefixed files.
686+
687+ Returns
688+ -------
689+ A tuple of ``(filename_prefix, dataset_id)``.
690+
691+ Raises
692+ ------
693+ RuntimeError
694+ If the feature slice file cannot be located.
695+ """
696+ if (path / VisiumHDKeys .FEATURE_SLICE_FILE .value ).exists ():
697+ return "" , dataset_id if dataset_id is not None else ""
698+
675699 if dataset_id is None :
676- if (path / VisiumHDKeys .FEATURE_SLICE_FILE .value ).exists ():
677- return "" , ""
678700 dataset_id = _infer_dataset_id (path )
679701
680702 if (path / f"{ dataset_id } _{ VisiumHDKeys .FEATURE_SLICE_FILE .value } " ).exists ():
681703 return f"{ dataset_id } _" , dataset_id
682704
683- assert ( path / VisiumHDKeys . FEATURE_SLICE_FILE . value ). exists (), (
684- f"Cannot locate the feature slice file, please ensure the file is present in the { path } directory and/or adjust "
685- "the `dataset_id` parameter"
705+ raise RuntimeError (
706+ f"Cannot locate the feature slice file, please ensure the file is present in the { path } directory and/or "
707+ "adjust the `dataset_id` parameter"
686708 )
687- return "" , ""
688709
689710
690711def _parse_metadata (path : Path , filename_prefix : str ) -> tuple [dict [str , Any ], dict [str , Any ]]:
0 commit comments