Draw

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 surface and visualise the surface. 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.

You can also import object contours from external files or create objects from categorical data which has been created in other software. Surfaces can also be directly exported or imported and textual information about the object can also be exported 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 object' group. The following buttons will then be coloured to match the currently selected object and drawing in the image window will 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 and most common method for drawing contours is to use the contour creation controls in the task page. There are two ways to use these: for normal data, enable the thresholds by clicking 'Show thresholds', in which case data in the current thresholded range will be displayed in a magenta tint. Alternatively, for categorical data (i.e. which already consists of a set of label values), clicking 'Show labels' will display the data colourised according to the label.

Automatically contouring thresholded data

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' control determines 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. If you want to segment a 3D object, you will need to set the 'every frame' slider to non-zero - see below.

The 'look for ridges, valleys' checkboxes and 'join gaps' slider act together to allow the segmentation of regions which are not exactly included in the magenta threshold. If neither 'ridges' nor 'valleys' is checked, then the segmented region can 'jump' over gaps as wide, in any direction, as the 'join gaps' slider. If 'look for 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, to a length loosely defined by the 'join gaps' slider, and so long as they connect two magenta regions. Similarly 'look for valleys' allows valleys to be excluded from the contours, even if they are within the magenta region. 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.

The 'Fix concavities' slider allows concavities (large inside regions with a relatively small opening to the outside) in either a 2D contour or 3D surface to be automatically filled in. A larger value will categorise more inside regions as being concave. This can be very useful for surfaces which have a very small gap in the data which you want to disregard. Setting this slider to zero will prevent any concavities from being filled in.

Automatically contouring labelled data

In a similar way to with thresholds, if you are showing labels and click on any of the coloured label regions, a contour will automatically be drawn around that region, representing the exact edge of the labelled data.

In this case, the only other controls which affect this contour are the 'contour accuracy' slider, described above, and the 'every frame' slider, described below.

Segmenting an entire 3D object

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

In this case, most of the controls for thresholds are 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 and valley following is also now performed in 3D, such that they are actually following thin laminar surfaces rather than ridges, or thin spaces between surfaces rather than valleys. This is designed to be able to accurately capture surfaces, for instance bones, with thin regions which drop below the threshold, or with gaps between them which rise above the threshold. See How-to: Create Surfaces for more advice on this.

The 'Split into objects' slider now controls whether to split the segmentation into multiple separate objects after automated thresholding. If set to one, all contours will stay in the same (current) object. Otherwise, up to this number of sequential objects will be used, starting with the current object which always contains the region which was initially clicked on. Following this are any regions which are distinct, in order of size, with all remaining regions placed in the last object.

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 erase 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 (and surfaces) can also be deleted or re-assigned in the 3D window, by exactly the same method. Simply use the erase tool to draw over the contours or surfaces you want to select, then either delete or re-assign them.

Finally, if you want to delete or re-assign a particular object, use the 'Delete' button under the current object selection. Depending on what information exists for this object, you will be prompted whether you want to delete all contours in this object, or just in the current frame, or to delete curves or landmarks associated with this object, or re-assign the whole object to another object. You can also delete all contours in all objects with the 'Delete' button in the 'All objects' section.

Contour area, object volume, and creation of a surface

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 'find 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, click on the 'Update' button for the current object (which just generates a surface for the current object), or alternatively the 'Update' button for all objects. The interpolation resolution is set by the 'Resolution' control in the 'surface creation' section: higher values generate surfaces with more, smaller, triangles. The surface can be smoothed using the 'Smoothing' control. This smoothing ensures that the surface does not shrink as it is being smoothed, i.e. it is a type of volume-preserving smoothing.

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. It is also possible to deliberately remove the surface by using the 'Revert' button for either all objects or just the current object.

Three checkboxes below these buttons control the precise way in which the contours are interpolated. The first two, 'body' 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. 'body' forces better connectivity of the regions within contours, whilst 'holes' does the same for regions outside contours. The last checkbox 'cover ends within data' 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.

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.

Visualisation of surfaces

