Pupillometer ID-300 | Compiled Research & Technical Documentation | Collateral Medical Pvt. Ltd.
PUPILLOMETER ID-300
Compiled Research & Technical Documentation
Internship Project Report
Collateral Medical Pvt. Ltd.
2024 – 2025
Prepared by: Sairaj
[Link] – Biomedical Engineering, VIT
Confidential – Collateral Medical Pvt. Ltd. Page 1 of 14
Pupillometer ID-300 | Compiled Research & Technical Documentation | Collateral Medical Pvt. Ltd.
1. Executive Summary
The Pupillometer ID-300 is a non-invasive, portable ophthalmic diagnostic device designed to
objectively quantify the Pupillary Light Reflex (PLR). The device captures the dynamic
constriction and subsequent dilation of the pupil in response to a controlled flash stimulus, and
derives a set of clinically meaningful metrics from the recorded video.
This document consolidates all research, system design decisions, algorithm rationale, and
implementation details produced during the internship. It is intended to serve as a complete
technical reference for any engineer or clinician who continues development of the system.
The system is built entirely in Python, runs on a Raspberry Pi 5 platform, and uses an OpenCV-
based computer vision pipeline for real-time pupil detection and offline analysis.
Confidential – Collateral Medical Pvt. Ltd. Page 2 of 14
Pupillometer ID-300 | Compiled Research & Technical Documentation | Collateral Medical Pvt. Ltd.
2. Background & Clinical Motivation
2.1 The Pupillary Light Reflex (PLR)
The pupillary light reflex is a fundamental neurological response mediated by the afferent (CN II
– optic nerve) and efferent (CN III – oculomotor nerve) pathways. When light strikes the retina,
signals are relayed via the pretectal nucleus to the Edinger-Westphal nucleus, which drives
sphincter pupillae contraction through the ciliary ganglion. The reflex is bilaterally symmetric,
generating both a direct response in the stimulated eye and a consensual response in the
contralateral eye.
Quantitative abnormalities in PLR parameters are associated with a wide range of neurological
conditions including raised intracranial pressure, traumatic brain injury, Horner's syndrome, third
nerve palsy, and opioid toxicity. Automated pupillometry removes observer-dependent variability
present in manual penlight examinations and enables serial monitoring with high reproducibility.
2.2 Clinical Parameters of Interest
Parameter Value / Description
Maximum Pupil Diameter (mm) Resting state diameter before stimulus
Minimum Pupil Diameter (mm) Peak constriction after flash stimulus
Percentage Change (%) Amplitude of constriction: (Max - Min) / Max × 100
Contraction Velocity (mm/s) Rate of pupil constriction in response to light
Dilation Velocity (mm/s) Rate of pupil re-dilation after peak constriction
Contraction Time (s) Duration from stimulus onset to peak constriction
Dilation Time (s) Duration from peak constriction to return toward baseline
NPi (Neurological Pupil index) Composite score (planned for future release)
2.3 Existing Technologies & Comparative Analysis
Several commercial pupillometers exist, including the NeurOptics NPi-300 and the BrainScope
PUPIL. These devices are proprietary, high-cost (often exceeding $10,000 USD per unit), and
typically restricted to intensive care or neurology settings. The ID-300 aims to provide equivalent
objective PLR metrics on a low-cost, open-platform embedded system accessible in point-of-
care environments.
Confidential – Collateral Medical Pvt. Ltd. Page 3 of 14
Pupillometer ID-300 | Compiled Research & Technical Documentation | Collateral Medical Pvt. Ltd.
3. System Architecture
3.1 High-Level Module Overview
Parameter Value / Description
uirefresh_modern.py Main application – GUI, session management, navigation
between pages
hardware_service.py Hardware Abstraction Layer – camera, IR LED, flash
LED, VideoWriter
analysis_pipeline.py Post-recording analysis engine – frame processing,
metrics, file I/O
pupil_processing.py Single source of truth for all detection and metric
algorithms
[Link] [Link] driver for IR illumination and flash LED via
PWM
[Link] Matplotlib graph generation (Agg backend, thread-safe)
[Link] Standalone CLI tool for testing and diagnostics
The architecture enforces strict separation of concerns. The hardware layer
(hardware_service.py) has no knowledge of the UI. The analysis engine (analysis_pipeline.py)
has no UI imports. All computer-vision algorithms are centralised in pupil_processing.py to
prevent code duplication across modules.
3.2 Hardware Platform
• Raspberry Pi 5 – primary compute unit (Linux, ARM64)
• USB/CSI camera – 640×480 @ real measured FPS (typically 20–30 fps)
• IR LED on GPIO BCM 13 – continuous near-infrared illumination for pupil visibility
• Flash LED on GPIO BCM 19 – PWM-driven white flash stimulus for PLR triggering
• Touchscreen display – tkinter-based GUI rendered via framebuffer
3.3 Thread Model
The application uses three concurrent threads to avoid blocking the GUI:
• HW-Capture thread – daemon thread; reads camera frames continuously and writes to
VideoWriter during recording
• HW-IR thread – daemon thread; executes the timed IR/flash sequence for each
recording session
• Main (GUI) thread – tkinter event loop; polls get_latest_frame() for live preview updates
Confidential – Collateral Medical Pvt. Ltd. Page 4 of 14
Pupillometer ID-300 | Compiled Research & Technical Documentation | Collateral Medical Pvt. Ltd.
Thread safety is guaranteed by two locks: _frame_lock (protects the latest camera frame) and
_rec_lock (protects the VideoWriter and recording state).
Confidential – Collateral Medical Pvt. Ltd. Page 5 of 14
Pupillometer ID-300 | Compiled Research & Technical Documentation | Collateral Medical Pvt. Ltd.
4. Recording Protocol & IR Sequence
Each recording session follows a fixed 6-second timeline designed to capture the complete PLR
waveform:
Parameter Value / Description
0.0 – 1.0 s Baseline phase: IR LED active, no flash. Pupil at resting
diameter.
1.0 s Flash triggered: white LED blinks at 10% PWM duty
cycle for 200 ms.
1.0 – 1.2 s Constriction phase onset: pupil begins rapid constriction.
1.2 – 6.0 s Post-flash phase: IR continues; pupil constricts to
minimum then dilates back.
6.0 s Recording stops. OS file buffer flushed. Analysis pipeline
invoked via callback.
A critical engineering fix implemented during this internship was the correction of a slow-motion
video bug. Previously, the VideoWriter was hard-coded to 20 fps while the camera might report
a different actual frame rate. The video file header then disagreed with the frame count, causing
the analysis pipeline to compute timestamps incorrectly (a 174-frame video at 30 fps was read
as if it were 20 fps, stretching time by 50%). The fix reads the camera's actual FPS via
[Link](cv2.CAP_PROP_FPS) and writes the same value to the VideoWriter header, so
frame_index / fps always yields the correct elapsed time.
Confidential – Collateral Medical Pvt. Ltd. Page 6 of 14
Pupillometer ID-300 | Compiled Research & Technical Documentation | Collateral Medical Pvt. Ltd.
5. Computer Vision Pipeline
5.1 Pupil Detection Algorithm
Pupil detection is implemented in pupil_processing.detect_pupil_by_shape(). The algorithm
follows these steps:
• Convert frame to grayscale
• Apply Gaussian blur to reduce noise
• Threshold to isolate dark circular regions (the pupil, under IR illumination, appears as the
darkest region)
• Find external contours in the thresholded image
• Filter contours by area, circularity (4π·Area / Perimeter²), and aspect ratio to reject non-
pupil candidates
• Fit minimum enclosing circle to the best candidate contour
• Return (center, radius) tuple, or None if no valid candidate found
IR illumination is critical to this approach: near-infrared light causes the pupil to appear uniformly
dark against a brighter iris, making thresholding robust and reliable even in ambient lighting
conditions.
5.2 Pixel-to-Millimetre Conversion
Pupil diameter in pixels is converted to millimetres using a geometric optical model derived from
the camera's physical specifications:
Parameter Value / Description
Focal Length 2.45 mm
Sensor Width 3.6 mm
Object Distance 50.8 mm (device-to-eye working distance)
Frame Width 640 pixels
Formula size_mm = (px_diameter × sensor_width ×
object_distance) / (frame_width × focal_length)
This conversion is handled by pupil_processing.calculate_pupil_size(). The optical constants
were determined empirically using a calibration target of known diameter at the design working
distance. Note: a pixel-to-mm API integration is planned as a future enhancement to make this
calibration more flexible and device-agnostic.
5.3 Outlier Rejection & Smoothing
Raw per-frame pupil size estimates contain occasional spurious detections (reflections, eyelid
occlusions, blinks). These are removed by pupil_processing.reject_and_interpolate_outliers(),
Confidential – Collateral Medical Pvt. Ltd. Page 7 of 14
Pupillometer ID-300 | Compiled Research & Technical Documentation | Collateral Medical Pvt. Ltd.
which discards any frame-to-frame jump exceeding 100% of the current value (jump_frac=1.0)
and linearly interpolates the gap.
Following outlier rejection, a 5-point moving-average filter (numpy convolve, mode='valid') is
applied to smooth the waveform while preserving the temporal structure of the PLR. This
reduces the dataset by 4 points (2 at each end) and the timestamps are trimmed accordingly.
Confidential – Collateral Medical Pvt. Ltd. Page 8 of 14
Pupillometer ID-300 | Compiled Research & Technical Documentation | Collateral Medical Pvt. Ltd.
6. Clinical Metrics Computation
Metrics are computed by pupil_processing._compute_phase_metrics(timestamps, sizes). The
function identifies:
• Maximum size – largest value in the smoothed waveform (baseline pupil diameter before
constriction)
• Minimum size – smallest value (peak constriction)
• Percentage change – (max - min) / max × 100, representing constriction amplitude
• Contraction time – time elapsed from waveform start to the sample at minimum size
• Dilation time – time elapsed from minimum size to the end of the waveform
• Contraction speed – (max - min) / contraction_time, expressed in mm/s
• Dilation speed – (max - min) / dilation_time, expressed in mm/s
These seven parameters are mapped to the UI short-codes (Dia, MIN, CH, CV, DV, LAT) used
in the results display table. The NPi (Neurological Pupil index) field is reserved but not yet
computed, as it requires a proprietary formula that is outside the scope of the current
implementation.
Confidential – Collateral Medical Pvt. Ltd. Page 9 of 14
Pupillometer ID-300 | Compiled Research & Technical Documentation | Collateral Medical Pvt. Ltd.
7. Data Management & File Structure
Parameter Value / Description
pupil_videos/{ts}_session.avi Raw recorded video (unprocessed frames)
pupil_videos/{ts}_session_pro.avi Processed video with detection overlay and annotations
pupil_data/{ts}_pupil_values.txt CSV of (time, pupil_size) pairs after smoothing
pupil_data/{ts}_pupil_metrics.txt Human-readable metric summary
pupil_data/{ts}_session.json Full session record (used by Patient History page)
pupil_plots/{ts}_graph.png Pupil-size-over-time graph (Matplotlib, saved as PNG)
All file names are keyed by a Unix timestamp (session_ts) to ensure uniqueness and to allow
chronological sorting. Session JSON files are the primary persistence mechanism for the
Patient History page, which reloads and renders historical results from disk.
On Raspberry Pi, all data is written under /home/parag/. On Windows/laptop, relative paths are
used for development and testing. This is abstracted through the IS_PI flag present in each
module.
Confidential – Collateral Medical Pvt. Ltd. Page 10 of 14
Pupillometer ID-300 | Compiled Research & Technical Documentation | Collateral Medical Pvt. Ltd.
8. Graphical User Interface
The GUI is implemented in uirefresh_modern.py using Python's tkinter library with a custom
dark-theme styling. The application is structured as a multi-page frame stack, with pages
including:
• Home / Welcome Page – patient identification and eye selection
• Live Preview Page – real-time camera feed with pupil detection overlay, IR controls, and
record button
• Results Page – displays processed video, graph, and metric table after analysis
completes
• Patient History Page – lists past sessions loaded from JSON, with ability to review
historical results
The UI is fully decoupled from hardware and analysis logic. It interacts with HardwareService
exclusively through get_latest_frame(), start_recording(), and the on_recording_done callback.
Confidential – Collateral Medical Pvt. Ltd. Page 11 of 14
Pupillometer ID-300 | Compiled Research & Technical Documentation | Collateral Medical Pvt. Ltd.
9. Testing & Validation
9.1 Cross-Platform Testing
All modules include a IS_PI guard that selects the correct OpenCV camera backend
(CAP_V4L2 on Linux, CAP_DSHOW on Windows) and file paths. This allowed full development
and unit testing on a Windows laptop before deployment to the Raspberry Pi 5.
9.2 CLI Diagnostic Tool
[Link] provides a standalone command-line interface for testing the complete pipeline
without the GUI. It opens a live preview window, accepts keypress-triggered recording, and runs
the full AnalysisPipeline, printing results to the terminal. This was used extensively during
algorithm tuning.
9.3 Mock Hardware
hardware_service.py loads a MockIRController automatically when [Link] is unavailable.
The mock prints actions to the console and sleeps the appropriate duration, allowing the
recording and IR timing logic to be tested identically on both platforms.
Confidential – Collateral Medical Pvt. Ltd. Page 12 of 14
Pupillometer ID-300 | Compiled Research & Technical Documentation | Collateral Medical Pvt. Ltd.
10. Future Recommendations & Next Steps
The following enhancements are recommended for the next phase of development:
10.1 Pixel-to-Millimetre Calibration API
The current optical conversion uses hardcoded constants (focal length, sensor width, working
distance). A calibration API or interactive calibration wizard should be developed to allow per-
device calibration using a reference target. This would improve measurement accuracy across
units with manufacturing tolerances and support future hardware revisions.
10.2 Barcode Scanner for Patient Identification
Patient data is currently entered manually via keyboard on the touchscreen, which is slow and
error-prone in clinical settings. Integrating a USB or GPIO-connected barcode/QR scanner
would allow instant patient ID lookup by scanning a wristband or patient card, streamlining the
workflow significantly.
10.3 Data Sharing & Connectivity
The device currently stores all data locally. A wireless data-sharing mechanism is needed to
transmit session results (JSON, PNG, processed video) to a hospital information system, cloud
dashboard, or clinician workstation. Options include:
• HTTPS REST API – POST session JSON to a cloud endpoint after each recording
• MQTT broker – lightweight publish/subscribe for real-time data streaming
• Bluetooth BLE – for proximity-based transfer to a tablet or mobile device
• Secure FTP / SFTP – for batch transfer of session files to a central server
The modular architecture of the codebase (analysis_pipeline returning a result dict) makes it
straightforward to add an upload step as a post-analysis action.
10.4 NPi Algorithm Implementation
The Neurological Pupil index (NPi), used clinically to quantify pupil reactivity on a 0–5 scale, is
currently displayed as N/A. Implementing the NPi formula (based on a logistic model
incorporating constriction velocity, amplitude, and latency) would significantly enhance the
clinical value of the device.
10.5 Additional Enhancements
• Bilateral simultaneous recording – capture both eyes in a single session
• Anomaly detection – flag recordings where PLR waveform is absent or abnormal
• PDF report generation – auto-generate a printable clinical report per session
• OTA firmware updates – allow software updates to deployed devices over the network
Confidential – Collateral Medical Pvt. Ltd. Page 13 of 14
Pupillometer ID-300 | Compiled Research & Technical Documentation | Collateral Medical Pvt. Ltd.
11. References & Literature
The following literature informed the design and algorithm choices of the Pupillometer ID-300:
• Larson MD, Muhiudeen I. Infrared pupillometry. J Clin Monit. 1995;11(3):221-228.
• Chen JW, Gombart ZJ, Rogers S, et al. Pupillary reactivity as an early indicator of
increased intracranial pressure. Surg Neurol Int. 2011;2:82.
• Meeker M, Du R, Bacchetti P, et al. Pupil examination: validity and clinical utility of an
automated pupillometer. J Neurosci Nurs. 2005;37(1):34-40.
• Bradski G. The OpenCV Library. Dr. Dobb's Journal of Software Tools. 2000.
• Fitzgibbon A, Pilu M, Fisher RB. Direct least square fitting of ellipses. IEEE TPAMI.
1999;21(5):476-480.
• NeurOptics NPi-300 Pupillometer – Clinical Reference Guide. NeurOptics Inc., 2020.
— End of Document —
Confidential – Collateral Medical Pvt. Ltd. Page 14 of 14