Skip to main content

Neuralyzer::Plots

Neuralyzer::Plots

Namespaces

Name
Neuralyzer::Plots::SelectionInstructions

Classes

Name
struct Neuralyzer::Plots::AxisTickConfig
Configuration for axis tick generation.
struct Neuralyzer::Plots::BinningParams
Parameters for simple histogram binning.
struct Neuralyzer::Plots::GaussianKernelParams
Parameters for Gaussian kernel smoothing (stub — not yet implemented).
struct Neuralyzer::Plots::CausalExponentialParams
Parameters for causal exponential filter (stub — not yet implemented).
struct Neuralyzer::Plots::UnitGatherContext
Bundles a GatherResult with its TimeFrame and source key.
struct Neuralyzer::Plots::RateEstimate
The universal output of any rate estimation method.
struct Neuralyzer::Plots::PerTrialData
Optional per-trial breakdown, for uncertainty and variability analysis.
struct Neuralyzer::Plots::RateEstimateWithTrials
Extended output when per-trial data is requested.
struct Neuralyzer::Plots::NormalizedRow
One row of normalized values (deprecated — use RateEstimate + applyScaling instead).
struct Neuralyzer::Plots::ConfidenceBand
Lower and upper bounds at each time point.
struct Neuralyzer::Plots::PreparedAlignmentWindows
Prepared row metadata for a plot-aligned gather.
struct Neuralyzer::Plots::AlignmentSourceResult
Result of alignment source lookup.
struct Neuralyzer::Plots::EventPlotEventHit
Result of hit-testing an event in a raster plot.
struct Neuralyzer::Plots::ViewAxisSyncSnapshot
Snapshot of view fields that affect axis display.
class Neuralyzer::Plots::PlotZoomProfile
Runtime-gated zoom/paint profiler (singleton).
class Neuralyzer::Plots::PlotZoomProfileWheelScope
RAII scope for wheelEvent synchronous profiling.
class Neuralyzer::Plots::PlotZoomProfilePaintGLScope
RAII scope for paintGL profiling.
class Neuralyzer::Plots::PlotZoomProfileAxisPaintScope
RAII scope for axis paintEvent profiling.
struct Neuralyzer::Plots::PlotTooltipHit
Result of a tooltip hit test.
struct Neuralyzer::Plots::PlotTooltipContent
Content to display in the tooltip.
class Neuralyzer::Plots::PlotTooltipManager
Manages tooltip lifecycle for plot widgets.
struct Neuralyzer::Plots::HeatmapPipelineConfig
Configuration for the heatmap data pipeline.
struct Neuralyzer::Plots::HeatmapPipelineResult
Result of the heatmap data pipeline.

Types

