You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @brief Increment voxels between two consecutive track points.
16
+
* @param index Index of the voxel of the current point
17
+
* @param indexNext Index of the voxel of the following point
18
+
* @param incrementTerm Term which will be added to each interpolate voxel (either 1, or 1/total_number_of_tracks if proportionArg is true)
19
+
* @param outImage Pointer to the output image, used to add incrementTerm to each interpolate voxel
20
+
* @param checkInterpolateIsInsideImage If true, we must check that interpolate voxels are inside image before adding incrementTerm
21
+
* @details Add interpolation voxels if two consecutive track points are separated by at least one voxel. Then increment the number or proprtion of tracks
IndexType indexTemp; //where the interpolate voxels' index will be stored
29
+
itk::Image <double, 3>::RegionType region = outImage->GetLargestPossibleRegion(); //the whole image
30
+
bool insideImage = true;
2
31
3
-
#include<animaReadWriteFunctions.h>
4
-
#include<animaShapesReader.h>
5
32
6
-
#include<vtkSmartPointer.h>
7
-
#include<vtkPoints.h>
8
-
#include<vtkPointData.h>
9
-
#include<vtkPolyData.h>
10
-
#include<vtkCell.h>
33
+
double dx = indexNext[0] - index[0]; //difference in x coordinate
34
+
double dy = indexNext[1] - index[1]; //difference in y coordinate
35
+
double dz = indexNext[2] - index[2]; //difference in z coordinate
36
+
double maxStep = std::max(std::max(std::abs(dx), std::abs(dy)), std::abs(dz)); //maximum between the three absolute differences
37
+
for (int l = 1; l < maxStep; l++)
38
+
{
39
+
//We enter this loop only if maxStep >= 2.
40
+
//In that case, we create interpolation voxels, to try to modify all and only all the voxels through which the track passes between point and pointNext
41
+
//We repeat maxStep - 1 times and not maxStep times, because otherwise, index = indexNext, and we would increment indexNext twice
* @brief Convert an input track file (vtp or vtk) into a density map.
67
+
* @details The density map is a 3D image giving for each voxel the number or proportion of tracks from the input image passing through it.
68
+
*/
14
69
intmain(int argc, char **argv)
15
70
{
16
-
TCLAP::CmdLine cmd("Filters fibers from a vtp file using a label image and specifying with several -t and -f which labels should be touched or are forbidden for each fiber. INRIA / IRISA - VisAGeS/Empenn Team", '',ANIMA_VERSION);
71
+
TCLAP::CmdLine cmd("This binary converts an input tracks file (vtp or vtk) into a density map, giving for each voxel the number or proportion of tracks from the input image passing through it. \n Warning : Anima uses LPS convention; if input file uses another convention (for example RAS) one must convert to LPS convention first. \n For example to move from RAS to LPS convention, one must rotate the input tracks file by 180° around z-axis. \nINRIA / IRISA - VisAGeS/Empenn Team", '',ANIMA_VERSION);
TCLAP::ValueArg<std::string> outArg("o", "output", "Output density map", true, "", "output density map file", cmd);
76
+
TCLAP::ValueArg<std::string> geomArg("g", "geometry", "Geometry image", true, "", "geometry image, file with ext .nii.gz or similar", cmd);
21
77
22
-
TCLAP::SwitchArg proportionArg("P","proportion","Output proportion of fibers going through each pixel",cmd,false);
78
+
TCLAP::SwitchArg proportionArg("P", "proportion", "Output proportion of tracks going through each voxel", cmd, false);
79
+
TCLAP::SwitchArg noInterpolationArg("N", "no-interpolatation", "No creation of interpolation voxels if two consecutive track points are separated by at least one voxel", cmd, false);
//TransformPhysicalPointToIndex enables to move from point coordinates to voxel index inside the output image. It returns true if the point is inside the image and false otherwise (in theory it should not happen)
158
+
if (outImage->TransformPhysicalPointToIndex(point, index))
72
159
{
73
-
if ((currentIndex[k] < 0)||(currentIndex[k] >= region.GetSize(k)))
160
+
if (!outImage->TransformPhysicalPointToIndex(pointNext, indexNext))
161
+
{
162
+
//The current point is inside the image but not the following one
163
+
outImage->SetPixel(index, outImage->GetPixel(index) + incrementTerm); //increment the current point's voxel
164
+
if (interpolateVoxels)
165
+
{
166
+
//Increment voxels between index of the current point and index of the following one
167
+
//As pointNext is not inside the image, we may create interpolate voxels which are not neither. So we put set last argument to true to check that interpolateVoxels are inside the image within the function
0 commit comments