-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Non-compartmental analysis (NCA) #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/normalized-row-api
Are you sure you want to change the base?
Conversation
| /// Number of points used | ||
| pub n_points: usize, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Points used for what? Regression?
| /// A validated concentration-time profile ready for NCA analysis | ||
| /// | ||
| /// This is an internal structure that normalizes data from various sources | ||
| /// (raw arrays, Occasion) into a consistent format with BLQ handling applied. | ||
| #[derive(Debug, Clone)] | ||
| pub(crate) struct Profile { | ||
| /// Time points (sorted, ascending) | ||
| pub times: Vec<f64>, | ||
| /// Concentration values (parallel to times) | ||
| pub concentrations: Vec<f64>, | ||
| /// Index of Cmax in the arrays | ||
| pub cmax_idx: usize, | ||
| /// Index of Clast (last positive concentration) | ||
| pub tlast_idx: usize, | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you prefer this over an implementation directly over Occasion?
| pub fn from_arrays( | ||
| times: &[f64], | ||
| concentrations: &[f64], | ||
| loq: f64, | ||
| blq_rule: BLQRule, | ||
| ) -> Result<Self, NCAError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a impl From too, I think.
| // Find Cmax index | ||
| let cmax_idx = proc_concs | ||
| .iter() | ||
| .enumerate() | ||
| .max_by(|a, b| a.1.partial_cmp(b.1).unwrap_or(std::cmp::Ordering::Equal)) | ||
| .map(|(i, _)| i) | ||
| .unwrap_or(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In cases where there are several "max" concentrations, this should report the first occurence. This is relevant for the Tmax, where we then are more interested in the time to the first maximum.
| // Find Tlast index (last positive concentration) | ||
| let tlast_idx = proc_concs | ||
| .iter() | ||
| .rposition(|&c| c > 0.0) | ||
| .unwrap_or(proc_concs.len() - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the last positive only?
| /// AUC calculation method (default: LinUpLogDown) | ||
| pub auc_method: AUCMethod, | ||
|
|
||
| /// Limit of quantification (default: 0.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "Lower limit of quantification"
| /// BLQ handling rule (default: Exclude) | ||
| pub blq_rule: BLQRule, | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about concentrations that are too high? Its an edge-case, but since you already care about lower limit.
No description provided.