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 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

      public static Mesh3D resampleMesh​(Mesh3D source_mesh, Mesh3D resample_mesh)
      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 resample
      resample_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 in A. 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 NeuroMeshFunctionsException
      Generates a set of sample rays from an instance of ScalpAndSkullModelOptions, including a brain hull surface and a T1-weighted brain image. Two sets of rays are generated:
      1. From the hull surface to the edge of the image
      2. From the hull surface to the scalp surface
      Parameters:
      options - The parameters used to sample the image
      rays_1 - Sample ray from the hull surface to the edge of the image
      rays_2 - Sample ray from the hull surface to the scalp surface
      progress - Progress updater (can be null)
      Throws:
      NeuroMeshFunctionsException
    • getRaysBlocking

      public static void getRaysBlocking​(ScalpAndSkullModelOptions options, java.util.ArrayList<SampleRay> rays_1, java.util.ArrayList<SampleRay> rays_2, ProgressUpdater progress) throws NeuroMeshFunctionsException
      Generates and fills three sets of sample rays based upon the parameters in options. 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 boundary
      rays_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

      public 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. 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 points
      rays -
      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 points
      rays -
      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 points
      rays -
      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:
      1. inner skull
      2. outer skull
      3. scalp
      4. control_point_A1
      5. control_point_A2
      6. control_point_A3
      7. control_point_A4
      ..and 4 additional meshes for subject control points
      Parameters:
      A - Average control points
      rays -
      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 below bottom_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.IOException
      Writes rays 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 a Grid3D 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, by sigma_normal (one standard deviation) and sigma_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 of setSigmaT:

      • "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
      The values returned will be those obtained by the Grid3D.getDoubleValue method, but can alternatively be normalized by setting the normalized flag.
      Parameters:
      mesh -
      grid -
      sigma_normal -
      sigma_tangent -
      sigma_max_normal -
      sigma_max_tangent -
      thickness - Either a double representing universal thickness, or an ArrayList, containing vertex-wise thickness values.
      normalize -
      Returns:
      Vertex-wise mapped values, or null if process fails or was cancelled.