original_docstring: 
      Perform landmarking of an input centerline to
      identify different segments along the vessel.
      Landmarking algorithm based on Bogunovic et al. (2012).
      Uses curvature and torsion to objectively subdivide
      the siphon into bends.
      Subdivision of individual siphon bends is
      performed by identifying locations of curvature and torsion peaks along
      the siphon and defining a bend for each curvature peak delimited by 2
      enclosing (proximal and distal) torsion peaks.
  
      Args:
          centerline (vtkPolyData): Centerline data points.
          base_path (str): Location of case to landmark.
          approximation_method (str): Method used for computing curvature.
          algorithm (str): Name of landmarking algorithm.
          resampling_step (float): Resampling step. Is None if no resampling.
          smooth_line (bool): Smooths centerline with VMTK if True.
          nknots (int): Number of knots for B-splines.
          smoothing_factor_curv (float): Smoothing factor for computing curvature.
          smoothing_factor_torsion (float): Smoothing factor for computing torsion.
          iterations (int): Number of smoothing iterations.
  
      Returns:
          landmarks (dict): Landmarking interfaces as points.
      
docstring: Perform landmarking of an input centerline to
  identify different segments along the vessel.
  Landmarking algorithm based on Bogunovic et al.
docstring_tokens: Perform landmarking of an input centerline to identify different segments along the vessel . Landmarking algorithm based on Bogunovic et al .
code: def landmarking_piccinelli(centerline, base_path, approximation_method, algorithm, resampling_step,
                             smooth_line, nknots, smoothing_factor_curv, smoothing_factor_torsion,
                             iterations):
      """
      Perform landmarking of an input centerline to
      identify different segments along the vessel.
      Landmarking algorithm based on Bogunovic et al. (2012).
      Uses curvature and torsion to objectively subdivide
      the siphon into bends.
      Subdivision of individual siphon bends is
      performed by identifying locations of curvature and torsion peaks along
      the siphon and defining a bend for each curvature peak delimited by 2
      enclosing (proximal and distal) torsion peaks.
  
      Args:
          centerline (vtkPolyData): Centerline data points.
          base_path (str): Location of case to landmark.
          approximation_method (str): Method used for computing curvature.
          algorithm (str): Name of landmarking algorithm.
          resampling_step (float): Resampling step. Is None if no resampling.
          smooth_line (bool): Smooths centerline with VMTK if True.
          nknots (int): Number of knots for B-splines.
          smoothing_factor_curv (float): Smoothing factor for computing curvature.
          smoothing_factor_torsion (float): Smoothing factor for computing torsion.
          iterations (int): Number of smoothing iterations.
  
      Returns:
          landmarks (dict): Landmarking interfaces as points.
      """
  
      if resampling_step is not None:
          centerline = vmtk_resample_centerline(centerline, resampling_step)
  
      if approximation_method == "spline":
          line, max_point_curv_ids, _ = spline_centerline_and_compute_geometric_features(centerline, smooth_line, nknots)
  
          # Get curvature and torsion, find peaks
          curvature = get_point_data_array("Curvature", line)
          torsion = get_point_data_array("Torsion", line)
          torsion_smooth = gaussian_filter(torsion, 10)
          max_point_tor_ids = list(argrelextrema(abs(torsion_smooth), np.greater)[0])
  
      elif approximation_method == "vmtk":
          line = centerline
          line_curv = vmtk_compute_geometric_features(centerline, True, outputsmoothed=False,
                                                      factor=smoothing_factor_curv, iterations=iterations)
          line_tor = vmtk_compute_geometric_features(centerline, True, outputsmoothed=False,
                                                     factor=smoothing_factor_torsion, iterations=iterations)
          # Get curvature and torsion, find peaks
          curvature = get_point_data_array("Curvature", line_curv)
          torsion = get_point_data_array("Torsion", line_tor)
  
          # Smooth torsion curve to remove noise
          torsion_smooth = gaussian_filter(torsion, 25)
  
          # Find maximum curvature and torsion
          max_point_curv_ids = list(argrelextrema(curvature, np.greater)[0])
          max_point_tor_ids = list(argrelextrema(abs(torsion_smooth), np.greater)[0])
  
      else:
          raise ValueError("ERROR: Selected method for computing curvature / torsion not available" +
                           "\nPlease select between 'spline' and 'vmtk'")
  
      # Extract local curvature minimums
      length = get_curvilinear_coordinate(line)
  
      # Ignore points close to the ends of the siphon
      for i in max_point_curv_ids:
          if length[i] in length[-10:] or length[i] in length[:10]:
              max_point_curv_ids.remove(i)
  
      # Remove curvature and torsion peaks too close to each other
      tolerance = 70
      dist = []
      dist_tor = []
      for i in range(len(max_point_curv_ids) - 1):
          dist.append(max_point_curv_ids[i + 1] - max_point_curv_ids[i])
      for i in range(len(max_point_tor_ids) - 1):
          dist_tor.append(max_point_tor_ids[i + 1] - max_point_tor_ids[i])
  
      # Remove curvature maxima which are saddle points within a bend
      curv_remove_ids = []
      for i, dx in enumerate(dist):
          if dx < tolerance:
              curv1 = curvature[max_point_curv_ids[i]]
              curv2 = curvature[max_point_curv_ids[i + 1]]
              if curv1 > curv2:
                  curv_remove_ids.append(max_point_curv_ids[i + 1])
              else:
                  curv_remove_ids.append(max_point_curv_ids[i])
  
      # Remove torsion maxima which are saddle points within a bend
      tor_remove_ids = []
      for i, dx in enumerate(dist_tor):
          if dx < tolerance:
              tor1 = torsion_smooth[max_point_tor_ids[i]]
              tor2 = torsion_smooth[max_point_tor_ids[i + 1]]
              if tor1 > tor2:
                  tor_remove_ids.append(max_point_tor_ids[i + 1])
              else:
                  tor_remove_ids.append(max_point_tor_ids[i])
  
      # Filter out curvature and torsion maxima saddle points
      max_point_curv_ids = [ID for ID in max_point_curv_ids if ID not in curv_remove_ids]
      max_point_tor_ids = [ID for ID in max_point_tor_ids if ID not in tor_remove_ids]
  
      # Compute and extract interface points
      interfaces = find_interface(max_point_curv_ids, max_point_tor_ids)
      landmarks = {}
      for k, v in interfaces.items():
          landmarks[k] = line.GetPoints().GetPoint(int(v))
  
      # Map landmarks to initial centerline
      landmarks = map_landmarks(landmarks, centerline, algorithm)
  
      # Save landmarks
      print("-- Case was successfully landmarked.")
      print("-- Number of landmarks (Segments): %s" % len(landmarks))
      try:
          os.remove(base_path + "_landmark_piccinelli_%s.particles" % approximation_method)
      except FileNotFoundError:
          pass
      if landmarks is not None:
          write_parameters(landmarks, base_path)
          create_particles(base_path, algorithm, approximation_method)
  
      return landmarks
