Skip to content

convert_coord_res

jaybgager edited this page Sep 29, 2026 · 1 revision

This function converts a set of point coordinates from one resolution to another.

Arguments:

  • point coords (list of integers, mandatory)
    • a list of point coordinates in their current resolution
  • res_current (list of integers, optional, default=[1,1,1])
    • the resolution of each coordinate dimension in nanometers per voxel for the passed coordinates
    • default value of [1,1,1] is "nanometer" resolution (i.e. 1 voxel = 1nm)
  • res_desired (list of integers, optional, default=[1,1,1])
    • the resolution of each coordinate dimension in nanometers per voxel you want to convert the coordinates to
    • default value of [1,1,1] is "nanometer" resolution (i.e. 1 voxel = 1nm)

Returns:

  • converted_point_coords (list of integers)
    • the converted point coordinates rounded down to the nearest integer

Example

Let's say we wanted to convert some coordinates [125283, 118263, 2860] from the "brain_and_nerve_cord" datastack's viewer resolution of [4,4,45] to "nanometer" resolution of [1,1,1]. This is often necessary in order to perform mathematical operations on coordinates like calculating 3D distances or checking them against other back-end information, which is frequently stored in nanometer resolution.

INPUT:

import tracertools as tt

# creates a list of banc-resolution coordinates
banc_coords = [125283, 118263, 2860]

# converts the banc-resolution coords to nanometer-resolution coords
nm_coords = tt.convert_coord_res(
    point_coords = banc_coords, 
    res_current = [4, 4, 45], 
    res_desired = [1, 1, 1],
)

print(nm_coords)

OUTPUT:

[501132, 473052, 128700]

Note

Although intended for use with 3D x,y,z coordinates, this function is written in such a way that it should work with coordinates with any number of dimensions so long as the resolutions passed have the same amount as the coordinates.

Clone this wiki locally