def chordialDiagram(fileStr, SM, Threshold, names, namesCategories):
	'''
	Generates a d3js chordial diagram that illustrates similarites
	'''
	#colors = textListToColors(namesCategories)
	colors = textListToColorsSimple(namesCategories)
	SM2 = SM.copy()
	SM2 = (SM2 + SM2.T) / 2.0
	for i in range(SM2.shape[0]):
		M = Threshold
#		a = np.sort(SM2[i,:])[::-1]
#		M = np.mean(a[0:int(SM2.shape[1]/3+1)])
		SM2[i,SM2[i,:]<M] = 0;

	dirChordial = fileStr + "_Chordial"
	if not os.path.isdir(dirChordial):
		os.mkdir(dirChordial)
	jsonPath 		= dirChordial + os.sep + "matrix.json"
	namesPath		= dirChordial + os.sep + "Names.csv"
 
	jsonSMMatrix = simplejson.dumps(SM2.tolist())
	f = open(jsonPath,'w'); f.write(jsonSMMatrix);  f.close()
	f = open(namesPath,'w'); f.write("name,color\n"); 
	for i, n in enumerate(names):
		f.write("{0:s},{1:s}\n".format(n,"#"+colors[i]))
	f.close()

	shutil.copyfile("data/similarities.html", dirChordial+os.sep+"similarities.html")
	shutil.copyfile("data/style.css", dirChordial+os.sep+"style.css")
dataset/ETHPy150Open tyiannak/pyAudioAnalysis/audioVisualization.py/chordialDiagram/original