original_docstring: 
  	Reads the csv files in directory_path and assembles the training matrix with 
  	the features extracted using the functions from EEG_feature_extraction.
  	
  	Parameters:
  		directory_path (str): directory containing the CSV files to process.
  		output_file (str): filename for the output file.
  		cols_to_ignore (list): list of columns to ignore from the CSV
  
      Returns:
  		numpy.ndarray: 2D matrix containing the data read from the CSV
  	
  	Author: 
  		Original: [lmanso] 
  		Updates and documentation: [fcampelo]
  		Updates: [vdevane]
  	
docstring: Reads the csv files in directory_path and assembles the training matrix with
  the features extracted using the functions from EEG_feature_extraction.
  
  directory_path (str): directory containing the CSV files to process.
  output_file (str): filename for the output file.
  cols_to_ignore (list): list of columns to ignore from the CSV
docstring_tokens: Reads the csv files in directory_path and assembles the training matrix with the features extracted using the functions from EEG_feature_extraction . directory_path ( str ) : directory containing the CSV files to process . output_file ( str ) : filename for the output file . cols_to_ignore ( list ) : list of columns to ignore from the CSV
code: def gen_training_matrix(directory_path, output_file, cols_to_ignore):
  	"""
  	Reads the csv files in directory_path and assembles the training matrix with 
  	the features extracted using the functions from EEG_feature_extraction.
  	
  	Parameters:
  		directory_path (str): directory containing the CSV files to process.
  		output_file (str): filename for the output file.
  		cols_to_ignore (list): list of columns to ignore from the CSV
  
      Returns:
  		numpy.ndarray: 2D matrix containing the data read from the CSV
  	
  	Author: 
  		Original: [lmanso] 
  		Updates and documentation: [fcampelo]
  		Updates: [vdevane]
  	"""
  	
  	# Initialise return matrix
  	FINAL_MATRIX = None
  	
  	for x in os.listdir(directory_path):
  
  		# Ignore non-CSV files
  		if not x.lower().endswith('.csv'):
  			continue
  		
  		# For safety we'll ignore files containing the substring "test". 
  		# [Test files should not be in the dataset directory in the first place]
  		if 'test' in x.lower():
  			continue
  		try:
  			name, state, _ = x[:-4].split('-')
  		except:
  			print ('Wrong file name', x)
  			sys.exit(-1)
  		if state.lower() == 'Negative':
  			state = 2.
  		elif state.lower() == 'Neutral':
  			state = 1.
  		elif state.lower() == 'Positive':
  			state = 0.
  		else:
  			print ('Wrong file name', x)
  			sys.exit(-1)
  			
  		print ('Using file', x)
  		full_file_path = directory_path  +   '/'   + x
  		vectors, header = generate_feature_vectors_from_samples(file_path = full_file_path, 
  														        nsamples = 150, 
  																period = 1.,
  																state = state,
  														        remove_redundant = True,
  																cols_to_ignore = cols_to_ignore)
  		
  		print ('resulting vector shape for the file', vectors.shape)
  		
  		
  		if FINAL_MATRIX is None:
  			FINAL_MATRIX = vectors
  		else:
  			FINAL_MATRIX = np.vstack( [ FINAL_MATRIX, vectors ] )
  
  	print ('FINAL_MATRIX', FINAL_MATRIX.shape)
  	
  	# Shuffle rows
  	np.random.shuffle(FINAL_MATRIX)
  	
  	# Save to file
  	np.savetxt(output_file, FINAL_MATRIX, delimiter = ',',
  			header = ','.join(header), 
  			comments = '')
  
  	return None
code_tokens: def gen_training_matrix ( directory_path , output_file , cols_to_ignore ) : FINAL_MATRIX = None for x in os . listdir ( directory_path ) : if not x . lower ( ) . endswith ( '.csv' ) : continue if 'test' in x . lower ( ) : continue try : name , state , _ = x [ : - 4 ] . split ( '-' ) except : print ( 'Wrong file name' , x ) sys . exit ( - 1 ) if state . lower ( ) == 'Negative' : state = 2. elif state . lower ( ) == 'Neutral' : state = 1. elif state . lower ( ) == 'Positive' : state = 0. else : print ( 'Wrong file name' , x ) sys . exit ( - 1 ) print ( 'Using file' , x ) full_file_path = directory_path + '/' + x vectors , header = generate_feature_vectors_from_samples ( file_path = full_file_path , nsamples = 150 , period = 1. , state = state , remove_redundant = True , cols_to_ignore = cols_to_ignore ) print ( 'resulting vector shape for the file' , vectors . shape ) if FINAL_MATRIX is None : FINAL_MATRIX = vectors else : FINAL_MATRIX = np . vstack ( [ FINAL_MATRIX , vectors ] ) print ( 'FINAL_MATRIX' , FINAL_MATRIX . shape ) np . random . shuffle ( FINAL_MATRIX ) np . savetxt ( output_file , FINAL_MATRIX , delimiter = ',' , header = ',' . join ( header ) , comments = '' ) return None
short_docstring: Reads the csv files in directory_path and assembles the training matrix with
  the features extracted using the functions from EEG_feature_extraction.
short_docstring_tokens: Reads the csv files in directory_path and assembles the training matrix with the features extracted using the functions from EEG_feature_extraction .
comment: """
  	Reads the csv files in directory_path and assembles the training matrix with 
  	the features extracted using the functions from EEG_feature_extraction.
  	
  	Parameters:
  		directory_path (str): directory containing the CSV files to process.
  		output_file (str): filename for the output file.
  		cols_to_ignore (list): list of columns to ignore from the CSV
  
      Returns:
  		numpy.ndarray: 2D matrix containing the data read from the CSV
  	
  	Author: 
  		Original: [lmanso] 
  		Updates and documentation: [fcampelo]
  		Updates: [vdevane]
  	"""$SEP$# Initialise return matrix$SEP$# Ignore non-CSV files$SEP$# For safety we'll ignore files containing the substring "test". $SEP$# [Test files should not be in the dataset directory in the first place]$SEP$# Shuffle rows$SEP$# Save to file