Smooth edge when masking volume data

Thanks, Tom. That helped a lot. However, is there anyway to smooth out the masked edge? I end up with chopped voxels (looks like stair-steps), rather than getting an interpolated smooth surface at the edge. This is true whether I am masking directly, or the inverted view.
Kelly
Hi Kelly, When you mask volume data in Chimera using Volume Eraser or the mask command it sets the density values to zero outside the surface. In places where high density crosses the surface the masked result looks horrible -- volume contour surface is jagged with stair-steps following the pattern of the volume grid. I don't have any trick to make that surface look smooth. I have two ideas about how to approach the problem. One is to not have the density fall to zero immediately outside the surface. If it rolled off gradually the contour surface of the masked data would look better. I'm not optimistic that that will produce a good result. The second approach is to do something different from masking. Instead clip the volume surface with the sphere surface and cover the resulting holes with patches of the actual smooth sphere surface. I think this would look very nice and the patches of sphere could be a different coloring which would give a nice visual indication that you have cut through high density. I have not implemented either of these two ideas. Just last week I had a lengthy discussion on this problem with Greg Pintilie and Ernesto Arias. Greg said he might try the gradual fall-off technique. I include that email discussion below. Tom -------- Original Message -------- From: Greg Pintilie To: Tom Goddard Date: 5/24/11 6:10 PM
Right - it's numpy to the rescue; I'll give it a shot... I think if we use a smoothing filter with relatively high width the staircase effect may not be as bad as you think... though then the boundaries may become exceedingly smooth; so it will be a fine balance. Will let you know how it goes!
Greg
On Tue, May 24, 2011 at 7:42 PM, Tom Goddard wrote:
Hi Greg,
It's an interesting idea. But it seems to me there will still be a discontinuity in map values. For example imagine you have a box shaped region with density values 1 inside and 0 outside. The Gaussian filter of that will give values approximately equal to 0.5 at the surface (if the Gaussian is half in the 1 region and half in the 0 region). So I think the drop from 1 to 0.5 on the surface is likely to give the same ugly artifacts. That said, implementation would be trivial. Just compute the Gaussian smoothing and copy it only where the original map has zeros (can be done with a line or two of tricky numpy Python code).
You know Gaussian smoothing is what the heat equation produces. If you modify your idea so the non-zero density points are fixed temperature sources, and the heat flows to the zero grid points (by averaging neighbor temperatures) then you would get a continuous fall-off. Again it is a pretty easy calculation in Python/numpy. But I'm not optimistic about the results. The trouble is we've created this horrible stair step surface and it will take pretty long range smoothing to get rid of the stair steps. I think a good smooth cut is going to require stepping back and not producing the stair steps in the first place -- you need a boundary definition that is smooth instead of discretized. For instance when we make a contour surface we trilinear interpolate the 8 nearest grid points and the surface comes out smooth. Not quite sure how to do the equivalent for watershed regions.
Tom
Sounds good - thanks for all those insights, Tom. I agree that solution is not ideal, but I'm glad it helps at least a bit. I just got an idea that might be interesting to try - I mentioned that you can Gaussian-filter the masked map, which would lessen that huge drop in density values at the boundary, but this removes good detail from the actual map as well. What I'm thinking to try is to do the filter, but only apply it to voxels with 0 density values (the masked portion); that way the original density map gets left alone, and the boundary no longer has a drop from some density value to 0... what do you think Tom, could there be an easy way to implement this using current functions? Done voxel by voxel in python would probably be exceedingly slow...
Greg
On Tue, May 24, 2011 at 7:04 PM, Ernesto Arias wrote:
Hi,
I tried and is working. The problem is that I'm visualizing the volume close to the noise level, so the segmentation at lower thresholds could be trickier, but I think I'll can deal with it.
I really appreciate your help. Ernesto.
On Tue, May 24, 2011 at 4:20 PM, Tom Goddard wrote:
Hi Ernesto,
Yes, now I understand. The Segger regions only include grid points above the contour level that was displayed when you made the segmentation. So when you mask to one of those regions, then use a contour level that is the same or lower (or even a little higher) than the Segger contour level you get a horrible surface because the density has been set to zero everywhere below the segmentation contour level. The solution is to use a low contour level when you do the segmentation -- a contour level substantially lower than what you plan to use to actually view the masked regions, so that the zero density values are not near the eventual contour surface you will be displaying. The Color Zone approach is effectively doing this, since it includes all the density out to a specified distance.
Tom
Hi,
I see what you mean, but I'm not sure why I get different results. Maybe I'm not explaining well what I'm doing There are attached some images and volumes to illustrate it better.
When I segment the map using segger, mask the original map using the segger "Regions->mask map with selected" I get the segger.mrc map or the segger_masked_region.png that I'm attaching. However, when I place some markers around the same region of the original map, color the map using Color Zone, and do the Split map option I get much better results (color_zone.mrc and color_zone_masked_region.png).
One thing I noticed is that the histograms of segger.mrc and color_zone.mrc are completely different. The segger.mrc volume has a sharp cutoff at low threshold values whereas color_zone.mrc has a more continuous histogram. Could it be the problem?
Thanks so much for your help. Ernesto.
On Tue, May 24, 2011 at 10:10 AM, Tom Goddard wrote:
Hi Ernesto, Greg,
The Color Zone splitting tool uses the same method of setting density values to zero outside the region. So the jagged surface appearance should be every bit as bad looking as the Segger ones. If color zone really does look better you'd have to show me an example. It shouldn't look any better.
The problem is fundamentally that Segger defined the boundary between regions by saying which grid point are in the region and which are outside the region. So the surface has stair steps matching the volume grid points. I don't have a good idea of how to smooth this jagged surface out. Ideally I'd want to see the jagged surface as smooth, but colored differently from the other parts of the surface. I'd like the different coloring because at this surface patch you have cut through high density -- it is an artificial boundary. When you hide that by masking it makes misleading images. I have an idea about how to achieve both these goals but it is not implemented yet. Basically I don't mask the volume. Instead I intersect the volume surface with the masking surface. By "intersect" I mean I show the mask surface wherever it lies inside the volume surface, and the volume surface wherever it lies inside the mask, and hide everything else. The mask surface and volume surface can have two different colors. Another way to think of this idea is that I clip the volume surface using the mask surface. We already allow you to clip a surface with a plane in Chimera. This is just a generalization where you can clip a surface with some arbitrary other surface. This isn't too hard to implement, but I want the boundary where the volume surface and the mask surface meet to be a smooth curve. That requires cutting up the the triangles of the original surfaces. I've been meaning to try this for years now. I think it would look great.
One further comment. Segger makes its region surfaces using the list grid points in the regions, so how does it make the surface look smooth? The main trick it uses is "surface smoothing", 5 iterations with smoothing factor 0.25. You can enable this for the volume surfaces using the Surface and Mesh Options panel and see if it helps. Segger also rebins the grid points which may help the appearance and that is possible but not so easy to duplicate with a volume surface using standard Chimera features.
Tom
> Hi Ernesto, > > That is a good point, I'm not completely familiar with how the color > zone tool splits out a subsection of the map, so I am cc-ing Tom > Goddard, who I think wrote that tool, and is a developer of Chimera > and co-developer of Segger. Tom, could you look at the message Ernesto > sent and my reply, both below? Let us know if you have any further > insights into how we can make segmented-region-masked maps have nicer > boundaries... > > Greg > > > > On Sun, May 22, 2011 at 8:26 PM, Ernesto > Arias > wrote: >> Hi Greg, >> >> Thanks so much for answering my question. Everything is crystal >> clear. >> For illustrating the segmentation results I can use the segmented >> regions, >> but I wanted to make a morphing and some movies using the segmented >> regions >> and I would be easier if I could save the maps without loosing >> details. >> I >> tried to use a lower threshold and also to filter the volume before >> segmenting it, but the results are not much better. >> >> I'm not a programmer so I'm sorry if I say nonsenses. Using Chimera >> "Color >> zone" tool you can color different regions in the volume using >> markers >> or >> atoms, and it has the option of splitting the colored regions into >> different >> maps and save them. In that case I don't notice a a coarser surface >> in >> the >> manually segmented maps. Could I use the segger information to color >> the >> volume with Color zone, and use the split map option to segment the >> map? >> >> Thanks again for your help, >> Ernesto. >> >> >> >> On Fri, May 20, 2011 at 7:50 AM, Greg Pintilie >> wrote: >>> Hi Ernesto, >>> >>> Sorry for the slow response - but thanks for the message and the >>> question. I believe the artefact you are noticing is that when you >>> mask the map with the segmented region, the map densities are set to >>> 0 >>> everywhere except inside the region. Hence instad of a gradual >>> decrease in density at the boundary, making the surface smooth, as >>> you >>> can see in your original map, now there is a sudden drop from some >>> density value to 0 in the segment-masked map. This manifests itself >>> as >>> a coarser surface (as you describe it, the triangles look bigger >>> because you can actually see them). I've sort of know about this >>> problem for a while, but I'm not sure I know yet a good way to >>> address >>> it. I've tried, for example, to extend the segmented regions by a >>> small number of voxels when masking the map, however this looks even >>> worse (it sometimes looks like little fragments coming out of the >>> surface). As long as you know why this happes (let me know if it's >>> still not clear, and I'll try to explain more), I hope at least it >>> seems reasonable. If you have any ideas on how to address it, please >>> let me know! Meanwhile, here are some things you might try to get >>> around this issue: >>> >>> 1) filter the masked map - use the Volume Data / Volume Filter tool >>> - >>> this will remove some signal from your map, but it will make the >>> boundaries smoother as well >>> >>> 2) if you're mainly concerned about illustrating the segmentation >>> results, re-segment the masked map, and use the segmented region for >>> illustration - the segmented region is always smooth as you might >>> have >>> noticed... >>> >>> I hope this helps, and again let me know if you have any ideas... >>> >>> Greg >>> >>> >>> >>> >>> On Tue, May 17, 2011 at 6:51 PM, Ernesto >>> Arias >>> wrote: >>>> Dear Greg, >>>> >>>> My name is Ernesto and I'm a postdoc in James Berger's lab at UC >>>> Berkeley. >>>> I'm using segment 1.6 built in chimera 1.5.3 and is working >>>> remarkably >>>> well. >>>> I have a question and I'd be grateful if you could answer it. >>>> I want to save in individual mrc files the segmented regions of my >>>> map, >>>> but >>>> when I do it and open the volume of the subregion region it seems >>>> like >>>> the >>>> triangle size is bigger than in the segmentation and in the >>>> original >>>> volume. >>>> I tryed to save the segmented volumes using the "File->save" >>>> options >>>> of >>>> segger as well as "Regions->Mask map with selected", but I get the >>>> same >>>> results. >>>> I don't know if I'm explaining myself clear enough, so I attach two >>>> pictures >>>> to try to illustrate what is happening. >>>> Do you know how can I save segmented regions without this loss of >>>> quality? >>>> >>>> Thanks very much for you help, >>>> Sincerely, >>>> Ernesto. >>>> >>>> >>>>
Thanks, Tom. That helped a lot. However, is there anyway to smooth out the masked edge? I end up with chopped voxels (looks like stair-steps), rather than getting an interpolated smooth surface at the edge. This is true whether I am masking directly, or the inverted view.
Kelly
On Mon, 16 May 2011 12:18:01 -0700 Tom Goddard wrote:
Hi Kelly,
There is no command to position the volume eraser sphere using typed coordinates.
If you want to erase a spherical region centered on the center of a virus map use the shape and mask commands:
shape sphere radius 120 center 0,0,0 coord #0 color blue mask #0 #1 invert true
The first command makes a spherical surface of radius 120 Angstroms at center 0,0,0 (Angstroms) in the map #0 coordinate frame colored blue. The second command copies the region of map #0 outside the sphere #1, making a new volume data set.
The main trouble here is figuring out the coordinates of the center of virus map. The virus map origin is set in the Volume dialog Coordinates panel where you specify the grid index for position (0,0,0). In the above example I've got the map origin set to the center of the virus (EMDB 1058, grid index 87 for a size 175 map, base index is 0). You can use
shape sphere radius 120 center #0 color blue
which puts the center at the center of the bounding box of the displayed surface for map #0. But that doesn't in general give you the exact center of symmetry. So it is better to find the exact grid point that is the center of symmetry used when the map was calculated.
Tom
Hi,
I would like to place the origin of the eraser to correspond with the center of my map but haven't found a way to define its position based on coordinates, only by moving it with the mouse. Is there a line command or other menu option that allows me to set the position more precisely?
Thanks, Kelly
participants (1)
-
Tom Goddard