Once a surface has been created, 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.

The material parameters for each surface are controlled by a line of tools for each object at the bottom of the draw task page. There will be a section for each object you have started to define, plus at least six further sections for new objects. As you create more objects, more will be displayed in this list.

At the left is a button which shows the current material used for this object. Clicking on the material sphere image brings up the material selector. This allows you to change colour, metallic, roughness and anisotropy values independently, or by selecting a pre-defined material type. New materials can also be saved to this list: by default, these are stored in the 'materials' sub-directory of the application data folder. These materials will be available whenever you run Stradview and can also be selected from the volume visualisation page.

On the right of this button is a text control which can be used to label the object. Below this is a slider which sets the opacity in the 3D window: setting this to zero (left) will disable display of this object in the reslice and 3D windows. Finally there is a check-box that you can use to indicate whether or not the object is solid and should have flat caps covering any otherwise open ends (though this does not work for imported surfaces, which are predefined as being solid or open in the PLY or VRML file).

These object properties can also be controlled for all objects simultaneously, by clicking the 'apply changes to all objects' checkbox. In this case, changing the colour or material sliders for any object will update that property for all other objects as well. These properties can be reset to their default values using the 'Reset' button for all objects or 'Reset properties' for the current object. Resetting properties in this manner will only change the object names to default values (e.g. 'Object 1') if there are no contours defined for the object. You can also 'Pack' all objects so all the currently defined objects are stored sequentially from the first object, with all other blank objects reset.

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. 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. The following 'Compounding' control determines exactly how this nearby data is projected on to the surface.

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

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.

Importing or creating objects

The contours for objects in Stradview can also be set up from a pre-defined segmentation. There are several ways to do this. In all cases, multiple objects can be created, starting from the currently selected object.

You may already have a data set which is mask or categorical data: i.e. the data value represents a label signifying which object that voxel belongs to. This could either contain multiple objects (several different labels) or a single object (i.e. binary data). This can be loaded up as a new data set: once this data set has been loaded, using 'Create from label data' will automatically contour the boundary of each label on each slice, and associate each different label with a different object. These contours are simplified according to the 'contour accuracy' slider, which will make them easier to manually edit afterwards.

You can also load such a data set directly to contours on top of existing image data by using the 'Import from data file' button on the draw task page. This will load and convert the file to contours as above, but will only work if the imported label data and loaded image data both match each other exactly, i.e. have the same image scale, size and locations. In this case it is possible to load multiple label data files simultaneously, which will each be placed in different objects.

If you have a DICOM RTSTRUCT or SEG file which corresponds to a data set that you have already loaded, then the 'Import from data file' button can also be used to import this data. Both these files contain the coordinates of the data as well as the segmentation structures, hence these files will only be loaded if the coordinates match the locations of the loaded images. The RTSTRUCT file already contains contours associated with named objects, so these contours are loaded directly. The SEG file contains segmented voxel data, so contours are created from the boundaries of this data. As in the case above, the contours are simplified according to the 'contour accuracy' slider: if you want the original RTSTRUCT contours, then set this slider to zero before importing them.

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' button, either just for the current object or for all objects. In the latter case, either all objects will be saved in one file (VRML) or in multiple files using the object names (PLY).

For regular data sets, for instance DICOM data, it is also possible to use these buttons to export the surface as a compressed NIFTI or NRRD mask. This is a volume representation, aligned with the loaded data, which contains a label 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, and can also be loaded back into Stradview then displayed using 'Show labels'.

Surfaces can also be imported directly into Stradview if you have already generated segmentations (presumably in some other application) and saved them as either a PLY or a VRML file, with the 'Import' button for the current object. 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.

Normally, a contour will be generated for every frame in the data set which overlaps with the surface. If you want a less dense set of contours, then set the 'Every frame' slider to a value larger than one before importing the surface.

If the imported surface is a patch (i.e. it is not a closed surface), 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.

If the imported surface is a PLY file, then Stradview will also load any surface landmarks or curves contained in this file, and delete any surface landmarks or curves that were previously associated with this object.

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.