This task page enables you to draw closed contours on frames and calculate the enclosed area. You can draw groups of contours to represent the shape of an object, calculate its volume and view its shape as a surface rendered image. It is also possible to define a surface patch by drawing on a 3D surface that you have created and 'cutting' the patch out of this surface. Finally, you can also export or import surfaces and export textual information about the object using this task page.

The draw task can be selected either by using the tabs at the top of the task pages, or by selecting from the task menu. To actually draw contours, you need also to select the drawing icon from the toolbar.

Drawing single object contours

Many different objects can be drawn on the same data. Select the current object to be drawn with the drop-down menu at the top of the 'current selection' group. The following four buttons will then be coloured to match the currently selected object. Drawing in the image window will then add contours to this object.

There are three ways to draw a single contour of an object in the image window. Clicking and dragging will draw a line in this window: when you release the mouse button, it will automatically be joined up to form a closed contour. Alternatively, if you click and release without moving the mouse, the contour will be defined with individual clicks until you click near an existing point towards the start of the contour.

The final method for drawing contours is to use the thresholding controls in the task page. With thresholds enabled (by checking the 'use thresholds' box), data in the current thresholded range will be displayed in magenta. The sliders for controlling the thresholded data values can be used in two ways. If the first slider is less than the second, the thresholded data will be between these values, otherwise, it will be less than the first and greater than the second. The 'not' slider determines data which will never be used in a region, even for the more flexible 'join gaps' procedure below. These sliders are all in 'brightness' values, with zero representing black and 255 representing white. For 16-bit data, the level is also affected by the windowing, which changes the mapping between actual data value and brightness. The thresholds are displayed in the actual data units just below the sliders.

If you click on any of the magenta regions, a contour will automatically be drawn around that region, using the actual data values and thresholds to define the exact location. The 'segment regions' checkboxes in the task page control which borders are drawn around: 'all' will create contours around both the inside and outside borders of the magenta region, whereas 'holes' and 'body' will only draw round the inner or outer edges. The accuracy with which this follows the region border is controlled by the 'contour accuracy' slider. Increasing this value generates less accurate contours but with fewer points. Alternatively, if the 'automate using zoom' button is clicked, accuracy is controlled by the current level of zoom in the review canvas. Zooming up close will generate a very accurate contour exactly following the edge, whereas zooming out will generate a less precise contour.

The 'follow ridges' checkbox and 'join gaps' slider act together to allow the segmentation of regions which are not exactly included in the magenta threshold. If 'follow ridges' is not checked, then the segmented region can 'jump' over gaps as wide, in any direction, as the 'join gaps' slider. If 'follow ridges' is checked, then the contour will always exactly follow the magenta region unless there is a ridge, which continues from the current region, and is still above the 'not' (darker magenta) threshold. In this case it can follow such ridges so long as they are shorter than the 'join gaps' slider, and they connect two magenta regions. If the 'join gaps' slider is set to 0, the contour will always precisely follow the edge of the magenta region.

The 'connected regions' checkbox restricts the contour drawing to regions which are connected to the initial click location. Otherwise, all magenta regions in the current frame will be segmented. Likewise, the 'Within ? mm' slider will restrict contour drawing to regions which are within this distance from the initial click point.

Segmenting an entire 3D object

If the 'every frame' slider is set to anything other than zero, then clicking in a magenta region will automatically generate contours in every n frames, where n is the value of this slider.

In this case, most of the controls are then interpreted in 3D rather than 2D. For instance, the 'connected regions only' checkbox will segment any region which is connected to the initial click point in a 3D sense. Also, the 'segment regions' options now interpret the 'inside' and 'outside' topology in 3D, not in 2D. The ridge or gap following is also performed in 3D rather than in 2D.

Editing object contours

Once a contour has been drawn, it can be edited by clicking and dragging points on the contour. If you move a contour point over another point from the same contour, Stradview will ask you if you want to split this contour at this point. If you move a contour point over another point from a different contour, Stradview will ask you if you want to merge these contours at this point. If you click and drag a segment between points, an additional point will be inserted and then dragged. Once you are moving an existing point on a contour, clicking with the other mouse button while the first button remains down will result in additional points being added to the contour.