code_tokens: def landmarking_piccinelli ( centerline , base_path , approximation_method , algorithm , resampling_step , smooth_line , nknots , smoothing_factor_curv , smoothing_factor_torsion , iterations ) : if resampling_step is not None : centerline = vmtk_resample_centerline ( centerline , resampling_step ) if approximation_method == "spline" : line , max_point_curv_ids , _ = spline_centerline_and_compute_geometric_features ( centerline , smooth_line , nknots ) curvature = get_point_data_array ( "Curvature" , line ) torsion = get_point_data_array ( "Torsion" , line ) torsion_smooth = gaussian_filter ( torsion , 10 ) max_point_tor_ids = list ( argrelextrema ( abs ( torsion_smooth ) , np . greater ) [ 0 ] ) elif approximation_method == "vmtk" : line = centerline line_curv = vmtk_compute_geometric_features ( centerline , True , outputsmoothed = False , factor = smoothing_factor_curv , iterations = iterations ) line_tor = vmtk_compute_geometric_features ( centerline , True , outputsmoothed = False , factor = smoothing_factor_torsion , iterations = iterations ) curvature = get_point_data_array ( "Curvature" , line_curv ) torsion = get_point_data_array ( "Torsion" , line_tor ) torsion_smooth = gaussian_filter ( torsion , 25 ) max_point_curv_ids = list ( argrelextrema ( curvature , np . greater ) [ 0 ] ) max_point_tor_ids = list ( argrelextrema ( abs ( torsion_smooth ) , np . greater ) [ 0 ] ) else : raise ValueError ( "ERROR: Selected method for computing curvature / torsion not available" + "\nPlease select between 'spline' and 'vmtk'" ) length = get_curvilinear_coordinate ( line ) for i in max_point_curv_ids : if length [ i ] in length [ - 10 : ] or length [ i ] in length [ : 10 ] : max_point_curv_ids . remove ( i ) tolerance = 70 dist = [ ] dist_tor = [ ] for i in range ( len ( max_point_curv_ids ) - 1 ) : dist . append ( max_point_curv_ids [ i + 1 ] - max_point_curv_ids [ i ] ) for i in range ( len ( max_point_tor_ids ) - 1 ) : dist_tor . append ( max_point_tor_ids [ i + 1 ] - max_point_tor_ids [ i ] ) curv_remove_ids = [ ] for i , dx in enumerate ( dist ) : if dx < tolerance : curv1 = curvature [ max_point_curv_ids [ i ] ] curv2 = curvature [ max_point_curv_ids [ i + 1 ] ] if curv1 > curv2 : curv_remove_ids . append ( max_point_curv_ids [ i + 1 ] ) else : curv_remove_ids . append ( max_point_curv_ids [ i ] ) tor_remove_ids = [ ] for i , dx in enumerate ( dist_tor ) : if dx < tolerance : tor1 = torsion_smooth [ max_point_tor_ids [ i ] ] tor2 = torsion_smooth [ max_point_tor_ids [ i + 1 ] ] if tor1 > tor2 : tor_remove_ids . append ( max_point_tor_ids [ i + 1 ] ) else : tor_remove_ids . append ( max_point_tor_ids [ i ] ) max_point_curv_ids = [ ID for ID in max_point_curv_ids if ID not in curv_remove_ids ] max_point_tor_ids = [ ID for ID in max_point_tor_ids if ID not in tor_remove_ids ] interfaces = find_interface ( max_point_curv_ids , max_point_tor_ids ) landmarks = { } for k , v in interfaces . items ( ) : landmarks [ k ] = line . GetPoints ( ) . GetPoint ( int ( v ) ) landmarks = map_landmarks ( landmarks , centerline , algorithm ) print ( "-- Case was successfully landmarked." ) print ( "-- Number of landmarks (Segments): %s" % len ( landmarks ) ) try : os . remove ( base_path + "_landmark_piccinelli_%s.particles" % approximation_method ) except FileNotFoundError : pass if landmarks is not None : write_parameters ( landmarks , base_path ) create_particles ( base_path , algorithm , approximation_method ) return landmarks
short_docstring: Perform landmarking of an input centerline to
  identify different segments along the vessel.
