Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions crates/timsrust-tdf/src/calibration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,8 @@ pub struct UncalibratedScan2ImConverter {

impl UncalibratedScan2ImConverter {
fn from_boundaries(im_min: f64, im_max: f64, scan_max_index: u32) -> Self {
let scan_intercept: f64 = im_max.sqrt();
let scan_slope: f64 =
(im_min.sqrt() - scan_intercept) / scan_max_index as f64;
let scan_intercept: f64 = im_max;
let scan_slope: f64 = (im_min - scan_intercept) / scan_max_index as f64;
Comment thread
sander-willems-bruker marked this conversation as resolved.
Self {
scan_intercept,
scan_slope,
Expand All @@ -138,23 +137,22 @@ impl UncalibratedScan2ImConverter {
.max()
.expect("SqlReader cannot return empty vecs, so there is always a max scan index");
let (im_min, im_max) = get_im_bounds(&sql_metadata).unwrap();
Self::from_boundaries(im_min, im_max, scan_max_index)
Self::from_boundaries(im_min, im_max, scan_max_index - 1)
}
}

impl Converter<ScanIndex, Im> for UncalibratedScan2ImConverter {
fn convert(&self, value: ScanIndex) -> Im {
let value = f64::from(value);
let im = self.scan_intercept + self.scan_slope * value;
let result = im * im;
Im::from(result)
Im::from(im)
}
}

impl Converter<Im, ScanIndex> for UncalibratedScan2ImConverter {
fn convert(&self, value: Im) -> ScanIndex {
let value = f64::from(value);
let result = (value.sqrt() - self.scan_intercept) / self.scan_slope;
let result = (value - self.scan_intercept) / self.scan_slope;
ScanIndex::try_from(result as u32)
.expect("ScanIndex conversion out of bounds")
}
Expand Down
Loading