#
#     ############ Calculate SDRR of clean data #########################
#
#     #RR_sec_detrended is in ms and std_dev will be in ms
#     sdrr_curr=np.std(RR_sec_detrended_ms);

#print("SDRR after filtering and detrending in ms for " + rec_name + "is: " + str(sdrr_curr));

#################### PLOT histograms for each record  ##############################################
#     fig_hist,plot_hist=graphs.plotHistPercent(rec_name, RR_sec,100, "RR (sec)", "Percentage of total points", "RR interval histogram")
#     fig_hist.savefig(output_folder+"hist_"+record+".png")
#     plt.close();

################### Append feature for 1 record to a list of lists ##############################
    all_features.append(feature_rec)

#nlm.plot_ctm(rec_name_array,ctm_list_list,radius_array)
#nlm.plot_dist(rec_name_array,dist_list_list,radius_array)
rw.write_value(global_vocab, output_folder, 'global_vocab.txt', 'w')
print(len(all_features))

#write to all_features to file
rw.write_value(all_features, output_folder, "all_features_readable.txt", 'w')
rw.write_features_to_file(all_features, output_folder,
                          "all_features_pickle.txt")
rw.write_features_to_file(global_vocab, output_folder,
                          "global_vocab_pickle.txt")
rw.write_features_to_file(rec_name_array, output_folder,
                          "rec_name_array_pickle.txt")
#plt.show()
Esempio n. 2
0
import wfdb_setup as ws;
import process_rr as pr;
import data_cleaning as dc;
import graphs 
import read_write as rw;
import non_linear_measures as nlm;
import classification_functions as cl

##############################################################################
output_folder="/home/ubuntu/Documents/Thesis_work/results/19_oct_results/non_linear/sodp_analysis/non_linear_features_edges_changed/"

#output_folder="/home/ubuntu/Documents/Thesis_work/results/19_oct_results/afpdb_test_records/"

### read values from text files ######
all_features=rw.read_features_frm_file(output_folder,"all_features_pickle.txt")
rw.write_value(all_features,output_folder,"list_of_list_before_cleaning","w")
global_vocab=rw.read_features_frm_file(output_folder,"global_vocab_pickle.txt")
rec_name_array=rw.read_features_frm_file(output_folder,"rec_name_array_pickle.txt")

##################### change key value pairs of global vocab ####################
inv_global_vocab = dict(zip(global_vocab.values(), global_vocab.keys()))
#print type(inv_global_vocab.values())
all_features_list=inv_global_vocab.values()
np.savetxt(output_folder+"all_features_list.txt",all_features_list,fmt="%s",delimiter=',',newline='\n')


#generate class labels
y=np.array(cl.generate_labels(rec_name_array))
print ("label array is: " + str(y))

Esempio n. 3
0
#     
#     pwave_var_0,pwave_var_1=pecg.calc_pwave_var(p_wave_times_0,p_wave_times_1)
#     feature_rec.append(pwave_var_0)
#     global_vocab_ecg,index_of_features_ecg=cl.fill_global_vocab("pwave_var_0", index_of_features_ecg, global_vocab_ecg)
#     
#     feature_rec.append(pwave_var_1)
#     global_vocab_ecg,index_of_features_ecg=cl.fill_global_vocab("pwave_var_1", index_of_features_ecg, global_vocab_ecg)
#      
#      
#     pwave_disp_0,pwave_disp_1=pecg.calc_pwave_disp(p_wave_times_0,p_wave_times_1)
# 
#          
#     feature_rec.append(pwave_disp_0)
#     global_vocab_ecg,index_of_features_ecg=cl.fill_global_vocab("pwave_disp_0", index_of_features_ecg, global_vocab_ecg)
#     
#     feature_rec.append(pwave_disp_1)
#     global_vocab_ecg,index_of_features_ecg=cl.fill_global_vocab("pwave_disp_1", index_of_features_ecg, global_vocab_ecg)
#     
    
    all_features.append(feature_rec)
print(' dict is: ' + str((global_vocab_ecg)))
print("all features is: ")
print all_features
print(len(all_features))
#write to all_features to file
rw.write_value(all_features,output_folder,"all_features_readable.txt",'w')
rw.write_features_to_file(all_features,output_folder,"all_features_pickle.txt") 
rw.write_features_to_file(global_vocab_ecg,output_folder,"global_vocab_pickle.txt")
rw.write_features_to_file(rec_name_array, output_folder, "rec_name_array_pickle.txt")    
exit()
#     #RR_sec_detrended is in ms and std_dev will be in ms
#     sdrr_curr=np.std(RR_sec_detrended_ms);

    #print("SDRR after filtering and detrending in ms for " + rec_name + "is: " + str(sdrr_curr));
    
    
    
    #################### PLOT histograms for each record  ##############################################
#     fig_hist,plot_hist=graphs.plotHistPercent(rec_name, RR_sec,100, "RR (sec)", "Percentage of total points", "RR interval histogram")
#     fig_hist.savefig(output_folder+"hist_"+record+".png")
#     plt.close();

    ################### Append feature for 1 record to a list of lists ##############################
    all_features.append(feature_rec)


#nlm.plot_ctm(rec_name_array,ctm_list_list,radius_array)
#nlm.plot_dist(rec_name_array,dist_list_list,radius_array)
rw.write_value(global_vocab, output_folder, 'global_vocab.txt', 'w')
print(len(all_features))


#write to all_features to file
rw.write_value(all_features,output_folder,"all_features_readable.txt",'w')
rw.write_features_to_file(all_features,output_folder,"all_features_pickle.txt") 
rw.write_features_to_file(global_vocab,output_folder,"global_vocab_pickle.txt")
rw.write_features_to_file(rec_name_array, output_folder, "rec_name_array_pickle.txt")
plt.show()


Esempio n. 5
0
import process_rr as pr
import data_cleaning as dc
import graphs
import read_write as rw
import non_linear_measures as nlm
import classification_functions as cl

##############################################################################
output_folder = "/home/ubuntu/Documents/Thesis_work/results/19_oct_results/non_linear/sodp_analysis/non_linear_features_edges_changed/"

#output_folder="/home/ubuntu/Documents/Thesis_work/results/19_oct_results/afpdb_test_records/"

### read values from text files ######
all_features = rw.read_features_frm_file(output_folder,
                                         "all_features_pickle.txt")
rw.write_value(all_features, output_folder, "list_of_list_before_cleaning",
               "w")
global_vocab = rw.read_features_frm_file(output_folder,
                                         "global_vocab_pickle.txt")
rec_name_array = rw.read_features_frm_file(output_folder,
                                           "rec_name_array_pickle.txt")

##################### change key value pairs of global vocab ####################
inv_global_vocab = dict(zip(global_vocab.values(), global_vocab.keys()))
#print type(inv_global_vocab.values())
all_features_list = inv_global_vocab.values()
np.savetxt(output_folder + "all_features_list.txt",
           all_features_list,
           fmt="%s",
           delimiter=',',
           newline='\n')