TrajectoryLogReader 2.0.0

dotnet add package TrajectoryLogReader --version 2.0.0
                    
NuGet\Install-Package TrajectoryLogReader -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TrajectoryLogReader" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TrajectoryLogReader" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="TrajectoryLogReader" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TrajectoryLogReader --version 2.0.0
                    
#r "nuget: TrajectoryLogReader, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TrajectoryLogReader@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TrajectoryLogReader&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=TrajectoryLogReader&version=2.0.0
                    
Install as a Cake Tool

TrajectoryLogReader

A .NET library for parsing, analyzing, and compressing Varian TrueBeam trajectory log files (*.bin). Supports standard Version 5.0 logs.

Installation

dotnet add package TrajectoryLogReader

Basic Usage

Reading Logs

using TrajectoryLogReader;
using TrajectoryLogReader.IO;

// Read standard binary log
var log = LogReader.ReadBinary("path/to/file.bin");

Data Model

The TrajectoryLog object provides two primary views of the data: Axes (columnar) and Snapshots (row-based).

1. Columnar Access (Axes)

Best for statistical analysis or plotting full time-series.

// Access raw arrays (IEnumerable<float>)
var gantryAngles = log.Axes.Gantry.ActualValues;
var cumulativeMu = log.Axes.MU.ActualValues;
var gantryErrors = log.Axes.Gantry.ErrorValues;

// Derived rates
var gantrySpeed = log.Axes.GantrySpeed.ActualValues; // deg/s
var doseRate = log.Axes.DoseRate.ActualValues;   

2. Temporal Access (Snapshots)

Best for sequential processing or state reconstruction.

foreach (var snapshot in log.Snapshots)
{
    var time = snapshot.Milliseconds;
    var gantry = snapshot.Gantry.Actual;
    
    // Access MLC leaf positions with 0-based index [bankIndex, leafIndex]
    var leafA1 = snapshot.Mlc.Leaves[0][0].Actual; 
}

These can also be access for each sub-beam, e.g

log.SubBeams.First().Axes.Gantry.ExpectedValues;
log.SubBeams.First().Snapshots.First().GantryRtn.Actual;

Analysis Features

Interpolation

Linear interpolation of machine state at any given time (ms).

int timeMs = 150;
// Axis position
double gantryAtT = log.InterpolateAxisData(Axis.GantryRtn, timeMs, RecordType.ActualPosition);
// Specific MLC leaf
double leafPos = log.InterpolateMLCPosition(timeMs, bank: 0, leafIndex: 10, RecordType.ActualPosition);

Fluence Reconstruction

Generates a 2D fluence map using Sutherland-Hodgman polygon clipping for accurate aperture area calculation.

var options = new FluenceOptions
{
    Rows = 512,
    Cols = 512,
    Width = 400, //mm
    Height = 400, // mm
};

var fluenceGrid = log.CreateFluence(options, RecordType.ActualPosition);
var fluenceGridBeam = log.SubBeams.First().CreateFluence(options, RecordType.ActualPosition);

<img width="400" height="400" alt="image" src="https://github.com/user-attachments/assets/738b82fc-f0a6-43d3-bbd5-4a9b6b266bb6" />

Gamma Analysis

Implements 2D Gamma Index (Low et al., 1998). Uses interpolation of the eval grid, which is configurable. The search radius is also configurable.

var gammaParams = new GammaParameters2D(dtaTolMm: 1, doseTolPercent: 1, global: true);
var result = GammaCalculator2D.Calculate(gammaParams, reference, evaluated);

Console.WriteLine($"Passing Rate: {result.FracPass * 100:F1}%");

Output

Output a log-file to TSV or CSV

log.SaveToCsv("/out/log.csv", includeHeaders: true, AxisScale.IEC61217);

<img width="50%" alt="image" src="https://github.com/user-attachments/assets/9f72a8e7-bc61-4f14-87a8-289dc80334cb" />

Writing Compressed Logs

The CompressedLogWriter will write the files to a compressed (lossy) format. Here we only store changes between each axis position as scaled 8/16 bit values.

While there is some loss in precision, the maximum loss for each axis is:

Axis Stream Type Scale Notes
MLC (All) Small 1000 0.001 cm res
Jaws (X1, X2, Y1, Y2) Small 1000 0.001 cm res
Couch Pitch / Roll Small 100 0.01 deg res
Couch Vrt / Lng / Lat Large 100 0.01 cm res
Gantry Rtn Large 100 0.01 deg res, Wraps
Collimator Rtn Large 100 0.01 deg res, Wraps
Couch Rtn Large 100 0.01 deg res, Wraps
MU Large 1000 0.001 unit res
ControlPoint Large 1000 0.001 unit res

Log file sizes are reduced by >90%, depending on the file.

// Writes to .cbin
CompressedLogWriter.Write(log, "path/to/output.cbin");
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

  • .NETStandard 2.1

    • No dependencies.
  • net10.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on TrajectoryLogReader:

Package Downloads
TrajectoryLogReader.DICOM

Provides methods for calculating fluence using DICOM plan data

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 0 1/28/2026
2.0.0-beta.3 24 1/27/2026
2.0.0-beta.2 32 1/27/2026
2.0.0-beta.1 34 1/26/2026
2.0.0-alpha.9 44 1/19/2026
2.0.0-alpha.8 41 1/19/2026
2.0.0-alpha.7 43 1/18/2026
2.0.0-alpha.6 44 1/16/2026
2.0.0-alpha.5 44 1/15/2026
2.0.0-alpha.4 39 1/15/2026
2.0.0-alpha.3 44 1/14/2026
2.0.0-alpha.2 42 1/11/2026
2.0.0-alpha.1 41 1/10/2026
1.2.0 167 12/23/2025
1.1.1 422 12/10/2025
1.1.0 418 12/10/2025
1.0.0 155 12/17/2024