From gabriel.devenyi at mcgill.ca Fri Nov 3 09:38:16 2017 From: gabriel.devenyi at mcgill.ca (Gabriel A. Devenyi) Date: Fri, 3 Nov 2017 09:38:16 -0400 Subject: [MINC-users] Display's "Smooth Polygon" on the command line? Message-ID: Hi minc-users, Is there a command-line program that implements Display's "Polygons -> Smooth Polygons" function? -- Gabriel A. Devenyi B.Eng. Ph.D. Research Computing Associate Computational Brain Anatomy Laboratory Cerebral Imaging Center Douglas Mental Health University Institute McGill University t: 514.761.6131x4781 e: gabriel.devenyi at mcgill.ca From bert at phalarope.com Fri Nov 3 09:44:50 2017 From: bert at phalarope.com (Robert D. Vincent) Date: Fri, 3 Nov 2017 09:44:50 -0400 Subject: [MINC-users] Display's "Smooth Polygon" on the command line? In-Reply-To: References: Message-ID: Hi Gabriel, To the best of my knowledge, no. It would be easy to add to the conglomerate package, however. -bert On Fri, Nov 3, 2017 at 9:38 AM, Gabriel A. Devenyi < gabriel.devenyi at mcgill.ca> wrote: > Hi minc-users, > > Is there a command-line program that implements Display's "Polygons -> > Smooth Polygons" function? > > -- > Gabriel A. Devenyi B.Eng. Ph.D. > Research Computing Associate > Computational Brain Anatomy Laboratory > Cerebral Imaging Center > Douglas Mental Health University Institute > McGill University > t: 514.761.6131x4781 > e: gabriel.devenyi at mcgill.ca > _______________________________________________ > MINC-users at bic.mni.mcgill.ca > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users > From andrew at biospective.com Fri Nov 17 17:31:17 2017 From: andrew at biospective.com (Andrew Wood) Date: Fri, 17 Nov 2017 17:31:17 -0500 Subject: [MINC-users] Side-specific behaviour of subdivide_polygons Message-ID: Hi all, I was wondering if someone could explain if there are meaningful differences between the following two operations: $ subdivide_polygons lowres_left.obj highres_left.obj $ transform_objects highres_left.obj xflip.xfm highres_right_0.obj vs $ transform_objects lowres_left.obj xflip.xfm lowres_right.obj $ subdivide_polygons lowres_right.obj highres_right_1.obj Flipping then subdividing yields different results from subdividing then flipping: $ diff -q highres_right_0.obj highres_right_1.obj Files highres_right_0.obj and highres_right_1.obj differ I get the impression that the set of vertices is equivalent between the two hires surfaces, but there connectivity is somehow different. Thanks, Andrew From claude at bic.mni.mcgill.ca Fri Nov 17 17:46:23 2017 From: claude at bic.mni.mcgill.ca (Claude LEPAGE) Date: Fri, 17 Nov 2017 17:46:23 -0500 Subject: [MINC-users] Side-specific behaviour of subdivide_polygons In-Reply-To: Message-ID: <201711172246.vAHMkNBf018297@login2.bic.mni.mcgill.ca> The two cases are different. When subdividing a "right" surface, the polygons will be oriented in the opposite direction than left. General rule: always re-orient the surface as a "left" surface before subdividing. Also, the sphere that comes out from create_tetra is "left" oriented. Here is my PERL wrapper for this: # subdivide a surface taking into account if it's a left or right hemisphere. sub subdivide_mesh { my $input = shift; my $npoly = shift; my $output = shift; my $npoly_input = `print_n_polygons $input`; chomp( $npoly_input ); if( !CheckFlipOrientation( $input ) ) { &run( "subdivide_polygons", $input, $output, $npoly ); } else { # flip right as left first before subdividing, then flip back. &run( "param2xfm", '-clobber', '-scales', -1, 1, 1, "${tmpdir}/flip.xfm" ); my $input_flipped = "${tmpdir}/right_flipped.obj"; &run( "transform_objects", $input, "${tmpdir}/flip.xfm", $input_flipped ); &run( "subdivide_polygons", $input_flipped, $output, $npoly ); &run( "transform_objects", $output, "${tmpdir}/flip.xfm", $output ); # flip.xfm is its own inverse unlink( $input_flipped ); unlink( "${tmpdir}/flip.xfm" ); } } # Check if the input surface has the same side orientation (left) # as the default template model. sub CheckFlipOrientation { my $obj = shift; my $npoly = `print_n_polygons $obj`; chomp( $npoly ); my $ret = `tail -5 $obj`; my @verts = split( ' ', $ret ); my @last3 = ( $verts[$#verts-2], $verts[$#verts-1], $verts[$#verts] ); my $dummy_sphere = "${tmpdir}/dummy_sphere.obj"; &run('create_tetra',$dummy_sphere,0,0,0,1,1,1,$npoly); $ret = `tail -5 $dummy_sphere`; unlink( $dummy_sphere ); @verts = split( ' ', $ret ); my @sphere3 = ( $verts[$#verts-2], $verts[$#verts-1], $verts[$#verts] ); if( $last3[0] == $verts[$#verts-2] && $last3[1] == $verts[$#verts-1] && $last3[2] == $verts[$#verts-0] ) { return 0; } else { return 1; } } > > Hi all, > > I was wondering if someone could explain if there are meaningful > differences between the following two operations: > > $ subdivide_polygons lowres_left.obj highres_left.obj > $ transform_objects highres_left.obj xflip.xfm highres_right_0.obj > vs > $ transform_objects lowres_left.obj xflip.xfm lowres_right.obj > $ subdivide_polygons lowres_right.obj highres_right_1.obj > > Flipping then subdividing yields different results from subdividing then > flipping: > > $ diff -q highres_right_0.obj highres_right_1.obj > Files highres_right_0.obj and highres_right_1.obj differ > > I get the impression that the set of vertices is equivalent between the two > hires surfaces, but there connectivity is somehow different. > > Thanks, > Andrew > _______________________________________________ > MINC-users at bic.mni.mcgill.ca > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users > From andrew at biospective.com Sat Nov 18 14:11:43 2017 From: andrew at biospective.com (Andrew Wood) Date: Sat, 18 Nov 2017 14:11:43 -0500 Subject: [MINC-users] Subdividing a coloured surface object Message-ID: Hi all, I have a .txt surface atlas defined on an object that I'd like to subdivide, and I'm trying to get the same atlas defined on my highres surface. So far I've tried this: # Apply the colors to the object $ Display surf_lowres.obj -vertex atlas_lowres.txt # File->Save File ./surf_lowres_coloured.obj # Subdivide the coloured mesh $ subdivide_polygons surf_lowres_coloured.obj surf_hires_coloured.obj $ Display surf_hires_coloured.obj I've also tried subdividing the polygons right in Display. In both cases, the vertex colours were lost. Is there a way to apply the same subdivision process to atlas values? Thanks, Andrew From bert at phalarope.com Sun Nov 19 12:28:30 2017 From: bert at phalarope.com (Robert D. Vincent) Date: Sun, 19 Nov 2017 12:28:30 -0500 Subject: [MINC-users] Subdividing a coloured surface object In-Reply-To: References: Message-ID: Hi Andrew, The existing "subdivide polygons" code in the BIC programming library ignores per-vertex or per-item colours. I'm in the process of fixing that, by extending the colour array using what is essentially a nearest-neighbour approach. However, this will not subdivide the actual per-vertex data, which is loaded separately. -bert On Sat, Nov 18, 2017 at 2:11 PM, Andrew Wood wrote: > Hi all, > > I have a .txt surface atlas defined on an object that I'd like to > subdivide, and I'm trying to get the same atlas defined on my highres > surface. So far I've tried this: > > # Apply the colors to the object > $ Display surf_lowres.obj -vertex atlas_lowres.txt # File->Save File > ./surf_lowres_coloured.obj > > # Subdivide the coloured mesh > $ subdivide_polygons surf_lowres_coloured.obj surf_hires_coloured.obj > > $ Display surf_hires_coloured.obj > > > I've also tried subdividing the polygons right in Display. In both cases, > the vertex colours were lost. Is there a way to apply the same subdivision > process to atlas values? > > Thanks, > Andrew > _______________________________________________ > MINC-users at bic.mni.mcgill.ca > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users > From andrew at biospective.com Sun Nov 19 15:06:24 2017 From: andrew at biospective.com (Andrew Wood) Date: Sun, 19 Nov 2017 15:06:24 -0500 Subject: [MINC-users] Subdividing a coloured surface object In-Reply-To: References: Message-ID: Hi Bert, Can you recommend a workaround? I've been trying vertstat_to_volume + subdivide_polygons + volume_object_evaluate, but so far haven't had great success. Thanks, Andrew On Sun, Nov 19, 2017 at 12:28 PM, Robert D. Vincent wrote: > Hi Andrew, > > The existing "subdivide polygons" code in the BIC programming library > ignores per-vertex or per-item colours. > > I'm in the process of fixing that, by extending the colour array using what > is essentially a nearest-neighbour approach. > > However, this will not subdivide the actual per-vertex data, which is > loaded separately. > > -bert > > On Sat, Nov 18, 2017 at 2:11 PM, Andrew Wood > wrote: > > > Hi all, > > > > I have a .txt surface atlas defined on an object that I'd like to > > subdivide, and I'm trying to get the same atlas defined on my highres > > surface. So far I've tried this: > > > > # Apply the colors to the object > > $ Display surf_lowres.obj -vertex atlas_lowres.txt # File->Save File > > ./surf_lowres_coloured.obj > > > > # Subdivide the coloured mesh > > $ subdivide_polygons surf_lowres_coloured.obj surf_hires_coloured.obj > > > > $ Display surf_hires_coloured.obj > > > > > > I've also tried subdividing the polygons right in Display. In both cases, > > the vertex colours were lost. Is there a way to apply the same > subdivision > > process to atlas values? > > > > Thanks, > > Andrew > > _______________________________________________ > > MINC-users at bic.mni.mcgill.ca > > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users > > > _______________________________________________ > MINC-users at bic.mni.mcgill.ca > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users > From bert at phalarope.com Sun Nov 19 21:32:31 2017 From: bert at phalarope.com (Robert D. Vincent) Date: Sun, 19 Nov 2017 21:32:31 -0500 Subject: [MINC-users] Subdividing a coloured surface object In-Reply-To: References: Message-ID: Hi Andrew, The fix I created is checked into the "develop" branch of https://github.org/BIC-MNI/bicpl You should be able to rebuild conglomerate and Display to get versions that will preserve appropriate colours when subdividing. -bert On Sun, Nov 19, 2017 at 3:06 PM, Andrew Wood wrote: > Hi Bert, > > Can you recommend a workaround? I've been trying vertstat_to_volume + > subdivide_polygons + volume_object_evaluate, but so far haven't had great > success. > > Thanks, > Andrew > > On Sun, Nov 19, 2017 at 12:28 PM, Robert D. Vincent > wrote: > > > Hi Andrew, > > > > The existing "subdivide polygons" code in the BIC programming library > > ignores per-vertex or per-item colours. > > > > I'm in the process of fixing that, by extending the colour array using > what > > is essentially a nearest-neighbour approach. > > > > However, this will not subdivide the actual per-vertex data, which is > > loaded separately. > > > > -bert > > > > On Sat, Nov 18, 2017 at 2:11 PM, Andrew Wood > > wrote: > > > > > Hi all, > > > > > > I have a .txt surface atlas defined on an object that I'd like to > > > subdivide, and I'm trying to get the same atlas defined on my highres > > > surface. So far I've tried this: > > > > > > # Apply the colors to the object > > > $ Display surf_lowres.obj -vertex atlas_lowres.txt # File->Save > File > > > ./surf_lowres_coloured.obj > > > > > > # Subdivide the coloured mesh > > > $ subdivide_polygons surf_lowres_coloured.obj surf_hires_coloured.obj > > > > > > $ Display surf_hires_coloured.obj > > > > > > > > > I've also tried subdividing the polygons right in Display. In both > cases, > > > the vertex colours were lost. Is there a way to apply the same > > subdivision > > > process to atlas values? > > > > > > Thanks, > > > Andrew > > > _______________________________________________ > > > MINC-users at bic.mni.mcgill.ca > > > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users > > > > > _______________________________________________ > > MINC-users at bic.mni.mcgill.ca > > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users > > > _______________________________________________ > MINC-users at bic.mni.mcgill.ca > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users > From claude at bic.mni.mcgill.ca Mon Nov 20 10:27:28 2017 From: claude at bic.mni.mcgill.ca (Claude LEPAGE) Date: Mon, 20 Nov 2017 10:27:28 -0500 Subject: [MINC-users] Subdividing a coloured surface object In-Reply-To: Message-ID: <201711201527.vAKFRSZl023045@login2.bic.mni.mcgill.ca> There are 2 tools: subdivide_texture and subdivide_values. Check them out. From andrew at biospective.com Mon Nov 20 19:40:18 2017 From: andrew at biospective.com (Andrew Wood) Date: Mon, 20 Nov 2017 19:40:18 -0500 Subject: [MINC-users] Subdividing a coloured surface object In-Reply-To: <201711201527.vAKFRSZl023045@login2.bic.mni.mcgill.ca> References: <201711201527.vAKFRSZl023045@login2.bic.mni.mcgill.ca> Message-ID: Hi again, I haven't had much luck with Claude's tools yet. subdivide_values seems to use a non-nearest-neighbour interpolant, so isn't suitable for my atlas application. subdivide_texture is giving me a segmentation fault, so I'm probably using it wrong. Bert's develop branch of bicpl/Display is getting me close, but I'm stuck on pulling the vertex labels out of the coloured object to a .txt file. obj_colour_to_texture complains that "PER_VERTEX_COLOURS not yet supported". I've been trying to dig directly in the .obj text file and it looks like the integer atlas labels that I loaded with -vertex in Display get converted to r/g/b triples. I can figure out the inverse colour map to get back from rgb=>integer, but I feel there's got to be a more direct way to do this. Thanks, Andrew On Mon, Nov 20, 2017 at 10:27 AM, Claude LEPAGE wrote: > There are 2 tools: > > subdivide_texture and subdivide_values. > > Check them out. > _______________________________________________ > MINC-users at bic.mni.mcgill.ca > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users > From bert at phalarope.com Thu Nov 23 14:54:09 2017 From: bert at phalarope.com (Robert D. Vincent) Date: Thu, 23 Nov 2017 14:54:09 -0500 Subject: [MINC-users] Display's "Smooth Polygon" on the command line? In-Reply-To: References: Message-ID: Hi Gabriel, For what it's worth, I added a "smooth_polygons" command to bicpl. In my (ahem) extensive testing it seems to give identical results to Display. Check out the develop branch... -bert On Fri, Nov 3, 2017 at 9:44 AM, Robert D. Vincent wrote: > Hi Gabriel, > > To the best of my knowledge, no. It would be easy to add to the > conglomerate package, however. > > -bert > > On Fri, Nov 3, 2017 at 9:38 AM, Gabriel A. Devenyi < > gabriel.devenyi at mcgill.ca> wrote: > >> Hi minc-users, >> >> Is there a command-line program that implements Display's "Polygons -> >> Smooth Polygons" function? >> >> -- >> Gabriel A. Devenyi B.Eng. Ph.D. >> Research Computing Associate >> Computational Brain Anatomy Laboratory >> Cerebral Imaging Center >> Douglas Mental Health University Institute >> McGill University >> t: 514.761.6131x4781 >> e: gabriel.devenyi at mcgill.ca >> _______________________________________________ >> MINC-users at bic.mni.mcgill.ca >> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users >> > >