Dna Archive Kymograph
The DnaArchiveKymographBuilder
class creates kymographs directly from DNA molecules stored in a DnaMoleculeArchive
. It provides a streamlined approach to generate kymographs by automatically extracting the DNA region, applying optional filtering and frame reduction, and projecting along the DNA trajectory. This builder combines region extraction, image processing, and kymograph generation into a single, convenient interface.
Constructor
DnaArchiveKymographBuilder(Context context, DnaMoleculeArchive dnaMoleculeArchive)
Creates a new builder for generating kymographs from DNA molecules.
Parameters:
context
: The SciJava context for dependency injectiondnaMoleculeArchive
: The archive containing the DNA molecules and associated image data
Methods
Molecule Configuration
Method | Description |
---|---|
setMolecule(DnaMolecule dnaMolecule) |
Set the DNA molecule to use for kymograph generation. Parameters: dnaMolecule - The DNA molecule objectReturns: This builder for method chaining |
setMolecule(String UID) |
Set the DNA molecule to use by its UID. Parameters: UID - The unique identifier of the DNA moleculeReturns: This builder for method chaining |
Kymograph Configuration
Method | Description |
---|---|
setProjectionWidth(int width) |
Set the width of the projection line for the kymograph. Parameters: width - The projection width in pixels (default: 1)Returns: This builder for method chaining |
setMinT(int minT) |
Set the minimum time point to include in the kymograph. Parameters: minT - The minimum time point (0-based)Returns: This builder for method chaining |
setMaxT(int maxT) |
Set the maximum time point to include in the kymograph. Parameters: maxT - The maximum time point (0-based)Returns: This builder for method chaining |
Frame Reduction Methods
Method | Description |
---|---|
skipFrames(int skipFactor) |
Include only every Nth frame in the kymograph. Parameters: skipFactor - Include every Nth frame (e.g., 5 means include frames 0, 5, 10, etc.)Returns: This builder for method chaining |
averageFrames(int groupSize) |
Average groups of N frames to create each kymograph frame. Parameters: groupSize - Number of frames to average togetherReturns: This builder for method chaining |
sumFrames(int groupSize) |
Sum groups of N frames to create each kymograph frame. Parameters: groupSize - Number of frames to sum togetherReturns: This builder for method chaining |
useAllFrames() |
Reset frame reduction to use all frames without reduction. Returns: This builder for method chaining |
Frame Processing
Method | Description |
---|---|
setVerticalReflection(boolean reflect) |
Enable or disable vertical reflection (flipping) of the frames. Parameters: reflect - True to vertically reflect frames, false for normal orientationReturns: This builder for method chaining |
medianFilter(int radius) |
Apply median filter to all frames before kymograph generation. Parameters: radius - The radius of the median filterReturns: This builder for method chaining |
gaussianFilter(double sigma) |
Apply Gaussian filter to all frames before kymograph generation. Parameters: sigma - The sigma value for the Gaussian filterReturns: This builder for method chaining |
tophatFilter(int radius) |
Apply top-hat filter to all frames before kymograph generation. Parameters: radius - The radius of the top-hat filterReturns: This builder for method chaining |
threads(int numThreads) |
Set the number of threads to use for filtering operations. Parameters: numThreads - The number of threads (minimum: 1)Returns: This builder for method chaining |
interpolation(double factor) |
Enable interpolation to increase resolution before kymograph generation. Parameters: factor - The factor by which to increase resolution (must be > 0)Returns: This builder for method chaining |
Building and Retrieval
Method | Description |
---|---|
build() |
Build the kymograph from the DNA molecule. The process includes: extracting the DNA region, applying frame reduction/filtering/interpolation, creating the projection line, and generating the final kymograph. Returns: A Dataset containing the generated kymograph |
getKymograph() |
Get the built kymograph (same as returned by build() ).Returns: The Dataset containing the kymograph |
Enums
FrameReductionMethod
Defines the available frame reduction strategies:
NONE
: Use all frames without reductionSKIP
: Skip frames (include every Nth frame)AVERAGE
: Average groups of framesSUM
: Sum groups of frames
ImageFilterMethod
Defines the available image filtering options:
NONE
: No filtering appliedMEDIAN
: Median filter for noise reductionGAUSSIAN
: Gaussian filter for smoothingTOPHAT
: Top-hat filter for background subtraction
Example Usage
Basic Kymograph Generation
// Create the builder
DnaArchiveKymographBuilder kymographBuilder =
new DnaArchiveKymographBuilder(context, dnaMoleculeArchive);
// Build a simple kymograph
Dataset kymograph = kymographBuilder
.setMolecule("dnaUID")
.setProjectionWidth(3)
.build();
Advanced Kymograph with Processing
// Create a kymograph with filtering and frame reduction
Dataset kymograph = kymographBuilder
.setMolecule("dnaUID")
.setProjectionWidth(5) // Wider projection for better signal
.setMinT(10) // Start from frame 10
.setMaxT(100) // End at frame 100
.skipFrames(2) // Use every 2nd frame
.gaussianFilter(1.5) // Apply Gaussian smoothing
.interpolation(2.0) // Double the resolution
.setVerticalReflection(true) // Flip vertically
.threads(4) // Use 4 threads for processing
.build();
Implementation Details
Automatic Region Extraction
The builder automatically determines the DNA region by:
- Reading DNA Parameters: Extracts DNA coordinates from molecule parameters (
Dna_Top_X1
,Dna_Top_Y1
,Dna_Bottom_X2
,Dna_Bottom_Y2
) - Adding Borders: Automatically adds 10-pixel borders around the DNA region
- Creating Interval: Constructs an ImgLib2 interval for the
MarsIntervalExporter
Processing Pipeline
The image processing follows this sequence:
- Region Extraction: Extract DNA region using
MarsIntervalExporter
- Frame Reduction: Apply temporal reduction if specified
- Filtering: Apply spatial filtering if specified
- Interpolation: Increase resolution if specified
- Reflection: Apply vertical reflection if specified
- Line Creation: Create projection line from DNA coordinates
- Kymograph Generation: Generate final kymograph using
KymographBuilder
Coordinate Transformation
The builder handles coordinate transformations:
- Global to Local: Converts DNA coordinates from global image space to the extracted region space
- Line Construction: Creates an ImageJ
Line
ROI with transformed coordinates - Projection Setup: Configures the
LinesBuilder
with the correct line width
Error Handling and Type Safety
The implementation includes robust error handling:
- Type Checking: Validates that images contain RealType pixels before processing
- Parameter Validation: Ensures valid values for filter parameters and thread counts
- Graceful Degradation: Returns original image if processing fails
- Generic Safety: Uses proper generic type handling with runtime type checking
Integration with Mars Utilities
The builder leverages MarsKymographUtils
for:
- Frame Reduction:
skipFrames()
,averageFrames()
,sumFrames()
- Image Filtering:
applyMedianFilter()
,applyGaussianFilter()
,applyTopHatFilter()
- Resolution Enhancement:
increaseResolution()
- Image Reflection:
applyVerticalReflection()
Performance Considerations
For optimal performance:
- Threading: Use multiple threads for filtering operations on large datasets
- Frame Reduction: Apply frame reduction early to reduce processing load
- Filter Selection: Choose appropriate filters based on data characteristics
- Memory Management: Consider interpolation factor impact on memory usage
Data Flow
DNA Molecule → Region Extraction → Frame Processing → Line Generation → Kymograph Creation
↓ ↓ ↓ ↓ ↓
Parameters → MarsIntervalExporter → MarsKymographUtils → LinesBuilder → KymographBuilder
Use Cases
The DnaArchiveKymographBuilder
is ideal for:
- Single-molecule DNA analysis: Tracking DNA dynamics over time
- Replication studies: Monitoring DNA replication fork progression
- Protein-DNA interactions: Visualizing protein movement along DNA
- High-throughput analysis: Processing many DNA molecules with consistent parameters
- Quality control: Generating kymographs with standardized processing pipelines
This builder provides a comprehensive solution for DNA kymograph generation, combining the flexibility of the underlying components with the convenience of an integrated workflow specifically designed for DNA molecule analysis.