Hi Tom,

Thanks a lot, this works great!
Just a caveat that these values are already with the 10% margin for the inner and outer radius respectively, i.e. the values actually used for unrolling. To get the exact radii from the current displayed surface the print statement should come in the parse_cylinder_size() function in the same file:

def parse_cylinder_size(inner_radius, outer_radius, length, center, axis,
                        v, subregion, step):

    if length is None:
        import numpy
        a = numpy.argmax(axis)
        xyz_min, xyz_max = v.xyz_bounds(step, subregion)
        h = xyz_max[a] - xyz_min[a]
    elif isinstance(length, (float, int)):
        h = length
    else:
        raise CommandError('length must be a number')
    if inner_radius is None or outer_radius is None:
        from . import unroll
        rmin, rmax = unroll.cylinder_radii(v, center, axis)
        # Let's print the inner and outer radii found:
        print(f'volume {v.name} threshold {v.maximum_surface_level}, measured inner {rmin:.3f}, outer {rmax:.3f}')
        pad = 0.10
        r0 = rmin * (1 - pad) if inner_radius is None else inner_radius
        r1 = rmax * (1 + pad) if outer_radius is None else outer_radius
    else:
        r0, r1 = inner_radius, outer_radius
    if not isinstance(r0, (float, int)):
        raise CommandError('inner_radius must be a number')
    if not isinstance(r1, (float, int)):
        raise CommandError('outer_radius must be a number')

    return r0, r1, h


Best wishes,

--
Ricardo Diogo Righetto


Em sáb., 27 de abr. de 2024 às 20:45, Tom Goddard <goddard@sonic.net> escreveu:
Hi Ricardo,

  You can edit the "volume unroll" python code in your ChimeraX to add a print statement to print the inner and outer radius.

open 1080 from emdb
volume unroll #1

> volume emdb 1080 threshold 0.852, unroll inner 11.888949394226074, outer 77.99255294799805

  The python code to modify is in the vopcommand.py file, on Mac, that is in your ChimeraX distribution at

ChimeraX.app/Contents/lib/python3.11/site-packages/chimerax/map_filter/vopcommand.py

Here is what the volume_unroll() Python function looks like

# -----------------------------------------------------------------------------
#
def volume_unroll(session, volumes, inner_radius = None, outer_radius = None, length = None,
              grid_spacing = None, axis = None, center = None, coordinate_system = None,
              subregion = 'all', step = (1,1,1), model_id = None):
    '''Flatten a cylindrical shell within a map.'''
    rv = []
    for v in volumes:
        a, c = axis_and_center(axis, center, coordinate_system, v.position)
        r0, r1, h = parse_cylinder_size(inner_radius, outer_radius, length,
                                        c, a, v, subregion, step)
        gsp = parse_grid_spacing(grid_spacing, v, step)
        from . import unroll
        uv = unroll.unroll_operation(v, r0, r1, h, c, a, gsp,
                                     subregion, step, model_id)
        rv.append(uv)
    return _volume_or_list(rv)

And you could add a print line after the parse_cylinder_size call like this

# -----------------------------------------------------------------------------
#
def volume_unroll(session, volumes, inner_radius = None, outer_radius = None, length = None,
              grid_spacing = None, axis = None, center = None, coordinate_system = None,
              subregion = 'all', step = (1,1,1), model_id = None):
    '''Flatten a cylindrical shell within a map.'''
    rv = []
    for v in volumes:
        a, c = axis_and_center(axis, center, coordinate_system, v.position)
        r0, r1, h = parse_cylinder_size(inner_radius, outer_radius, length,
                                        c, a, v, subregion, step)
        print(f'volume {v.name} threshold {v.maximum_surface_level}, unroll inner {r0}, outer {r1}')
        gsp = parse_grid_spacing(grid_spacing, v, step)
        from . import unroll
        uv = unroll.unroll_operation(v, r0, r1, h, c, a, gsp,
                                     subregion, step, model_id)
        rv.append(uv)
    return _volume_or_list(rv)

Then restart ChimeraX and it will print the radii when you use volume unroll.

Tom


On Apr 27, 2024, at 5:55 AM, Ricardo Righetto via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:

Hi,

We've been using the 'volume unroll' command on a cylindrical structure, and while we do get some very decent results with the defaults, we want to do a systematic comparison with values entered manually for the inner and outer radius.

Specifically, I'd like to know if I can get ChimeraX to report what minimum and maximum radii it is currently using for unrolling the volume?

Currently, all I get in the reply log is this:
volume unroll #1
Opened unrolled SPA_density.mrc as #2, grid size 68,697,492, pixel 1.22,1.2,1.2, shown at step 1, values float32

From the help here it says:
(...) and inner and outer radii r1 and r2 (defaults are 90% of the smallest radius and 110% of the largest radius of the displayed isosurface, respectively, given the cylinder center and axis direction).

Since this is a high-resolution cryo-EM map with many intricate features, it's hard to visually find exactly what are the smallest and largest radii currently displayed at the isosurface. So we'd like to know what ChimeraX is finding by itself and compare it to our measurements.

Any tips are appreciated. Thank you!

--
Ricardo Diogo Righetto
_______________________________________________
ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu
To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu
Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/