short_docstring_tokens: Perform landmarking of an input centerline to identify different segments along the vessel .
comment: """
      Perform landmarking of an input centerline to
      identify different segments along the vessel.
      Landmarking algorithm based on Bogunovic et al. (2012).
      Uses curvature and torsion to objectively subdivide
      the siphon into bends.
      Subdivision of individual siphon bends is
      performed by identifying locations of curvature and torsion peaks along
      the siphon and defining a bend for each curvature peak delimited by 2
      enclosing (proximal and distal) torsion peaks.
  
      Args:
          centerline (vtkPolyData): Centerline data points.
          base_path (str): Location of case to landmark.
          approximation_method (str): Method used for computing curvature.
          algorithm (str): Name of landmarking algorithm.
          resampling_step (float): Resampling step. Is None if no resampling.
          smooth_line (bool): Smooths centerline with VMTK if True.
          nknots (int): Number of knots for B-splines.
          smoothing_factor_curv (float): Smoothing factor for computing curvature.
          smoothing_factor_torsion (float): Smoothing factor for computing torsion.
          iterations (int): Number of smoothing iterations.
  
      Returns:
          landmarks (dict): Landmarking interfaces as points.
      """$SEP$# Get curvature and torsion, find peaks$SEP$# Get curvature and torsion, find peaks$SEP$# Smooth torsion curve to remove noise$SEP$# Find maximum curvature and torsion$SEP$# Extract local curvature minimums$SEP$# Ignore points close to the ends of the siphon$SEP$# Remove curvature and torsion peaks too close to each other$SEP$# Remove curvature maxima which are saddle points within a bend$SEP$# Remove torsion maxima which are saddle points within a bend$SEP$# Filter out curvature and torsion maxima saddle points$SEP$# Compute and extract interface points$SEP$# Map landmarks to initial centerline$SEP$# Save landmarks