A method for training a machine learning model for automatically detecting abnormal pupil behaviour based on assessing pupil reactivity invulnerable to external light conditions, a computer program comprising instructions thereof, and a system implementing the model
A machine learning model addresses the challenge of assessing pupil reactivity in varying light conditions by calculating a light-invariant PuRe score, improving the reliability and objectivity of pupillary light response measurements.
Patent Information
- Application Number
- PCT/EP2024/088428
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-22
- Filing Date
- 2024-12-23
- Publication Date
- 2025-06-26
AI Technical Summary
Current methods for assessing pupil reactivity are subjective and prone to error, especially in varying external light conditions, which affects the reliability of pupillary light response measurements.
A machine learning model is trained using a dataset of pupillary light reaction measurements from various external light conditions to calculate a light-corrected pupillometry score, known as PuRe, which is invariant to external light conditions.
The PuRe score provides a reliable and objective assessment of pupil reactivity, reducing variability due to external light and improving the separation between reactive and non-reactive pupils, thus enhancing diagnostic accuracy.
Smart Images

Figure EP2024088428_26062025_PF_FP_ABST
Abstract
Description
[0001] A method for training a machine learning model for automatically detecting abnormal pupil behaviour based on assessing pupil reactivity invulnerable to external light conditions, a computer program comprising instructions thereof, and a system implementing the model Technical field The present disclosure relates to the field of medicine, ophthalmology, neuro-ophthalmology with a subfield of pupillometry. The subject matter of the invention relates to a method of assessing pupil reactivity insusceptible to external illumination conditions, a method of performing pupil reactivity measurements and a method for assessing neurological health of a subject. Prior art Typical pupillary evaluation during the medical examination involves the assessment of two components —pupil size and pupil reactivity to light. Pupil size is traditionally measured using a pupil gauge to estimate the diameter in millimetres of the pupil at rest state before any light is shone into the eye. Manual measurement is subjective and prone to subjective error of a medical personnel performing the examination. Pupil light reactivity is evaluated by shining a light into a patient's eye to make the pupil constrict in reaction to the light. The pupil should dilate (expand its diameter) again when the light is moved away or turned off. One of the most frequently used oculography index is so-called Nuerological Pupil IndexTM(or simply NPi) : [https: / / en.wikipedia.org / wiki / Neurological_pupil_index]. The pupil's reaction is numerically graded, typically using a range spanning the range 1-3 i.e. reactive, sluggish, non-reactive (these terms are subjective and applied without a standard clinical protocol or definition) or 0-4.9 as in a case of NPi. In the paper, Ghauri, Muhammad S., et al. [Evaluating the reliability of neurological pupillary index as a prognostic measurement of neurological function in critical care patients." Cureus 14.9 (2022)] authors study the use of the Neurological Pupil index (NPi) in a clinical context. It found a statistically significant correlation between NPi and established neurological assessment tools like the Glasgow Coma Scale (GCS) and the modified Rankin Scale (mRS). Despite limitations such as the study's single-institutional nature, the paper suggests NPi can be a useful prognostic tool in neurocritical care settings. As elucidated in scientific article published [Ong C, Hutch M, Smirnakis S. The Effect of Ambient Light Conditions on Quantitative Pupillometry. Neurocrit Care. 2019 Apr;30(2):316-321. doi: 10.1007 / s12028-018-0607-8. PMID: 30218349.] automated devices collecting quantitative measurements of pupil size and reactivity are increasingly used for critically ill patients with neurological disease. The data presented in the publication show that ambient light levels impact pupil reaction parameters in both healthy and critically ill subjects and recommend that medical and clinical practitioners should standardize external lighting conditions in the medical premises to maximize measurement reliability. In scientific publication [W. Taylor et al., entitled "Quantitative pupillometry, a new technology: normative data and preliminary observations in patients with acute head injury. Technical note.", JOURNAL OF NEUROSURGERY, 2003, (200301), vol. 98, no. 1] authors conclude that quantitative pupillometry is a reliable and safe method that provides detailed and accurate information regarding patterns of pupillary responsiveness. The research data presented in that article is based on the assessment of several canonical parameters used in the pupillometry such as maximum aperture (INIT), minimum aperture (END), reduction in pupil diameter (DELTA), constriction velocity (MCV) and pupil reaction latency (LAT). The publication doesn’t discuss the effect of ambient light level on the pupillary responsiveness as well as does not suggest any means to assess pupil reactivity measured under different illumination conditions. A prior art patent document [WO2009137614A2] describes a use of scalar value to assess neurological status of a patient. It describes a methods, systems and devices for determining whether a patient has an abnormally high level of intracranial pressure. The method includes a pupillometer to obtain pupillary response data from the patient. The method further includes a data analysis system comprising a microprocessor that is in communication with the pupillometer. The microprocessor includes an algorithm that converts the pupillary response data to a scalar value that is indicative of the patient's level of intracranial pressure. The microprocessor can be a stand-alone computer connected to the pupillometer or it can be integral with the pupillometer. The scalar value can be represented by a numerical value, graphical depiction, colour, sound, or other visual or audio means that indicates a value. The scalar value indicates that the patient's pupillary response characteristics is within a normal range, an abnormal range, or that the pupil is nonresponsive. Another prior art patent document [WO2023059325A1] entitled “Methods, systems, programs and devices to predict patient outcome using differential in pupillary index”, describes a method of predicting the outcome of a hospitalized acute brain injury patient. The method includes using a pupilometer to take paired pupillary measurements of a left and right eye of the patient; using the pupilometer to determine neurological pupil index (NPI) of the left eye and display it on a display of the pupillometer; using the pupillometer to determine NPI of the right eye and display it on the display of the pupillometer; calculating a differential between NPI of the left eye and NPI of the right eye and display said NPI differential on the display of the pupillometer; and predicting an unfavourable health or neurological outcome if the NPIs of the left and right eyes indicate normal pupillary responses for each eye but the NPI differential meets or exceeds a given threshold value. Another patent document [US20190159671] describes a computer program for performing a method, that involves recording images of a response of a left pupil to a stimulus thereby resulting in a first set of sequential images; recording images of a response of a right pupil to the same stimulus at the same time as the first images were recorded, thereby resulting in a second set of sequential images. Next, displaying simultaneously on the display the first and the second set of images, wherein the two sets of images are synchronized, and wherein a centre of the left pupil of each image from the first set of sequential images is aligned with a centre of the right pupil from the second set of sequential images on the display. Purpose of an invention is to diagnose anisocoria and asymmetry in pupillary response, because in some cases it might be symptoms of very serious and immediately life threatening conditions, hence it is important for medical practitioners to have tools for easy, quick and convenient ways to accurately detect, measure, and view in real-time differences in pupillary size and pupillary reaction to stimulus between the right and left pupils. Problem from the state of the art Clinicians and medical personnel routinely check the pupils of critically injured and ill patients to monitor their neurological status. However, manual pupil measurements (performed using a handheld penlight or ophthalmoscope) have been shown to be subjective, inaccurate, and not repeatable or consistent. Automated pupillometers are used to assess a variety of objective statical and dynamical pupillary light response variables including pupil size, pupil constriction velocity, constriction latency, and dilation velocity. The problem from the state of the art is the reliable assessment of pupil reactivity especially in a wide range of external light conditions which affect the pupillary light response variables. Another problem is a construction of a pupil reactivity score (or index) which could reliably assess the reactivity of the pupil in highly varying external light condition. Solution to the problem In order to solve the problem of pupil reactivity score (or index) invulnerable to external light conditions a set of light corrected pupillometry parameters selected from the group of INIT, END, CAMP, ACV, ADV, MCV, PDV, DELTA, FIN, LAT, FT75, DAMP (defined in the glossary) is calculated using the cohort average values as well as light corrected values based on the predictive models and light sensor settings readout from a diagnostic device. The predictive models are optimized with a use of dataset D1 consisting of pupillary light reaction measurements performed on the plurality of subjects for various external light conditions. Afterwards a reactivity score (or index) is constructed as a machine learning model realised in the form of linear combination of numeric constant and light corrected parameters with a particular set of coefficient values optimized (model training) to ensure external light invariance as well as high discriminability between two groups in dataset D2 consisting e.g. of the measurements of reactive and non-reactive pupils. Glossary and definitions of terms known in the state of the art and used in the patent specification Throughout the present specification (both above and below the glossary section), the terms used have the following meanings described in the definitions below: The term “PuRe” or “Pupil Reactivity score” is an index describing a pupil reactivity in a numerical scale within a predefined numerical range, preferably in the range from 0 to 5. In the priority documents [EP23461699.3, and EP23461698.5, and as well as US provisional application US 63 / 614,064] filed on 22 December 2023 proposed pupillometric index was so-called NPx (Neuro Pupillary Index), that is currently fully renamed into PuRe score and the subject matter presented in priority documents as NPx index is fully covered by here PuRe score. The term “pupillary light response” or “pupillary light reflex” is an automatic physiological response which optimizes light reaching the retina by controlling the pupil diameter in response to the intensity (luminance) of light that falls on the retinal ganglion cells of the retina. The contraction or dilation of the pupil is realized using the iris sphincter. The term “pupillogram” denotes a characteristic curve reflecting pupillary light response which is created by plotting time against the pupil diameter before, during and after light stimulus. The term “INIT” is a pupillometric parameter specifying the pupil diameter before the light stimulation. The parameter is usually expressed in millimetres. The term “END” is a pupillometric parameter specyfing the smallest pupil diameter observed during the light stimulation. The parameter is usually expressed in millimetres. The term “CAMP” is a pupillometric parameter describing the amplitude of pupil constriction induced by the stimulus light. The parameter is usually expressed in millimetres. The term "ACV” is a pupillometric parameter describing the average velocity of pupil constriction induced by the stimulus light. The parameter is usually expressed in millimetres / second. The term "ADV” is a pupillometric parameter describing the average velocity of pupil dilation induced by turning off the stimulus light. The parameter is usually expressed in millimetres / second. The term "MCV” is a pupillometric parameter describing the maximum velocity of pupil constriction induced by the stimulus light. The parameter is usually expressed in millimetres / second. The term "PDV” is a pupillometric parameter describing the maximal (peak) velocity of pupil dilation induced by turning off the stimulus light. The parameter is usually expressed in millimetres / second. The term “DELTA” is a pupillometric parameter describing the relative constriction of the pupil. It is defined as CAMP / INIT. The parameter dimensionless and is usually expressed in percents. The term “FIN” is a pupillometric parameter specifying the pupil diameter which is asymptotically reached by the pupil after the light stimulus is over. The term “LAT” is a pupillometric parameter describing the time interval between the onset of light stimulation and the commencement of pupil constriction. The term “FT75” is a pupillometric parameter describing a time interval required to recuperate 75% of the constriction amplitude post constriction termination. The term “DAMP” is a pupillometric parameter describing the amplitude of pupil dilation after the stimulus light is turned off. The parameter is usually expressed in millimetres and might be calculated using a formula DAMP = FIN-END. The term “diagnostic device” or alternatively “measurement device” means electronic device equipped with a central processing unit, a memory unit, a light sensor (camera chip, photodiode, photoreceptor etc), a light source and optical imaging system with adjustable focusing distance, which can capture an image. This includes a dedicated stand-alone device, a digital camera, portable video device, or a smartphone equipped with one or several cameras. The said optical imaging system with adjustable focusing distance contains a plurality of lenses. The term “visible light” means a part of electromagnetic light spectrum which can be detected by the eye of the measured subject such as human or animal and thus induce pupillary light response. The term "exposure time - τ" means the setting of light sensor which defines the exposition time τ of each video frame. Usually, exposure time values ranging from below milliseconds up to tens of milliseconds are used. The term “dataset D1” denotes a set of data consisting of pupillary light reaction measurements performed using a diagnostic device on the cohort of plurality of subjects for various external light conditions spanning the expected range of further external light invulnerability of reactivity assessment. The term “dataset D2” denotes a set of data consisting of pupillary light reaction measurements divided into a pair of labelled groups i.e. the first group (control group) and the second group (experimental group). As an example it might consist of data consisting of pupillary light reaction measurements performed on the plurality of healthy subjects, with each subject subjected to the administration of drug reducing pupil reactivity (such as tropicamide or pilocarpine) and the reactivity measurements are performed before (these measurements are labelled as “pre”) and after the drug administration (these measurements are labelled as “post”). The term “exposure value” also referred to as EV is an indicator of camera settings, corresponding to actual combination of exposure time, aperture size and ISO setting such that all combinations of aforementioned parameters that yield the same exposure conditions result in the same EV of the captured image. The term exposure value is of a broad use in photography. The term "external light" or “ambient light” means total light illuminating the pupil independently from stimulus light source. Sources of the external light might include room lighting, day light or any other source which is not controlled by the diagnostic device. Non-controlled environmental conditions such as changing intensity of external light affects the initial pupil diameter and in consequence increases the variability of pupillary light response in visible-light pupillometry performed by a diagnostic device. The term “ISOtau” is an aggregated parameter read out from the camera settings of light sensor which corresponds to the external light illuminating the subject pupil. The parameter ISOtau is calculated by multiplying exposure value parameter ISO and exposure time parameter τ. The term “focusing element” means a moveable plurality of lenses (or lens assembly) or a single lens which is a part of camera imaging system and is responsible for setting the focusing distance of the camera. The term "ISO" means the gain setting of light sensor which modifies its sensitivity to capturing light. Higher ISO values correspond to high sensor sensitivity allowing for video capture in low external light conditions, whereas lower ISO values correspond to low sensor sensitivity allowing for video capture in high external light conditions. The parameter is a digital equivalent of an exposure index / score used for the characterisation in an analogy to photographic film. The term "light sensor" means a CCD image sensor, EMCCD image sensor, CMOS image sensor, sCMOS sensor containing an array of light sensitive pixels used for creating digital images or other optoelectronic device such as photodiode or photoresistor. The term “PLR” means Pupillary Light Reflex or photo-pupillary reflex is a light illumination that controls the diameter of the pupil, in response to the intensity (luminance) of light that falls on the retinal ganglion cells of the retina in the back of the eye, thereby assisting in adaptation of vision to various levels of lightness / darkness. The term “region of interest” is a selected part of an image which provides a basis for the exposure setting algorithm. The term "stimulus light" means a light emitted from a visible light source that is generated by the diagnostic device in order to induce pupillary light reaction. A level of a stimulus light is controlled by the diagnostic device. The term “sigmoid function” means any bounded, real function that is defined for all real input values and has a non-negative derivative at each point and exactly one inflection point. An example being logistic function, hyperbolic tangent, error function, spline or piecewise linear function. The term "^^^^^^^^" denotes a set of raw pupillometry parameters extracted from measured pupillograms, a set of measured pupillometry parameters ^^^^^^^^comprising ^^^^^^^^1 = ^^^^^^^^, ^^2^^^^^^= ^^^^^^, ^^^^^^^^3 = ^^^^^^^^, ^^ ^^^^^^4 = ^^^^^^, ^^5^^^^^^= ADV, ^^^^^^^^6 = ^^^^^^, ^^ ^^^^^^7 = ^^^^^^, ^^ ^^^^^^8 = ^^^^^^^^^^,^^^^^^^^9 = ^^^^^^, ^^ ^^^^^^10 = ^^^^^^, ^^ ^^^^^^11 = ^^^^75 , ^^ ^^^^^^12 = ^^^^^^^^.The term "^^^^^^^^^^" denotes a set of light corrected parameter values that are calculated using a method according to the invention. The term "^^^^^^^^^^" denotes a set of models predicted parameters, each model responsible for predicting a behaviour of a single pupillometric parameter. The term “static pupillometric parameters” or “static parameters” denotes a subset of parameters including: INIT, END, CAMP, DELTA, FIN, LAT, FT75, DAMP. The term “dynamic pupillometric parametes” or “dynamic parameters” denotes a velocity based subset of parameters including: PDV, ACV, MCV, ADV. Summary of the invention An invention relates to a method for training a machine learning model for automatically detecting abnormal pupil behaviour through assigning a numerical scale to pupil reactivity, comprising the following steps: (a) a pupillary light reaction measurements are performed using a diagnostic device on the cohort of plurality of subjects under various external light conditions spanning the expected range of further external light invulnerability forming a first dataset (D1), similarly pupillary light reaction measurements are performed on the cohort of plurality of subjects with the measurements divided into a pair of labelled groups, with a first group of measurements performed before administration of drug reducing pupil reactivity, such as tropicamide or pilocarpine, and the second group of measurements performed after the drug administration, both forming a dataset (D2), (b) based on the measured pupillograms, a pupillometry parameter ^^^^^^^^, preferably at least one parameter selected from a set of measured pupillometry parameters comprising: ^^^^^^^^1 = ^^^^^^^^, maximum aperture, ^^ ^^^^^^2 = ^^^^^^, minimum aperture, ^^3^^^^^^= ^^^^^^^^, amplitude of pupil constriction, ^^^^^^^^4 = ^^^^^^, average velocity of pupilconstriction, ^^5^^^^^^= ADV, average velocity of pupil dilation, ^^^^^^^^6 = ^^^^^^, constrictionvelocity, ^^^^^^^^ ^7 = ^^^^^^, maximal (peak) velocity of pupil dilation, ^^ ^^^^^8 = ^^^^^^^^^^,reduction in pupil diameter, ^^^^^^^^9 = ^^^^^^, pupil diameter which is asymptotically reachedby the pupil after the light stimulus is over, ^^^^^^^^10 = ^^^^^^, pupil reaction latency^^1^1^^^^^= ^^^^75 , time interval required to recuperate 75% of the constriction amplitude post constriction termination, ^^^^^^^^12 = ^^^^^^^^, is extracted from each measurement; (k) a light invariant reactivity score PuRe is calculated by feeding a sigmoid function with RI such that the value of PuRe, is within a predefined numerical range, preferably in the range from 0 to 5. Preferably, it further comprises the steps, performed after step (b) and before step (k): (c) parameters of light sensor reflecting external light intensity such as the sensitivity ISO and / or exposure time τ are read out from a camera forming a single parameter ISOtau = ISO∙τ; (d) for each pupillometry parameter ^^^^selected in step (b), except for ^^^^^^^^1 = ^^^^^^^^, itscohort average value is calculated based on the dataset D1, referred as ^^ ^^^^^^ 1 ; (e) for each pupillometry parameter ^^^^^^^^^^except for ^^1 = ^^^^^^^^, multiple predictivemodels are created, wherein each model is a linear combination of the predictors ISOtau, INIT, their logarithms, squares, cubes, reciprocals as well as the pairwise products of before-mentioned and / or image intensity in the video recording, giving in total N predictors of a model, the predictive models are constructed using a binary feature inclusion with a total number of models equal 2N; (f) the selection of the best model from all created models in step (e) predicting a pupillometry parameter ^^^^relies on selecting the model with the lowest Bayesian information criterion (BIC) or similar method of model selection, with the best model yielding the predicted value of the parameter ^^ ^^^^^^^^ ^^solely based on the predictors enlisted in the step (e); (g) a set of pre-corrected pupillometry parameters is calculated based on the formula ^^ ^^^^^^−^^^^^^^^= ^^ ^^^^^^ − ^^^^^^^^^^+ ^^^^^^^^ , where ^^^^^^ ^^ ^^ ^^ ^^^^^^is a cohort average value calculated in the step (d), ^^^^^^^^^^ ^^is a value predicted by the best model selected in the step (f), while ^^^^^^^^^^is a parameter value extracted directly from the pupillary light reaction measurement; (h) a set of light corrected pupillometry parameters ^^^^^^^^^^^^^^^^−^^^^^^^^ ^^ = ^^^^^^ + (1 − ^^)^^^^^^^^^^is calculated, where ^^ ^^ [0,1] , ^^ ^^^^^^^^ ^^is a value predicted by step (f), while ^^^^^^^^^^being a parameter value extracted directly from the pupillary light reaction measurement; (i) a pupil reactivity numerical scale invulnerable to external light conditions is constructed as a linear combination of numerical constant, and the product of light corrected pupillometry parameters i.e. ^^^^ = ^^ + ∑^^^^^^^^^^^^^^^^^^ ^^^^^^^^, where ^^^^ = ^^^^^^^^^^denotes measured INIT, ^^2^^^^^^^^denotes light ^^3^^^^^^^^denotes light corrected CAMP, ^^4^^^^^^^^denotes light corrected ACV, ^^5^^^^^^^^denotes light corrected ADV, ^^6^^^^^^^^denotes light corrected MCV, ^^7^^^^^^^^denotes light corrected PDV, ^^8^^^^^^^^denotes light corrected DELTA, ^^9^^^^^^^^denotes light corrected FIN, ^^1^^0^^^^^^denotes light corrected LAT, ^^1^^1^^^^^^denotes light corrected FT75, ^^1^^2^^^^^^denotes light corrected DAMP, whereas C and Ai are real-valued constants; (j) to find a set of coefficients C and Aia D2 dataset is used with a particular set of coefficient values found using a logistic regression fitted to the data with elastic-net regularization and additional light invariance regularisation; Preferably, in the steps (b) and optionally steps (d)-(i) at least one static pupillometric parameter selected from parameters: INIT, END, CAMP, DELTA, FIN, LAT, FT75, DAMP are only considered, and none of the dynamic parameters are used. Preferably, in the steps (b) and optionally steps (d)-(i) at least one dynamic pupillometric parameter selected from parameters: PDV, ACV, MCV, ADV are only considered, and none of the static parameters are used. Preferably, in step (i) ^^^^^^^^^^parameters are used instead of ^^^^^^^^^^^^. It means that in said step (i) RIis calculated as ^^^^ = ^^ + ∑ ^^ ^^^^^^^ ^^ ^^ ^^^. Preferably, wherein the diagnostic device is a smartphone. Preferably, wherein datasets D1 and D2 are supplemented with additional data after each measurement result in order to retrain predictive models ^^ ^^^^^^^^ ^^mentioned in claim 1 steps (e) and (f) as well as improve a set of coefficients mentioned in claim 1 step (j). Preferably, in a step (i) the parameter values are in the range ^^ ^^ [−50,50] and ^^^^^^ [−10,10]. Preferably, in addition to the datasets D1 and D2, other medical data relating to said subjects is used for training said machine learning model, wherein said other medical data preferably includes one or more of the following: Glasgow Coma Scale (GCS) scores, modified Rankin Scale (mRS) scores, National Institutes of Health Stroke Scale (NIHSS) scores, Sequential Organ Failure Assessment (SOFA) scores, Acute Physiology and Chronic Health Evaluation (APACHE) scores, Richmond Agitation-Sedation Scale (RASS) scores, neurological assessment results, intracranial pressure (ICP) measurements, cerebral perfusion pressure (CPP) values, electroencephalography (EEG) recordings, magnetic resonance imaging (MRI) scans, functional MRI (fMRI) data, computed tomography (CT) scans, cerebral blood flow measurements, cerebral oxygen saturation levels, neurotransmitter levels, biomarkers of brain injury, medical history of neurological conditions, administered medications affecting pupillary response, concurrent vital signs during pupillary measurements, demographic data including age and gender, time elapsed since injury or onset of symptoms, diagnoses of conditions affecting autonomic nervous system, previous pupillary response measurements, and clinical outcome data. Preferably, invariant reactivity score PuRe depend on more than one pupillometry parameter ^^^^^^^^. Preferably, the ambient / external light estimations is measured using external light sensor, such as luxometer, phototransistors, photoresistors and photodiodes, or ambient light measurements rely on video / camera settings. Preferably, the pupillary reactivity score PuRe relies on healthy normative data PLR parameters measured on the cohort of healthy people measured in varying ambient light conditions. Preferably, the pupillary reactivity score PuRe assumes that no change in pupil size during the flash stimulation corresponds to PuRe equal to minimal score, preferably 0. Preferably, the pupillary reactivity score PuRe changes monotonically and sensitively with PLR parameters for small reactivities and saturates at PuRe equal to a maximal score, preferably 5, for PLR parameters for the upper tail of the distribution of healthy individuals. Preferably, the pupillary reactivity score PuRe sensitivity is tuned by putting a predefined threshold of abnormal PuRe values such as PuRe = 3 with respect to the deviation from a mean for the healthy population. Another invention is related to a method for assessing pupillary reactivity while compensating for ambient light variations, comprising: performing pupillary light reflex measurements under varying ambient light conditions on a plurality of subjects to create at least one reference dataset; estimating ambient illumination levels during said measurements through at least one of: analysing video frames captured during pupillary measurements, reading device or camera settings including exposure time and sensitivity, performing software-based scene analysis, or using dedicated light sensors; extracting pupillometry parameters from said measurements, said parameters characterizing pupillary response dynamics; applying a computational model that: compensates for variations in ambient illumination based on said ambient illumination level estimates, establishes normative pupillary response parameters from said reference dataset, accounts for non-reactive and abnormally reactive pupillary conditions through analysis of pupillary response distributions, and generates a standardized pupillary reactivity index through either trained machine learning model inference or mathematical scaling functions; wherein said pupillary reactivity index maintains quantitative consistency and clinical discriminative power across the predefined range of ambient light conditions while preserving sensitivity to abnormal pupillary responses or lack of pupillary response, equals unreactive pupil. Preferably, wherein said method includes training a mathematical or machine learning model for automatically diagnosing abnormal pupil behaviour by assigning a numerical scale to pupil reactivity through acquiring measurements of pupillary light reflex from a diverse cohort of subjects under various ambient lighting conditions; optionally administering pharmacological agents known to induce alterations in pupil reactivity to a subset of subjects to generate data representing abnormal responses; extracting at least one pupillometry parameter from each measurement, including static or dynamic parameters comprising initial pupil diameter, minimum pupil diameter, amplitude of constriction, velocities, latencies, and recovery times; generating an ambient light estimate for each measurement instance using any combination of hardware- or software-based methods; building multiple predictive models correlating pupillometry parameters with ambient light estimates and selecting at least one best-performing model based on model selection criteria including Bayesian information criterion, cross-validation performance, or similar metrics; normalizing pupillometry parameters relative to said best-performing model to obtain light-corrected parameters; applying a machine learning approach with additional regularization terms that encourage invariance to lighting variations; and obtaining final coefficients in a mathematical or learned function that define the numerical pupillary reactivity score, wherein the score maintains robust invariance across ambient lighting conditions, exhibits continuity and monotonicity with respect to key pupillometry parameters, and saturates at clinically relevant maximum reactivity values. Preferably, the pupil reactivity score is generated using a model constructed from healthy subject pupillary measurements spanning ambient light illumination intensities from 0 to 10,000 lux, wherein said model defines normative response parameters under both such range of ambient light conditions, extrapolates these parameters for non-reactive or partially reactive subjects, and maintains consistency in the pupil reactivity score while preserving clinical sensitivity across the operational illumination range, said model being selected from any combination of parametric, non-parametric, statistical, or machine learning frameworks, including but not limited to linear, polynomial, spline-based, kernel-based, distribution-free, or tree-based methods. Preferably, the model employs one or more saturation functions to map pupillary response parameters to a standardized numerical scale, each saturation function satisfying zero response for non-reactive pupils, strictly monotonic increase with increasing pupillary reactivity, and saturation at a predefined maximum value corresponding to healthy or near-maximal reactivity, wherein said saturation functions are selected from exponential, logistic, hyperbolic tangent, logarithmic, power-law, piecewise, rational, splines, neural networks, or any other continuous or piecewise-continuous implementations, with parameters dynamically adapting to reflect ambient light variations across the operational illumination range. Preferably, modelling of normal population data to derive pupillary response parameters under varying ambient light comprises parametric approaches, including but not limited to linear or polynomial relationships of any order, piecewise polynomials, exponential or logarithmic forms, rational functions, or any combination thereof; non-parametric or data-driven methods, such as kernel density estimation, distribution-free quantile approaches, tree-based ensembles, neural networks, and regression splines; and statistical or machine learning fitting procedures that incorporate measures of variance, confidence intervals, or ensemble averaging, ensuring the model robustly covers typical pupillary responses over the entire operational illumination range. Preferably, ambient light conditions are estimated by analysing video frames captured before, during, or after pupillary light reflex stimulation, using metrics including root mean square intensity, histogram moments, colour-channel analysis, frame differencing, temporal filtering, spectral transforms, or scene-segmentation techniques; camera sensor parameters including exposure time, ISO, aperture, or gain; hardware sensor readings such as photodiodes or phototransistors; and hybrid or machine learning models that integrate multiple input features for improved accuracy, wherein flash stimulus energy consistency facilitates ambient light calibration by isolating the impact of the stimulus from the baseline illumination level. Preferably, threshold determination for abnormal pupil reactivity is performed using parametric statistical models; non-parametric approaches that derive abnormality cutoffs from empirical population percentiles, bootstrapped confidence intervals, or distribution-free quantiles; machine learning classification or anomaly detection algorithms; or any combination thereof, ensuring that thresholds automatically adjust according to ambient light variations and subject-specific pupillary response distributions. Preferably, model parameters, including but not limited to scaling constants, exponents, polynomial coefficients, spline breakpoints, neural network weights, or regularization hyperparameters, are optimized to maintain a coefficient of variation in the pupil reactivity score below 20% for healthy subjects across the operational illumination range, mean score variation of under 0.5 units from moderate to extreme illumination conditions in normative data, and high classification accuracy for identifying abnormal reactivity, wherein optimization is performed by any combination of variance minimization, cross-validation, Bayesian model selection, or direct clinical outcome correlation, ensuring the resulting pupil reactivity score is robust to changes in ambient light and individual variability. The invention comprises also a computer program comprising instructions which, when the program is executed on a computer, cause the computer to carry out the method according to the present invention. The invention comprises also a computer-readable medium comprising such a computer program. The invention comprises also a system implementing the machine learning model as set out above for automatically detecting abnormal pupil behaviour based on assessing a pupil reactivity of a patient by assigning a numerical scale, said system comprising a memory, a processor, a camera, a light source, a light sensor and a digital display, wherein the system is configured and programmed for assessing pupil reactivity of the patient by the following steps: (a) physical parameters of light sensor including the sensitivity ISO and / or exposure time τ is read out from a camera forming a single parameter ISOtau = ISO*τ; (b) a pupillary light reaction measurement is performed using a diagnostic device on a single subject (patient); (c) based on the measured pupillogram, at least one parameter selected from a set of measured pupillometry parameters ^^^^^^^^comprising ^^^^^^^^1 = ^^^^^^^^, ^^ ^^^^^^ ^^^^^^2 = ^^^^^^, ^^3 = ^^^^^^^^,^^^^^^^^ ^^^^^^ ^^^^^^ ^^^^^4 = ^^^^^^, ^^5^^^^^^= ADV, ^^6 = ^^^^^^, ^^7 = ^^^^^^, ^^ ^ ^^^^^^8 = ^^^^^^^^^^, ^^9 = ^^^^^^, ^^1^0^^^^^= ^^^^^^, ^^^^^^^^11 = ^^^^75 , ^^ ^^^^^^12 = ^^^^^^^^, is extracted from each measurement;, is extracted fromthe measurement; (d) a set of light corrected pupillometry parameters ^^^^^^^^^^^^is retrieved based on the real time physical measurements and measured pupillometry parameters ^^^^^^^^^^as well as a set of best predictive models; (e) a pupil reactivity score invulnerable to external light conditions is calculated as a linear combination of numerical constant, and light corrected pupillometry parameters, i.e. ^^^^ = ^^ + ∑^^^^^^^^^^^^^^^^^^ ^^^^^^^^, wherein ^^1 = ^^1^^^^^^denotes measured INIT, ^^2^^^^^^^^denotes light corrected END, ^^3^^^^^^^^denotes light corrected CAMP, ^^4^^^^^^^^denotes light corrected ACV, ^^5^^^^^^^^denotes light corrected ADV, ^^6^^^^^^^^denotes light corrected MCV, ^^7^^^^^^^^denotes light corrected PDV, ^^8^^^^^^^^denotes light corrected DELTA and ^^9^^^^^^^^denotes light corrected FIN, ^^1^^0^^^^^^denotes light corrected LAT, ^^1^^1^^^^^^denotes light corrected FT75, ^^1^^2^^^^^^denotes light corrected DAMP, whereas C and Aiare real-valued constants resulting from the machine learning model training; (f) a light invariant reactivity score PuRe is calculated by feeding a sigmoid function with RI such that the value of PuRe is within a predefined numerical range, preferably in the range from 0 to 5, and optionally displaying the value of PuRe on the display; (g) based on the PuRe threshold the measured pupil is classified as reactive or non-reactive and the device informs the operator on the non-reactivity of the pupil by activating sound and / or visual alarm on the diagnostic device. referably, in step (e) ^^^^^^^^^^parameters are used instead of ^^^^^^^^^^^^. It means that in said step (e) RI is calculated as ^^^^ = ^^ + ∑^^^^^^ ^^ ^^^^^^^^. Preferably, the parameter values are in the range ^^ ^^ [−50,50] and ^^^^^^ [−10,10]. Another aspect of the invention is related to a computer program comprising instructions which, when the program is executed in the system as set out above, enables the system to automatically diagnose condition of a patient in a numerical scale from 0 to 5 by carrying out the method steps specified above. Yet another aspect of the invention is related to a computer-readable medium comprising such a computer program. The invention is related also to a method for generating the Pupil Reactivity score, PuRe, using the dataset D2 acquired during pharmacological intervention, comprising: o creating a plurality of light-invariant pupillometry parameters; o acquiring the dataset D1 under controlled light conditions, involving: a. Measuring ambient light intensity using a calibrated sensor; b. Recording pupillary light reflex, PLR, responses in subjects under varying light conditions; c. Altering light conditions systematically to span a predetermined range of intensities; d. Repeating measurements across a diverse cohort of subjects to ensure robust data representation; e. Developing a predictive model that estimates the pupillary light reflex, PLR, parameters, utilizing functions of measured light intensity as predictors; o conducting ambient light measurements and pupillary light reflex, PLR, assessments as described in any other method related inventions; o administering a pharmacologically active agent known to influence pupillary light reflex, PLR, to subjects; o repeating the measurement process under varying light conditions and across different subjects post-administration to capture drug-induced pupillary light reflex, PLR, variations; o creating a predictive model that accounts for the drug's effect on pupillary light reflex, PLR, using functions of light intensity and light-corrected pupillary light reflex, PLR, parameters as predictors. Last but not least, the invention covers also a method for measuring the Pupil Reactivity score, PuRe, by measuring ambient light conditions pupillary light reflex, PLR, responses, and utilizing light-corrected parameters to calculate the score, followed by its display on a mobile device. Advantageous effects of the invention The invention according to the present patent specification has numerous advantages over the existing solutions. The use of pupil reactivity assessment according to the machine learning approach implemented in the invention is likely to be more useful than the state-of-the-art thanks to its significantly reduced external light variability. This allows for a more reliable separation between two patient groups based on their pupil reactivity measured within uncontrolled external light conditions. Moreover, a machine learning approach allows for constantly improving the precision of reactivity assessment and group separation by expanding the training datasets (D1 and D2). Widespread adoption of disclosed light-corrected pupil reactivity score is an important step towards the standardization of PLR measurements performed across clinics and research groups. Advantageously, the present patent documentation discloses a full mathematical apparatus used for a practical application of Pupil Reactivity score(PuRe) on a mobile device such as smartphone. This machine-learning approach presents fully reliable tool that is useful for medics to quickly assess patient condition using numerical range. The invention can be simply implemented on any mobile device (including a smartphone), without need of buying any additional stand-alone medical hardware device (such as US9402542B2 or WO2010062400A1). Possible areas of application of the invention The present invention finds a primary use in a broad field of pupillometry, ophthalmology and neurological studies. A pupillary light response is nowadays studied within the context of other technological fields, such as medicine, automotive, virtual reality, gaming, education, drug development, quick drug detection in law enforcement etc. The visible light pupillometry is prone to the variability resulting from non-controlled light measurements conditions. The construction of light pupil reactivity invulnerable to external light might play a crucial role in increasing a sensitivity of prospective algorithms designed for neurodegenerative disorders diagnostics and tracking their progress. It might also find a use in ICU and critical care environment where the pupil reactivity assessment is a crucial part of the diagnostics and triage procedures. Preferred embodiments of the invention Now, the invention will be presented in more detail, in a preferred embodiment, with reference to the attached drawing in which: Fig.1 presents a general overview of method steps leading to the training of machine learning model for pupil reactivity assessment invulnerable to external light conditions. Fig.2 (a) presents the results of average pupillary light reaction measurements performed on the cohort of 9 healthy subjects (dataset D1) with external light conditions spanning the range of 5- 8600 lux. Uncertainty of the measurement is represented by a shaded area. (b) presents the results of average pupillary light reaction measurements performed on another cohort of 15 healthy subjects, with each subject subjected to the administration of tropicamide and the reactivity measurements are performed before and after the drug administration (dataset D2) Fig.3 presents extracted (canonical) pupillometry parameters INIT, END, FIN, MCV, PDV, CAMP from the measurements performed on the cohort of 9 healthy subjects with external light conditions spanning the range of 5-10000 lux Fig.4 presents the readout of light sensor parameters including the sensitivity ISO and exposure time τ for each of the measured subject and external light conditions spanning the range 5-10000 lux Fig.5 presents selected light corrected pupillometry parameters aggregated over the measured subjects compared with the uncorrected pupillometric parameters Fig.6 presents the values of pupil reactivity score (PuRe), invulnerable to external light conditions calculated on the cohort of 9 healthy subjects with external light conditions spanning the range of 5-10000 lux. In panel (a) the machine learning model leading to reactivity index / score has been trained according to embodiment 1, in panel (b) the machine learning model leading to reactivity index / score has been trained according to embodiment 2, in panel (c) the machine learning model leading to reactivity index / score has been trained according to embodiment 3 Fig.7 (a) presents a system implementing a method for automatically diagnosing abnormal pupil behaviour through assigning a numerical scale to pupil reactivity (b) presents a general idea of utilizing measured pupillogram for calculating external light invariant reactivity score (PuRe) by utilizing trained machine learning model. Fig.8 presents an application of reactivity index for the observation of reactivity loss, where each subject has been measured before (pre) and after (post) drug administration. Used reactivity index is based on the machine learning model trained according to embodiment 1. A threshold of the score PuRe = 3 allow for unambiguous classification of a measurement belonging either to the first or the second group. Fig.9 presents a sigmoid function mapping a pupil reactivity score (PuRe) invulnerable to external light conditions RI to the rescaled version of the PuRe score that spans the numerical range 0-5. Fig.10 illustrates the relationship between Pupil Light Reflex (PLR) Activity Score (PuRe), Delta (percent change in pupil size), and ambient light levels across three panels. In the panel A, PuRe is plotted against Delta for five different ambient light levels: 30 lux, 100 lux, 500 lux, 1000 lux, and 2000 lux, representing a range from very dark to very bright conditions. The curve for 30 lux corresponds to dim environments with baseline flash illumination, while light levels of 100 to 500 lux are typical of standard ICU or indoor settings, and 1000 to 2000 lux reflect very bright environments such as daylight. The data show that PuRe saturates at a maximum value of approximately 5, indicating a physiological limit to pupil constriction under bright conditions. In dark settings, such as at 30 lux, PuRe is highly sensitive to Delta, with a threshold response between 10% and 15%. Conversely, in brighter conditions, even small or negligible changes in Delta yield high PuRe values, as the pupil is already constricted to its minimum size. In the Panel B examines PuRe as a function of ambient light intensity, expressed on a log10 scale. Here, the population mean is adjusted to approximately 4.8 PuRe, with an abnormality threshold set at 3 PuRe, consistently spanning three orders of magnitude of ambient light. For simplicity, light levels below 10 lux are coerced to 10 lux and those above 10,000 lux are coerced to 10,000 lux, as these conditions exceed the reliable measurement range or are unsupported by the available data. The plot also includes hypothetical curves for fixed Delta values (1%, 5%, 10%, and 20%), which illustrate how different relative changes in pupil size would manifest across varying light conditions. These curves provide insight into how Delta impacts PuRe under controlled conditions, offering a useful tool for evaluating pupil responsiveness in diverse environments. In the panel C, Delta is plotted against ambient light (log10 scale), showing a simplified model of population variability. The solid blue line represents the mean Delta across light levels, while the dashed red lines indicate ±3σ bounds, assuming a normal distribution. This representation highlights the variability within the population and provides a statistical framework for assessing expected pupil response under different lighting conditions. Together, these panels illustrate how PuRe saturates in bright conditions, how it varies logarithmically with ambient light, and how population-level distributions can be used to model pupil dynamics. These findings have significant implications for designing robust calibration systems for pupillometry devices, ensuring consistent performance across a wide range of lighting environments. Fig.11 presents real measured data on the system, illustrating the relative change in pupil size under different ambient light level illuminations. The x-axis depicts the base-10 logarithm of the ambient light conditions, as measured by an external luxometer. This data is also utilized to train the model that evaluates ambient light conditions directly. In this semi-logarithmic scale, a linear trend is observed within the range of ambient light level conditions, similar to the trend depicted in Fig.10. Additionally, it is noticeable that the width of the distribution changes; specifically, there is reduced variability in the pupil response under brighter illumination. As these are empirical data representing mathematical conditions, we expect the system to perform similarly within and slightly beyond these conditions. This data serves the purpose of determining mean and standard deviation of the relative change Delta in different light conditions to determine PuRe in those ambient light conditions. Consequently, a simplified regression is applied to the mean versus light, as well as the standard deviation, along with its derivatives, such as the three-sigma range previously presented in Fig.10. Fig.12 presents data of distribution probability density of DELTA values (lux_measured_log = 1.0 ± 0.2). Its presents histogram distribution of DELTA values, as well as kernel density estimation (KDE) and Gaussian fit. This figure represents a histogram of the data for a given range of illumination intensity, derived from the data previously presented in Figure 11. This figure illustrates the histogram, the carrying intensity plot, and the Gaussian fitting applied to the histogram, which was used to estimate the variance and its derivatives, such as the sigma value and the width. These parameters were directly used to determine the abnormality threshold, as outlined in Figure 10. A similar procedure of deriving histograms for evenly distributed ranges of ambient light was applied across the entire range of ambient light conditions, spanning from an ambient light logarithm of 10.1 to 10.4, which corresponds to illumination intensities from 10 lux to 10,000 lux. From this, both the mean and the normality ranges were derived based on the sigma range values, further supporting the thresholds and observations previously presented in Fig.10. Fig.13 graphically compares true ambient light values with predictions from various models on the test set. Accurate estimation of ambient light conditions is crucial for calculating the pupil reactivity score. This estimation is achieved by analyzing video recordings of the pupil light reflex under LED or flashlight stimulation. Ambient light features are derived from both video frames and camera settings, such as exposure time and gain (ISO), collectively referred to as ISOtau. Key frames analyzed include those preceding the flash onset, the first frame during the flash, the last frame during the flash, and the first frame after the flash. Metrics used in the analysis range from simple RMS pixel intensity calculations to advanced statistical features, such as percentile levels and semantic content. Models are trained using camera settings, frame intensities, or a combination of both, employing methods like linear calibrations, non-linear “quad-fit” adjustments, decision trees, and random forests. Results demonstrate that ambient light can be accurately estimated using either camera settings or video frame features during flash transitions, as illustrated in Fig.13. Embodiments of the invention The following examples are included only to illustrate the invention and to explain particular aspects thereof, and not to limit it, and should not be interpreted as the entire range thereof which is defined in the appended patent claims. In the following embodiments, unless indicated otherwise, standard materials and methods used in the technical field were used or manufacturers' recommendations for specific devices, materials and methods were followed. It must be noted that, as used in the described embodiments and the appended claims, the singular forms "a," "an," and "the" include plural referents unless the context clearly dictates otherwise. Embodiment 1 A method for training a machine learning model for automatically diagnosing abnormal pupil behaviour through assigning a numerical scale to pupil reactivity, relying on the combination of dynamic and static pupillometric parameters and assessment of external light intensity In the following example a training of machine learning model for assessing pupil reactivity invulnerable to external light conditions is realised by performing a series of pupillary light reaction measurements for various external light conditions spanning 5-10000 lux on the cohort of 9 subjects. These measurements are forming the dataset D1. The averaged pupillary light reactions measured under various external light conditions are presented in the Figure 2 (a). The influence of external light on the observed pupillogram is clearly visible, for instance the amplitude of pupil contraction is heavily reduced for increased external light intensity. A second series of pupillary light reaction measurements is performed on another cohort of 15 subjects with each subject undergoing the administration of tropicamide. The reactivity measurements are performed before and after the drug administration forming the dataset D2 which is presented in the Figure 2 (b). Afterwards for each measurement a set of pupillometry parameters is extracted comprising ^^^^^^^^1 = ^^^^^^^^, ^^ ^^^^^^2 = ^^^^^^, ^^ ^^^^^^3 = ^^^^^^^^, ^^ ^^^^^^4 = ^^^^^^, ^^5^^^^^^= ADV, ^^^^^^^^ ^^^^^^6 = ^^^^^^, ^^7 = ^^^^^^, . Some of extracted pupillometric parameters are presented in the Figure 3. The dependence of pupillometric parameters on the external light intensity is especially pronounced for parameters INIT, CAMP and MCV - all of them significantly decreasing under increasing external light intensity. Similarly for each measurement light sensor parameter ISOtau is read out from the camera settings. The dependence of ISOtau on the external light is presented in Figure 4, with a clear anti-correlation visible between ISOtau and external light level. In the next step a cohort average ^^ ^^^^^^ 1 is calculated based on the dataset D1 for each pupillometry parameter ^^^^ except for ( ^^1 = ^^^^^^^^) yielding a set of values summarized in the table presentedbelow:
[0002] Parameter Variable name Cohort average value INIT^^1Not applicable END^^2^^ ^^^^^^ 2 = 2.771 mm CAMP ^^ ^^^^^^ 3 ^^3= 0.844 mm MCV ^^^^^^ ^^6^^6= 1.986 mm / s PDV^^^ 7 ^^ ^^^^^ 7 = 0.839 mm / s FIN^^9^^9= 3.403 mm Table 1: Calculated cohort average ^^ ^^^^^^ 1 based on the dataset D1 for each pupillometricparameter ^^^^ except for ^^1 = ^^^^^^^^In the discussed embodiment for each pupillometry parameter ^^^^ (except for ^^1 = ^^^^^^^^) amultiple predictive models are created were each model is a linear combination of the predictors ISOtau, INIT, their logarithms, squares, cubes, reciprocals as well as the pairwise products of before-mentioned. The selection of the best model for each pupillometry parameter ^^^^(predicting its behaviour in a most reliable manner) is realised by selecting the model with the lowest Bayesian information criterion (BIC). The selection yields a following list of best predictive models each model responsible for predicting a behaviour of a single pupillometric parameter:
[0003] Variable Parameter Best predictive model name INIT^^1Not applicable (INIT is one of a predictors) ^^ ^^^^^^^^ 1= ^^1^^^^^^^^ ^^^^^^^^ 2 = 0.97 + 0.59*INIT - 0.00062*INIT2- 0.00018*ISOtau2- END^^20.078*Log(INIT)*Log(ISOtau) ^^ ^^^^^^^^ 3 = -0.42 + 0.13*INIT + 0.029*INIT2+ 0.00016*ISOtau2+ CAMP^^30.098*Log(INIT)*Log(ISOtau) ^^ ^^^^^^^^ 6 = -1.5 + 1.0047*INIT - 0.93*Log(ISOtau) - 0.103*INIT2+ MCV ^^61.193*Log(INIT)*Log(ISOtau) ^^ ^^^^^^^^ 7 = -0.00020*ISOtau2+ 0.16*ISOtau-1+ PDV ^^70.36*Log(INIT)*Log(ISOtau) FIN^^9 ^^^^^^^^^^ 9 = 0.46 + 1.97*Log(INIT) + 0.041*INIT2-0.00014*ISOtau2Table 2: Best model for each selected pupillometric parameter ^^^^After the selection of the best model for each pupillometric parameter ^^^^(except for a predictor parameter ^^1 = ^^^^^^^^) a set of light pre-corrected parameter values is calculated using a followingformula: ^^ ^^^^^^−^^^^^^^^ ^^^^^^^^ ^^ ^^ = ^^ ^^^^^^^^ − ^^^^^^ ^^ + ^^^^ It is worth mentioning that for the individuals which reaction perfectly follows the predictive model, the value of pre-corrected parameter is equal to the population average. Afterwards a set of light corrected parameter values is calculated using a formula: ^^^^^^^^^^^^^^^^−^^^^^^^^ ^^ = ^^^^^^ + (1 − ^^)^^^^^^^^^^with the factor ^^ = 1 yielding:^^^^^^^^^^^^^^^^−^^^^^^ ^^ = ^^^^ ^^In general, this step might involve another form of factor ^^ ^^ [0,1]. Selected light corrected parameters are presented in Fig.5. Finally, pupil reactivity score (or index) invulnerable to external light conditions is constructed as a following linear combination of light corrected parameters (except for a predictor parameter ^^^^^^^^^^1 = ^^ ^^^^^^1 = ^^^^^^^^):^^^^ = ^^ + ∑ ^^^^^^^^^^^^^^ ^^ The exact values of coefficients C and Aiare found using a logistic regression with elastic-net regularization fitted to the data from the dataset D2 and additional light invariance regularisation. The procedure yields a following set of non-zero coefficients:
[0004] Coefficient Numerical Value C 8.64 x 10-11A1 -0.0066 A22.44 A3-2.60 A6 -0.84 A7-1.24 A9 -2.77 Table 3: Numerical value of non-zero coefficients used for calculating reactivity index RI relying on the combination of dynamic and static pupillometric parameters Once pupil reactivity index RI is found, one might calculate the rescaled version of the index that spans the numerical range 0-5 by feeding a sigmoid function with reactivity index RI . In this embodiment a piecewise linear sigmoid function has been used of the form presented in Figure 9. This index shall be referred as PuRe (Pupil Reactivity score). In Figure 6 (a) we present the values of PuRe calculated under various external light conditions for the measurements of the cohort of 9 individuals forming a dataset D1. It is clearly visible that the assessment of pupil reactivity remains stable across the entire range of external light. Embodiment 2 A method for training a machine learning model for automatically diagnosing abnormal pupil behaviour through assigning a numerical scale to pupil reactivity, relying on the combination of static pupillometric parameters and assessment of external light intensity In the following example a training of machine learning model for assessing pupil reactivity invulnerable to external light conditions is realised by performing a series of pupillary light reaction measurements for various external light conditions spanning 5-10000 lux on the cohort of 9 subjects. These measurements are forming the dataset D1. The averaged pupillary light reactions measured under various external light conditions are presented in the Figure 2 (a). The influence of external light on the observed pupillogram is clearly visible, for instance the amplitude of pupil contraction is heavily reduced for increased external light intensity. A second series of pupillary light reaction measurements is performed on another cohort of 15 subjects with each subject undergoing the administration of tropicamide. The reactivity measurements are performed before and after the drug administration forming the dataset D2 which is presented in the Figure 2 (b). Afterwards for each measurement a set of pupillometry parameters is extracted comprising ^^^^^^^^ ^^^^^^ ^^^^^^ ^^^^^^ ^^1 = ^^^^^^^^, ^^2 = ^^^^^^, ^^3 = ^^^^^^^^, ^^8 = ^^^^^^^^^^, ^^ ^^^^ ^^^^^^9 = ^^^^^^, ^^12 = ^^^^^^^^. . Some of extracted pupillometric parameters are presented in the Figure 3. The dependence of pupillometric parameters on the external light intensity is especially pronounced for parameters INIT, CAMP - all of them significantly decreasing under increasing external light intensity. Similarly for each measurement light sensor parameter ISOtau is read out from the camera settings. The dependence of ISOtau on the external light is presented in Figure 4, with a clear anti-correlation visible between ISOtau and external light level. In the next step a cohort average ^^ ^^^^^^ ^^is calculated based on the dataset D1 for each pupillometry parameter ^^^^ except for (^^1 = ^^^^^^^^) yielding a set of values summarized in the table presentedbelow: Parameter Variable name Cohort average value INIT^^1Not applicable END^^2^^ ^^^^^^ 2 = 2.771 mm CAMP ^^3^^ ^^^^^^ 3 = 0.844 mm DELTA ^^^^^^ ^^8^^8= 18.375 FIN^^^^^^ 9 ^^ ^^ 9 = 3.403 mm DAMP^^^^^^^^ 12^^12= 0.632 mm Table 4: Calculated cohort average ^^ ^^^^^^ ^^based on the dataset D1 for each pupillometricparameter ^^^^ except for ^^1 = ^^^^^^^^In the discussed embodiment for each pupillometry parameter ^^^^ (except for ^^1 = ^^^^^^^^) amultiple predictive models are created were each model is a linear combination of the predictors ISOtau, INIT, their logarithms, squares, cubes, reciprocals as well as the pairwise products of before-mentioned. The selection of the best model for each pupillometry parameter ^^^^(predicting its behaviour in a most reliable manner) is realised by selecting the model with the lowest Bayesian information criterion (BIC). The selection yields a following list of best predictive models each model responsible for predicting a behaviour of a single pupillometric parameter:
[0005] Variable Parameter Best predictive model name INIT^^1Not applicable (INIT is one of a predictors) ^^ ^^^^^^^^ 1= ^^1^^^^^^^^ ^^^^^^^^ 2 = 0.97 + 0.59*INIT - 0.00062*INIT2- 0.00018*ISOtau2- END^^20.078*Log(INIT)*Log(ISOtau) ^^ ^^^^^^^^ 3 = -0.42 + 0.13*INIT + 0.029*INIT2+ 0.00016*ISOtau2+ CAMP^^30.098*Log(INIT)*Log(ISOtau) ^^ ^^^^^^^^ 8 = -6.64 + 0.011*ISOtau2+ 6.56*Log(INIT)2- 0.34*ISOtau-2+ DELTA ^^84.52*ISOtau-1-0.17*INIT*ISOtau + 7.07*Log(INIT)*Log(ISOtau) FIN^^9 ^^^^^^^^^^ 9 = 0.46+1.97*Log(INIT)+0.41*INIT2-0.00013*ISOtau2^^ ^^^^^^^^ 12= 0.25*Log(INIT)2+0.041*ISOtau-1- 0.15*Log(INIT)2DAMP ^^12+0.13*Log(INIT)*Log(ISOtau) Table 5: Best model for each selected pupillometric parameter ^^^^After the selection of the best model for each pupillometric parameter ^^^^(except for a predictorparameter ^^1 = ^^^^^^^^) a set of light pre-corrected parameter values is calculated using a followingformula: ^^ ^^^^^^−^^^^^^^^= ^^ ^^^^^^ − ^^^^^^^^^^+ ^^^^^^^^ ^^ ^^ ^^ ^^ It is worth mentioning that for the individuals which reaction perfectly follows the predictive model, the value of pre-corrected parameter is equal to the population average. Afterwards a set of light corrected parameter values is calculated using a formula: ^^^^^^^^^^^^^^^^−^^^^^^^^ ^^ = ^^^^^^ + (1 − ^^)^^^^^^^^^^ with the factor ^^ = 1 yielding:^^^^^^^^^^^^^^^^−^^^^^^ ^^ = ^^^^ ^^In general, this step might involve another form of factor ^^ ^^ [0,1]. Selected light corrected parameters are presented in Fig.5. Finally, pupil reactivity score (or index) invulnerable to external light conditions is constructed as a following linear combination of light corrected parameters (except for a predictor parameter ^^^^^^^^^^1 = ^^ ^^^^^^1 = ^^^^^^^^):^^^^ = ^^ + ∑ ^^^^^^^^^^^^^^ ^^ The exact values of coefficients C and Aiare found using a logistic regression with elastic-net regularization fitted to the data from the dataset D2 and additional light invariance regularisation. The procedure yields a following set of non-zero coefficients:
[0006] Coefficient Numerical Value C 3.18 x 10-7A1 -0.0304 A20.03 A3-0.84 A8 -0.14 A9-0.35 A12 -5.26 Table 6: Numerical value of non-zero coefficients used for calculating reactivity index RI relying on the combination of static pupillometric parameters Once pupil reactivity index RI is found, one might calculate the rescaled version of the index that spans the numerical range 0-5 by feeding a sigmoid function with reactivity index RI. In this embodiment a piecewise linear sigmoid function has been used of the form presented in Figure 9. This index shall be referred as PuRe (Pupil Reactivity score). In Figure 6 (b) we present the values of PuRe calculated under various external light conditions for the measurements of the cohort of 9 individuals forming a dataset D1. It is clearly visible that the assessment of pupil reactivity remains stable across the entire range of external light. Embodiment 3 A method for training a machine learning model for automatically diagnosing abnormal pupil behaviour through assigning a numerical scale to pupil reactivity, relying on the combination of dynamic pupillometric parameters and assessment of external light intensity In the following example a training of machine learning model for assessing pupil reactivity invulnerable to external light conditions is realised by performing a series of pupillary light reaction measurements for various external light conditions spanning 5-10000 lux on the cohort of 9 subjects. These measurements are forming the dataset D1. The averaged pupillary light reactions measured under various external light conditions are presented in the Figure 2 (a). The influence of external light on the observed pupillogram is clearly visible, for instance the amplitude of pupil contraction is heavily reduced for increased external light intensity. A second series of pupillary light reaction measurements is performed on another cohort of 15 subjects with each subject undergoing the administration of tropicamide. The reactivity measurements are performed before and after the drug administration forming the dataset D2 which is presented in the Figure 2 (b). Afterwards for each measurement a set of pupillometry parameters is extracted comprising ^^6^^^^^^= MCV, ^^7^^^^^^= PDV. Some of extracted pupillometric parameters are presented in the Figure 3. The dependence of pupillometric parameters on the external light intensity is especially pronounced for parameters MCV, PDV - all of them significantly decreasing under increasing external light intensity. Similarly for each measurement light sensor parameter ISOtau is read out from the camera settings. The dependence of ISOtau on the external light is presented in Figure 4, with a clear anti-correlation visible between ISOtau and external light level. In the next step a cohort average ^^ ^^^^^^ ^^is calculated based on the dataset D1 for each pupillometryparameter ^^^^ except for (^^1 = ^^^^^^^^) yielding a set of values summarized in the table presentedbelow: Parameter Variable name Cohort average value INIT^^1Not applicable MCV^^6^^ ^^^^^^ 6 = 1.986 mm / s PDV ^^7^^ ^^^^^^ 7 = 0.839 mm / s Table 7: Calculated cohort average ^^ ^^^^^^ ^^based on the dataset D1 for each pupillometric parameter ^^^^except for ^^1= INIT In the discussed embodiment for each pupillometry parameter ^^^^(except for ^^1= INIT) a multiple predictive models are created were each model is a linear combination of the predictors ISOtau, INIT, their logarithms, squares, cubes, reciprocals as well as the pairwise products of before mentioned. The selection of the best model for each pupillometry parameter ^^^^(predicting its behaviour in a most reliable manner) is realised by selecting the model with the lowest Bayesian information criterion (BIC). The selection yields a following list of best predictive models each model responsible for predicting a behaviour of a single pupillometric parameter:
[0007] Variable Parameter Best predictive model name INIT^^ ^^^^^^^^ 1 Not applicable (INIT is one of a predictors) ^^1 = ^^1^^^^^^^^ ^^^^^^^^ 6 = -1.5 + 1.0047*INIT - 0.93*Log(ISOtau) - 0.103*INIT2+ MCV^^61.193*Log(INIT)*Log(ISOtau) ^^ ^^^^^^^^ 7 = -0.00020*ISOtau2+ 0.16*ISOtau-1+ PDV^^70.36*Log(INIT)*Log(ISOtau) Table 8: Best model for each selected pupillometric parameter ^^^^After the selection of the best model for each pupillometric parameter ^^^^(except for a predictor parameter ^^1 = ^^^^^^^^) a set of light pre-corrected parameter values is calculated using a followingformula: ^^ ^^^^^^−^^^^^^^^ ^^^^^^^ ^^ = ^^ ^^^^^^^ ^^^^^^ ^^ − ^^^^ + ^^^^ It is worth mentioning that for the individuals which reaction perfectly follows the predictive model, the value of pre-corrected parameter is equal to the population average. Afterwards a set of light corrected parameter values is calculated using a formula: ^^^^^^^^^^^^^^^^−^^^^^^^^ ^^ = ^^^^^^ + (1 − ^^)^^^^^^^^^^ with the factor ^^ = 1 yielding:^^^^^^^^^^^^^^^^−^^^^^^^^ ^^ = ^^^^ In general, this step might involve another form of factor ^^ ^^ [0,1]. Selected light corrected parameters are presented in Fig.5. Finally, pupil reactivity score (or index) invulnerable to external light conditions is constructed as a following linear combination of light corrected parameters (except for a predictor parameter ^^^^^^^^^^1 = ^^ ^^^^^^1 = ^^^^^^^^ ):^^^^ = ^^ + ∑ ^^^^^^^^^^^^^^ ^^ The exact values of coefficients C and Aiare found using a logistic regression with elastic-net regularization fitted to the data from the dataset D2 and additional light invariance regularisation. The procedure yields a following set of non-zero coefficients: Coefficient Numerical Value C -1.83 A6 -2.33 A7-2.82 Table 9: Numerical value of non-zero coefficients used for calculating reactivity index RI relying on the combination of dynamic pupillometric parameters Once pupil reactivity index RI is found, one might calculate the rescaled version of the index that spans the numerical range 0-5 by feeding a sigmoid function with reactivity index RI. In this embodiment a piecewise linear sigmoid function has been used of the form presented in Figure 9. This index shall be referred as PuRe (Pupil Reactivity score). In Figure 6 (c) we present the values of PuRe calculated under various external light conditions for the measurements of the cohort of 9 individuals forming a dataset D1. It is clearly visible that the assessment of pupil reactivity remains stable across the entire range of external light. Embodiment 4 A system implementing a method for automatically diagnosing abnormal pupil behaviour through assigning a numerical scale to pupil reactivity invulnerable to external light conditions based on the trained machine learning model In the system implementing a method for automatically diagnosing abnormal pupil behaviour the assessment of pupil reactivity is realised by performing a pupillary light reaction measurement using a diagnostic device on a single subject. Additionally physical parameters of light sensor including the sensitivity ISO and / or exposure time τ is read out from a camera forming a single parameter ISOtau = ISO*τ; The system has been illustrated in the Figure 7(a). Afterwards a set of pupillometric parameters is extracted comprising ^^^^^^^^1 = ^^^^^^^^, ^^ ^^^^^^2 = ^^^^^^, ^^ ^^^^^^ ^^^^^^ ^^^^^^3 = ^^^^^^^^, ^^6 = ^^^^^^, ^^7 = ^^^^^^,^^^^^^^^9 = ^^^^^^, and a parameter of light sensor ISOtau .A set of light pre-corrected parameter values is calculated using a following formula: ^^ ^^^^^^−^^^^^^^^ ^^^^^^ ^^ = ^^ ^^^^^^^^ − ^^^^ ^^^^^^ ^^ + ^^^^, where cohort average values ^^ ^^^^^^ ^^are presented in Table 1, while best predictive models for calculating ^^ ^^^^^^^^ ^^are presented in Table 2. Similarly a set of light corrected parameter values is calculated using a formula below: ^^^^^^^^^^^^^^^^−^^^ ^^ = ^^^^^^^^^ ^^ + (1 − ^^)^^^^^^^^^^ with the factor α = 1 resulting in: ^^^^^^^^^^^^^^^^−^^^^^^^^ ^^ = ^^^^Afterwards a pupil reactivity index invulnerable to external light conditions is calculated as a following linear combination of light corrected parameters (except for a predictor parameter ^^^^^^^^^^^^ = ^^ ^^^^^^^^ = ^^^^^^^^) :^^^^ = ^^ + ∑ ^^^^^^^^^^^^ ^^where numerical values of been obtained by training a machine learning model according to the method presented in embodiment 1, and their non-zero values are presented in Table 3. Once pupil reactivity index is found, one might calculate the rescaled version of the index that spans the numerical range 0-5 by feeding a sigmoid function with reactivity index RI. In this embodiment a piecewise linear sigmoid function has been used of the form presented in Figure 9. This index shall be referred as PuRe (Pupil Reactivity score). Based on the PuRe threshold the measured pupil is classified as reactive or non-reactive. In Fig. 8 we present the assessment of pupil reactivity performed by a system revealing the pupil reactivity loss induced by the administration of tropicamide. In the illustrated scenario each subject has been measured before (pre) and after (post) the administration of the tropicamide modifying the reactivity of the pupil. It is clearly visible that the reactivity dropped down sharply following the expected influence of the drug. Each measurement can be unambiguously classified to one of the measurement groups (pre or post) by reading out an PuRe value and comparing it with a numerical threshold of PuRe = 3. If the measured PuRe value is below 3, the diagnostic device activates sound and visual alarm informing the user about pupil reaction abnormality. Integration of Clinical and Medical Data The pupil reactivity assessment model can be enhanced through integration with broader clinical and medical data sources. This integration supports both model training and clinical interpretation. The comprehensive medical dataset may include standardized clinical scores such as Glasgow Coma Scale (GCS), modified Rankin Scale (mRS), National Institutes of Health Stroke Scale (NIHSS), Sequential Organ Failure Assessment (SOFA), Acute Physiology and Chronic Health Evaluation (APACHE), and Richmond Agitation-Sedation Scale (RASS). These scores provide validated metrics for patient status assessment and enable correlation analysis with pupillary response patterns. Additionally, the model incorporates neurological monitoring data including intracranial pressure (ICP) measurements, cerebral perfusion pressure (CPP) values, and electroencephalography (EEG) recordings. Advanced neuroimaging data from magnetic resonance imaging (MRI), functional MRI (fMRI), and computed tomography (CT) scans provide structural and functional insights that may influence pupillary response interpretation. Physiological parameters such as cerebral blood flow measurements, cerebral oxygen saturation levels, and neurotransmitter levels offer direct indicators of brain function that can be correlated with pupillary reactivity. The model also considers clinical history factors including biomarkers of brain injury, medical history of neurological conditions, and medications affecting pupillary response. Temporal aspects such as time elapsed since injury or symptom onset are tracked to account for disease progression. Patient-specific factors including demographic data, diagnoses affecting autonomic nervous system function, and previous pupillary response measurements provide important context for individualized assessment. This comprehensive data integration enables more sophisticated model training and validation. By correlating pupillary response patterns with multiple clinical indicators, the model can better account for individual variation and provide more clinically relevant assessments. The integration of concurrent vital signs during pupillary measurements and ultimate clinical outcomes helps validate the model's predictive capabilities and clinical utility. Embodiment 5 Generalized Saturation Curve for Light-Invariant Pupillometry Example Overview Apart from the machine learning method, in this embodiment alternative approach is tested, particularly a hybrid solution where reliance on data from non-reactive pupils is minimized. Instead, it is assumed that fully non-reactive pupils are associated with a baseline parameter, such as the relative change or absolute change in pupil diameter during the flash, which effectively becomes zero. This allows the method to simply rely on data obtained under varying light conditions from healthy individuals, as illustrated in Figure 11 and Figure 12 demonstrates delta values (^^) across different light levels represented on a logarithmic scale. For simplicity, a linear regression model was created to fit this data, enabling a robust baseline for normalization. In Figure 12, an example fitting of a normal distribution to this data at a given light intensity is presented. By assigning values within the normal range and employing a saturation curve, the method smoothly extrapolates values to zero while maintaining stability for healthy distributions. The pupil reactivity score (PuRe) must possess specific properties: it should saturate and approach a maximum value (e.g., 5) for data aligning with the healthy distribution while dropping rapidly to zero outside this range. The range deemed normal can be parameterized to allow flexibility and adaptability across various conditions. Figure 10 represents an embodiment of the PuRe implementation, showcasing how saturation curves change with delta across different light levels and how PuRe varies with light intensity under fixed delta or a delta closely following a normal distribution. Panel C in Figure 10 simplifies the distribution of delta, representing the relative change in the pupil parameter versus light. Figure 13 introduces graphically another embodiment, focusing on light estimation methods that do not solely rely on camera parameters such as exposure time and / or ISO, which represents the gain of the camera sensor. In the pupil light reflex protocol, it is provided a fixed-energy light stimulus that influences the video frames, causing a brightness increase when the flash is on and a decrease when the flash is off. By analyzing the properties of frames adjacent to these flash transitions—such as root mean square, mean, median, and percentile values—it is possible to construct linear, non-linear, or decision tree models to estimate light levels. Figure 13 illustrates data from various models, comparing true ambient light values with predicted ones. The results demonstrate that the decision tree model offers the highest accuracy and most reliable properties for ambient light estimation. This hybrid approach ensures robustness and adaptability in various lighting conditions while preserving simplicity in implementation. This embodiment introduces a method and system for calculating a pupil reactivity score (PuRe) using a generalized saturation function. The PuRe score enables light-invariant assessment of pupil light reflex (PLR), scaling smoothly with changes in relative pupil constriction (^^ - DELTA) while remaining robust across varying environmental conditions. The invention ensures thefunction is monotonic, zero at ^^ = 0, and saturates at a defined maximum score (PuReMAX).Data presented on Fig.10, Fig.11, Fig.12 and Fig.13 are encompassed in embodiment 5, and captions for those figures are incorporated in this embodiment. Fig 12 represents a histogram of the data for a given range of illumination intensity, derived from the data previously presented in Figure 11. This figure illustrates the histogram, the carrying intensity plot, and the Gaussian fitting applied to the histogram, which was used to estimate the variance and its derivatives, such as the sigma value and the width. These parameters were directly used to determine the abnormality threshold, as outlined in Figure 10. A similar procedure of deriving histograms for evenly distributed ranges of ambient light was applied across the entire range of ambient light conditions, spanning from an ambient light logarithm of 10.1 to 10.4, which corresponds to illumination intensities from 10 lux to 10,000 lux. From this, both the mean and the normality ranges were derived based on the sigma range values, further supporting the thresholds and observations previously presented in Figure 10. To calculate the pupil reactivity score, it is crucial to accurately estimate ambient light conditions. This is achieved through the analysis of the video recording of the pupil light reflex, during which LED or flashlight stimulation is delivered. Ambient light and its related features are extracted directly from the video, as well as from camera settings, particularly from parameters such as exposure time and gain (e.g., ISO), which we collectively refer to as ISOtau throughout this text. The analysis focuses on specific video frames, including those preceding the flash onset, the first frame during the flash, the last frame during the flash, and the first frame post-flash. Various approaches are employed, ranging from simple metrics, such as calculating root mean square (RMS) values of pixel intensities across all color channels, to more advanced statistical metrics, including mean perturbations, percentile levels, and features related to the semantic content of the images. Using these extracted features, models were trained that rely solely on camera settings, combine simple linear calibrations with additional non-linear calibrations (referred to here as “quad-fit”), or employ more sophisticated models such as decision trees and random forests. These models take into account features derived from both camera settings and frame intensities. By comparing these four distinct approaches, it is demonstrated that an accurate estimation of ambient light can be achieved using information derived from either camera settings or video frame features during the flash transition. Mathematical Model Here it is presented a one specific model among many possible mathematical models. For the purpose of Embodiment 5, the PuRe score is calculated using the following mathematical equation formula: Core Requirements The saturation functions used in PuRe score calculation must satisfy the following properties: 1. Zero at Origin: For zero pupil constriction (^^ = 0), PuRe must be zero:PuRe(0) = 02. Monotonicity: PuRe must increase monotonically with increasing pupil constriction: ^^ ^^^^PuRe(^^) ≥ 0 ∀^^ ≥ 03. Saturation: For large pupil constriction values, PuRe approaches a maximum value: ^ l^i→m∞PuRe(^^) = PuReMAX4. Light-Invariance: Parameters of the function adapt to ambient light conditions to maintain consistent scoring across different lighting environments. General Form The PuRe score is defined using a scaled saturation function: PuRe(^^) = PuReMAX ⋅ ^^(^^; ^^, ^^)where: •^^ ≥ 0 is the relative pupil constriction• PuReMAXis typically set to 5.0 •^^(^^; ^^, ^^) is a saturation function with parameters ^^ and ^^• ^^(0; ^^, ^^) = 0 and lim^^→∞^^(^^; ^^, ^^) = 1 Exponential Saturation The primary implementation uses an exponential saturation function: ^^(^^; ^^, ^^) = 1 − ^^−^^^^^^ Parameters ^^ and ^^ are determined from normative data: ln(−ln(^^ )) − l ( )^^ = 1 n(−ln ^^2 )− ^^ =−ln(^^1)^^^^Sigmoid (Logistic) Saturation A shifted and scaled logistic function provides an alternative implementation: ^^(^^; ^^, ^^) = 2 (1 1 ^^−^^^^ ^^− )The shift and scaling ensure ^^ Hyperbolic Tangent Saturation The hyperbolic tangent naturally provides appropriate boundary conditions: ^^(^^; ^^, ^^) = tanh(^^^^^^)Logarithmic Saturation A normalized logarithmic function offers gradual saturation: ln ^^^^(^^; ^^, ^^) = (1 + ^^^^ )ln(1 + ^^)Piecewise Linear Saturation A simple piecewise linear implementation using a saturation threshold ^^sat: 0^^ = 0^^ ^^ ^ ^^Light-Invariance The relationship between pupillary response parameters and ambient light follows both linear and nonlinear patterns, established through analysis of normative data across multiple orders of magnitude of illumination (1 to 10,000 lux). Linear Light Dependencies For moderate light levels (101to 103lux), the mean pupillary constriction follows an approximately linear relationship with the logarithm of ambient light: ^^mean(^^10) = ^^0 − ^^1^^10 where: •^^10 = log10(^^) is the logarithm of ambient light in lux• ^^0ranges from 40.0 to 43.0, typically centered at 41.5 • ^^1ranges from 8.0 to 9.5, typically centered at 8.7 Similarly, the standard deviation of pupillary response shows a linear dependence: ^^^^(^^10) = ^^0 − ^^1^^10where: • ^^0ranges from 7.0 to 8.5, typically centered at 7.8 • ^^1ranges from 1.2 to 1.6, typically centered at 1.4 ExtensionsFor extreme light conditions (^^ < 10 lux or ^^ > 103 lux), the relationships become nonlinear andcan be modeled using generalized forms: ^^mean(^^10) = ^^0 − ^^1^^10 + ^^2^^210where ^^2typically ranges at extreme light levels. Alternative nonlinear models include exponential saturation: ^^mean(^^10) = ^^0exp(−^^^^10)with ^^ ranging from 0.1 to 0.3. Threshold Calculation The abnormality threshold is computed using a variable number of standard deviations: ^^threshold(^^10) = ^^mean(^^10) − ^^(^^10)^^^^(^^10)where ^^(^^10) can vary with light level: ^^(^^10) = ^^0 + ^^1^^10with: • ^^0ranging from 2.8 to 3.2 • ^^1ranging from -0.1 to 0.1 Parameter Adaptation These relationships enable dynamic recalculation of saturation function parameters. For the exponential model: () ( )^^(^^ ln(−ln ^^1 ) − ln(−ln ^^2 )10) =ln(^^mean(^^10)) − ln(^^threshold(^^10))^^(^^−ln(^^1) 10) = ^^where: • ^^1typically ranges from 0.15 to 0.25 • ^^2typically ranges from 0.75 to 0.85 Statistical Validation These relationships have been validated across the full operating range: • Very low light: 1-10 lux (requires baseline flash illumination) • Normal indoor: 10-1,000 lux (linear regime) • Bright conditions: 1,000-10,000 lux (nonlinear / saturation effects) At each light level, the coefficient of variation in PuRe score remains below 10% for healthy subjects, demonstrating robust light invariance. The mean PuRe score varies by less than 0.2 units across the entire light range for normative data. Alternative Formulations The framework accommodates alternative functional forms while maintaining light invariance. For instance, power-law relationships: ^^ an(^ 10)−^^ me ^ = ^^0^^10with ^^ ranging from 0.2 to 0.4, or logarithmic dependencies: ^^mean(^^10) = ^^0 − ^^1ln(1 + ^^^^10) where ^^ typically ranges from 0.1 to 1.0. In the preferred embodiment parameters are adjusted based on ambient light level ^^10= log10(^^) using normative data relationships: ^^mean(^^10) = 41.5 − 8.7^^10^^^^(^^10) = 7.8 − 1.4^^10^^threshold(^^10) = ^^mean(^^10) − ^^^^^^(^^10)These relationships enable parameter recalculation for each light level: ln ( ) ( )^^(^^ (−ln ^^ ) − ln(−ln10) = 1 ^^2 )ln(^^mean(^^10)) − ln(^^threshold(^^10)) ^^(^^−l ( ) 10) =n ^^1^^mean(^^10)^^(^^10) Example ValuesExample PuRe values (PuReMAX = 5.0) for different saturation functions.^^(%) Exponential Sigmoid Tanh Piecewise Logarithmic 0 0.0000 0.0000 0.0000 0.0000 0.0000 1 0.4760 0.2550 0.4985 0.1665 0.0078 2 0.9065 0.5000 0.9870 0.3335 0.0311 5 1.9675 1.2270 2.3105 0.8335 0.1924 10 3.1605 2.3100 3.8080 1.6665 0.7425 20 4.3235 3.8100 4.8200 3.3335 2.6225 30 4.7510 4.5250 4.9755 5.0000 5.0000 Discussion Each saturation function implementation offers distinct advantages: • The exponential form provides smooth transition and intuitive parameter interpretation • Sigmoid and tanh functions offer natural S-shaped response curves • Logarithmic saturation enables very gradual approach to maximum • Piecewise linear provides simplest implementation with clear threshold The choice of function can be adapted to specific clinical requirements while maintaining the essential properties of zero baseline, monotonicity, and appropriate saturation behavior. Parameter determination from normative data ensures light-invariance regardless of the chosen functional form. Advantages of the embodiment 5: • Flexibility: Multiple saturation functions allow customization for specific clinical scenarios. • Light-Invariance: Adjustments for light intensity and environmental variations ensure robust measurements. • Abnormality Sensitivity: Enhanced sensitivity for detecting small deviations in PLR, aiding early neurological diagnosis. ****Additional information, related to the present invention and technical effects of the invention can be found in the application no. EP 23461698.5 of 22 December 2023 - the disclosure of which is hereby referred to and fully incorporated.
Claims
CLAIMS 1. A method for training a machine learning model for automatically detecting abnormal pupil behaviour through assigning a numerical scale to pupil reactivity, comprising the following steps: (a) a pupillary light reaction measurements are performed using a diagnostic device on the cohort of plurality of subjects under various external light conditions spanning the expected range of further external light invulnerability forming a first dataset (D1), similarly pupillary light reaction measurements are performed on the cohort of plurality of subjects with the measurements divided into a pair of labelled groups, with a first group of measurements performed before administration of drug reducing pupil reactivity, such as tropicamide or pilocarpine, and the second group of measurements performed after the drug administration, both forming a dataset (D2), (b) based on the measured pupillograms, a pupillometry parameter ^^^^^^^^, preferably at least one parameter selected from a set of measured pupillometry parameters comprising: ^^^^^^^^1 = ^^^^^^^^, maximum aperture, ^^ ^^^^^^2 = ^^^^^^, minimum aperture, ^^3^^^^^^= ^^^^^^^^, amplitude of pupil constriction, ^^^^^^^^4 = ^^^^^^, average velocity of pupilconstriction, ^^^^^^^5^^^^^^= ADV, average velocity of pupil dilation, ^^^6 = ^^^^^^, constrictionvelocity, ^^^^^^^^7 = ^^^^^^, maximal (peak) velocity of pupil dilation, ^^ ^^^^^^8 = ^^^^^^^^^^,reduction in pupil diameter, ^^^^^^^^9 = ^^^^^^, pupil diameter which is asymptotically reachedby the pupil after the light stimulus is over, ^^^^^^^^10 = ^^^^^^, pupil reaction latency^^1^1^^^^^= ^^^^75 , time interval required to recuperate 75% of the constriction amplitude post constriction termination, ^^^^^^^^12 = ^^^^^^^^, is extracted from each measurement;(k) a light invariant reactivity score PuRe is calculated by feeding a sigmoid function with RI such that the value of PuRe, is within a predefined numerical range, preferably in the range from 0 to 5.
2. The method according to claim 1 , characterized in that it further comprises the steps, performed after step (b) and before step (k): (c) parameters of light sensor reflecting external light intensity such as the sensitivity ISO and / or exposure time τ are read out from a camera forming a single parameter ISOtau = ISO∙τ; (d) for each pupillometry parameter ^^^^selected in step (b), except for ^^^^^^^^1 = ^^^^^^^^, itscohort average value is calculated based on the dataset D1, referred as ^^ ^^^^^^ 1 ;(e) for each pupillometry parameter ^^^^^^^^^^except for ^^1 = ^^^^^^^^, multiple predictivemodels are created, wherein each model is a linear combination of the predictors ISOtau, INIT, their logarithms, squares, cubes, reciprocals as well as the pairwise products of before-mentioned and / or image intensity in the video recording, giving in total N predictors of a model, the predictive models are constructed using a binary feature inclusion with a total number of models equal 2N; (f) the selection of the best model from all created models in step (e) predicting a pupillometry parameter ^^^^relies on selecting the model with the lowest Bayesian information criterion (BIC) or similar method of model selection, with the best model yielding the predicted value of the parameter ^^ ^^^^^^^^ ^^solely based on the predictors enlisted in the step (e);(g) a set of pre-corrected pupillometry parameters is calculated based on the formula ^^ ^^^^^^−^^^^^^^^ ^^^^^^^^ ^^^ ^^ = ^^ ^^^^^^^^ − ^^^^ + ^^^^^ ^^, where ^^ ^^^^^^ ^^is a cohort average value calculated inin the step (f), while ^^^^^^^^^^is a parameter value extracted directly from the pupillary light reaction measurement; (h) a set of light corrected pupillometry parameters ^^^^^^^^^^^^^^^^−^^^^^^^^ ^^ = ^^^^^^ + (1 − ^^)^^^^^^^^^^is calculated, where ^^ ^^ [0,1] , ^^ ^^^^^^^^ is a value predicted bystep (f), while ^^^^^^^^^^being a parameter value extracted directly from the pupillary light reaction measurement; (i) a pupil reactivity numerical scale invulnerable to external light conditions is constructed as a linear combination of numerical constant, and the product of light corrected pupillometry parameters i.e. ^^^^ = ^^ + ∑^^^^^^^^^^^^^^^^^^ ^^^^^^^^, where ^^1 = ^^1^^^^^^denotes measured INIT, ^^2^^^^^^^^denotes light corrected END, ^^3^^^^^^^^denotes light corrected CAMP, ^^4^^^^^^^^denotes light corrected ACV, ^^5^^^^^^^^denotes light corrected ADV, ^^6^^^^^^^^denotes light corrected MCV, ^^7^^^^^^^^denotes light corrected PDV, ^^8^^^^^^^^denotes light corrected DELTA, ^^9^^^^^^^^denotes light corrected FIN, ^^1^^0^^^^^^denotes light corrected LAT, ^^1^^1^^^^^^denotes light corrected FT75, ^^1^^2^^^^^^denotes light corrected DAMP, whereas C and Aiare real-valued constants; (j) to find a set of coefficients C and Ai a D2 dataset is used with a particular set of coefficient values found using a logistic regression fitted to the data with elastic-net regularization and additional light invariance regularisation; 3. The method according to any one of the preceding claims 1 or 2, characterized in that in the steps (b) and optionally steps (d)-(i) at least one static pupillometric parameter selected fromparameters: INIT, END, CAMP, DELTA, FIN, LAT, FT75, DAMP are only considered, and none of the dynamic parameters are used.
4. The method according to any one of the preceding claims 1, 2 or 3, characterized in that in the steps (b) and optionally steps (d)-(i) at least one dynamic pupillometric parameter selected from parameters: PDV, ACV, MCV, ADV are only considered, and none of the static parameters are used.
5. The method according to any one of the preceding claims 2-4 characterized in that in said step (i) ^^^^^^^^^^parameters are used instead of ^^^^^^^^^^^^.
6. The method according to any one of the preceding claims 1-5, wherein the diagnostic device is a smartphone.
7. The method according to any one of the preceding claims 1-6, wherein datasets D1 and D2 are supplemented with additional data after each measurement result in order to retrain predictive models ^^ ^^^^^^^^ ^^mentioned in claim 1 steps (e) and (f) as well as improve a set of coefficients mentioned in claim 1 step (j).
8. The method according to any one of the preceding claims 1-7, characterized in that in a step (i) the parameter values are in the range ^^ ^^ [−50,50] and ^^^^^^ [−10,10].
9. The method according to any one of the preceding claims 1-8, characterized in that in addition to the datasets D1 and D2, other medical data relating to said subjects is used for training said machine learning model, wherein said other medical data preferably includes one or more of the following: Glasgow Coma Scale (GCS) scores, modified Rankin Scale (mRS) scores, National Institutes of Health Stroke Scale (NIHSS) scores, Sequential Organ Failure Assessment (SOFA) scores, Acute Physiology and Chronic Health Evaluation (APACHE) scores, Richmond Agitation-Sedation Scale (RASS) scores, neurological assessment results, intracranial pressure (ICP) measurements, cerebral perfusion pressure (CPP) values, electroencephalography (EEG) recordings, magnetic resonance imaging (MRI) scans, functional MRI (fMRI) data, computed tomography (CT) scans, cerebral blood flow measurements, cerebral oxygen saturation levels, neurotransmitter levels, biomarkers of brain injury, medical history of neurological conditions, administered medications affecting pupillary response, concurrent vital signs during pupillary measurements, demographic data including age and gender, time elapsed since injury or onset of symptoms, diagnoses of conditions affecting autonomic nervous system, previous pupillary response measurements, and clinical outcome data.
10. The method according to any one of the preceding claims 1-9, characterized in that invariant reactivity score PuRe depend on more than one pupillometry parameter ^^^^^^^^.
11. The method according to any one of the claims 1-10, characterized in that the ambient / external light estimations is measured using external light sensor, such as luxometer, phototransistors, photoresistors and photodiodes, or ambient light measurements rely on video / camera settings.
12. The method according to any one of the preceding claims 1-11, characterized in that the pupillary reactivity score PuRe relies on healthy normative data PLR parameters measured on the cohort of healthy people measured in varying ambient light conditions.
13. The method according to any one of the preceding claims 1-12, characterized in that the pupillary reactivity score PuRe assumes that no change in pupil size during the flash stimulation corresponds to PuRe equal to minimal score, preferably 0.
14. The method according to any one of the preceding claims 1-13, characterized in that the pupillary reactivity score PuRe changes monotonically and sensitively with PLR parameters forsmall reactivities and saturates at PuRe equal to a maximal score, preferably 5, for PLR parameters for the upper tail of the distribution of healthy individuals.
15. The method according to any one of the preceding claims 1-14, characterized in that the pupillary reactivity score PuRe sensitivity is tuned by putting a predefined threshold of abnormal PuRe values such as PuRe = 3 with respect to the deviation from a mean for the healthy population.
16. A method for assessing pupillary reactivity while compensating for ambient light variations, comprising: performing pupillary light reflex measurements under varying ambient light conditions on a plurality of subjects to create at least one reference dataset; estimating ambient illumination levels during said measurements through at least one of: analysing video frames captured during pupillary measurements, reading device or camera settings including exposure time and sensitivity, performing software-based scene analysis, or using dedicated light sensors; extracting pupillometry parameters from said measurements, said parameters characterizing pupillary response dynamics; applying a computational model that: compensates for variations in ambient illumination based on said ambient illumination level estimates, establishes normative pupillary response parameters from said reference dataset, accounts for non-reactive and abnormally reactive pupillary conditions through analysis of pupillary response distributions, and generates a standardized pupillary reactivity index through either trained machine learning model inference or mathematical scaling functions; wherein said pupillary reactivity index maintains quantitative consistency and clinical discriminative power across the predefined range of ambient light conditions while preserving sensitivity to abnormal pupillary responses or lack of pupillary response, equals unreactive pupil.
17. The method according to claim 16, wherein said method includes training a mathematical or machine learning model for automatically diagnosing abnormal pupil behaviour by assigning anumerical scale to pupil reactivity through acquiring measurements of pupillary light reflex from a diverse cohort of subjects under various ambient lighting conditions; optionally administering pharmacological agents known to induce alterations in pupil reactivity to a subset of subjects to generate data representing abnormal responses; extracting at least one pupillometry parameter from each measurement, including static or dynamic parameters comprising initial pupil diameter, minimum pupil diameter, amplitude of constriction, velocities, latencies, and recovery times; generating an ambient light estimate for each measurement instance using any combination of hardware- or software-based methods; building multiple predictive models correlating pupillometry parameters with ambient light estimates and selecting at least one best-performing model based on model selection criteria including Bayesian information criterion, cross-validation performance, or similar metrics; normalizing pupillometry parameters relative to said best- performing model to obtain light-corrected parameters; applying a machine learning approach with additional regularization terms that encourage invariance to lighting variations; and obtaining final coefficients in a mathematical or learned function that define the numerical pupillary reactivity score, wherein the score maintains robust invariance across ambient lighting conditions, exhibits continuity and monotonicity with respect to key pupillometry parameters, and saturates at clinically relevant maximum reactivity values.
18. The method according to any one of the preceding claims, characterized in that the pupil reactivity score is generated using a model constructed from healthy subject pupillary measurements spanning ambient light illumination intensities from 0 to 10,000 lux, wherein said model defines normative response parameters under both such range of ambient light conditions, extrapolates these parameters for non-reactive or partially reactive subjects, and maintains consistency in the pupil reactivity score while preserving clinical sensitivity across the operational illumination range, said model being selected from any combination of parametric, non-parametric, statistical, or machine learning frameworks, including but not limited to linear, polynomial, spline-based, kernel-based, distribution-free, or tree-based methods.
19. The method according to any one of the preceding claims, characterized in that the model employs one or more saturation functions to map pupillary response parameters to a standardized numerical scale, each saturation function satisfying zero response for non-reactive pupils, strictly monotonic increase with increasing pupillary reactivity, and saturation at a predefined maximum value corresponding to healthy or near-maximal reactivity, wherein said saturation functions are selected from exponential, logistic, hyperbolic tangent, logarithmic, power-law, piecewise, rational, splines, neural networks, or any other continuous or piecewise-continuous implementations, with parameters dynamically adapting to reflect ambient light variations across the operational illumination range.
20. The method according to any one of the preceding claims, characterized in that modelling of normal population data to derive pupillary response parameters under varying ambient light comprises parametric approaches, including but not limited to linear or polynomial relationships of any order, piecewise polynomials, exponential or logarithmic forms, rational functions, or any combination thereof; non-parametric or data-driven methods, such as kernel density estimation, distribution-free quantile approaches, tree-based ensembles, neural networks, and regression splines; and statistical or machine learning fitting procedures that incorporate measures of variance, confidence intervals, or ensemble averaging, ensuring the model robustly covers typical pupillary responses over the entire operational illumination range.
21. The method according to any one of the preceding claims, characterized in that ambient light conditions are estimated by analysing video frames captured before, during, or after pupillary light reflex stimulation, using metrics including root mean square intensity, histogram moments, colour-channel analysis, frame differencing, temporal filtering, spectral transforms, or scene-segmentation techniques; camera sensor parameters including exposure time, ISO, aperture, or gain; hardware sensor readings such as photodiodes or phototransistors; and hybrid or machine learning models that integrate multiple input features for improved accuracy, wherein flash stimulus energy consistency facilitates ambient light calibration by isolating the impact of the stimulus from the baseline illumination level.
22. The method according to any one of the preceding claims, characterized in that threshold determination for abnormal pupil reactivity is performed using parametric statistical models; non- parametric approaches that derive abnormality cutoffs from empirical population percentiles, bootstrapped confidence intervals, or distribution-free quantiles; machine learning classification or anomaly detection algorithms; or any combination thereof, ensuring that thresholds automatically adjust according to ambient light variations and subject-specific pupillary response distributions.
23. The method according to any one of the preceding claims, characterized in that model parameters, including but not limited to scaling constants, exponents, polynomial coefficients, spline breakpoints, neural network weights, or regularization hyperparameters, are optimized to maintain a coefficient of variation in the pupil reactivity score below 20% for healthy subjects across the operational illumination range, mean score variation of under 0.5 units from moderate to extreme illumination conditions in normative data, and high classification accuracy for identifying abnormal reactivity, wherein optimization is performed by any combination of variance minimization, cross-validation, Bayesian model selection, or direct clinical outcome correlation, ensuring the resulting pupil reactivity score is robust to changes in ambient light and individual variability.
24. A computer program comprising instructions which, when the program is executed on a computer, cause the computer to carry out the method according to any one of claims 1 to 23.
25. A computer-readable medium comprising the computer program according to claim 24.
26. A system implementing the machine learning model according to any claims 1-25 for automatically detecting abnormal pupil behaviour based on assessing a pupil reactivity of a patient by assigning a numerical scale, said system comprising a memory, a processor, a camera, a light source, a light sensor and a digital display, wherein the system is configured and programmed for assessing pupil reactivity of the patient by the following steps: (a) physical parameters of light sensor including the sensitivity ISO and / or exposure time τ is read out from a camera forming a single parameter ISOtau = ISO*τ; (b) a pupillary light reaction measurement is performed using a diagnostic device on a single subject (patient); (c) based on the measured pupillogram, at least one parameter selected from a set of measured pupillometry parameters ^^^^^^^^comprising ^^^^^^^^1 = ^^^^^^^^, ^^ ^^^^^^2 = ^^^^^^, ^^ ^^^^^^3 = ^^^^^^^^,^^^^^^^^4 = ^^^^^^, ^^5^^^^^^= ADV, ^^^^^^^^ ^^^^^^ ^^^^^^ ^^^^^^6 = ^^^^^^, ^^7 = ^^^^^^, ^^8 = ^^^^^^^^^^, ^^9 = ^^^^^^, ^^1^0^^^^^= ^^^^^^, ^^^^^^^^11 = ^^^^75 , ^^ ^^^^^^12 = ^^^^^^^^, is extracted from each measurement;, is extracted fromthe measurement; (d) a set of light corrected pupillometry parameters ^^^^^^^^^^^^is retrieved based on the real time physical measurements and measured pupillometry parameters ^^^^^^^^^^as well as a set of best predictive models; (e) a pupil reactivity score invulnerable to external light conditions is calculated as a linear combination of numerical constant, and light corrected pupillometry parameters, i.e. ^^^^ = ^^ + ∑ ^^ ^^^^^^^^^^^^^^ ^^, wherein ^^^^^^^^^^1 = ^^1^^^^^^denotes measured INIT, ^^2^^^^^^^^denotes light corrected END, ^^3^^^^^^^^denotes light corrected CAMP, ^^4^^^^^^^^denotes light corrected ACV,^^5^^^^^^^^denotes light corrected ADV, ^^6^^^^^^^^denotes light corrected MCV, ^^7^^^^^^^^denotes light corrected PDV, ^^8^^^^^^^^ denotes light corrected DELTA and ^^9^^^^^^^^ denotes light correctedFIN, ^^1^^0^^^^^^denotes light corrected LAT, ^^1^^1^^^^^^denotes light corrected FT75, ^^1^^2^^^^^^denotes light corrected DAMP, whereas C and Aiare real-valued constants resulting from the machine learning model training; (f) a light invariant reactivity score PuRe is calculated by feeding a sigmoid function with RI such that the value of PuRe is within a predefined numerical range, preferably in the range from 0 to 5, and optionally displaying the value of PuRe on the display; (g) based on the PuRe threshold the measured pupil is classified as reactive or non-reactive and the device informs the operator on the non-reactivity of the pupil by activating sound and / or visual alarm on the diagnostic device.
27. The system according to claim 26, characterized in that in step (e) ^^^^^^^^^^parameters are used instead of ^^^^^^^^^^^^.
28. The system according to claim 26 or 27 characterized in that the parameter values are in the range ^^ ^^ [−50,50] and ^^^^^^ [−10,10].
29. A computer program comprising instructions which, when the program is executed in the system according to any one of the claims 26 to 28 enable the system to automatically diagnose condition of a patient in a numerical scale from 0 to 5 by carrying out the steps specified in any one of claims 1 to 17.
30. A computer-readable medium comprising the computer program according to claim 29.
31. A method for generating the Pupil Reactivity score, PuRe, using the dataset D2 acquired during pharmacological intervention, comprising:o creating a plurality of light-invariant pupillometry parameters; o acquiring the dataset D1 under controlled light conditions, involving: a. Measuring ambient light intensity using a calibrated sensor; b. Recording pupillary light reflex, PLR, responses in subjects under varying light conditions; c. Altering light conditions systematically to span a predetermined range of intensities; d. Repeating measurements across a diverse cohort of subjects to ensure robust data representation; e. Developing a predictive model that estimates the pupillary light reflex, PLR, parameters, utilizing functions of measured light intensity as predictors; o conducting ambient light measurements and pupillary light reflex, PLR, assessments as described in any of claims 16-23; o administering a pharmacologically active agent known to influence pupillary light reflex, PLR, to subjects; o repeating the measurement process under varying light conditions and across different subjects post-administration to capture drug-induced pupillary light reflex, PLR, variations; o creating a predictive model that accounts for the drug's effect on pupillary light reflex, PLR, using functions of light intensity and light-corrected pupillary light reflex, PLR, parameters as predictors.
32. A method for measuring the Pupil Reactivity score, PuRe, by measuring ambient light conditions pupillary light reflex, PLR, responses, and utilizing light-corrected parameters to calculate the score, followed by its display on a mobile device.
Citation Information
Patent Citations
A method for training a machine learning model for automatically diagnosing abnormal pupil behaviour based on assessing pupil reactivity invulnerable to external light conditions, a computer program comprising instructions thereof, and a system implementing the model
EP4574018A1
Methods, systems, and devices for monitoring anisocoria and asymmetry of pupillary reaction to stimulus
US20190159671A1
Pupilometer with pupil irregularity detection, pupil tracking, and pupil response detection capability, glaucoma screening capability, intracranial pressure detection capability, and ocular aberration measurement capability
US9402542B2
Methods, systems, and devices for monitoring anisocoria and asymmetry of pupillary reaction to stimulus
WO2010062400A1
Methods, systems, programs and devices to predict patient outcome using differential in pupillary index
WO2023059325A1
Cited By
Non-imaging photoetching illumination system of i-line photoetching machine
CN121832213A
Non-imaging lithography illumination system for an i-line photolithography machine
CN121832213B