def visualizeFeaturesFolder(folder, dimReductionMethod, priorKnowledge = "none"):
	'''
	This function generates a chordial visualization for the recordings of the provided path.
	ARGUMENTS:
		- folder:		path of the folder that contains the WAV files to be processed
		- dimReductionMethod:	method used to reduce the dimension of the initial feature space before computing the similarity.
		- priorKnowledge:	if this is set equal to "artist"
	'''
	if dimReductionMethod=="pca":
		allMtFeatures, wavFilesList = aF.dirWavFeatureExtraction(folder, 30.0, 30.0, 0.050, 0.050, computeBEAT = True)
		if allMtFeatures.shape[0]==0:
			print "Error: No data found! Check input folder"
			return
		
		namesCategoryToVisualize = [ntpath.basename(w).replace('.wav','').split(" --- ")[0] for w in wavFilesList]; 
		namesToVisualize  	 = [ntpath.basename(w).replace('.wav','') for w in wavFilesList]; 

		(F, MEAN, STD) = aT.normalizeFeatures([allMtFeatures])
		F = np.concatenate(F)
		pca = mlpy.PCA(method='cov') # pca (eigenvalue decomposition)
		pca.learn(F)
		coeff = pca.coeff()
		
		# check that the new PCA dimension is at most equal to the number of samples
		K1 = 2
		K2 = 10
		if K1 > F.shape[0]:
			K1 = F.shape[0]
		if K2 > F.shape[0]:
			K2 = F.shape[0]

		finalDims = pca.transform(F, k=K1)
		finalDims2 = pca.transform(F, k=K2)
	else:	
		allMtFeatures, Ys, wavFilesList = aF.dirWavFeatureExtractionNoAveraging(folder, 20.0, 5.0, 0.040, 0.040) # long-term statistics cannot be applied in this context (LDA needs mid-term features)
		if allMtFeatures.shape[0]==0:
			print "Error: No data found! Check input folder"
			return
		
		namesCategoryToVisualize = [ntpath.basename(w).replace('.wav','').split(" --- ")[0] for w in wavFilesList]; 
		namesToVisualize  	 = [ntpath.basename(w).replace('.wav','') for w in wavFilesList]; 

		ldaLabels = Ys
		if priorKnowledge=="artist":
			uNamesCategoryToVisualize = list(set(namesCategoryToVisualize))
			YsNew = np.zeros( Ys.shape )
			for i, uname in enumerate(uNamesCategoryToVisualize):		# for each unique artist name:
				indicesUCategories = [j for j, x in enumerate(namesCategoryToVisualize) if x == uname]
				for j in indicesUCategories:
					indices = np.nonzero(Ys==j)
					YsNew[indices] = i
			ldaLabels = YsNew

		(F, MEAN, STD) = aT.normalizeFeatures([allMtFeatures])
		F = np.array(F[0])

		clf = LDA(n_components=10)
		clf.fit(F, ldaLabels)	
		reducedDims =  clf.transform(F)

		pca = mlpy.PCA(method='cov') # pca (eigenvalue decomposition)
		pca.learn(reducedDims)
		coeff = pca.coeff()
		reducedDims = pca.transform(reducedDims, k=2)

		# TODO: CHECK THIS ... SHOULD LDA USED IN SEMI-SUPERVISED ONLY????

		uLabels = np.sort(np.unique((Ys)))		# uLabels must have as many labels as the number of wavFilesList elements
		reducedDimsAvg = np.zeros( (uLabels.shape[0], reducedDims.shape[1] ) )
		finalDims = np.zeros( (uLabels.shape[0], 2) ) 
		for i, u in enumerate(uLabels):
			indices = [j for j, x in enumerate(Ys) if x == u]
			f = reducedDims[indices, :]
			finalDims[i, :] = f.mean(axis=0)
		finalDims2 = reducedDims

	for i in range(finalDims.shape[0]):			
		plt.text(finalDims[i,0], finalDims[i,1], ntpath.basename(wavFilesList[i].replace('.wav','')), horizontalalignment='center', verticalalignment='center', fontsize=10)
		plt.plot(finalDims[i,0], finalDims[i,1], '*r')
	plt.xlim([1.2*finalDims[:,0].min(), 1.2*finalDims[:,0].max()])
	plt.ylim([1.2*finalDims[:,1].min(), 1.2*finalDims[:,1].max()])			
	plt.show()

	SM = 1.0 - distance.squareform(distance.pdist(finalDims2, 'cosine'))
	for i in range(SM.shape[0]):
		SM[i,i] = 0.0;


	chordialDiagram("visualization", SM, 0.50, namesToVisualize, namesCategoryToVisualize)

	SM = distance.squareform(distance.pdist(F, 'cosine')) - 1.0
	for i in range(SM.shape[0]):
		SM[i,i] = 0.0;
	chordialDiagram("visualizationInitial", SM, 0.50, namesToVisualize, namesCategoryToVisualize)

	# plot super-categories (i.e. artistname
	uNamesCategoryToVisualize = sort(list(set(namesCategoryToVisualize)))
	finalDimsGroup = np.zeros( (len(uNamesCategoryToVisualize), finalDims2.shape[1] ) )
	for i, uname in enumerate(uNamesCategoryToVisualize):
		indices = [j for j, x in enumerate(namesCategoryToVisualize) if x == uname]
		f = finalDims2[indices, :]
		finalDimsGroup[i, :] = f.mean(axis=0)

	SMgroup = 1.0 - distance.squareform(distance.pdist(finalDimsGroup, 'cosine'))
	for i in range(SMgroup.shape[0]):
		SMgroup[i,i] = 0.0;
	chordialDiagram("visualizationGroup", SMgroup, 0.50, uNamesCategoryToVisualize, uNamesCategoryToVisualize)
dataset/ETHPy150Open tyiannak/pyAudioAnalysis/audioVisualization.py/visualizeFeaturesFolder/swapped operands of `-`