Skip to content

Conversation

Copy link

Copilot AI commented Aug 7, 2025

This PR adds comprehensive XNAT server support to lavlab-python-utils, following the same service provider architecture as the existing OMERO integration.

Overview

XNAT is a widely used neuroimaging data management platform, and this addition enables seamless integration with XNAT servers alongside our existing OMERO support. The implementation maintains consistency with the established patterns while providing XNAT-specific functionality.

Key Features Added

Core XNAT Module (src/lavlab/xnat/)

  • XNATServiceProvider: Handles authentication and connection management using the xnat library
  • Helper functions: Utilities for common XNAT operations including project/subject/experiment listing, file downloads, and search functionality
  • Logging integration: Consistent logging patterns with existing modules

Configuration & Installation

  • Added xnat as an optional dependency in pyproject.toml
  • Registered XNAT service provider in entry points for dynamic discovery
  • Updated all development environments to include XNAT features
  • Added mypy type checking configuration for XNAT module

Usage Example

import lavlab.xnat
from lavlab.xnat.helpers import get_projects, download_scan_file

# Connect using configuration
session = lavlab.xnat.connect()

# List available projects
projects = get_projects(session)

# Download scan files with automatic cleanup
with download_scan_file(session, exp_id, scan_id, filename) as file_path:
    # Process downloaded file
    pass

Configuration

Users can configure XNAT service in their ~/.lavlab.yml:

histology:
  service:
    name: 'xnat'
    host: 'https://your-xnat-server.org'
    # username/password managed via keyring

Architecture Consistency

The XNAT implementation follows the exact same patterns as OMERO:

  • Service provider inheritance from AbstractServiceProvider
  • Credential management through keyring
  • Entry point registration for dynamic service discovery
  • Consistent error handling and logging
  • Similar helper function organization

Testing & Documentation

  • Comprehensive unit test suite with mocking for offline testing
  • Full documentation in docs/xnat.md with usage examples
  • Example script demonstrating common workflows
  • Updated README with installation instructions

Installation

Users can install XNAT support with:

pip install 'lavlab-python-utils[xnat]'
# or for all features:
pip install 'lavlab-python-utils[all]'

This addition provides a solid foundation for XNAT integration that can be extended with additional specialized modules (similar to OMERO's images, ROIs, tiles modules) as needed in the future.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits August 7, 2025 22:52
Co-authored-by: barrettMCW <103449618+barrettMCW@users.noreply.github.com>
Co-authored-by: barrettMCW <103449618+barrettMCW@users.noreply.github.com>
Copilot AI changed the title [WIP] Add xnatpy support similar to our omero support Add XNAT support similar to existing OMERO integration Aug 7, 2025
Copilot AI requested a review from barrettMCW August 7, 2025 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants