[img]https://i.stack.imgur.com/gcNFn.png[/img]
This surface is too densely tessellated for me, so I subsample it to get a coarser surface. To do this, I used Matlab's reducepatch function. This works pretty well: [code]https://i.stack.imgur.com/U6sVm.png[/code] White matter subsampled

Unfortunately, the coloring is based on a variable called sulcal_depth, which is defined for every vertex of my tessellated surface. So I need to retain sulcal depth information only from the vertices which remain after subsampling. Essentially, I need reducepatch to give me not just the subsampled version of the surface, but also the indices of vertex points that it retained. If I know the preserved indices, I can just index my sulcal_depth variable to get the new depth map.

Currently, I'm doing this as follows (this is also how I colored the subsampled version above):
[code]function indices = compute_reduced_indices(before, after) %% Function to compute the indices of vertices preserved during an operation of % reducepatch. This allows you to use reducepatch to subsample a surface and % re-compute an original signal on the vertices for the new subsampled mesh indices = zeros(length(after), 1); for i = 1:length(after) dotprods = (before * after(i, :)') ./ sqrt(sum(before.^2, 2)); [~, indices(i)] = max(dotprods); end[/code] But as you might imagine, this is pretty slow, because of the for loop over vertices. I don't have enough memory to vectorize the loop and compute the full dot product matrix in one go.

Is there a smart way to get reducepatch to give me indices, or an alternative approach (with or without reducepatch) that's faster?"> [img]https://i.stack.imgur.com/gcNFn.png[/img]
This surface is too densely tessellated for me, so I subsample it to get a coarser surface. To do this, I used Matlab's reducepatch function. This works pretty well: [code]https://i.stack.imgur.com/U6sVm.png[/code] White matter subsampled

Unfortunately, the coloring is based on a variable called sulcal_depth, which is defined for every vertex of my tessellated surface. So I need to retain sulcal depth information only from the vertices which remain after subsampling. Essentially, I need reducepatch to give me not just the subsampled version of the surface, but also the indices of vertex points that it retained. If I know the preserved indices, I can just index my sulcal_depth variable to get the new depth map.

Currently, I'm doing this as follows (this is also how I colored the subsampled version above):
[code]function indices = compute_reduced_indices(before, after) %% Function to compute the indices of vertices preserved during an operation of % reducepatch. This allows you to use reducepatch to subsample a surface and % re-compute an original signal on the vertices for the new subsampled mesh indices = zeros(length(after), 1); for i = 1:length(after) dotprods = (before * after(i, :)') ./ sqrt(sum(before.^2, 2)); [~, indices(i)] = max(dotprods); end[/code] But as you might imagine, this is pretty slow, because of the for loop over vertices. I don't have enough memory to vectorize the loop and compute the full dot product matrix in one go.

Is there a smart way to get reducepatch to give me indices, or an alternative approach (with or without reducepatch) that's faster?"> [img]https://i.stack.imgur.com/gcNFn.png[/img]
This surface is too densely tessellated for me, so I subsample it to get a coarser surface. To do this, I used Matlab's reducepatch function. This works pretty well: [code]https://i.stack.imgur.com/U6sVm.png[/code] White matter subsampled

Unfortunately, the coloring is based on a variable called sulcal_depth, which is defined for every vertex of my tessellated surface. So I need to retain sulcal depth information only from the vertices which remain after subsampling. Essentially, I need reducepatch to give me not just the subsampled version of the surface, but also the indices of vertex points that it retained. If I know the preserved indices, I can just index my sulcal_depth variable to get the new depth map.

Currently, I'm doing this as follows (this is also how I colored the subsampled version above):
[code]function indices = compute_reduced_indices(before, after) %% Function to compute the indices of vertices preserved during an operation of % reducepatch. This allows you to use reducepatch to subsample a surface and % re-compute an original signal on the vertices for the new subsampled mesh indices = zeros(length(after), 1); for i = 1:length(after) dotprods = (before * after(i, :)') ./ sqrt(sum(before.^2, 2)); [~, indices(i)] = max(dotprods); end[/code] But as you might imagine, this is pretty slow, because of the for loop over vertices. I don't have enough memory to vectorize the loop and compute the full dot product matrix in one go.

Is there a smart way to get reducepatch to give me indices, or an alternative approach (with or without reducepatch) that's faster?">
MATLAB Projects

Retaining color when subsampling a triangulated surface: get indices from reducepatch?

I have a very densely tessellated surface which looks like this: White matter dense
[img]https://i.stack.imgur.com/gcNFn.png[/img]
This surface is too densely tessellated for me, so I subsample it to get a coarser surface. To do this, I used Matlab's reducepatch function. This works pretty well: [code]https://i.stack.imgur.com/U6sVm.png[/code] White matter subsampled

Unfortunately, the coloring is based on a variable called sulcal_depth, which is defined for every vertex of my tessellated surface. So I need to retain sulcal depth information only from the vertices which remain after subsampling. Essentially, I need reducepatch to give me not just the subsampled version of the surface, but also the indices of vertex points that it retained. If I know the preserved indices, I can just index my sulcal_depth variable to get the new depth map.

Currently, I'm doing this as follows (this is also how I colored the subsampled version above):
[code]function indices = compute_reduced_indices(before, after) %% Function to compute the indices of vertices preserved during an operation of % reducepatch. This allows you to use reducepatch to subsample a surface and % re-compute an original signal on the vertices for the new subsampled mesh indices = zeros(length(after), 1); for i = 1:length(after) dotprods = (before * after(i, :)') ./ sqrt(sum(before.^2, 2)); [~, indices(i)] = max(dotprods); end[/code] But as you might imagine, this is pretty slow, because of the for loop over vertices. I don't have enough memory to vectorize the loop and compute the full dot product matrix in one go.

Is there a smart way to get reducepatch to give me indices, or an alternative approach (with or without reducepatch) that's faster?


JLCPCB – Prototype 10 PCBs for $2 (For Any Color)

China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w

Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir