Package mgui.geometry.neuro.mesh
Class NeuroMeshFunctions
java.lang.Object
mgui.interfaces.Utility
mgui.geometry.neuro.mesh.NeuroMeshFunctions
public class NeuroMeshFunctions extends Utility
Utility class for mesh functions related to neuroscience applications.
TODO: remove all obsolete functions; add status tags
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
-
Field Summary
Fields Modifier and Type Field Description static int
debug_index
static boolean
no_weight
static boolean
normal_weight
-
Constructor Summary
Constructors Constructor Description NeuroMeshFunctions()
-
Method Summary
Modifier and Type Method Description static VectorSet3DInt
generateRayShapes(java.util.ArrayList<SampleRay> rays, java.lang.String name)
Generates a vector 3D set from a list of sample rays; adds sample data to shapes.static int[][]
getAverageRayPoints(java.util.ArrayList<java.util.ArrayList<java.lang.Double>> average_rays)
static Mesh3D[]
getAverageSkullAndScalpMeshes(Mesh3D hull_mesh, int[][] A, java.util.ArrayList<java.lang.Double> resample_scales, org.jogamp.vecmath.Point3f center_pt)
Returns average meshes for the control points inA
.protected static java.util.ArrayList<java.lang.Integer>
getBottomPointingRays(java.util.ArrayList<SampleRay> rays, float bottom_z)
Returns a list of indices corresponding to rays which project to a point with a z coordinate belowbottom_z
.static Mesh3D[]
getControlPointMeshes(int[][] A, java.util.ArrayList<SampleRay> rays, ScalpAndSkullModelOptions options)
Generates four meshes corresponding to the average control points.static int[][]
getRayControlPoints(java.util.ArrayList<SampleRay> rays)
Determines a set of control points which can be used to constrain the search for skull and scalp surfaces.static java.util.ArrayList<java.util.ArrayList<java.lang.Double>>
getRayCurves(ScalpAndSkullModelOptions options, java.lang.String subject, java.lang.String output_file)
static java.util.ArrayList<java.util.ArrayList<java.lang.Double>>
getRayCurves(ScalpAndSkullModelOptions options, java.lang.String subject, java.lang.String output_file, java.util.ArrayList<java.util.ArrayList<java.lang.Double>> unnormalized, Mesh3D hull_mesh, java.util.ArrayList<java.lang.Double> scales)
static java.util.ArrayList<java.util.ArrayList<java.lang.Double>>
getRayCurvesBak(ScalpAndSkullModelOptions options, java.lang.String subject, java.lang.String output_file, java.util.ArrayList<java.util.ArrayList<java.lang.Double>> unnormalized, Mesh3D hull_mesh)
static void
getRays(ScalpAndSkullModelOptions options, java.util.ArrayList<SampleRay> rays_1, java.util.ArrayList<SampleRay> rays_2, ProgressUpdater progress)
Generates a set of sample rays from an instance ofScalpAndSkullModelOptions
, including a brain hull surface and a T1-weighted brain image.static void
getRaysBlocking(ScalpAndSkullModelOptions options, java.util.ArrayList<SampleRay> rays_1, java.util.ArrayList<SampleRay> rays_2, ProgressUpdater progress)
Generates and fills three sets of sample rays based upon the parameters inoptions
.static Mesh3D[]
getSkullAndScalpMeshes(int[][] A, java.util.ArrayList<SampleRay> scalp_rays, java.util.ArrayList<SampleRay> full_rays, ScalpAndSkullModelOptions options)
Generates meshes, given the control points; array is ordered as: inner skull outer skull scalpstatic Mesh3D[]
getSkullAndScalpMeshes(int[][] A, java.util.ArrayList<SampleRay> scalp_rays, java.util.ArrayList<SampleRay> full_rays, ScalpAndSkullModelOptions options, ProgressUpdater updater)
Generates meshes, given the control points; array is ordered as: inner skull outer skull scalp control_point_A1 control_point_A2 control_point_A3 control_point_A4static Mesh3D[]
getSkullAndScalpMeshesBlocking(int[][] A, java.util.ArrayList<SampleRay> scalp_rays, java.util.ArrayList<SampleRay> full_rays, ScalpAndSkullModelOptions options, ProgressUpdater updater)
Generates meshes, given the control points; array is ordered as: inner skull outer skull scalp control_point_A1 control_point_A2 control_point_A3 control_point_A4 ..and 4 additional meshes for subject control pointsstatic int[][]
loadAverageRays(java.lang.String average_ray_file, boolean smooth, ScalpAndSkullModelOptions options, Mesh3D mesh, java.util.ArrayList<java.lang.Double> scales)
static int[][]
loadAverageRays(java.lang.String average_ray_file, java.util.ArrayList<java.lang.Double> scales)
static java.util.ArrayList<MguiNumber>
mapGrid3DToCortexGaussian(Mesh3D mesh, Volume3DInt volume, java.lang.String channel, double sigma_normal, double sigma_tangent, double sigma_max_normal, double sigma_max_tangent, double thickness, boolean normalize)
static java.util.ArrayList<MguiNumber>
mapVolumeToCortexGaussian(Mesh3D mesh, Volume3DInt volume, java.lang.String channel, double sigma_normal, double sigma_tangent, double sigma_max_normal, double sigma_max_tangent, java.lang.Object _thickness, boolean normalize, ProgressUpdater progress, boolean output_matrix, java.lang.String matrix_file)
Maps values from aGrid3D
object to a mesh object representing a middle cortical surface, by applying a Gaussian kernal to voxels in the vicinity of each mesh vertex.static boolean
modelScalpAndSkull(ScalpAndSkullModelOptions options, InterfaceProgressBar progress_bar)
static boolean
modelScalpAndSkullJob(ScalpAndSkullModelOptions options, InterfaceProgressBar progress_bar)
static boolean
modelScalpAndSkullJob(ScalpAndSkullModelOptions options, InterfaceProgressBar progress_bar, java.lang.String subject)
static boolean
modelScalpAndSkullJob(ScalpAndSkullModelOptions options, InterfaceProgressBar progress_bar, java.lang.String subject, boolean set_points)
static boolean
modelSkullAndScalp2()
static boolean
modelSkullAndScalp2Blocking(ScalpAndSkullModelOptions options, java.lang.String average_ray_file, java.lang.String subject_dir, java.lang.String subject, java.lang.String output_prefix, int[][] A, java.util.ArrayList<java.lang.Double> scales, boolean avr_out)
static Mesh3D
resampleMesh(Mesh3D source_mesh, Mesh3D resample_mesh)
Resamples the source mesh with the vertices of the resample mesh (typically a sphere).static boolean
writeRaysToFile(java.util.ArrayList<SampleRay> rays, java.lang.String file_prefix, int precision)
Writesrays
to two tab-delimited text files, one with its vectors:static void
writeRayToFile(java.util.ArrayList<java.lang.Double> ray, java.lang.String output_file)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
debug_index
public static int debug_index -
normal_weight
public static boolean normal_weight -
no_weight
public static boolean no_weight
-
-
Constructor Details
-
NeuroMeshFunctions
public NeuroMeshFunctions()
-
-
Method Details
-
modelSkullAndScalp2
public static boolean modelSkullAndScalp2() -
resampleMesh
Resamples the source mesh with the vertices of the resample mesh (typically a sphere). Uses a ray tracing approach; source mesh must be a convex surface.- Parameters:
source_mesh
- Mesh to resampleresample_mesh
- Mesh whose vertices are used for resampling- Returns:
- the resampled mesh
-
modelSkullAndScalp2Blocking
public static boolean modelSkullAndScalp2Blocking(ScalpAndSkullModelOptions options, java.lang.String average_ray_file, java.lang.String subject_dir, java.lang.String subject, java.lang.String output_prefix, int[][] A, java.util.ArrayList<java.lang.Double> scales, boolean avr_out) -
writeRayToFile
public static void writeRayToFile(java.util.ArrayList<java.lang.Double> ray, java.lang.String output_file) -
getAverageSkullAndScalpMeshes
public static Mesh3D[] getAverageSkullAndScalpMeshes(Mesh3D hull_mesh, int[][] A, java.util.ArrayList<java.lang.Double> resample_scales, org.jogamp.vecmath.Point3f center_pt)Returns average meshes for the control points inA
. Returns an array: 0: A1 surface 1: A2 surface 2: A3 surface- Parameters:
hull_mesh
-A
-resample_scales
-center_pt
-- Returns:
-
loadAverageRays
public static int[][] loadAverageRays(java.lang.String average_ray_file, java.util.ArrayList<java.lang.Double> scales) -
loadAverageRays
public static int[][] loadAverageRays(java.lang.String average_ray_file, boolean smooth, ScalpAndSkullModelOptions options, Mesh3D mesh, java.util.ArrayList<java.lang.Double> scales) -
getAverageRayPoints
public static int[][] getAverageRayPoints(java.util.ArrayList<java.util.ArrayList<java.lang.Double>> average_rays) -
getRayCurves
public static java.util.ArrayList<java.util.ArrayList<java.lang.Double>> getRayCurves(ScalpAndSkullModelOptions options, java.lang.String subject, java.lang.String output_file) -
getRayCurves
public static java.util.ArrayList<java.util.ArrayList<java.lang.Double>> getRayCurves(ScalpAndSkullModelOptions options, java.lang.String subject, java.lang.String output_file, java.util.ArrayList<java.util.ArrayList<java.lang.Double>> unnormalized, Mesh3D hull_mesh, java.util.ArrayList<java.lang.Double> scales) -
getRayCurvesBak
public static java.util.ArrayList<java.util.ArrayList<java.lang.Double>> getRayCurvesBak(ScalpAndSkullModelOptions options, java.lang.String subject, java.lang.String output_file, java.util.ArrayList<java.util.ArrayList<java.lang.Double>> unnormalized, Mesh3D hull_mesh) -
modelScalpAndSkullJob
public static boolean modelScalpAndSkullJob(ScalpAndSkullModelOptions options, InterfaceProgressBar progress_bar) -
modelScalpAndSkullJob
public static boolean modelScalpAndSkullJob(ScalpAndSkullModelOptions options, InterfaceProgressBar progress_bar, java.lang.String subject) -
modelScalpAndSkullJob
public static boolean modelScalpAndSkullJob(ScalpAndSkullModelOptions options, InterfaceProgressBar progress_bar, java.lang.String subject, boolean set_points) -
modelScalpAndSkull
public static boolean modelScalpAndSkull(ScalpAndSkullModelOptions options, InterfaceProgressBar progress_bar) -
getRays
public static void getRays(ScalpAndSkullModelOptions options, java.util.ArrayList<SampleRay> rays_1, java.util.ArrayList<SampleRay> rays_2, ProgressUpdater progress) throws NeuroMeshFunctionsExceptionGenerates a set of sample rays from an instance ofScalpAndSkullModelOptions
, including a brain hull surface and a T1-weighted brain image. Two sets of rays are generated:- From the hull surface to the edge of the image
- From the hull surface to the scalp surface
- Parameters:
options
- The parameters used to sample the imagerays_1
- Sample ray from the hull surface to the edge of the imagerays_2
- Sample ray from the hull surface to the scalp surfaceprogress
- Progress updater (can benull
)- Throws:
NeuroMeshFunctionsException
-
getRaysBlocking
public static void getRaysBlocking(ScalpAndSkullModelOptions options, java.util.ArrayList<SampleRay> rays_1, java.util.ArrayList<SampleRay> rays_2, ProgressUpdater progress) throws NeuroMeshFunctionsExceptionGenerates and fills three sets of sample rays based upon the parameters inoptions
. ArrayList arguments should already be instantiated.- Parameters:
options
- Specifies the source T1, brain mask hull, thresholds, etc.rays_1
- Rays from mask hull to T1 boundaryrays_2
- Rays from mask hull to scalp surface- Throws:
NeuroMeshFunctionsException
-
generateRayShapes
public static VectorSet3DInt generateRayShapes(java.util.ArrayList<SampleRay> rays, java.lang.String name)Generates a vector 3D set from a list of sample rays; adds sample data to shapes.- Parameters:
rays
-name
-
-
getRayControlPoints
Determines a set of control points which can be used to constrain the search for skull and scalp surfaces. Returned array is n * {A0, A1, A2, A3}.- Parameters:
rays
-- Returns:
-
getControlPointMeshes
public static Mesh3D[] getControlPointMeshes(int[][] A, java.util.ArrayList<SampleRay> rays, ScalpAndSkullModelOptions options)Generates four meshes corresponding to the average control points.- Parameters:
A
- average control pointsrays
-options
-- Returns:
-
getSkullAndScalpMeshes
public static Mesh3D[] getSkullAndScalpMeshes(int[][] A, java.util.ArrayList<SampleRay> scalp_rays, java.util.ArrayList<SampleRay> full_rays, ScalpAndSkullModelOptions options)Generates meshes, given the control points; array is ordered as:- inner skull
- outer skull
- scalp
- Parameters:
A
- Average control pointsrays
-- Returns:
- Four meshes, as above
-
getSkullAndScalpMeshes
public static Mesh3D[] getSkullAndScalpMeshes(int[][] A, java.util.ArrayList<SampleRay> scalp_rays, java.util.ArrayList<SampleRay> full_rays, ScalpAndSkullModelOptions options, ProgressUpdater updater)Generates meshes, given the control points; array is ordered as:- inner skull
- outer skull
- scalp
- control_point_A1
- control_point_A2
- control_point_A3
- control_point_A4
- Parameters:
A
- Average control pointsrays
-- Returns:
- Four meshes, as above
-
getSkullAndScalpMeshesBlocking
public static Mesh3D[] getSkullAndScalpMeshesBlocking(int[][] A, java.util.ArrayList<SampleRay> scalp_rays, java.util.ArrayList<SampleRay> full_rays, ScalpAndSkullModelOptions options, ProgressUpdater updater)Generates meshes, given the control points; array is ordered as:- inner skull
- outer skull
- scalp
- control_point_A1
- control_point_A2
- control_point_A3
- control_point_A4
- Parameters:
A
- Average control pointsrays
-- Returns:
- Four meshes, as above
-
getBottomPointingRays
protected static java.util.ArrayList<java.lang.Integer> getBottomPointingRays(java.util.ArrayList<SampleRay> rays, float bottom_z)Returns a list of indices corresponding to rays which project to a point with a z coordinate belowbottom_z
.- Parameters:
rays
-bottom_z
-- Returns:
-
writeRaysToFile
public static boolean writeRaysToFile(java.util.ArrayList<SampleRay> rays, java.lang.String file_prefix, int precision) throws java.io.IOExceptionWritesrays
to two tab-delimited text files, one with its vectors:Line 1: [no. vectors]
Line i: [x] [y] [z]and the second rays; one ray per line, of the form:
Line i: [sample_1] [sample_2] ... [sample_n]
- Parameters:
rays
-file
-- Throws:
java.io.IOException
-
mapGrid3DToCortexGaussian
public static java.util.ArrayList<MguiNumber> mapGrid3DToCortexGaussian(Mesh3D mesh, Volume3DInt volume, java.lang.String channel, double sigma_normal, double sigma_tangent, double sigma_max_normal, double sigma_max_tangent, double thickness, boolean normalize) -
mapVolumeToCortexGaussian
public static java.util.ArrayList<MguiNumber> mapVolumeToCortexGaussian(Mesh3D mesh, Volume3DInt volume, java.lang.String channel, double sigma_normal, double sigma_tangent, double sigma_max_normal, double sigma_max_tangent, java.lang.Object _thickness, boolean normalize, ProgressUpdater progress, boolean output_matrix, java.lang.String matrix_file)Maps values from aGrid3D
object to a mesh object representing a middle cortical surface, by applying a Gaussian kernal to voxels in the vicinity of each mesh vertex. The Gaussian is defined in the direction normal to the vertex, bysigma_normal
(one standard deviation) andsigma_max_normal
(the distance, in standard deviations, at which to stop considering voxels). It is defined in the plane tangent to the normal depending on the value ofsetSigmaT
:- "Parameter":
sigma_tangent
is set to the passed parameter - "From mean area": for each vertex,
sigma_tangent
is set to sqrt(A_tri_mean / Pi) - "From mean length": for each vertex,
sigma_tangent
is set to the mean length of all edges connecting the vertex
Grid3D.getDoubleValue
method, but can alternatively be normalized by setting thenormalized
flag.- Parameters:
mesh
-grid
-sigma_normal
-sigma_tangent
-sigma_max_normal
-sigma_max_tangent
-thickness
- Either a double representing universal thickness, or anArrayList
, containing vertex-wise thickness values.normalize
-- Returns:
- Vertex-wise mapped values, or
null
if process fails or was cancelled.
- "Parameter":
-