Name
enum class AxisTickMode { Auto, Fixed}
Tick spacing mode for axis widgets.
enum class AxisDisplayMode { Plot, Ruler}
Visual display mode for axis widgets.
enum class ScalingMode { FiringRateHz, ZScore, Normalized01, RawCount, CountPerTrial}
Scaling mode for rate estimate values.
enum class AlignmentPoint { Start, End, Center}
Plot-facing interval alignment point.
enum class std::uint8_t ViewAxisRefresh { None = 0, Horizontal = 1 << 0, Vertical = 1 << 1, Both = Horizontal
using std::variant< BinningParams, GaussianKernelParams, CausalExponentialParams > EstimationParams
Tagged union of all supported rate estimation method parameter structs.
using ScalingMode HeatmapScaling
using std::function< std::optional< PlotTooltipHit >(QPoint screen_pos)> TooltipHitTestFn
Callback that performs a hit test at a screen position.
using std::function< QString(PlotTooltipHit const &hit)> TooltipTextFn
Callback that generates tooltip text from a hit result.
using std::function< PlotTooltipContent(PlotTooltipHit const &hit)> TooltipContentFn
Callback that generates rich tooltip content from a hit result.

Functions

Name
double computeNiceTickInterval(double range, int target_tick_count)
Compute a human-friendly tick interval for a given range.
double computeTickInterval(double range, AxisTickConfig const & config)
Resolve the tick interval from configuration and visible range.
std::vector< double > computeTickPositions(double min, double max, AxisTickConfig const & config)
Generate tick positions covering [min, max] at the configured interval.
bool isMajorTick(double value, double tick_interval)
Determine whether a tick value is a major tick.
bool shouldDrawTick(double value, double tick_interval, bool show_minor_ticks)
Determine whether a tick should be drawn given minor-tick visibility.
std::optional< UnitGatherContext > createUnitGatherContext(std::shared_ptr< DataManager > const & data_manager, std::string const & event_key, PlotAlignmentData const & alignment_data)
Create a UnitGatherContext for a single DigitalEventSeries key.
std::vector< UnitGatherContext > createUnitGatherContexts(std::shared_ptr< DataManager > const & data_manager, std::vector< std::string > const & event_keys, PlotAlignmentData const & alignment_data)
Create UnitGatherContexts for a batch of DigitalEventSeries keys.
RateEstimate estimateRate(GatherResult< DigitalEventSeries > const & gathered, TimeFrame const * time_frame, double window_size, EstimationParams const & params =BinningParams)
Estimate the rate for a single unit (aggregate across trials).
RateEstimateWithTrials estimateRateWithTrials(GatherResult< DigitalEventSeries > const & gathered, TimeFrame const * time_frame, double window_size, EstimationParams const & params =BinningParams)
Estimate rate with per-trial breakdown for a single unit.
std::vector< RateEstimate > estimateRates(std::vector< UnitGatherContext > const & units, double window_size, EstimationParams const & params =BinningParams)
Estimate rates for multiple units.
char const * scalingLabel(ScalingMode mode)
Return a human-readable label for a ScalingMode value.
char const * scalingAxisLabel(ScalingMode mode)
Return the axis label appropriate for a scaling mode.
std::vector< ScalingMode > allScalingModes()
All available scaling modes (for populating combo boxes).
void toFiringRateHz(std::span< double > values, size_t num_trials, double sample_spacing, double time_units_per_second)
Convert raw counts to firing rate (Hz).
void toCountPerTrial(std::span< double > values, size_t num_trials)
Convert raw counts to count-per-trial.
void zScoreNormalize(std::span< double > values)
Apply per-unit z-score normalization.
void minMaxNormalize(std::span< double > values)
Apply per-unit min-max normalization to [0, 1].
void applyScaling(RateEstimate & estimate, ScalingMode mode, double time_units_per_second)
Apply a named scaling to a RateEstimate in-place.
void applyScaling(RateEstimateWithTrials & data, ScalingMode mode, double time_units_per_second)
Apply scaling consistently to aggregate + all per-trial curves.
ConfidenceBand computeSEM(RateEstimateWithTrials const & data, double k =1.0)
Compute SEM-based confidence band as mean ± k × SEM.
ConfidenceBand computePercentileCI(RateEstimateWithTrials const & data, double lower_pct =2.5, double upper_pct =97.5)
Compute percentile-based confidence band.
ConfidenceBand bootstrapCI(RateEstimateWithTrials const & data, size_t n_resamples =1000, double ci_level =0.95)
Bootstrap confidence band (resamples trials).
CorePlotting::Interaction::GlyphPreview buildLineSelectionPreview(QPoint const & start_screen, QPoint const & end_screen, bool remove_mode)
Build a line-selection GlyphPreview for the selection rubber-band.
std::vector< CorePlotting::LineBatchIndex > runLineSelectionIntersection(CorePlotting::ILineBatchIntersector & intersector, CorePlotting::LineBatchData const & cpu_data, glm::vec2 start_ndc, glm::vec2 end_ndc, glm::mat4 const & projection_matrix, glm::mat4 const & view_matrix)
Run line-vs-batch intersection and return hit line indices.
template <typename T >
GatherResult< T >
gatherWithEventAlignment(std::shared_ptr< T > source, std::shared_ptr< DigitalEventSeries > alignment_events, double pre_window, double post_window)
template <typename T >
GatherResult< T >
gatherWithIntervalAlignment(std::shared_ptr< T > source, std::shared_ptr< DigitalIntervalSeries > alignment_intervals, AlignmentPoint align =AlignmentPoint::Start)
template <typename T >
GatherResult< T >
gatherWithIntervalAlignment(std::shared_ptr< T > source, std::shared_ptr< DigitalIntervalSeries > alignment_intervals, AlignmentPoint align, double pre_window, double post_window)
Gather data aligned to a DigitalIntervalSeries with explicit window.
template <typename T >
GatherResult< T >
createAlignedGatherResult(std::shared_ptr< DataManager > const & data_manager, std::string const & source_key, PlotAlignmentData const & alignment_data)
template <typename T >
GatherResult< T >
createAlignedGatherResult(std::shared_ptr< DataManager > const & data_manager, std::string const & source_key, PlotAlignmentState const * alignment_state)
Overload using PlotAlignmentState pointer.
AlignmentPoint toAlignmentPoint(IntervalAlignmentType type)
Convert IntervalAlignmentType to the plot-facing AlignmentPoint enum.
Neuralyzer::Transforms::V2::Examples::IntervalEventPoint toIntervalEventPoint(AlignmentPoint point)
Convert a plot alignment point to the TransformsV2 interval-to-event enum.
AlignmentSourceResult getAlignmentSource(std::shared_ptr< DataManager > const & data_manager, std::string const & alignment_key)
Look up an alignment source from DataManager.
std::vector< ClockTicks > extractAlignmentTimes(DigitalEventSeries const & events)
Extract absolute alignment times from a DigitalEventSeries.
std::vector< ClockTicks > extractAlignmentTimes(DigitalIntervalSeries const & intervals, AlignmentPoint align)
Extract absolute alignment times from a DigitalIntervalSeries.
std::vector< size_t > pruneOverlappingAlignmentTimes(std::vector< ClockTicks > const & alignment_times, int64_t pre_window, int64_t post_window)
Prune alignment times whose expanded windows would overlap.
std::shared_ptr< DigitalEventSeries > createFilteredEventSeries(std::shared_ptr< DigitalEventSeries const > const & source, std::vector< size_t > const & kept_indices)
Create a filtered copy of a DigitalEventSeries.
std::shared_ptr< DigitalIntervalSeries > createFilteredIntervalSeries(std::shared_ptr< DigitalIntervalSeries const > const & source, std::vector< size_t > const & kept_indices)
Create a filtered copy of a DigitalIntervalSeries.
TimeFrameInterval physicalWindowToInterval(ClockTicks alignment_time, int64_t pre_window, int64_t post_window, std::shared_ptr< TimeFrame > const & target_time_frame)
Convert an absolute-time window to interval indices in a target TimeFrame.
std::shared_ptr< DigitalIntervalSeries > createWindowsAroundEvents(std::shared_ptr< DigitalEventSeries const > const & alignment_events, int64_t pre_window, int64_t post_window, std::shared_ptr< TimeFrame > const & window_time_frame)
Build overlapping window intervals around alignment events.
std::vector< size_t > keptWindowIndices(DigitalIntervalSeries const & windows)
Compute kept row indices for greedy overlap pruning of interval bounds.
PreparedAlignmentWindows prunePreparedAlignmentWindows(std::shared_ptr< DigitalIntervalSeries const > const & windows, std::shared_ptr< DigitalEventSeries const > const & alignment_points)
Prune windows and companion alignment points together.
PreparedAlignmentWindows prepareEventAlignmentWindows(std::shared_ptr< DigitalEventSeries const > const & alignment_events, int64_t pre_window, int64_t post_window, std::shared_ptr< TimeFrame > const & window_time_frame, bool prevent_overlap =false)
Prepare event-aligned gather windows.
PreparedAlignmentWindows prepareIntervalAlignmentWindows(std::shared_ptr< DigitalIntervalSeries const > const & alignment_intervals, AlignmentPoint align =AlignmentPoint::Start)
Prepare interval-aligned gather windows that use the full interval bounds.
PreparedAlignmentWindows prepareIntervalAlignmentWindows(std::shared_ptr< DigitalIntervalSeries const > const & alignment_intervals, AlignmentPoint align, int64_t pre_window, int64_t post_window, std::shared_ptr< TimeFrame > const & window_time_frame, bool prevent_overlap =false)
Prepare interval-aligned gather windows around selected interval points.
AlignmentSourceResult getFilteredAlignmentSource(std::shared_ptr< DataManager > const & data_manager, PlotAlignmentData const & alignment_data)
Look up alignment source with optional overlap pruning.
size_t countNonOverlappingAlignmentEvents(std::shared_ptr< DataManager > const & data_manager, PlotAlignmentData const & alignment_data)
Compute the number of alignment rows that survive overlap pruning.
PreparedAlignmentWindows prepareAlignmentWindows(std::shared_ptr< DataManager > const & data_manager, PlotAlignmentData const & alignment_data, std::shared_ptr< TimeFrame > const & window_time_frame)
Prepare windows from DataManager and PlotAlignmentData.
int trialIndexFromWorldY(float world_y, std::size_t num_trials)
Derive trial index from world-space Y coordinate.
float rowWorldYCenter(int row_index, std::size_t num_trials, float viewport_y_min =-1.0f, float viewport_y_max =1.0f)
Compute world Y center for a raster row using RowLayoutStrategy geometry.
int64_t absoluteTimeFromHit(int64_t alignment_time, float relative_time_ms)
Convert a hit event’s relative time and trial alignment to absolute time.
glm::vec2 screenToNDC(QPoint const & screen_pos, int widget_width, int widget_height)
Convert screen pixel coordinates to normalized device coordinates (NDC).
QPointF screenToWorld(glm::mat4 const & projection_matrix, int widget_width, int widget_height, QPoint const & screen_pos)
Convert screen pixel coordinates to world coordinates.
QPoint worldToScreen(glm::mat4 const & projection_matrix, int widget_width, int widget_height, float world_x, float world_y)
Convert world coordinates to screen pixel coordinates.
template <ViewStateLike ViewState>
glm::mat4
computeOrthoProjection(ViewState const & view_state, float x_range, float x_center, float y_range, float y_center)
Compute an orthographic projection matrix from zoom/pan view state.
template <ViewStateWithBounds ViewState>
glm::mat4
computeOrthoProjection(ViewState const & view_state)
Compute orthographic projection from view state with bounds.
template <ZoomPanSettable State,ViewStateLike ViewState>
void
handlePanning(State & state, ViewState const & view_state, int delta_x, int delta_y, float x_range, float y_range, int widget_width, int widget_height)
Apply a pixel-space drag delta as a pan update to the state.
template <ZoomPanSettable State,ViewStateWithBounds ViewState>
void
handlePanning(State & state, ViewState const & view_state, int delta_x, int delta_y, int widget_width, int widget_height)
Apply pan from view state with bounds (derives x_range/y_range).
float wheelDeltaToZoomSteps(int pixel_delta_y, int angle_delta_y, int angle_delta_x, float pixels_per_zoom_step =DEFAULT_WHEEL_PIXELS_PER_ZOOM_STEP)
Convert raw wheel deltas to fractional zoom steps for handleZoom().
double adaptiveZoomMultiplier(double delta)
Compute the zoom multiplier for adaptive range-proportional wheel zoom.
template <ZoomPanSettable State,ViewStateLike ViewState>
void
handleZoom(State & state, ViewState const & view_state, float delta, bool y_only, bool both_axes)
Apply a scroll-wheel zoom step to the state.
bool affectsAxis(ViewAxisRefresh mask, ViewAxisRefresh axis)
Test whether mask includes axis.
template <ViewStateZoomPanLike ViewState>
ViewAxisSyncSnapshot
makeViewAxisSyncSnapshot(ViewState const & view_state)
Capture zoom/pan fields from a view state.
template <ViewStateZoomPanLike ViewState>
ViewAxisSyncSnapshot
makeViewAxisSyncSnapshot(ViewState const & view_state)
Capture zoom/pan and data bounds from a view state.
ViewAxisRefresh computeViewAxisRefreshMask(ViewAxisSyncSnapshot const & before, ViewAxisSyncSnapshot const & after)
Determine which axes need refresh between two snapshots.
std::shared_ptr< DigitalEventSeries > extractEdgeEvents(std::shared_ptr< DigitalIntervalSeries const > intervals, IntervalAlignmentType edge)
Extract edge events from a DigitalIntervalSeries.
HeatmapPipelineResult runHeatmapPipeline(std::shared_ptr< DataManager > const & data_manager, std::vector< std::string > const & unit_keys, PlotAlignmentData const & alignment_data, HeatmapPipelineConfig const & config)
Execute the heatmap data pipeline without an OpenGL context.
std::vector< std::size_t > computeSortOrder(HeatmapPipelineResult const & result, std::vector< std::string > const & unit_keys, HeatmapSortMode sort_mode, bool ascending)
Compute a permutation vector that sorts the pipeline rows.
void applySortOrder(HeatmapPipelineResult & result, std::vector< std::string > & unit_keys, std::vector< std::size_t > const & sort_indices)
Apply a precomputed permutation to the pipeline result and unit keys.

Attributes

Name
float DEFAULT_WHEEL_PIXELS_PER_ZOOM_STEP
Pixels of vertical trackpad movement equivalent to one mouse-wheel notch.
float WHEEL_ANGLE_DELTA_PER_NOTCH
Qt angleDelta units per physical wheel notch (8 degrees x 15).
double ADAPTIVE_ZOOM_RANGE_FRACTION
Visible-range fraction removed per zoom step (matches DataViewer adaptive normal mode).
double MIN_ADAPTIVE_VISIBLE_RANGE_SCALE
Minimum visible-range scale factor in a single wheel event (prevents runaway zoom).

Types Documentation

enum AxisTickMode

Enumerator Value Description
Auto Nice-number intervals based on visible range.
Fixed Fixed interval in coordinate units.

Tick spacing mode for axis widgets.

enum AxisDisplayMode

Enumerator Value Description
Plot Standard plot axis with extent labels.
Ruler Slim Inkscape-style ruler without extent labels.

Visual display mode for axis widgets.

enum ScalingMode

Enumerator Value Description
FiringRateHz count / (sample_spacing_s × num_trials) → spikes/s
ZScore Per-unit z-score: (rate - mean) / std across all time points.
Normalized01 Per-unit min-max normalization to [0, 1].
RawCount Raw event count (no normalization).
CountPerTrial count / num_trials

Scaling mode for rate estimate values.

Controls how raw event counts are transformed. Shared between HeatmapWidget, PSTHWidget, and any future rate-based plot widgets. Applied per-unit (per-row for heatmaps) after rate estimation.

enum AlignmentPoint

Enumerator Value Description
Start Use interval.start as alignment time.
End Use interval.end as alignment time.
Center Use (interval.start + interval.end) / 2 as alignment time.

Plot-facing interval alignment point.

This mirrors the UI choices without depending on GatherResult interval adapters.

enum ViewAxisRefresh

Enumerator Value Description
None 0
Horizontal 1 << 0
Vertical 1 << 1
Both Horizontal | Vertical

Which plot axes need refresh after a view-state change.

using EstimationParams

using Neuralyzer::Plots::EstimationParams =  std::variant<BinningParams, GaussianKernelParams, CausalExponentialParams>;

Tagged union of all supported rate estimation method parameter structs.

Note: GaussianKernelParams and CausalExponentialParams are included in the variant but their implementations return empty RateEstimate (stub).

This is the single variation point for estimation method selection. Selecting a method at runtime is zero-overhead compared to a virtual base-class strategy — std::visit dispatches via a jump table.

To add a new method:

