
Hi Jeff, I've attached a script that opens a density map and a Chimera marker file and writes a new volume corresponding to a zone around the markers. It does not require showing the Chimera user interface to do this. Perhaps you don't need this now (I just got your follow-up email.) but perhaps you will find it useful in writing other scripts. Karin Gross at Max Planck Institute of Biochemistry has written a Chimera extension to slice tomograms at arbitrary angles. I saw it when I visited Munich in December. They also were planning on allowing marker placement on those planes. The volume planes tool could be made to average neighboring planes. Currently it simply displays a NxMx1 subvolume in solid rendering mode. Since there is no existing code in Chimera to support averaging adjacent planes that would have to be added. Probably the easiest solution is to add the adjacent planes in Python and create a new single plane volume on the fly. Tom Jeff wrote:
thanks Tom,
I will try that. alongside that, is there a way for me to run a 'zone' function and save a subregion from a python command line (no chimera launched, just import a library?)?
I have used the volume planes tool to generate a marker set of a membrane, it was handy. But, it only handles orthogonal directions, it can't provide an arbitrary interpolant (which is a large reason I rely heavily on IMOD's slicer tool); this functionality would be very useful. A second addition to the volume planes tool would simply be allowing averaging several slices together (reduces noise) in the direction normal to the planes, which may already be there (the documentation online said something about this feature, but it wasn't clear to me)
it the volume planes tool were able to handle an arbitrary view/interpolant, then I wouldn't have to depend on the slicer tool, and the previous request about rotating markers that was related to that requirement (different features available in different slicer orientations in IMOD, necessitating a rotation prior to visualization with the volume planes tool in chimera, thus requiring old marker set from original volume to be rotated to be used in new volume, etc) would effectively be voided
-Jeff
# ---------------------------------------------------------------------------- # Save a volume zone around a given set of markers as a new volume file. # def save_zone(volume_path, markers_path, radius, volume_out_path): # Read zone points atoms, bonds = marker_set_atoms_and_bonds(markers_path) from chimera import Xform xform = Xform() # Identity transform for marker points from SurfaceZone import path_points points = path_points(atoms, bonds, xform) from VolumeData import open_file_type vol = open_file_type(volume_path, 'mrc') # Get containing volume subregion ijk_min, ijk_max = containing_subregion(vol, points, radius) from VolumeData import Grid_Subregion subvol = Grid_Subregion(vol, ijk_min, ijk_max) # Make new volume with zeros outside radius from VolumeViewer import zone_masked_grid_data masked_vol = zone_masked_grid_data(subvol, points, radius) # Write new volume from VolumeData.mrc import write_mrc2000_grid_data write_mrc2000_grid_data(masked_vol, volume_out_path) # ---------------------------------------------------------------------------- # def marker_set_atoms_and_bonds(markers_path): from VolumePath.markerset import load_marker_set_xml msets = load_marker_set_xml(markers_path) atoms = [] bonds = [] for mset in msets: atoms.extend(map(lambda m: m.atom, mset.markers())) bonds.extend(map(lambda l: l.bond, mset.links())) return atoms, bonds # ---------------------------------------------------------------------------- # def containing_subregion(vol, points, radius): from VolumeViewer import points_ijk_bounds, clamp_region ijk_min, ijk_max = points_ijk_bounds(points, radius, vol) ijk_min, ijk_max = clamp_region((ijk_min, ijk_max, None), vol.size)[:2] from math import floor, ceil ijk_min = map(lambda x: int(floor(x)), ijk_min) ijk_max = map(lambda x: int(ceil(x)), ijk_max) return ijk_min, ijk_max # ---------------------------------------------------------------------------- # volume_path = '/usr/local/src/chimera-demos/volume/examples/tricorn_map.mrc' markers_path = '/usr/local/src/staff/goddard/chimera/devel/ZoneScript/test.cmm' radius = 5 volume_out_path = '/usr/local/src/staff/goddard/chimera/devel/ZoneScript/test.mrc' save_zone(volume_path, markers_path, radius, volume_out_path)