It is also possible to use parts of existing contours in a new contour: this is useful if you have created contours by thresholding the data (as described above) but parts of the contours are missing or incorrect due to a poorly defined threshold. Start drawing a new contour by clicking and releasing in one of the regions where a new section of contour is required. Then continue defining new contour points until you reach an existing (correct) section of contour. Now click on the nearest point in the correct contour. You will see an arrow appear, which defines the direction and location at which an existing contour will be used. If this arrow is incorrect, simply click some distance away from the contour and it will disappear. If it is correct, then click on the last point in the contour you want to use: that section will be added to the current contour. You can then continue defining as usual, clicking on the initial point to finish. Note both the new and partially used old contour will still exist at the end of this operation, and you will probably want to delete the old contour once you have finished.

Contours can be deleted by using the delete tool and drawing over the contour. As each contour is drawn over, it will appear slightly transparent. Once the mouse button is released, Stradview prompts for whether you want to delete the selected contours or re-assign them to another object. If only a single contour is selected using this method, it is also possible to delete all the contours inside the selected contour, or delete contour concavities. In the latter case, the detected concavities will be displayed as contour points only, with no line passing through them. Alternatively, clicking on a single point will remove that point from the contour.

Contours can also be deleted or re-assigned in the 3D window, by exactly the same method. Simply use the delete tool to draw over the contours you want to select, then either delete or re-assign them.

Finally, if you want to delete all contours in a particular object, or all contours in this object in the current frame, there is a button on the task page beside each object definition which can be used for this purpose.

Contour area, object volume, and 3D visualisation

In order to estimate the volume of the object, you need to draw several contours, in different frames, such that the whole set of contours as seen in the 3D window is representative of the shape of the object. In particular, you should ensure that the first and last contour are close to the edges of the object. All the contours in the current object can be quickly located by using the 'review contours' slider.

Once you have drawn several contours to represent one or more objects, you can get Stradview to interpolate a surface through the contours and display a surface-rendered image of the object (or objects) in the 3D window. To do this you click on the 'Update' button (which just generates a surface for the current object), or alternatively the 'Update all' button. The interpolation resolution is set by the 'Surface resolution' control: higher values generate surfaces with more, smaller, triangles. The surface can be smoothed using the 'Smoothing strength' control. The 'Standard' smoothing ensures that the surface does not shrink as it is being smoothed, i.e. it is a type of volume-preserving smoothing. 'Pre-version 4.7' smoothing is just a simple average of neighbouring vertices.

If you edit one of the contours after creating a surface, the surface will revert to contours until you click the button to update it again.

Three checkboxes below these buttons control the precise way in which the contours are interpolated. The first two, 'object' and 'holes' connectivity, enable a more complex interpolation (maximal disc-guided shape-based interpolation) which will perform better when the contours are very different from each other or particularly sparse. As the names suggest, 'object' forces better connectivity of the regions within contours, whilst 'holes' does the same for regions outside contours. The last checkbox 'triangulate over ends' causes the interpolation algorithm to extrapolate a surface after the last contour, providing the image data continues beyond this contour. The default behaviour (checkbox not ticked) is to stop at the last contour and just include a perfectly flat 'cap' at each end.

The 'compounding depth' slider allows nearby image data to be projected onto the surface, producing a texture-mapped display: this is best appreciated when the surface's colour is set to black (see 'Object controls' below). Setting the slider to a negative value compounds data from within the object whereas setting it to a positive value will compound data from outside the object.

Generally, if the contours are generated manually, the best way to get a good representation of an object is to draw the minimum number of contours that are needed to effectively represent the shape. It is not necessary to manually outline the object on every frame. On the other hand, for automated contours, more details can be seen if more contours are generated.

When a surface is generated for each object, the centre of gravity of the surface is also calculated. This is displayed for the current object just below the area and perimeter for the current contour. The 'Find' button can be used to locate orthogonal views which intersect with the centre of gravity, as well as the nearest frame, just as the 'Find' buttons on the landmarks task page. This also temporarily sets the centre of rotation in the 3D window to the centre of the current object: changing the size of the window, or clicking in it with the 'zoom' tool will reset this behaviour.

The intersection of any existing surface is shown in the reslices and all the frames as a dotted line. These intersection lines cannot be edited.

You can delete the surface (without deleting the underlying contours) by using the 'delete' button for the corresponding object.

Creating a patch from a surface

If you want to define a surface patch (i.e. a non-closed surface) you must first create a closed surface as above, which contains the patch you are interested in. Having done this, you can use the 'draw' tool to draw on the surface in the 3D window, and define the edge of the patch as a curve: see the landmark task page for more information on defining surface-based curves. The edge is drawn one point at a time, with the point always positioned exactly on the surface, underneath the draw tool.

