original_docstring: 
      Maps voxel coordinates to show connection patterns for n factors.
  
      Parameters:
          U (int arr): target shape (nx * r)
          V (int arr): source shape (r * ny)
          testname (str) : 'flatmap' or 'top_view'
          output_name (str) : part of outputted file's name
          n (int) : number of factors to create
      Optional parameters:
          nneg (bool) : indicates a nonnegative solution
      
docstring: Maps voxel coordinates to show connection patterns for n factors.
docstring_tokens: Maps voxel coordinates to show connection patterns for n factors .
code: def plot_svectors(U, V, testname, output_name, n, nneg=False):
      '''
      Maps voxel coordinates to show connection patterns for n factors.
  
      Parameters:
          U (int arr): target shape (nx * r)
          V (int arr): source shape (r * ny)
          testname (str) : 'flatmap' or 'top_view'
          output_name (str) : part of outputted file's name
          n (int) : number of factors to create
      Optional parameters:
          nneg (bool) : indicates a nonnegative solution
      '''
      voxel_coords_source, voxel_coords_target, view_lut = load_mat.load_voxel_coords(testname)
  
      if(nneg):
  
          Q1 = U.copy()
          Q2 = (V.T).copy()
  
          r = Q1.shape[1]
          factor_norms_sq = np.zeros(r)
  
          for rank in range(r):
              
              Q1_r = Q1[:, rank]
              Q2_r = Q2[:, rank]
              Q2_norm = np.linalg.norm(Q2_r)
  
              factor_norms_sq[rank] = np.linalg.norm(Q1_r) *Q2_norm 
  
              Q1[:, rank] *= Q2_norm
              Q2[:, rank] /= Q2_norm
  
          indexlist = np.argsort(-1*factor_norms_sq)
          Q1 = Q1[:, indexlist]
          Q2 = Q2[:, indexlist]
      else:
  
          Q1, R1 = np.linalg.qr(U, mode='reduced')
          Q2, R2 = np.linalg.qr(V.T)
          u, S, vh = np.linalg.svd(R1 @ (R2.T) )
          Q1 = Q1 @ u * S
          Q2 = Q2 @ vh.T
   
    
  
      for i in range(int(n)):
          # Correct the sign such that the maximum element is positive
          argmax = np.argmax(np.abs(Q1[:,i]))
          sign = 1/np.sign(Q1[:,i][argmax])
          
          target_img = map_to_grid(Q1[:,i] * sign, voxel_coords_target, view_lut)
          source_img = map_to_grid(Q2[:,i] * sign , voxel_coords_source, view_lut)
  
          filename = str(output_name)+'_factor_'+str(i+1)
          plot_factor(target_img, source_img, testname, filename, np.linalg.norm(Q1[:,i]), i+1)
code_tokens: def plot_svectors ( U , V , testname , output_name , n , nneg = False ) : voxel_coords_source , voxel_coords_target , view_lut = load_mat . load_voxel_coords ( testname ) if ( nneg ) : Q1 = U . copy ( ) Q2 = ( V . T ) . copy ( ) r = Q1 . shape [ 1 ] factor_norms_sq = np . zeros ( r ) for rank in range ( r ) : Q1_r = Q1 [ : , rank ] Q2_r = Q2 [ : , rank ] Q2_norm = np . linalg . norm ( Q2_r ) factor_norms_sq [ rank ] = np . linalg . norm ( Q1_r ) * Q2_norm Q1 [ : , rank ] *= Q2_norm Q2 [ : , rank ] /= Q2_norm indexlist = np . argsort ( - 1 * factor_norms_sq ) Q1 = Q1 [ : , indexlist ] Q2 = Q2 [ : , indexlist ] else : Q1 , R1 = np . linalg . qr ( U , mode = 'reduced' ) Q2 , R2 = np . linalg . qr ( V . T ) u , S , vh = np . linalg . svd ( R1 @ ( R2 . T ) ) Q1 = Q1 @ u * S Q2 = Q2 @ vh . T for i in range ( int ( n ) ) : argmax = np . argmax ( np . abs ( Q1 [ : , i ] ) ) sign = 1 / np . sign ( Q1 [ : , i ] [ argmax ] ) target_img = map_to_grid ( Q1 [ : , i ] * sign , voxel_coords_target , view_lut ) source_img = map_to_grid ( Q2 [ : , i ] * sign , voxel_coords_source , view_lut ) filename = str ( output_name ) + '_factor_' + str ( i + 1 ) plot_factor ( target_img , source_img , testname , filename , np . linalg . norm ( Q1 [ : , i ] ) , i + 1 )
short_docstring: Maps voxel coordinates to show connection patterns for n factors.
short_docstring_tokens: Maps voxel coordinates to show connection patterns for n factors .
comment: '''
      Maps voxel coordinates to show connection patterns for n factors.
  
      Parameters:
          U (int arr): target shape (nx * r)
          V (int arr): source shape (r * ny)
          testname (str) : 'flatmap' or 'top_view'
          output_name (str) : part of outputted file's name
          n (int) : number of factors to create
      Optional parameters:
          nneg (bool) : indicates a nonnegative solution
      '''$SEP$# Correct the sign such that the maximum element is positive