  1. Define a new *Params struct above
  2. Append it to this alias
  3. Add the implementation in [EventRateEstimation.cpp](/api_generated/Files/EventRateEstimation_8cpp.md#file-eventrateestimation.cpp)

using HeatmapScaling

using Neuralyzer::Plots::HeatmapScaling =  ScalingMode;

Deprecated:

Use [ScalingMode](/api_generated/Namespaces/namespaceNeuralyzer_1_1Plots.md#enum-scalingmode) instead

using TooltipHitTestFn

using Neuralyzer::Plots::TooltipHitTestFn = 
        std::function<std::optional<PlotTooltipHit>(QPoint screen_pos)>;

Callback that performs a hit test at a screen position.

Returns a PlotTooltipHit on success, or std::nullopt if nothing is under the cursor. This callback may perform spatial queries (QuadTree, etc.) and is only called after the dwell timer fires.

using TooltipTextFn

using Neuralyzer::Plots::TooltipTextFn = 
        std::function<QString(PlotTooltipHit const & hit)>;

Callback that generates tooltip text from a hit result.

using TooltipContentFn

using Neuralyzer::Plots::TooltipContentFn = 
        std::function<PlotTooltipContent(PlotTooltipHit const & hit)>;

Callback that generates rich tooltip content from a hit result.

Use this for expensive content generation (rendering glyphs, mini-plots). Returns a full PlotTooltipContent, allowing the provider to choose between text and pixmap on a per-hit basis.

Functions Documentation

function computeNiceTickInterval

inline double computeNiceTickInterval(
    double range,
    int target_tick_count
)

Compute a human-friendly tick interval for a given range.

Parameters:

  • range Total axis range (max - min)
  • target_tick_count Desired approximate number of tick intervals

Return: Tick interval rounded to 1, 2, 5, or 10 × 10^n

Precondition:

  • range > 0
  • target_tick_count > 0

function computeTickInterval

inline double computeTickInterval(
    double range,
    AxisTickConfig const & config
)

Resolve the tick interval from configuration and visible range.

Parameters:

  • range Total axis range (max - min)
  • config Tick configuration

Return: Tick interval in coordinate units

Precondition: range > 0

function computeTickPositions

inline std::vector< double > computeTickPositions(
    double min,
    double max,
    AxisTickConfig const & config
)

Generate tick positions covering [min, max] at the configured interval.

Parameters:

  • min Minimum visible coordinate
  • max Maximum visible coordinate
  • config Tick configuration

Return: Sorted tick positions in ascending order

Precondition: max > min

function isMajorTick

inline bool isMajorTick(
    double value,
    double tick_interval
)

Determine whether a tick value is a major tick.

Parameters:

  • value Tick coordinate value
  • tick_interval Spacing between ticks

Return: true if the tick should be drawn as major (including zero)

function shouldDrawTick

inline bool shouldDrawTick(
    double value,
    double tick_interval,
    bool show_minor_ticks
)

Determine whether a tick should be drawn given minor-tick visibility.

Parameters:

  • value Tick coordinate value
  • tick_interval Spacing between ticks
  • show_minor_ticks Whether minor ticks are enabled

Return: true if the tick should be painted

function createUnitGatherContext

std::optional< UnitGatherContext > createUnitGatherContext(
    std::shared_ptr< DataManager > const & data_manager,
    std::string const & event_key,
    PlotAlignmentData const & alignment_data
)

Create a UnitGatherContext for a single DigitalEventSeries key.

Parameters:

  • data_manager DataManager containing the event and alignment series
  • event_key DataManager key of the [DigitalEventSeries](/api_generated/Classes/classDigitalEventSeries.md) to gather
  • alignment_data Alignment configuration (alignment key, window size, etc.)

Return: Populated [UnitGatherContext](/api_generated/Classes/structNeuralyzer_1_1Plots_1_1UnitGatherContext.md), or std::nullopt on failure

Calls [createAlignedGatherResult](/api_generated/Namespaces/namespaceNeuralyzer_1_1Plots.md#function-createalignedgatherresult)<[DigitalEventSeries](/api_generated/Classes/classDigitalEventSeries.md)> and also retrieves the source [TimeFrame](/api_generated/Classes/classTimeFrame.md). Returns std::nullopt when:

  • data_manager is null or event_key is empty
  • The gather result is empty (alignment key not found or no events in window)
  • The source series does not have a [TimeFrame](/api_generated/Classes/classTimeFrame.md)

function createUnitGatherContexts

std::vector< UnitGatherContext > createUnitGatherContexts(
    std::shared_ptr< DataManager > const & data_manager,
    std::vector< std::string > const & event_keys,
    PlotAlignmentData const & alignment_data
)

Create UnitGatherContexts for a batch of DigitalEventSeries keys.

Parameters:

  • data_manager DataManager containing the event and alignment series
  • event_keys DataManager keys of the [DigitalEventSeries](/api_generated/Classes/classDigitalEventSeries.md) to gather
  • alignment_data Alignment configuration shared across all units

Return: Vector of successfully gathered [UnitGatherContext](/api_generated/Classes/structNeuralyzer_1_1Plots_1_1UnitGatherContext.md) objects

Applies [createUnitGatherContext](/api_generated/Namespaces/namespaceNeuralyzer_1_1Plots.md#function-createunitgathercontext) to each key in event_keys with the same alignment settings. Keys for which gathering fails are silently skipped; the returned vector may therefore be shorter than event_keys.

Order is preserved: the i-th element of the result corresponds to the i-th key that succeeded.

function estimateRate

RateEstimate estimateRate(
    GatherResult< DigitalEventSeries > const & gathered,
    TimeFrame const * time_frame,
    double window_size,
    EstimationParams const & params =BinningParams{}
)

Estimate the rate for a single unit (aggregate across trials).

Parameters:

  • gathered Trial-aligned views of one [DigitalEventSeries](/api_generated/Classes/classDigitalEventSeries.md)
  • time_frame TimeFrame of the source series (may be null)
  • window_size Total window span in time units (bins cover ±window_size/2)
  • params Estimation method and parameters (default: [BinningParams](/api_generated/Classes/structNeuralyzer_1_1Plots_1_1BinningParams.md){})

Return: [RateEstimate](/api_generated/Classes/structNeuralyzer_1_1Plots_1_1RateEstimate.md) with times, values, num_trials, and metadata

Returns a [RateEstimate](/api_generated/Classes/structNeuralyzer_1_1Plots_1_1RateEstimate.md) with paired times[] (bin centers for binning) and values[] (raw event counts summed across all trials).

Uses time_frame to convert each event’s [TimeFrameIndex](/api_generated/Classes/structTimeFrameIndex.md) to an absolute time before computing the relative time with respect to the per-trial alignment time from gathered.

If time_frame is null, [TimeFrameIndex::getValue()](/api_generated/Classes/structTimeFrameIndex.md#function-getvalue) is used directly as the absolute time (identity mapping).

function estimateRateWithTrials

RateEstimateWithTrials estimateRateWithTrials(
    GatherResult< DigitalEventSeries > const & gathered,
    TimeFrame const * time_frame,
    double window_size,
    EstimationParams const & params =BinningParams{}
)

Estimate rate with per-trial breakdown for a single unit.

Parameters:

  • gathered Trial-aligned views of one [DigitalEventSeries](/api_generated/Classes/classDigitalEventSeries.md)
  • time_frame TimeFrame of the source series (may be null)
  • window_size Total window span in time units
  • params Estimation method and parameters (default: [BinningParams](/api_generated/Classes/structNeuralyzer_1_1Plots_1_1BinningParams.md){})

Return: [RateEstimateWithTrials](/api_generated/Classes/structNeuralyzer_1_1Plots_1_1RateEstimateWithTrials.md) with aggregate + per-trial data

Same as [estimateRate()](/api_generated/Namespaces/namespaceNeuralyzer_1_1Plots.md#function-estimaterate) but additionally returns per-trial rate curves in [RateEstimateWithTrials::trials](/api_generated/Classes/structNeuralyzer_1_1Plots_1_1RateEstimateWithTrials.md#variable-trials). The aggregate estimate is the trial-summed result (same as [estimateRate()](/api_generated/Namespaces/namespaceNeuralyzer_1_1Plots.md#function-estimaterate)), and each trial’s individual histogram is stored separately.

Use this when you need uncertainty quantification (SEM, CI, bootstrap) via the functions in [RateUncertainty.hpp](/api_generated/Files/RateUncertainty_8hpp.md#file-rateuncertainty.hpp).

function estimateRates

std::vector< RateEstimate > estimateRates(
    std::vector< UnitGatherContext > const & units,
    double window_size,
    EstimationParams const & params =BinningParams{}
)

Estimate rates for multiple units.

Parameters:

  • units Per-unit gather contexts (from [createUnitGatherContexts](/api_generated/Namespaces/namespaceNeuralyzer_1_1Plots.md#function-createunitgathercontexts))
  • window_size Total window span in time units
  • params Estimation method and parameters (default: [BinningParams](/api_generated/Classes/structNeuralyzer_1_1Plots_1_1BinningParams.md){})

Return: One [RateEstimate](/api_generated/Classes/structNeuralyzer_1_1Plots_1_1RateEstimate.md) per unit, in input order

Applies [estimateRate](/api_generated/Namespaces/namespaceNeuralyzer_1_1Plots.md#function-estimaterate) independently to each [UnitGatherContext](/api_generated/Classes/structNeuralyzer_1_1Plots_1_1UnitGatherContext.md) in units. All units share the same window_size and params. The output vector is in the same order as the input and has the same length.

This is the primary entry point for [HeatmapWidget](/api_generated/Classes/classHeatmapWidget.md), which needs a units × time_bins rate matrix.

function scalingLabel

char const * scalingLabel(
    ScalingMode mode
)

Return a human-readable label for a ScalingMode value.

function scalingAxisLabel

char const * scalingAxisLabel(
    ScalingMode mode
)

Return the axis label appropriate for a scaling mode.

function allScalingModes

inline std::vector< ScalingMode > allScalingModes()

All available scaling modes (for populating combo boxes).

function toFiringRateHz

void toFiringRateHz(
    std::span< double > values,
    size_t num_trials,
    double sample_spacing,
    double time_units_per_second
)

Convert raw counts to firing rate (Hz).

Parameters:

  • values Value vector to modify in-place
  • num_trials Number of trials
  • sample_spacing Spacing between evaluation points (in data time units)
  • time_units_per_second Conversion factor (e.g. 1000.0 for milliseconds)

Formula: values[i] /= (num_trials × sample_spacing_s) where sample_spacing_s = sample_spacing / time_units_per_second

function toCountPerTrial

void toCountPerTrial(
    std::span< double > values,
    size_t num_trials
)

Convert raw counts to count-per-trial.

Parameters:

  • values Value vector to modify in-place
  • num_trials Number of trials (no-op if 0)

Formula: values[i] /= num_trials

function zScoreNormalize

void zScoreNormalize(
    std::span< double > values
)

Apply per-unit z-score normalization.

Parameters:

  • values Value vector to modify in-place

Formula: values[i] = (values[i] - mean) / std If std is zero (constant signal), all values become 0.

function minMaxNormalize

void minMaxNormalize(
    std::span< double > values
)

Apply per-unit min-max normalization to [0, 1].

Parameters:

  • values Value vector to modify in-place

If all values are equal, all become 0.

function applyScaling

void applyScaling(
    RateEstimate & estimate,
    ScalingMode mode,
    double time_units_per_second
)

Apply a named scaling to a RateEstimate in-place.

Parameters:

  • estimate RateEstimate to modify in-place
  • mode Scaling mode to apply
  • time_units_per_second Conversion factor (e.g. 1000.0 for ms)

Dispatches to the appropriate normalization primitive based on mode. Reads estimate.metadata.sample_spacing and estimate.num_trials automatically.

ScalingMode Transform
FiringRateHz count / (sample_spacing_s × num_trials)
CountPerTrial count / num_trials
RawCount no transform
Normalized01 per-unit (v - min) / (max - min)
ZScore per-unit (v - mean) / std (after count/trial)

function applyScaling

void applyScaling(
    RateEstimateWithTrials & data,
    ScalingMode mode,
    double time_units_per_second
)

Apply scaling consistently to aggregate + all per-trial curves.

Parameters:

  • data RateEstimateWithTrials to modify in-place
  • mode Scaling mode to apply
  • time_units_per_second Conversion factor (e.g. 1000.0 for ms)

For z-score: uses the aggregate mean/std to normalize all trials, ensuring CI bounds computed afterward are in the same z-score space as the mean.

function computeSEM

ConfidenceBand computeSEM(
    RateEstimateWithTrials const & data,
    double k =1.0
)

Compute SEM-based confidence band as mean ± k × SEM.

Parameters:

  • data RateEstimateWithTrials (must have per-trial data)
  • k Multiplier for SEM (1.0 for ±1 SEM, 1.96 for 95% CI)

Return: ConfidenceBand with lower and upper bounds

Note: Stub — returns empty bands. Implementation deferred to PSTH Phase 3.

function computePercentileCI

ConfidenceBand computePercentileCI(
    RateEstimateWithTrials const & data,
    double lower_pct =2.5,
    double upper_pct =97.5
)

Compute percentile-based confidence band.

Parameters:

  • data RateEstimateWithTrials (must have per-trial data)
  • lower_pct Lower percentile (e.g. 2.5 for 95% CI)
  • upper_pct Upper percentile (e.g. 97.5 for 95% CI)

Return: ConfidenceBand with lower and upper bounds

Note: Stub — returns empty bands. Implementation deferred to PSTH Phase 3.

function bootstrapCI

ConfidenceBand bootstrapCI(
    RateEstimateWithTrials const & data,
    size_t n_resamples =1000,
    double ci_level =0.95
)

Bootstrap confidence band (resamples trials).

Parameters:

  • data RateEstimateWithTrials (must have per-trial data)
  • n_resamples Number of bootstrap resamples
  • ci_level Confidence level (e.g. 0.95 for 95% CI)

Return: ConfidenceBand with lower and upper bounds

Note: Stub — returns empty bands. Implementation deferred to PSTH Phase 3.

function buildLineSelectionPreview

inline CorePlotting::Interaction::GlyphPreview buildLineSelectionPreview(
    QPoint const & start_screen,
    QPoint const & end_screen,
    bool remove_mode
)

Build a line-selection GlyphPreview for the selection rubber-band.

Parameters:

  • start_screen Selection line start in widget pixel coordinates.
  • end_screen Selection line end in widget pixel coordinates.
  • remove_mode If true, use red stroke; otherwise white.

Return: GlyphPreview with Type::Line and stroke styling.

PreviewRenderer expects canvas pixel coordinates (top-left origin). White stroke for normal selection, red for remove mode.

function runLineSelectionIntersection

inline std::vector< CorePlotting::LineBatchIndex > runLineSelectionIntersection(
    CorePlotting::ILineBatchIntersector & intersector,
    CorePlotting::LineBatchData const & cpu_data,
    glm::vec2 start_ndc,
    glm::vec2 end_ndc,
    glm::mat4 const & projection_matrix,
    glm::mat4 const & view_matrix
)

Run line-vs-batch intersection and return hit line indices.

Parameters:

  • intersector The intersector (CPU or GPU backend).
  • cpu_data Current line batch CPU data from the store.
  • start_ndc Selection line start in NDC [-1, 1].
  • end_ndc Selection line end in NDC [-1, 1].
  • projection_matrix Current orthographic projection matrix.
  • view_matrix Current view matrix (typically identity).

Return: Indices of lines that intersect the selection segment (0-based into cpu_data.lines). Empty if no intersector or batch empty.

Builds a LineIntersectionQuery from the selection segment (NDC) and current projection/view matrices, then calls the intersector. The caller applies the result to its own selection state (e.g. trial indices or entity IDs).

function gatherWithEventAlignment

template <typename T >
GatherResult< T > gatherWithEventAlignment(
    std::shared_ptr< T > source,
    std::shared_ptr< DigitalEventSeries > alignment_events,
    double pre_window,
    double post_window
)

function gatherWithIntervalAlignment

template <typename T >
GatherResult< T > gatherWithIntervalAlignment(
    std::shared_ptr< T > source,
    std::shared_ptr< DigitalIntervalSeries > alignment_intervals,
    AlignmentPoint align =AlignmentPoint::Start
)

function gatherWithIntervalAlignment

template <typename T >
GatherResult< T > gatherWithIntervalAlignment(
    std::shared_ptr< T > source,
    std::shared_ptr< DigitalIntervalSeries > alignment_intervals,
    AlignmentPoint align,
    double pre_window,
    double post_window
)

Gather data aligned to a DigitalIntervalSeries with explicit window.

Parameters:

  • source Source data to create views from
  • alignment_intervals Intervals defining alignment points
  • align Which point in each interval to use for alignment
  • pre_window Absolute time units before alignment to include
  • post_window Absolute time units after alignment to include

Template Parameters:

Return: GatherResult with one view per interval

Uses the specified alignment point (Start/End/Center) of each interval, but creates a view window of [alignment - pre_window, alignment + post_window] in absolute time units rather than using the raw interval bounds.

This is essential for raster plots where the user specifies a display window that extends beyond the interval boundaries.

function createAlignedGatherResult

template <typename T >
GatherResult< T > createAlignedGatherResult(
    std::shared_ptr< DataManager > const & data_manager,
    std::string const & source_key,
    PlotAlignmentData const & alignment_data
)

function createAlignedGatherResult

template <typename T >
GatherResult< T > createAlignedGatherResult(
    std::shared_ptr< DataManager > const & data_manager,
    std::string const & source_key,
    PlotAlignmentState const * alignment_state
)

Overload using PlotAlignmentState pointer.

Convenience overload that extracts data() from the state object.

function toAlignmentPoint

inline AlignmentPoint toAlignmentPoint(
    IntervalAlignmentType type
)

Convert IntervalAlignmentType to the plot-facing AlignmentPoint enum.

Parameters:

  • type UI alignment type.

Return: Corresponding plot alignment point.

Postcondition: End maps to AlignmentPoint::End; all other current values map to Start.

function toIntervalEventPoint

inline Neuralyzer::Transforms::V2::Examples::IntervalEventPoint toIntervalEventPoint(
    AlignmentPoint point
)

Convert a plot alignment point to the TransformsV2 interval-to-event enum.

Parameters:

  • point Plot-facing alignment point.

Return: Equivalent TransformsV2 interval event point.

Postcondition: The returned value preserves start/end/center semantics.

function getAlignmentSource

inline AlignmentSourceResult getAlignmentSource(
    std::shared_ptr< DataManager > const & data_manager,
    std::string const & alignment_key
)

Look up an alignment source from DataManager.

Parameters:

Return: AlignmentSourceResult containing the series or an error message.

Postcondition: The result is valid only for digital event or digital interval data.

function extractAlignmentTimes

inline std::vector< ClockTicks > extractAlignmentTimes(
    DigitalEventSeries const & events
)

Extract absolute alignment times from a DigitalEventSeries.

Parameters:

  • events Event series to inspect.

Return: Absolute-time values in event row order.

Postcondition: If the series has no TimeFrame, raw event indices are returned.

function extractAlignmentTimes

inline std::vector< ClockTicks > extractAlignmentTimes(
    DigitalIntervalSeries const & intervals,
    AlignmentPoint align
)

Extract absolute alignment times from a DigitalIntervalSeries.

Parameters:

  • intervals Interval series to inspect.
  • align Which interval point to use.

Return: Absolute-time values in interval row order.

Postcondition: If the series has no TimeFrame, raw interval indices are returned.

function pruneOverlappingAlignmentTimes

inline std::vector< size_t > pruneOverlappingAlignmentTimes(
    std::vector< ClockTicks > const & alignment_times,
    int64_t pre_window,
    int64_t post_window
)

Prune alignment times whose expanded windows would overlap.

Parameters:

  • alignment_times Sorted absolute alignment times.
  • pre_window Time units before each alignment time.
  • post_window Time units after each alignment time.

Return: Indices into alignment_times that survive greedy keep-first pruning.

Precondition: alignment_times is sorted in ascending order.

Postcondition: Touching windows are treated as overlapping.

function createFilteredEventSeries

inline std::shared_ptr< DigitalEventSeries > createFilteredEventSeries(
    std::shared_ptr< DigitalEventSeries const > const & source,
    std::vector< size_t > const & kept_indices
)

Create a filtered copy of a DigitalEventSeries.

Parameters:

  • source Source event series.
  • kept_indices Indices in source view order to keep.

Return: Owning event series with the same TimeFrame as source.

Precondition: source must be non-null and kept_indices must be sorted ascending.

Postcondition: Output row order follows kept_indices.

function createFilteredIntervalSeries

inline std::shared_ptr< DigitalIntervalSeries > createFilteredIntervalSeries(
    std::shared_ptr< DigitalIntervalSeries const > const & source,
    std::vector< size_t > const & kept_indices
)

Create a filtered copy of a DigitalIntervalSeries.

Parameters:

  • source Source interval series.
  • kept_indices Indices in source view order to keep.

Return: Owning interval series with the same TimeFrame as source.

Precondition: source must be non-null and kept_indices must be sorted ascending.

Postcondition: Output row order follows kept_indices.

function physicalWindowToInterval

inline TimeFrameInterval physicalWindowToInterval(
    ClockTicks alignment_time,
    int64_t pre_window,
    int64_t post_window,
    std::shared_ptr< TimeFrame > const & target_time_frame
)

Convert an absolute-time window to interval indices in a target TimeFrame.

Parameters:

  • alignment_time Absolute alignment time.
  • pre_window Time units before alignment.
  • post_window Time units after alignment.
  • target_time_frame TimeFrame for the output interval, or null for raw time indices.

Return: Interval expressed in target_time_frame indices.

Postcondition: The start uses the next index at/after the window start; the end uses the nearest preceding index.

function createWindowsAroundEvents

inline std::shared_ptr< DigitalIntervalSeries > createWindowsAroundEvents(
    std::shared_ptr< DigitalEventSeries const > const & alignment_events,
    int64_t pre_window,
    int64_t post_window,
    std::shared_ptr< TimeFrame > const & window_time_frame
)

Build overlapping window intervals around alignment events.

Parameters:

  • alignment_events Events providing t=0 points.
  • pre_window Absolute time units before each event.
  • post_window Absolute time units after each event.
  • window_time_frame TimeFrame in which output windows should be expressed.

Return: Overlapping DigitalIntervalSeries row windows.

Precondition: alignment_events must be non-null.

Postcondition: Output row count matches alignment_events size.

function keptWindowIndices

inline std::vector< size_t > keptWindowIndices(
    DigitalIntervalSeries const & windows
)

Compute kept row indices for greedy overlap pruning of interval bounds.

Parameters:

  • windows Candidate window series.

Return: Kept row indices in input order.

Precondition: windows must be non-null and sorted by start time.

Postcondition: Touching windows are treated as overlapping.

function prunePreparedAlignmentWindows

inline PreparedAlignmentWindows prunePreparedAlignmentWindows(
    std::shared_ptr< DigitalIntervalSeries const > const & windows,
    std::shared_ptr< DigitalEventSeries const > const & alignment_points
)

Prune windows and companion alignment points together.

Parameters:

  • windows Candidate window series.
  • alignment_points Companion event series with matching row order.

Return: PreparedAlignmentWindows containing pruned windows and alignment events.

Precondition: windows and alignment_points must be non-null and have the same row count.

Postcondition: Output windows and alignment points have matching row counts.

function prepareEventAlignmentWindows

inline PreparedAlignmentWindows prepareEventAlignmentWindows(
    std::shared_ptr< DigitalEventSeries const > const & alignment_events,
    int64_t pre_window,
    int64_t post_window,
    std::shared_ptr< TimeFrame > const & window_time_frame,
    bool prevent_overlap =false
)

Prepare event-aligned gather windows.

Parameters:

  • alignment_events Events defining one row per event.
  • pre_window Absolute time units before each event.
  • post_window Absolute time units after each event.
  • window_time_frame TimeFrame in which windows should be expressed.
  • prevent_overlap Whether to greedily prune overlapping windows.

Return: Prepared windows and companion alignment events.

Precondition: alignment_events must be non-null.

Postcondition: If valid, windows and alignment_points have matching row counts.

function prepareIntervalAlignmentWindows

inline PreparedAlignmentWindows prepareIntervalAlignmentWindows(
    std::shared_ptr< DigitalIntervalSeries const > const & alignment_intervals,
    AlignmentPoint align =AlignmentPoint::Start
)

Prepare interval-aligned gather windows that use the full interval bounds.

Parameters:

  • alignment_intervals Intervals defining row windows.
  • align Which interval point to use as t=0.

Return: Prepared windows and companion alignment events.

Precondition: alignment_intervals must be non-null.

Postcondition: If valid, windows and alignment_points have matching row counts.

function prepareIntervalAlignmentWindows

inline PreparedAlignmentWindows prepareIntervalAlignmentWindows(
    std::shared_ptr< DigitalIntervalSeries const > const & alignment_intervals,
    AlignmentPoint align,
    int64_t pre_window,
    int64_t post_window,
    std::shared_ptr< TimeFrame > const & window_time_frame,
    bool prevent_overlap =false
)

Prepare interval-aligned gather windows around selected interval points.

Parameters:

  • alignment_intervals Intervals that provide alignment points.
  • align Which interval point to use as t=0.
  • pre_window Absolute time units before each alignment point.
  • post_window Absolute time units after each alignment point.
  • window_time_frame TimeFrame in which windows should be expressed.
  • prevent_overlap Whether to greedily prune overlapping windows.

Return: Prepared windows and companion alignment events.

Precondition: alignment_intervals must be non-null.

Postcondition: If valid, windows and alignment_points have matching row counts.

function getFilteredAlignmentSource

inline AlignmentSourceResult getFilteredAlignmentSource(
    std::shared_ptr< DataManager > const & data_manager,
    PlotAlignmentData const & alignment_data
)

Look up alignment source with optional overlap pruning.

Parameters:

  • data_manager DataManager to query.
  • alignment_data Full alignment configuration.

Return: AlignmentSourceResult with a filtered copy when prevent_overlap is enabled.

Postcondition: Filtering is based on physical display windows around alignment points.

function countNonOverlappingAlignmentEvents

inline size_t countNonOverlappingAlignmentEvents(
    std::shared_ptr< DataManager > const & data_manager,
    PlotAlignmentData const & alignment_data
)

Compute the number of alignment rows that survive overlap pruning.

Parameters:

  • data_manager DataManager to query.
  • alignment_data Alignment configuration.

Return: Number of non-overlapping alignment rows, or 0 on error.

Postcondition: The count uses the same physical-window pruning policy as plot preparation.

function prepareAlignmentWindows

inline PreparedAlignmentWindows prepareAlignmentWindows(
    std::shared_ptr< DataManager > const & data_manager,
    PlotAlignmentData const & alignment_data,
    std::shared_ptr< TimeFrame > const & window_time_frame
)

Prepare windows from DataManager and PlotAlignmentData.

Parameters:

  • data_manager DataManager containing the alignment source.
  • alignment_data Alignment configuration.
  • window_time_frame TimeFrame in which generated display windows should be expressed.

Return: Prepared window/alignment metadata, or an invalid result on error.

Postcondition: Event and interval display-window paths use physical window units.

function trialIndexFromWorldY

inline int trialIndexFromWorldY(
    float world_y,
    std::size_t num_trials
)

Derive trial index from world-space Y coordinate.

Parameters:

  • world_y World Y coordinate in the raster plot viewport.
  • num_trials Number of trials (rows).

Return: Trial index in [0, num_trials), or -1 if num_trials == 0.

Matches RowLayoutStrategy row placement and trialIndexAxis labeling: trial 0 at world y ≈ -1 (bottom), trial (N-1) at world y ≈ +1 (top).

function rowWorldYCenter

inline float rowWorldYCenter(
    int row_index,
    std::size_t num_trials,
    float viewport_y_min =-1.0f,
    float viewport_y_max =1.0f
)

Compute world Y center for a raster row using RowLayoutStrategy geometry.

Parameters:

  • row_index Zero-based row index (0 = bottom row).
  • num_trials Total number of rows.
  • viewport_y_min Minimum viewport Y (default -1).
  • viewport_y_max Maximum viewport Y (default +1).

Return: World Y coordinate at the center of the row.

function absoluteTimeFromHit

inline int64_t absoluteTimeFromHit(
    int64_t alignment_time,
    float relative_time_ms
)

Convert a hit event’s relative time and trial alignment to absolute time.

Parameters:

  • alignment_time Absolute alignment time for the trial (ClockTicks value).
  • relative_time_ms Event time relative to alignment (world X from hit test).

Return: Absolute time in the same units as alignment_time.

Used by EventPlot double-click navigation: absolute = alignment + relative.

function screenToNDC

inline glm::vec2 screenToNDC(
    QPoint const & screen_pos,
    int widget_width,
    int widget_height
)

Convert screen pixel coordinates to normalized device coordinates (NDC).

Parameters:

  • screen_pos Mouse position in widget-local pixels.
  • widget_width Widget width in pixels.
  • widget_height Widget height in pixels.

Return: NDC (x, y) as glm::vec2.

NDC X is in [-1, 1] (left to right), NDC Y is in [-1, 1] (bottom to top). Same conversion used as the first step of screenToWorld; useful for selection rectangles and hit-testing in NDC space.

function screenToWorld

inline QPointF screenToWorld(
    glm::mat4 const & projection_matrix,
    int widget_width,
    int widget_height,
    QPoint const & screen_pos
)

Convert screen pixel coordinates to world coordinates.

Parameters:

  • projection_matrix The current orthographic projection.
  • widget_width Widget width in pixels.
  • widget_height Widget height in pixels.
  • screen_pos Mouse position in widget-local pixels.

Return: World (x, y) as a QPointF.

Uses the inverse of the projection matrix. Identical across all plot widgets.

function worldToScreen

inline QPoint worldToScreen(
    glm::mat4 const & projection_matrix,
    int widget_width,
    int widget_height,
    float world_x,
    float world_y
)

Convert world coordinates to screen pixel coordinates.

Parameters:

  • projection_matrix The current orthographic projection.
  • widget_width Widget width in pixels.
  • widget_height Widget height in pixels.
  • world_x World X coordinate.
  • world_y World Y coordinate.

Return: Screen (x, y) as a QPoint.

function computeOrthoProjection

template <ViewStateLike ViewState>
glm::mat4 computeOrthoProjection(
    ViewState const & view_state,
    float x_range,
    float x_center,
    float y_range,
    float y_center
)

Compute an orthographic projection matrix from zoom/pan view state.

Parameters:

  • view_state The cached view state (zoom + pan fields).
  • x_range Total data range on the X axis (e.g. x_max - x_min).
  • x_center Center of the data range on X (e.g. (x_min + x_max) / 2).
  • y_range Total data range on the Y axis.
  • y_center Center of the data range on Y.

Template Parameters:

  • ViewState A type satisfying [ViewStateLike].

Return: The orthographic projection matrix.

This consolidates the updateMatrices() logic from all plot widgets. The caller provides the data ranges and centers (which vary per widget), and this function applies zoom and pan to produce the final projection.

function computeOrthoProjection

template <ViewStateWithBounds ViewState>
glm::mat4 computeOrthoProjection(
    ViewState const & view_state
)

Compute orthographic projection from view state with bounds.

Parameters:

  • view_state The cached view state (zoom, pan, and axis bounds).

Template Parameters:

  • ViewState A type satisfying [ViewStateWithBounds].

Return: The orthographic projection matrix.

Convenience overload for view states that have x_min, x_max, y_min, y_max. Derives x_range, x_center, y_range, y_center and calls the 4-arg computeOrthoProjection.

function handlePanning

template <ZoomPanSettable State,
ViewStateLike ViewState>
void handlePanning(
    State & state,
    ViewState const & view_state,
    int delta_x,
    int delta_y,
    float x_range,
    float y_range,
    int widget_width,
    int widget_height
)

Apply a pixel-space drag delta as a pan update to the state.

Parameters:

  • state The mutable state object (setPan will be called).
  • view_state The cached view state snapshot.
  • delta_x Horizontal mouse drag in pixels.
  • delta_y Vertical mouse drag in pixels.
  • x_range Total data range on the X axis.
  • y_range Total data range on the Y axis.
  • widget_width Widget width in pixels.
  • widget_height Widget height in pixels.

Template Parameters:

  • State A type satisfying [ZoomPanSettable] (has setPan()).
  • ViewState A type satisfying [ViewStateLike].

Converts the pixel delta to world-space using the provided data ranges, widget dimensions, and current zoom level, then calls state.setPan().

function handlePanning

template <ZoomPanSettable State,
ViewStateWithBounds ViewState>
void handlePanning(
    State & state,
    ViewState const & view_state,
    int delta_x,
    int delta_y,
    int widget_width,
    int widget_height
)

Apply pan from view state with bounds (derives x_range/y_range).

Parameters:

  • state The mutable state object (setPan will be called).
  • view_state The cached view state snapshot (must have bounds).
  • delta_x Horizontal mouse drag in pixels.
  • delta_y Vertical mouse drag in pixels.
  • widget_width Widget width in pixels.
  • widget_height Widget height in pixels.

Template Parameters:

  • State A type satisfying [ZoomPanSettable].
  • ViewState A type satisfying [ViewStateWithBounds].

Convenience overload for view states that have x_min, x_max, y_min, y_max. Derives x_range and y_range and calls the 8-arg handlePanning.

function wheelDeltaToZoomSteps

inline float wheelDeltaToZoomSteps(
    int pixel_delta_y,
    int angle_delta_y,
    int angle_delta_x,
    float pixels_per_zoom_step =DEFAULT_WHEEL_PIXELS_PER_ZOOM_STEP
)

Convert raw wheel deltas to fractional zoom steps for handleZoom().

Parameters:

  • pixel_delta_y Vertical pixel delta from QWheelEvent::pixelDelta().
  • angle_delta_y Vertical angle delta from QWheelEvent::angleDelta().
  • angle_delta_x Horizontal angle delta from QWheelEvent::angleDelta().
  • pixels_per_zoom_step Pixels of vertical movement per one zoom step.

Return: Fractional zoom steps; positive = zoom in.

Prefers pixel_delta_y when non-zero (trackpads and smooth scrolling). Otherwise uses angle_delta_y, falling back to angle_delta_x on platforms (e.g. WSL/X11) that redirect vertical scroll to the horizontal axis.

function adaptiveZoomMultiplier

inline double adaptiveZoomMultiplier(
    double delta
)

Compute the zoom multiplier for adaptive range-proportional wheel zoom.

Parameters:

Return: Multiplier to apply to the current axis zoom value.

Each zoom step changes the visible axis range by ADAPTIVE_ZOOM_RANGE_FRACTION of the current visible span (3% per step, matching DataViewer adaptive normal mode). Positive delta zooms in; negative delta zooms out.

function handleZoom

template <ZoomPanSettable State,
ViewStateLike ViewState>
void handleZoom(
    State & state,
    ViewState const & view_state,
    float delta,
    bool y_only,
    bool both_axes
)

Apply a scroll-wheel zoom step to the state.

Parameters:

  • state The mutable state object (setXZoom/setYZoom called).
  • view_state The cached view state snapshot.
  • delta Scroll wheel delta (positive = zoom in).
  • y_only If true, zoom only the Y axis.
  • both_axes If true, zoom both axes simultaneously.

Template Parameters:

  • State A type satisfying [ZoomPanSettable].
  • ViewState A type satisfying [ViewStateLike].

Uses adaptive range-proportional scaling: each wheel step changes the visible span by 3% of the current range (same feel as DataViewer adaptive mode). Modifier keys select the axis:

  • Default (no modifier): X-axis only
  • y_only (Shift): Y-axis only
  • both_axes (Ctrl): Both axes simultaneously

function affectsAxis

bool affectsAxis(
    ViewAxisRefresh mask,
    ViewAxisRefresh axis
)

Test whether mask includes axis.

function makeViewAxisSyncSnapshot

template <ViewStateZoomPanLike ViewState>
ViewAxisSyncSnapshot makeViewAxisSyncSnapshot(
    ViewState const & view_state
)

Capture zoom/pan fields from a view state.

function makeViewAxisSyncSnapshot

template <ViewStateZoomPanLike ViewState>
ViewAxisSyncSnapshot makeViewAxisSyncSnapshot(
    ViewState const & view_state
)

Capture zoom/pan and data bounds from a view state.

function computeViewAxisRefreshMask

inline ViewAxisRefresh computeViewAxisRefreshMask(
    ViewAxisSyncSnapshot const & before,
    ViewAxisSyncSnapshot const & after
)

Determine which axes need refresh between two snapshots.

function extractEdgeEvents

inline std::shared_ptr< DigitalEventSeries > extractEdgeEvents(
    std::shared_ptr< DigitalIntervalSeries const > intervals,
    IntervalAlignmentType edge
)

Extract edge events from a DigitalIntervalSeries.

Parameters:

  • intervals Source interval series to extract edges from
  • edge Which edge to extract (Beginning = start times, End = end times)

Return: New DigitalEventSeries with one event per interval edge, or nullptr on error

Creates a new DigitalEventSeries containing either the start or end times of each interval, depending on the specified edge type. The TimeFrame from the source interval series is propagated to the result.

function runHeatmapPipeline

HeatmapPipelineResult runHeatmapPipeline(
    std::shared_ptr< DataManager > const & data_manager,
    std::vector< std::string > const & unit_keys,
    PlotAlignmentData const & alignment_data,
    HeatmapPipelineConfig const & config
)

Execute the heatmap data pipeline without an OpenGL context.

Parameters:

  • data_manager DataManager with loaded event and alignment data
  • unit_keys DigitalEventSeries keys (one per row)
  • alignment_data Alignment configuration (event key, window size, etc.)
  • config Pipeline configuration (scaling, estimation params, etc.)

Return: Pipeline result with rows and intermediate data; success is false when the pipeline produces no output (e.g. empty gather, no alignment).

This function replicates the data flow from HeatmapOpenGLWidget::rebuildScene() as a testable free function:

  1. Gather trial-aligned DigitalEventSeries data for all unit keys
  2. Estimate firing rates for each unit
  3. Apply scaling (Hz, z-score, etc.)
  4. Convert RateEstimate to CorePlotting::HeatmapRowData

function computeSortOrder

std::vector< std::size_t > computeSortOrder(
    HeatmapPipelineResult const & result,
    std::vector< std::string > const & unit_keys,
    HeatmapSortMode sort_mode,
    bool ascending
)

Compute a permutation vector that sorts the pipeline rows.

Parameters:

  • result Pipeline result containing rows and rate_estimates
  • unit_keys Unit keys (parallel to rows) — used for Alphabetical sort
  • sort_mode Sorting criterion
  • ascending Sort direction

Return: Index permutation of size result.rows.size()

Returns indices into the original row order such that rows[result[0]] is the first row in sorted order, etc.

function applySortOrder

void applySortOrder(
    HeatmapPipelineResult & result,
    std::vector< std::string > & unit_keys,
    std::vector< std::size_t > const & sort_indices
)

Apply a precomputed permutation to the pipeline result and unit keys.

Parameters:

  • result Pipeline result to reorder (modified in-place)
  • unit_keys Unit keys to reorder in parallel (modified in-place)
  • sort_indices Permutation from computeSortOrder()

Reorders result.rows, result.rate_estimates, and unit_keys in-place according to the given index permutation.

Attributes Documentation

variable DEFAULT_WHEEL_PIXELS_PER_ZOOM_STEP

float DEFAULT_WHEEL_PIXELS_PER_ZOOM_STEP = 20.0f;

Pixels of vertical trackpad movement equivalent to one mouse-wheel notch.

variable WHEEL_ANGLE_DELTA_PER_NOTCH

float WHEEL_ANGLE_DELTA_PER_NOTCH = 120.0f;

Qt angleDelta units per physical wheel notch (8 degrees x 15).

variable ADAPTIVE_ZOOM_RANGE_FRACTION

double ADAPTIVE_ZOOM_RANGE_FRACTION = 0.03;

Visible-range fraction removed per zoom step (matches DataViewer adaptive normal mode).

variable MIN_ADAPTIVE_VISIBLE_RANGE_SCALE

double MIN_ADAPTIVE_VISIBLE_RANGE_SCALE = 0.01;

Minimum visible-range scale factor in a single wheel event (prevents runaway zoom).


Updated on 2026-11-13 at 20:25:41 +0000