You can change to the 'rotate' tool at any point in order to change the viewpoint. Otherwise the 'draw' tool can also be used to move existing points, or to insert points if you click on an existing line between two points.

The 'erase' tool can be used to delete an existing point, but it is also used to cut the surface once the curve has been defined. This is achieved in two stages. Firstly, click on one of the lines connecting two points, and you will have the option either to erase the whole curve or to split the surface using this curve. If you select the latter, the current surface will be split along this curve and the projection of the curve onto the surface will turn red to indicate this has been done. This splitting can also be achieved by using the 'split' button on the landmarks task page. At this stage, the patch is still regarded as being in the same object. You can repeat the splitting operation using further curves if the topology is complex and more than one split is needed to separate out the patch.

Once the surface has been split, clicking on the patch with the 'erase' tool will give you the opportunity to assign this patch to another object. After this, it can be exported separately: the patch will also be removed from the original object.

Note that there are some situations where the curve you have drawn might be ambiguous and the surface will not be split. If this is the case, the ambiguous segment will be highlighted in red, and you will then need to define some more points in this segment before attempting to split the surface again.

If you find that you are unable to select a line, try clicking slightly closer to one of the points at each end of the line: particularly if the line passes a long way from the actual surface.

Exporting and importing surfaces

All the contours which define a surface are saved in the stradwin files. So if you load this data again, you can re-create the surface by using the 'Update' button. If you want to export this surface (rather than just the contours), it can also be saved to either a PLY or a VRML file, using the 'Save' (for just the current surface) or 'Save all' (for all surfaces in the same file or set of files) buttons.

For regular data sets, for instance DICOM data, it is also possible to use these buttons to export the surface as a compressed NIFTI mask. This is a volume representation, aligned with the loaded data, which contains a value for each voxel corresponding to which stradview object (if any) this voxel is inside. This can be used as a template in various external software packages.

Surfaces can also be imported directly into Stradviw if you have already generated segmentations (presumably in some other application) and saved them as either a PLY or a VRML file. Use the 'Import surface' button near the top of the page. Stradview will then read in and display the surface, and additionally generate a set of contours that are consistent with this surface. If you edit the contours, Stradview will discard the imported surface, though you can generate a new surface consistent with the edited contours using the 'Update' button.

Note that if the imported surface is a patch (i.e. it is not closed), then Stradview will still generate non-closed contours, but will not be able to re-create the surface patch from these contours once the surface is deleted.

When importing a surface, Stradview also looks for a file with the same name as the surface but with a '.mtx' extension. If such a file exists, it can be used to define a 4 x 4 homogeneous transformation matrix which will be applied to the surface as it is read in. The file should be in a simple text format, with four numbers on each of four lines, separated by spaces. These directly represent the transformation matrix you wish to apply to the vertices and normals (if defined) of the imported surface. Similarly, if the object extension is '.euler' then the file is presumed to be from elastix and the TransformParameters as defined in ITK are used.

Note that Stradview will not allow a surface to be read-in which does not overlap with at least some of the image data. Stradview will only generate contours which intersect with the image data. If point normals have been defined in the file, these are used for display, otherwise they are calculated from the triangles.

Exporting a text file with object information

When exporting a surface, it is also possible to save it as a TXT (plain text) or CSV (comma separated value) file. In this case, various summary information is reported about the object, including the volume, area, perimeter and minimum, maximum and average data value enclosed by the surface. This information is also reported for each original contour (if the surface has not yet been updated) or for every image which intersects the surface (if the surface has been updated). The files contain headers explaining the information and units, and the CSV file can easily be loaded into most spreadsheet software.

Object controls

The draw task page contains two lines of controls for each object which you have started to define, plus at least six further lines for new objects. As you create more objects, more will be displayed in this list.

In each first line, there is a button which can be used to control the colour of the object. Next is a text control which can be used to label the object. After this, there is a button which can be used to clear all contours for that object, or all contours in the current frame for that object, or just delete the 3D surface representation of the object. On the next line there is a box to set the opacity of the object in the 3D window: setting this to zero will disable display of this object in the reslice and 3D windows. After this is a check-box that you can use to indicate whether or not the object is solid and should have closed ends (though this does not work for imported surfaces, which are predefined as being solid or open in the PLY or VRML file).

There are also several key presses which affect the display of surfaces in the 3D window.