Skip to content

Conversation

@Siel
Copy link
Member

@Siel Siel commented Jan 3, 2026

No description provided.

Comment on lines +361 to +362
/// Number of points used
pub n_points: usize,
Copy link
Collaborator

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?

Comment on lines +9 to +24
/// 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,
}

Copy link
Collaborator

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?

Comment on lines +36 to +41
pub fn from_arrays(
times: &[f64],
concentrations: &[f64],
loq: f64,
blq_rule: BLQRule,
) -> Result<Self, NCAError> {
Copy link
Collaborator

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.

Comment on lines +101 to +107
// 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);
Copy link
Collaborator

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.

Comment on lines +109 to +113
// Find Tlast index (last positive concentration)
let tlast_idx = proc_concs
.iter()
.rposition(|&c| c > 0.0)
.unwrap_or(proc_concs.len() - 1);
Copy link
Collaborator

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)
Copy link
Collaborator

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"

Comment on lines +28 to +30
/// BLQ handling rule (default: Exclude)
pub blq_rule: BLQRule,

Copy link
Collaborator

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.

@mhovd mhovd changed the title nca feat: Non-compartmental analysis (NCA) Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants