
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
The RTPConnect library allows you to read, edit and write RTPConnect files in Ruby. RTPConnect is a file format used in radiotherapy (e.g. Mosaiq) for export & import of treatment planning data. The library is written entirely in Ruby and has no external dependencies.
gem install rtp-connect
require 'rtp-connect'
include RTP
# Read file:
rtp = Plan.read('some_file.rtp')
# Extract the Patient's Name:
name = rtp.patient_last_name
# Modify the Patient's Name:
rtp.patient_last_name = 'Anonymous'
# Write to file:
rtp.write('new_file.rtp')
# Create the instance:
rtp = Plan.new
# Set the Patient's ID attribute:
rtp.patient_id = '12345'
# Export the instance to an RTP string (with CRC):
output = rtp.to_s
# Read an RTP file containing invalid checksum(s):
rtp = Plan.read('invalid_crc.rtp', ignore_crc: true)
# Read an RTP file containing unknown record type(s):
rtp = Plan.read('custom.rtp', skip_unknown: true)
# Read an RTP file containing invalid CSV format:
rtp = Plan.read('invalid_csv.rtp', repair: true)
# Write a corrected RTP file:
rtp.write('valid.rtp')
# Mosaiq 2.4:
rtp.write('treatment_plan.rtp', version: 2.4)
# Mosaiq 2.5:
rtp.write('treatment_plan.rtp', version: 2.5)
# Mosaiq 2.6 (and 2.62):
rtp.write('treatment_plan.rtp', version: 2.6)
# By default files are outputted at the latest supported version (currently 2.64) when omitting the version parameter:
rtp.write('treatment_plan.rtp')
p = Plan.read('some_file.rtp')
dcm = p.to_dcm
dcm.write('rtplan.dcm')
# Change the log level so that only error messages are displayed:
RTP.logger.level = Logger::ERROR
# Setting up a simple file log:
l = Logger.new('my_logfile.log')
RTP.logger = l
# Create a logger which ages logfile daily/monthly:
RTP.logger = Logger.new('foo.log', 'daily')
RTP.logger = Logger.new('foo.log', 'monthly')
For more comprehensive and useful examples, check out the scripts folder which contains various Ruby scripts that intends to show off real world usage scenarios of the RTPConnect library.
When working with the RTPConnect library in irb, you may be annoyed with all the information that is printed to screen, regardless of your log level. This is because in irb every variable loaded in the program is automatically printed to the screen. A useful hack to avoid this effect is to append ";0" after a command.
Example:
rtp = Plan.read('some_file.rtp') ;0
If you encounter an RTP file with an unsupported record type, please contact me.
Copyright 2011-2020 Christoffer Lervåg
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/ .
Please don't hesitate to email me if you have any feedback related to this project!
FAQs
Unknown package
We found that rtp-connect demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.