Skip to content

Commit

Permalink
Truncate the mass range to time-of-flight conversion to ensure consis…
Browse files Browse the repository at this point in the history
…tent range extraction (#56)

* Remove wrapping functions to prevent leakage

* Remove timeit statements

* Comment the mass range -> ToF conversion

* Don't include the wrap variable in the zip loop for _set_tof_ranges
  • Loading branch information
alex-l-kong authored Jul 12, 2023
1 parent a8cbc1f commit 14ae319
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/mibi_bin_tools/bin_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ def _set_tof_ranges(fov: Dict[str, Any], higher: np.ndarray, lower: np.ndarray,
"""
key_names = ('upper_tof_range', 'lower_tof_range')
mass_ranges = (higher, lower)
wrapping_functions = (np.ceil, np.floor)

for key, masses, wrap in zip(key_names, mass_ranges, wrapping_functions):
fov[key] = \
wrap(
_mass2tof(masses, fov['mass_offset'], fov['mass_gain'], time_res)
).astype(np.uint16)
for key, masses in zip(key_names, mass_ranges):
# truncate the conversion to ensure consistency
fov[key] = _mass2tof(
masses, fov['mass_offset'], fov['mass_gain'], time_res
).astype(np.uint16)


def _write_out(img_data: np.ndarray, out_dir: str, fov_name: str, targets: List[str],
Expand Down

0 comments on commit 14ae319

Please sign in to comment.