2D vs. 3D Challenges in MorphoSource Media Analysis: A High-Level Overview

When working with scientific media on MorphoSource, we face distinct challenges in handling 2D volumetric images versus 3D mesh models. Our automation needs to be smart enough to identify the media type and apply the appropriate interaction patterns. Let’s explore how we tackle these challenges.

Understanding the Difference

2D Volumetric Images

3D Mesh Models

Detecting Media Types

Here’s how we identify whether we’re dealing with 2D or 3D content:

def check_media_types(url):
    driver = None
    try:
        driver = setup_driver()
        driver.get(url)
        
        # First, check for any server issues
        if check_for_server_error(driver):
            status_data = {
                'status': 'server_error',
                'url': url,
                'has_mesh': False,
                'has_volumetric_images': False
            }
            create_status_file(status_data)
            return False

        # Look for media type indicators
        has_mesh = False
        has_volumetric = False
        
        try:
            type_elements = driver.find_elements(By.CLASS_NAME, 
                                               'text-muted-value')
            for element in type_elements:
                text = element.text.lower()
                logging.info(f"Found media type: {text}")
                if 'mesh' in text:
                    has_mesh = True
                if 'volumetric image series' in text.lower():
                    has_volumetric = True
        except Exception as e:
            logging.error(f"Error checking types: {str(e)}")

Key Components of Our Detection System

1. Error Handling

We implement comprehensive error checking:

def check_for_server_error(driver):
    try:
        title = driver.title
        if "MorphoSource temporarily unavailable (500)" in title:
            logging.warning("Detected MorphoSource 500 error page")
            return True
        if "MorphoSource temporarily unavailable (500)" in driver.page_source:
            logging.warning("Detected MorphoSource 500 error in page source")
            return True
        return False
    except Exception as e:
        if "MorphoSource temporarily unavailable (500)" in str(e):
            logging.warning("Detected MorphoSource 500 error in exception")
            return True
        return False

2. Status Tracking

We maintain detailed status information:

def create_status_file(status_data):
    try:
        with open('url_check_status.json', 'w') as f:
            json.dump(status_data, f, indent=2)
        logging.info("Status file saved")
    except Exception as e:
        logging.error(f"Failed to save status file: {str(e)}")

Different Workflows for Different Media Types

2D Workflow Requirements

  1. Slice Navigation
    • Need to locate and control slice viewer
    • Must handle loading states between slices
    • Require timing coordination for image capture
  2. Data Validation
    • Verify slice count
    • Confirm image quality
    • Check navigation controls

3D Workflow Requirements

  1. Orientation Control
    • Multiple view angles
    • Rotation controls
    • Zoom levels
  2. Model Validation
    • Mesh integrity
    • Texture loading
    • View manipulation

Integration with GitHub Actions

We’ve built in CI/CD integration:

github_output = os.getenv('GITHUB_OUTPUT')
if github_output:
    with open(github_output, 'a') as f:
        f.write(f"has_mesh={str(has_mesh).lower()}\n")
        f.write(f"has_volumetric_images={str(has_volumetric).lower()}\n")
        f.write("has_media_error=false\n")
        f.write("has_server_error=false\n")

Logging and Monitoring

We maintain comprehensive logging:

logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(levelname)s - %(message)s',
    handlers=[
        logging.StreamHandler(sys.stdout)
    ]
)

Challenges and Solutions

2D-Specific Challenges

  1. Slice Loading
    • Problem: Inconsistent loading times
    • Solution: Dynamic wait times and load verification
  2. Navigation Control
    • Problem: Complex slider interactions
    • Solution: Robust element location and interaction patterns

3D-Specific Challenges

  1. View Management
    • Problem: Multiple orientation states
    • Solution: Standardized view positions and rotation sequences
  2. Resource Usage
    • Problem: Heavy memory usage for 3D models
    • Solution: Optimized browser settings and resource management

Future Improvements

  1. Intelligent Type Detection
    • Enhanced metadata parsing
    • Automatic workflow selection
    • Predictive loading patterns
  2. Performance Optimization
    • Parallel processing for different media types
    • Cached responses for repeated checks
    • Resource-aware execution

Conclusion

The distinction between 2D and 3D content in MorphoSource requires carefully crafted workflows and robust detection mechanisms. By understanding these differences and implementing appropriate handling strategies, we’ve created a system that can effectively process both types of media while maintaining reliability and performance.

Our URL checking system serves as the foundation for determining the appropriate workflow, ensuring that each media type receives the specific handling it requires. This approach allows us to maintain high-quality automated testing and validation across our diverse media collection.

Conclusion

The evolution of our Selenium testing framework mirrors the broader journey of microservices development. By applying principles of resilience, observability, and maintainability, we’ve created a robust testing solution that supports our growing platform.

As we continue to enhance MorphoSource, these lessons in microservices architecture and test automation will guide our future development, ensuring we maintain high quality and reliability in our service delivery.


Next Post →