diff --git a/PyNutil/io/atlas_loader.py b/PyNutil/io/atlas_loader.py index f4e371e..5c6c98f 100644 --- a/PyNutil/io/atlas_loader.py +++ b/PyNutil/io/atlas_loader.py @@ -88,38 +88,13 @@ def process_atlas_volume(vol): @lru_cache(maxsize=8) def load_custom_atlas(atlas_path, hemi_path, label_path): - """Load a custom atlas from local annotation and label files. - - Parameters - ---------- - atlas_path - Path to the atlas annotation volume, typically an ``.nrrd`` file. - hemi_path - Path to a hemisphere-label volume, or ``None`` if hemisphere-specific - quantification is not available for this atlas. - label_path - Path to a CSV file containing atlas labels and colors. + """ + Loads a custom atlas from provided file paths. Returns ------- AtlasData - Atlas volume, optional hemisphere map, and label table. - - Examples - -------- - Load a custom atlas from local files: - - >>> atlas = load_custom_atlas( - ... atlas_path="path/to/annotation.nrrd", - ... hemi_path=None, - ... label_path="path/to/labels.csv", - ... ) - - Notes - ----- - The loaded atlas is cached by file path, so repeated calls with the same - arguments reuse the previously loaded result within the same Python - process. + Bundle containing atlas volume, hemisphere map, and labels. """ atlas_volume, _ = nrrd.read(atlas_path) diff --git a/PyNutil/io/file_operations.py b/PyNutil/io/file_operations.py index 922975e..ef829dd 100644 --- a/PyNutil/io/file_operations.py +++ b/PyNutil/io/file_operations.py @@ -119,43 +119,15 @@ def save_analysis( colormap="gray", settings_dict=None, ): - """Write PyNutil outputs to disk. - - Parameters - ---------- - output_folder - Directory where reports and export files will be written. - result - Extraction result returned by one of the coordinate extraction - functions. - atlas_labels - Atlas labels to use when writing MeshView outputs. This may be a - labels :class:`pandas.DataFrame`, an :class:`~PyNutil.AtlasData` - instance, or a BrainGlobe atlas object. - label_df - Optional whole-series quantification table, typically returned by - :func:`PyNutil.quantify_coords`. - colormap - Colormap name used when writing intensity-based MeshView exports. - settings_dict - Optional settings dictionary to store as ``pynutil_settings.json`` in - the output folder. - - Notes - ----- - Depending on the supplied data, this function writes whole-series CSV - reports, MeshView JSON point clouds, and a reference settings file. - For quantified segmentation runs, the main table is written to - ``whole_series_report/counts.csv``. For intensity runs, the main table is - written to ``whole_series_report/intensity.csv``. - - Examples - -------- - Save a quantified analysis run: - - >>> label_df = quantify_coords(result, atlas) - >>> save_analysis("path/to/output", result, atlas, label_df=label_df) - >>> # Outputs include whole_series_report/ and whole_series_meshview/ + """Save analysis output to the specified directory. + + Args: + output_folder: Directory to write output files. + result: ExtractionResult from coordinate extraction. + atlas_labels: Atlas labels DataFrame (or AtlasData — ``.labels`` used). + label_df: Whole-series quantification DataFrame. + colormap: Colormap for MeshView intensity output. + settings_dict: Optional dict written to pynutil_settings.json. """ atlas_labels = resolve_atlas_labels(atlas_labels) diff --git a/PyNutil/processing/adapters/registry.py b/PyNutil/processing/adapters/registry.py index 608e078..ba21e63 100644 --- a/PyNutil/processing/adapters/registry.py +++ b/PyNutil/processing/adapters/registry.py @@ -60,44 +60,38 @@ def read_alignment( deformation_provider: Optional[DeformationProvider] = None, damage_provider: Optional[DamageProvider] = None, ) -> RegistrationData: - """Load registration data for downstream PyNutil processing. - - Parameters - ---------- - path - Path to a registration file produced by a supported workflow such as - QuickNII, VisuAlign, or BrainGlobe registration. - loader_name - Explicit loader name to use. If ``None``, PyNutil attempts to detect - the appropriate loader automatically from the file. - apply_deformation - If ``True``, apply non-linear deformation when supported by the input - registration source. Set to ``False`` to keep only the linear - anchoring transform. - apply_damage - If ``True``, load and attach damage masks when available. - deformation_provider - Optional custom deformation provider to use instead of the default - provider selected for the detected registration type. - damage_provider - Optional custom damage provider to use instead of the default QCAlign - integration. - - Returns - ------- - RegistrationData - Registration metadata and per-section transforms used by the - segmentation, intensity, and coordinate pipelines. - - Examples - -------- - Load a standard QUINT alignment file: - - >>> registration = read_alignment("alignment.json") - - Load BrainGlobe registration output in the same way: - - >>> registration = read_alignment("brainglobe-registration.json") + """Load registration data with composable pipeline. + + This is the main entry point for loading registration data. It supports + mixing and matching different components. + + Args: + path: Path to the registration file. + loader_name: Explicit loader name, or None for auto-detection. + apply_deformation: Whether to apply deformation from the file. + Set False to use only linear anchoring. + apply_damage: Whether to apply damage masks from the file. + deformation_provider: Custom deformation provider to use instead of + the default (VisuAlign for QUINT files). + damage_provider: Custom damage provider to use instead of + the default (QCAlign for QUINT files). + + Returns: + RegistrationData with all components applied. + + Examples: + # Standard QUINT workflow + data = read_alignment("alignment.json") + + # Linear only (no VisuAlign deformation) + data = read_alignment("alignment.json", apply_deformation=False) + + # Separate anchoring and damage files + from .damage import QCAlignDamageProvider + data = read_alignment( + "quicknii.json", + damage_provider=QCAlignDamageProvider("qcalign_output.json") + ) """ # 1. Load anchoring if loader_name: