Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions build-and-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mvn install -pl weasis-dicom/weasis-dicom-viewer2d -am -DskipTests -q
cd weasis-distributions && mvn clean package -DskipTests -q
pkill -f "AppLauncher" || true; sleep 1
rm -rf /tmp/weasis-build; mkdir -p /tmp/weasis-build
unzip -o target/native-dist/weasis-native.zip -d /tmp/weasis-build/ > /dev/null
export JAVA_HOME=$(brew --prefix openjdk)/libexec/openjdk.jdk/Contents/Home
cd /tmp/weasis-build/bin-dist/weasis
$JAVA_HOME/bin/java -cp weasis-launcher.jar:felix.jar org.weasis.launcher.AppLauncher >weasis-stdout.log 2>weasis-stderr.log &
166 changes: 166 additions & 0 deletions docs/CURVED_MPR_IMPLEMENTATION_SPEC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# Curved Multi-Planar Reconstruction (cMPR) Feature Specification

## Overview

The Curved Multi-Planar Reconstruction (cMPR) feature enables users to draw a curved path through a 3D medical volume and generate a straightened panoramic view. This is particularly useful for visualizing curved anatomical structures such as blood vessels, airways, or bone surfaces in a single, easy-to-analyze 2D image.

### Key Capabilities

- **Curve Drawing**: Draw arbitrary curves in any MPR plane (axial, coronal, sagittal, or oblique)
- **3D Path Definition**: Automatically converts 2D curve points to 3D volume coordinates
- **Panoramic Generation**: Creates a straightened 2D view by sampling the volume along the curved path
- **Configurable Parameters**: Adjust the width and sampling resolution of the panoramic view
- **Real-time Updates**: Modify parameters and see updated panoramic views immediately
- **Standard Image Tools**: All standard viewing tools (zoom, pan, window/level, measurements) work on the panoramic view

## User Workflow

### Creating a Curved MPR View

1. **Open an MPR View**: Start with any standard MPR view of a 3D volume
2. **Activate Curve Drawing**: Select the curved MPR drawing tool from the toolbar
3. **Draw the Curve**: Click to place points along the desired anatomical path
4. **Complete the Curve**: Double-click or right-click to finish drawing
5. **Generate Panoramic View**: The curved MPR view automatically opens, showing the straightened panoramic view

### Using the Panoramic View

The panoramic view displays the volume data sampled perpendicular to the drawn curve:

- **Horizontal Axis**: Represents distance along the curve path
- **Vertical Axis**: Represents the width perpendicular to the curve
- **Default Width**: 40mm (adjustable)
- **Default Sampling**: Uses the volume's native resolution

### Adjusting Parameters

Users can modify the following parameters:

- **Width**: Controls how far perpendicular to the curve the view extends (e.g., 20mm to 100mm)
- **Sampling Step**: Controls the resolution along the curve (smaller steps = higher resolution)
- Changes to these parameters regenerate the panoramic view in real-time

## Feature Components

### Curve Drawing Tool

A specialized drawing tool that:
- Allows freehand polyline drawing in any 2D MPR plane
- Stores 2D screen coordinates that are converted to 3D volume coordinates
- Provides context menu options for generating the curved MPR view
- Validates that curves have sufficient points (minimum 2)

### Path Definition

The curve defines a 3D path through the volume:
- Points are converted from 2D screen coordinates to 3D voxel coordinates
- The path is stored in volume coordinate space for consistency
- The source plane's orientation is preserved for proper perpendicular sampling

### Panoramic Image Generation

The panoramic view is generated by:

1. **Curve Resampling**: The drawn curve is resampled at uniform intervals along its arc length
2. **Perpendicular Sampling**: At each point along the curve, the volume is sampled perpendicular to the curve direction
3. **Image Construction**: Samples are assembled into a 2D panoramic image
4. **Metadata Assignment**: DICOM metadata is assigned for proper display and measurements

### Sampling Algorithm

The generation process uses the following approach:

- **Arc-Length Parameterization**: Ensures uniform sampling along curved paths
- **Tangent Computation**: Calculates the direction of the curve at each sample point
- **Perpendicular Direction**: Computes a direction perpendicular to both the curve tangent and the original plane normal
- **Volume Interpolation**: Uses trilinear interpolation for smooth sampling
- **Boundary Handling**: Returns background values for samples outside the volume

### Viewer Integration

The curved MPR viewer integrates with the existing viewing system:

- **Standard 2D View**: Uses the same 2D viewer infrastructure as other views
- **Image Tools**: Supports zoom, pan, window/level adjustments
- **Measurements**: Distance and angle measurements can be performed on the panoramic view
- **Layout Options**: Opens in a separate viewer window or panel

## Technical Characteristics

### Coordinate Systems

- **Input Coordinates**: 2D screen coordinates in the source MPR plane
- **Working Coordinates**: 3D voxel coordinates in volume space
- **Output Coordinates**: 2D image coordinates in the panoramic view

### Image Properties

- **Image Type**: Synthetic DICOM-like image
- **Width**: Determined by curve length and sampling step
- **Height**: Determined by the configurable width parameter
- **Pixel Spacing**: Matches the volume's native resolution
- **Intensity Range**: Matches the source volume's intensity range

### Performance Considerations

- **Default Parameters**: Chosen for good performance on typical volumes
- **Resolution Limits**: Width and step parameters can be adjusted to balance quality and speed
- **Caching**: Generated images are cached to avoid unnecessary regeneration
- **Background Sampling**: Out-of-bounds samples are handled efficiently

## Use Cases

### Vessel Analysis

- Visualize curved blood vessels in a single straightened view
- Measure vessel diameter along its length
- Assess stenosis or aneurysms along tortuous paths

### Airway Evaluation

- Examine bronchial tubes or other tubular structures
- Follow airway paths through branching regions
- Assess wall thickness or abnormalities

### Bone Surface Analysis

- Follow curved bone surfaces
- Analyze cortical thickness along curved paths
- Visualize fracture lines or deformities

### General Path Following

- Any scenario where a curved anatomical structure needs to be visualized linearly
- Reduces cognitive load by straightening complex 3D paths
- Facilitates comparison of different regions along the same structure

## Limitations and Constraints

### Curve Requirements

- Minimum 2 points required
- Curves cannot self-intersect (may produce unexpected results)
- Very tight curves may produce distorted panoramic views

### Volume Boundaries

- Sampling outside the volume returns background values
- Curves extending beyond volume edges will have truncated regions
- Best results when curve stays within volume boundaries

### Performance

- Large widths and small sampling steps increase generation time
- Very long curves may produce large panoramic images
- Real-time updates may be delayed on slower systems for complex curves

## Optional Enhancements

Potential future improvements:

- **Spline Smoothing**: Use Catmull-Rom or other spline interpolation for smoother curves
- **Slab Thickness**: Add maximum/minimum/average intensity projection options
- **Live Synchronization**: Update panoramic view when source MPR changes
- **Curve Editing**: Modify existing curves with live preview
- **Multi-threading**: Parallelize image generation for better performance
- **Advanced Measurements**: Enable specialized measurements for curved structures
Loading