Tuesday, April 2, 2013

ADAC/Philips Pinnacle3 Postscript to PDF Hotscripts

A few months ago, I noticed a need at work for an improved method of digitization treatment plans for radiation therapy. The images that were being digitally archived were pretty poor quality. To improve the images and simplify workflow, I developed a set of three hotscripts in Pinnacle3. Below are descriptions and links to each script. The scripts are saved as .txt files so they can be easily viewed in your browser, but to use them they should just have the .p3rtp extension. Anyone who uses these will likely need to edit the file paths for their clinic's specific filesystem.

  1. MakePatientFolder2.Script.p3rtp - This script makes a patient directory named with the patient's last name and their medical record number. In Pinnacle, it also sets the current printer to "Print to file" in that directory for both color and plan printing.
  2. Ps2PdfMerge3.Script.p3rtp - This script takes all .ps files (must be named *.ps) that are in the current patient's directory (as created by the first script above) and merges them into one PDF file. The quality is reasonably high (see below for a few more details). 
  3. DeletePatientFolder.Script.p3rtp - Optional script to delete the current patient's folder and anything inside it. Useful for keeping the directory free of clutter without manually going in and deleting folders and files. WARNING: Be careful when editing the file paths if using this. If you put in the wrong file path, you just might start recursively deleting everything on your server. While it might make a cool (toy) story, it may not make for a pleasant performance review.
When I originally wrote the script, I was using the PS2PDF option "-dColorImageFilter=/FlateEncode", which produces lossless images. It really made some great looking PDF files, and they were pretty small in size. However, after the clinic started using the scripts, I found that certain pages in some files (but not all) were throwing an "Insufficient data for an image" error in Adobe Reader 11 (and Acrobat 9, and likely others, but not Reader 8 or Foxit reader). After struggling with it for a while, I finally had to admit defeat and changed to using the option "-dPDFSETTINGS=/prepress", which is the highest lossy quality available. The file sizes are about twice what they were with the lossless option, and there are some small compression artifacts, but the results are still good. There's some more information about this in comments in the Ps2PdfMerge3 script.

Link to folder of scripts: https://drive.google.com/folderview?id=0B5kK96g_etabamJLMzZxdTRmaGc&usp=sharing