Skip to content

Commit d57952e

Browse files
authored
Merge pull request #8 from katjaq/master
Master
2 parents fb1d9c5 + dddebbb commit d57952e

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ A command-line tool to work with volume data.
1818
<tr><td>-info</td> <td>information: dimensions, data type, pixel size</td></tr>
1919
<tr><td>-threshold float int</td> <td>threshold(level,direction)</td></tr>
2020
<tr><td>-volume</td> <td>calculate volume</td></tr>
21+
<tr><td>-new</td> <td>create a new volume with dimx,dimy,dimz,pixx,pixy,pixz,offx,offy,offz</td></tr>
2122
<tr><td>-zigzag</td> <td>print volume values in zigzag order</td></tr>
2223
<tr><td>-decompose str</td> <td>decompose(basename) a volume with many values into volumes with one single value</td></tr>
23-
<tr><td>-strokeMesh str</td> <td>set the vertices of the mesh (text format) at input path to value=max+1</td></tr>
24+
<tr><td>-strokeMesh str</td> <td>set the surface of the mesh (text format) at input path to value=max+1; mesh needs to be in voxel coordinates</td></tr>
2425
<tr><td>-surfaceNets level path</td> <td>extract isosurface from the volume at the indicated level using the surface nets algorithm, save at the indicated path</td></tr>
2526
<tr><td> -sampleMesh str1 str2</td> <td>sampleMesh(mesh_path, result_path) save the volume values at the vertices of the mesh pointed by the file path to the result path</td></tr>
2627
</table>

main.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,8 @@ void strokeMesh(char *path)
18611861
sz.y=max.y-min.y;
18621862
sz.z=max.z-min.z;
18631863
*/
1864-
1864+
1865+
/*
18651866
// transform vertex coordinates to voxel indices
18661867
printf("offset: %f, %f, %f\n",h->srow_x[3],h->srow_y[3],h->srow_z[3]);
18671868
printf("pixdim: %f, %f, %f\n",pixdim[0],pixdim[1],pixdim[2]);
@@ -1871,7 +1872,8 @@ void strokeMesh(char *path)
18711872
p[i].y=(p[i].y-h->srow_y[3])/pixdim[1];
18721873
p[i].z=(p[i].z-h->srow_z[3])/pixdim[2];
18731874
}
1874-
1875+
*/
1876+
18751877
// scan triangles
18761878
for(l=0;l<nt;l++)
18771879
{
@@ -2559,7 +2561,6 @@ int saveMaskedVolume_Text(char *path, char *maskpath){
25592561
AnalyzeHeader *mask_hdr;
25602562
char *mask_img;
25612563
int mask_dim[4];
2562-
int i, j, k;
25632564

25642565
loadVolume(maskpath,&mask_hdr,&mask_img);
25652566
mask_dim[0]=mask_hdr->dim[1];
@@ -2572,9 +2573,9 @@ int saveMaskedVolume_Text(char *path, char *maskpath){
25722573

25732574
printf("volume: min:%f max:%f \n",min(),max());
25742575

2575-
for(i=0;i<dim[0];i++)
2576-
for(j=0;j<dim[1];j++)
2577-
for(k=0;k<dim[2];k++){
2576+
for(int i=0;i<dim[0];i++)
2577+
for(int j=0;j<dim[1];j++)
2578+
for(int k=0;k<dim[2];k++){
25782579
int mask_i = k*mask_dim[1]*mask_dim[0]+j*mask_dim[0]+i;
25792580
if (getValue2(mask_i,mask_hdr, mask_img)!=0 ){ //masking
25802581
fprintf(f, "%f ",getValue(i, j, k));
@@ -2883,10 +2884,11 @@ void xor(char *path)
28832884
-info information: dimensions, data type, pixel size
28842885
-threshold float,int threshold(level,direction)
28852886
-volume calculate volume
2887+
-new create a new volume with dimx,dimy,dimz,pixx,pixy,pixz,offx,offy,offz
28862888
-zigzag print volume values in zigzag order
28872889
-decompose str decompose(basename) a volume with many values into volumes with one single value
28882890
-resize int,int,int resize the volume to the new dimensions x, y, z. The original volume is kept at the center
2889-
-strokeMesh str set the vertices of the mesh (text format) at input path to value=max+1
2891+
-strokeMesh str set the surface of the mesh (text format) at input path to value=max+1; the mesh needs to be in voxel coordinates; (you need to either provide an empty volume or stroke the mesh over the MRI that the segmentation used for mesh extraction had been created on)
28902892
-surfaceNets level,path extract isosurface from the volume at the indicated level using the surface nets algorithm, save at the indicated path
28912893
-sampleMesh str1 str2 sampleMesh(mesh_path, result_path) save the volume values at the vertices of the mesh pointed by the file path to the result path
28922894
*/
@@ -3151,7 +3153,8 @@ int main (int argc, const char * argv[])
31513153
f=fopen(path,"w");
31523154
fprintf(f,"%i %i\n",m.np,m.nt);
31533155
for(i=0;i<m.np;i++)
3154-
fprintf(f,"%f %f %f\n",m.p[i].x*hdr->pixdim[1],m.p[i].y*hdr->pixdim[2],m.p[i].z*hdr->pixdim[3]);
3156+
// fprintf(f,"%f %f %f\n",m.p[i].x*hdr->pixdim[1],m.p[i].y*hdr->pixdim[2],m.p[i].z*hdr->pixdim[3]);
3157+
fprintf(f,"%f %f %f\n",m.p[i].x,m.p[i].y,m.p[i].z);
31553158
for(i=0;i<m.nt;i++)
31563159
fprintf(f,"%i %i %i\n",m.t[i].a,m.t[i].b,m.t[i].c);
31573160
fclose(f);

0 commit comments

Comments
 (0)