def get_list_amount_activities_RescueTime_interval_with_mindwave( self, session_id, statistic_type): result_x = [] result_y = [] datetime_from_session, datetime_to_session = self.dasession.get_dates_session( session_id) list_dates = self.rescuetimeDataProcessing.get_dates_list( datetime_from_session, datetime_to_session) mindwave_data_list = Mindwave_data_processing.get_mindwave_data_filtered_smoothed( datetime_from_session, datetime_to_session, 10) for interval in list_dates: rescueTime_data = self.darescuetime.get_data_specific_period( interval[0], interval[1]) result_x.append(len(rescueTime_data)) sublist = Mindwave_data_processing.get_sublist( mindwave_data_list, datetime_from_session, datetime_to_session) if statistic_type == Calculate_statistics_enumeration.AVG: attention, meditation = Mindwave_data_processing.calculate_avg_attention_meditation( sublist) elif statistic_type == Calculate_statistics_enumeration.STD: attention, meditation = Mindwave_data_processing.calculate_std_attention_meditation( sublist) else: raise Exception.UnknownID("The statistic_type is unknown") result_y.append(attention) print "rescuetime amount" print "result_x" print result_x print "result_y" print result_y return result_x, result_y
def get_list_amount_activities_RescueTime_interval_with_mindwave(self,session_id,statistic_type): result_x = [] result_y = [] datetime_from_session, datetime_to_session = self.dasession.get_dates_session(session_id) list_dates = self.rescuetimeDataProcessing.get_dates_list(datetime_from_session, datetime_to_session) mindwave_data_list = Mindwave_data_processing.get_mindwave_data_filtered_smoothed(datetime_from_session,datetime_to_session,10) for interval in list_dates: rescueTime_data = self.darescuetime.get_data_specific_period(interval[0], interval[1]) result_x.append(len(rescueTime_data)) sublist = Mindwave_data_processing.get_sublist(mindwave_data_list,datetime_from_session,datetime_to_session) if statistic_type == Calculate_statistics_enumeration.AVG: attention, meditation = Mindwave_data_processing.calculate_avg_attention_meditation(sublist) elif statistic_type == Calculate_statistics_enumeration.STD: attention, meditation = Mindwave_data_processing.calculate_std_attention_meditation(sublist) else: raise Exception.UnknownID("The statistic_type is unknown") result_y.append(attention) print "rescuetime amount" print "result_x" print result_x print "result_y" print result_y return result_x, result_y
def test_merge_buckets(self): dates = [] dates.append(datetime.datetime.strptime("2013-12-28 08:00:00","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:01","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:02","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:03","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:04","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:05","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:06","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:07","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:08","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:09","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:10","%Y-%m-%d %H:%M:%S")) mindwave_data = [] mindwave_data.append([dates[0],dates[1],0.2,0.2,0,0]) mindwave_data.append([dates[1],dates[2],0.4,0.5,0,0]) mindwave_data.append([dates[2],dates[3],0.8,0.2,0,0]) mindwave_data.append([dates[3],dates[4],0.1,0.5,0,0]) mindwave_data.append([dates[4],dates[5],0.9,0.1,0,0]) mindwave_data.append([dates[5],dates[6],0.4,0.8,0,0]) mindwave_data.append([dates[6],dates[7],0.8,0.3,0,0]) mindwave_data.append([dates[7],dates[8],0.2,0.6,0,0]) mindwave_data.append([dates[8],dates[9],0.0,1.0,0,0]) mindwave_data.append([dates[9],dates[10],0.4,0.5,0,0]) datetime_from = datetime.datetime.strptime("2013-12-28 08:00:00","%Y-%m-%d %H:%M:%S") datetime_to = datetime.datetime.strptime("2013-12-28 08:30:00","%Y-%m-%d %H:%M:%S") attention_bucket, meditation_bucket = Mindwave_data_processing.get_attention_meditation_buckets(datetime_from,datetime_to,mindwave_data) attention_bucket_array = [attention_bucket, attention_bucket] meditation_bucket_array = [meditation_bucket, meditation_bucket] attention_bucket_result, meditation_bucket_result = Mindwave_data_processing.merge_buckets(attention_bucket_array, meditation_bucket_array) self.assertEqual(attention_bucket_result[0],0.20) self.assertEqual(attention_bucket_result[1],0.20) self.assertEqual(attention_bucket_result[2],0.30) self.assertEqual(attention_bucket_result[3],0.0) self.assertEqual(attention_bucket_result[4],0.3) self.assertEqual(meditation_bucket_result[0],0.1) self.assertEqual(meditation_bucket_result[1],0.3) self.assertEqual(meditation_bucket_result[2],0.3) self.assertEqual(meditation_bucket_result[3],0.1) self.assertEqual(meditation_bucket_result[4],0.2) print str("attention_bucket") print attention_bucket_result print str("meditation_bucket") print meditation_bucket_result
def get_mindwave_data_avg_per_RescueTime_interval(self, datetime_from, datetime_to): #datetime_from, datetime_to = self.daSession.get_dates_session(session_id) list_mindwave_data = self.get_mindwave_data_smoothened(datetime_from, datetime_to) list_dates_Rescuetime = self.daRescueTime.get_dates(datetime_from, datetime_to) x_axis, attention_data, meditation_data = Mindwave_data_processing.convert_mindwave_data_to_RescueTime_intervals( list_mindwave_data, list_dates_Rescuetime) x_axis_converted = [] attention_data_converted = [] meditation_data_converted = [] mindwave_data_converted = [] for index in range(0, len(list_mindwave_data)): try: datetime_from_mindwave = datetime.datetime.strptime(list_mindwave_data[index][1], "%Y-%m-%d %H:%M:%S.%f") except: datetime_from_mindwave = datetime.datetime.strptime(list_mindwave_data[index][1], "%Y-%m-%d %H:%M:%S") try: datetime_to_mindwave = datetime.datetime.strptime(list_mindwave_data[index][2], "%Y-%m-%d %H:%M:%S.%f") except: datetime_to_mindwave = datetime.datetime.strptime(list_mindwave_data[index][2], "%Y-%m-%d %H:%M:%S") for index_m_c in range(0, len(x_axis)): if datetime_from_mindwave >= x_axis[index_m_c][0] and datetime_from_mindwave < x_axis[index_m_c][1]: x_axis_converted.append(datetime_from_mindwave) attention_data_converted.append(attention_data[index_m_c]) meditation_data_converted.append(meditation_data[index_m_c]) mindwave_data_converted.append([datetime_from_mindwave,datetime_to_mindwave,attention_data[index_m_c],meditation_data[index_m_c]]) mindwave_data_specific_period = [mindwave_data_converted, x_axis_converted, attention_data_converted, meditation_data_converted] return mindwave_data_specific_period
def get_mindwave_data_avg_per_manualLog_interval(self, list_manual_log): datetime_from = list_manual_log[0][0] datetime_to = list_manual_log[len(list_manual_log) - 1][1] list_mindwave_data = self.get_mindwave_data_smoothened(datetime_from, datetime_to) x_axis, attention_data, meditation_data = Mindwave_data_processing.convert_mindwave_data_to_manualLog_intervals( list_mindwave_data, list_manual_log) x_axis_converted = [] attention_data_converted = [] meditation_data_converted = [] mindwave_data_converted = [] for index in range(0, len(list_mindwave_data)): try: datetime_from_mindwave = datetime.datetime.strptime(list_mindwave_data[index][1], "%Y-%m-%d %H:%M:%S.%f") except: datetime_from_mindwave = datetime.datetime.strptime(list_mindwave_data[index][1], "%Y-%m-%d %H:%M:%S") try: datetime_to_mindwave = datetime.datetime.strptime(list_mindwave_data[index][2], "%Y-%m-%d %H:%M:%S.%f") except: datetime_to_mindwave = datetime.datetime.strptime(list_mindwave_data[index][2], "%Y-%m-%d %H:%M:%S") for index_m_c in range(0, len(x_axis)): if datetime_from_mindwave >= x_axis[index_m_c][0] and datetime_from_mindwave < x_axis[index_m_c][1]: x_axis_converted.append(datetime_from_mindwave) attention_data_converted.append(attention_data[index_m_c]) meditation_data_converted.append(meditation_data[index_m_c]) mindwave_data_converted.append([datetime_from_mindwave,datetime_to_mindwave,attention_data[index_m_c],meditation_data[index_m_c]]) return mindwave_data_converted, x_axis_converted, attention_data_converted, meditation_data_converted
def test_get_sublist(self): dates = [] dates.append(datetime.datetime.strptime("2013-12-28 08:00:00","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:01.630000","%Y-%m-%d %H:%M:%S.%f")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:02.630000","%Y-%m-%d %H:%M:%S.%f")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:03","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:04","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:05","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:06","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:07","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:08","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:09","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:10","%Y-%m-%d %H:%M:%S")) mindwave_data = [] mindwave_data.append([dates[0],dates[1],0.2,0.2]) mindwave_data.append([dates[1],dates[2],0.4,0.5]) mindwave_data.append([dates[2],dates[3],0.8,0.2]) mindwave_data.append([dates[3],dates[4],0.1,0.5]) mindwave_data.append([dates[4],dates[5],0.9,0.1]) mindwave_data.append([dates[5],dates[6],0.4,0.8]) mindwave_data.append([dates[6],dates[7],0.8,0.3]) mindwave_data.append([dates[7],dates[8],0.2,0.6]) mindwave_data.append([dates[8],dates[9],0.0,1.0]) mindwave_data.append([dates[9],dates[10],0.4,0.5]) datetime_from = datetime.datetime.strptime("2013-12-28 08:00:02","%Y-%m-%d %H:%M:%S") datetime_to = datetime.datetime.strptime("2013-12-28 08:00:10","%Y-%m-%d %H:%M:%S") sublist = Mindwave_data_processing.get_sublist(mindwave_data,datetime_from,datetime_to) self.assertEqual(sublist[0][0],dates[2]) self.assertEqual(sublist[len(sublist)-1][1],dates[10]) self.assertEqual(len(sublist),8)
def test_calculate_avg_attention_meditation(self): dates = [] dates.append(datetime.datetime.strptime("2013-12-28 08:00:00","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:01.630000","%Y-%m-%d %H:%M:%S.%f")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:02.630000","%Y-%m-%d %H:%M:%S.%f")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:03","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:04","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:05","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:06","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:07","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:08","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:09","%Y-%m-%d %H:%M:%S")) dates.append(datetime.datetime.strptime("2013-12-28 08:00:10","%Y-%m-%d %H:%M:%S")) mindwave_data = [] mindwave_data.append([dates[0],dates[1],0.2,0.2]) mindwave_data.append([dates[1],dates[2],0.4,0.5]) mindwave_data.append([dates[2],dates[3],0.8,0.2]) mindwave_data.append([dates[3],dates[4],0.1,0.5]) mindwave_data.append([dates[4],dates[5],0.9,0.1]) mindwave_data.append([dates[5],dates[6],0.4,0.8]) attention_avg, meditation_avg = Mindwave_data_processing.calculate_avg_attention_meditation(mindwave_data) self.assertEqual(round(attention_avg,2),0.47) self.assertEqual(round(meditation_avg,2),0.38)
def test_get_sublist(self): dates = [] dates.append( datetime.datetime.strptime("2013-12-28 08:00:00", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:01.630000", "%Y-%m-%d %H:%M:%S.%f")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:02.630000", "%Y-%m-%d %H:%M:%S.%f")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:03", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:04", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:05", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:06", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:07", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:08", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:09", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:10", "%Y-%m-%d %H:%M:%S")) mindwave_data = [] mindwave_data.append([dates[0], dates[1], 0.2, 0.2]) mindwave_data.append([dates[1], dates[2], 0.4, 0.5]) mindwave_data.append([dates[2], dates[3], 0.8, 0.2]) mindwave_data.append([dates[3], dates[4], 0.1, 0.5]) mindwave_data.append([dates[4], dates[5], 0.9, 0.1]) mindwave_data.append([dates[5], dates[6], 0.4, 0.8]) mindwave_data.append([dates[6], dates[7], 0.8, 0.3]) mindwave_data.append([dates[7], dates[8], 0.2, 0.6]) mindwave_data.append([dates[8], dates[9], 0.0, 1.0]) mindwave_data.append([dates[9], dates[10], 0.4, 0.5]) datetime_from = datetime.datetime.strptime("2013-12-28 08:00:02", "%Y-%m-%d %H:%M:%S") datetime_to = datetime.datetime.strptime("2013-12-28 08:00:10", "%Y-%m-%d %H:%M:%S") sublist = Mindwave_data_processing.get_sublist(mindwave_data, datetime_from, datetime_to) self.assertEqual(sublist[0][0], dates[2]) self.assertEqual(sublist[len(sublist) - 1][1], dates[10]) self.assertEqual(len(sublist), 8)
def getListUnimportantActivities_V2_buckets(datetime_from,datetime_to,link_to_main): daRescueTime = DARescueTime_SQLite.RescueTime(link_to_main) unimportant_activities_list = daRescueTime.get_data_unimportant_activities_specific_period_group_by_activity(datetime_from,datetime_to) result = [] previous_datetime_to = None for activity in unimportant_activities_list: activity_details = daRescueTime.get_data_unimportant_activities_specific_period_activity(datetime_from,datetime_to,activity[1]) attention_bucket_total = [] meditation_bucket_total = [] gemiddelde_reading = 0.0 totaal_reading = 0.0 for activity_detail in activity_details: start_datetime = datetime.datetime.strptime(activity_detail[1],"%Y-%m-%d %H:%M:%S") end_datetime = start_datetime + datetime.timedelta(minutes=5) # Mindwave, gemiddelde berekenen list_mindwave_data = Mindwave_data_processing.get_mindwave_data_filtered_smoothed(datetime_from,datetime_to,10) # Mindwave, gemiddelde berekenen attention_bucket, meditation_bucket = Mindwave_data_processing.get_attention_meditation_buckets(start_datetime,end_datetime,list_mindwave_data) attention_bucket_total.append(attention_bucket) meditation_bucket_total.append(meditation_bucket) # reading reading_temp = Read_detection_processing.get_average_reading_specific_period(start_datetime,end_datetime) if reading_temp > 0: gemiddelde_reading += reading_temp totaal_reading += 1 # moet refereren naar item in lijst activity_details, niet naar end_datetime previous_datetime_to = datetime.datetime.strptime(activity_detail[1],"%Y-%m-%d %H:%M:%S") + datetime.timedelta(minutes=5) if len(attention_bucket_total) > 0: attention_bucket_avg, meditation_bucket_avg = Mindwave_data_processing.merge_buckets(attention_bucket_total, meditation_bucket_total) if totaal_reading > 0: gemiddelde_reading = float(gemiddelde_reading / totaal_reading) result.append([activity[1],activity[0],attention_bucket_avg, meditation_bucket_avg,gemiddelde_reading]) return result
def get_list_concentration_time_spent_activity(self,manual_log_list,mindwave_data,activity,type_statistics): result_x = [] result_y = [] for item in manual_log_list: difference = (item[1] - item[0]).seconds if item[2] == activity and difference >= self.treshold_activity_duration: try: sublist = Mindwave_data_processing.get_sublist(mindwave_data,item[0],item[1]) if type_statistics == Calculate_statistics_enumeration.AVG: attention, meditation = Mindwave_data_processing.calculate_avg_attention_meditation(sublist) elif type_statistics == Calculate_statistics_enumeration.STD: attention, meditation = Mindwave_data_processing.calculate_std_attention_meditation(sublist) result_x.append(difference) result_y.append(attention) except Exception,e: print str(e)
def get_statistics_attention_userstates(self,activities,manual_log_list, mindwave_data_list,statistic_type): result_x = [] result_y = [] for activity in activities: try: sublist_mindwave_activity = [] for item in manual_log_list: if item[2] == activity: sublist_mindwave_activity += Mindwave_data_processing.get_sublist(mindwave_data_list,item[0],item[1]) if statistic_type == Calculate_statistics_enumeration.AVG: attention, meditation = Mindwave_data_processing.calculate_avg_attention_meditation(sublist_mindwave_activity) elif statistic_type == Calculate_statistics_enumeration.STD: attention, meditation = Mindwave_data_processing.calculate_std_attention_meditation(sublist_mindwave_activity) else: raise Exception.UnknownID("The type_statistics ID is unknown") result_y.append(attention) result_x.append(activity) except Exception, e: str(e)
def mindwave_data_raw(self, session_id): datetime_from, datetime_to = self.dasession.get_dates_session( session_id) attention_data, x, y_attention, y_meditation = Mindwave_data_processing.get_mindwave_data_raw( datetime_from, datetime_to) title = "session_ID: " + str(session_id) + "mindwave data raw" self.plot_data(attention_data, x, y_attention, y_meditation, None, None, None, title, self.x_label, self.y_label)
def get_list_amount_used_programs_concentration_per_interval(self,mindwave_data,manual_log, list_dates_interval,type_statistic): result_x = [] result_y = [] for i in range(0,len(list_dates_interval)): datetime_from = list_dates_interval[i][0] datetime_to = list_dates_interval[i][1] sublist = Mindwave_data_processing.get_sublist(mindwave_data,datetime_from,datetime_to) try: if type_statistic==Calculate_statistics_enumeration.AVG: attention, meditation = Mindwave_data_processing.calculate_avg_attention_meditation(sublist) elif type_statistic==Calculate_statistics_enumeration.STD: attention, meditation = Mindwave_data_processing.calculate_std_attention_meditation(sublist) else: raise Exception.UnknownID("The type_statistics ID is unknown") amount = self.count_activities(manual_log,datetime_from,datetime_to) result_x.append(amount) result_y.append(attention) except Exception, e: str(e)
def get_list_impact_concentration_manual_logs(self,manual_log_list,mindwave_data): activities,manual_log_testpersoon_B = Manual_log.get_manual_logfile_Testpersoon_B_enkel_programmas_websites() datetime_from = manual_log_testpersoon_B[0][0] datetime_to = manual_log_testpersoon_B[len(manual_log_testpersoon_B) - 1][1] mindwave_data_list = Mindwave_data_processing.get_mindwave_data_filtered_smoothed(datetime_from,datetime_to,10) result_x, result_y = self.get_list_concentration_differences_manual_log(manual_log_testpersoon_B,mindwave_data_list) return result_x, result_y
def mindwave_userfeedback_data(self, session_id): datetime_from, datetime_to = self.dasession.get_dates_session( session_id) attention_data, x, y_attention, y_meditation, y_userfeedback = Mindwave_data_processing.get_mindwave_userfeedback_data( datetime_from, datetime_to, self.window_RescueTime) title = "mindwave data per user estimated concentration" self.plot_data(attention_data, x, y_attention, y_meditation, y_userfeedback, None, None, title, self.x_label, self.y_label) print str("function 'mindwave_userfeedback_data' for session_Id: " + str(session_id) + " completed")
def test_calculate_avg_attention_meditation(self): dates = [] dates.append( datetime.datetime.strptime("2013-12-28 08:00:00", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:01.630000", "%Y-%m-%d %H:%M:%S.%f")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:02.630000", "%Y-%m-%d %H:%M:%S.%f")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:03", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:04", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:05", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:06", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:07", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:08", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:09", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:10", "%Y-%m-%d %H:%M:%S")) mindwave_data = [] mindwave_data.append([dates[0], dates[1], 0.2, 0.2]) mindwave_data.append([dates[1], dates[2], 0.4, 0.5]) mindwave_data.append([dates[2], dates[3], 0.8, 0.2]) mindwave_data.append([dates[3], dates[4], 0.1, 0.5]) mindwave_data.append([dates[4], dates[5], 0.9, 0.1]) mindwave_data.append([dates[5], dates[6], 0.4, 0.8]) attention_avg, meditation_avg = Mindwave_data_processing.calculate_avg_attention_meditation( mindwave_data) self.assertEqual(round(attention_avg, 2), 0.47) self.assertEqual(round(meditation_avg, 2), 0.38)
def get_mindwave_data_avg_per_RescueTime_interval(self, datetime_from, datetime_to): #datetime_from, datetime_to = self.daSession.get_dates_session(session_id) list_mindwave_data = self.get_mindwave_data_smoothened( datetime_from, datetime_to) list_dates_Rescuetime = self.daRescueTime.get_dates( datetime_from, datetime_to) x_axis, attention_data, meditation_data = Mindwave_data_processing.convert_mindwave_data_to_RescueTime_intervals( list_mindwave_data, list_dates_Rescuetime) x_axis_converted = [] attention_data_converted = [] meditation_data_converted = [] mindwave_data_converted = [] for index in range(0, len(list_mindwave_data)): try: datetime_from_mindwave = datetime.datetime.strptime( list_mindwave_data[index][1], "%Y-%m-%d %H:%M:%S.%f") except: datetime_from_mindwave = datetime.datetime.strptime( list_mindwave_data[index][1], "%Y-%m-%d %H:%M:%S") try: datetime_to_mindwave = datetime.datetime.strptime( list_mindwave_data[index][2], "%Y-%m-%d %H:%M:%S.%f") except: datetime_to_mindwave = datetime.datetime.strptime( list_mindwave_data[index][2], "%Y-%m-%d %H:%M:%S") for index_m_c in range(0, len(x_axis)): if datetime_from_mindwave >= x_axis[index_m_c][ 0] and datetime_from_mindwave < x_axis[index_m_c][1]: x_axis_converted.append(datetime_from_mindwave) attention_data_converted.append(attention_data[index_m_c]) meditation_data_converted.append( meditation_data[index_m_c]) mindwave_data_converted.append([ datetime_from_mindwave, datetime_to_mindwave, attention_data[index_m_c], meditation_data[index_m_c] ]) mindwave_data_specific_period = [ mindwave_data_converted, x_axis_converted, attention_data_converted, meditation_data_converted ] return mindwave_data_specific_period
def mindwave_userfeedback_data_per_activity(self, session_id, activity): datetime_from, datetime_to = self.get_dates_session(session_id) activity_details = self.daRescueTime.gat_sum_time_secnds_specific_activity_with_treshold( datetime_from, datetime_to, activity) attention_data, x, y_attention, y_meditation, y_activityDuration = Mindwave_data_processing.get_mindwave_activity_data( datetime_from, datetime_to, activity_details, self.window_other) dates_activity = self.convert_activityDetailsList_to_datesList( activity_details) self.modify_per_dates(attention_data, y_attention, y_meditation, y_activityDuration, dates_activity) title = "session_ID: " + str( session_id) + "mindwave data for activity: " + str(activity) self.plot_data(attention_data, x, y_attention, y_meditation, y_activityDuration, None, None, title, self.x_label, self.y_label)
def get_mindwave_data_avg_per_manualLog_interval(self, list_manual_log): datetime_from = list_manual_log[0][0] datetime_to = list_manual_log[len(list_manual_log) - 1][1] list_mindwave_data = self.get_mindwave_data_smoothened( datetime_from, datetime_to) x_axis, attention_data, meditation_data = Mindwave_data_processing.convert_mindwave_data_to_manualLog_intervals( list_mindwave_data, list_manual_log) x_axis_converted = [] attention_data_converted = [] meditation_data_converted = [] mindwave_data_converted = [] for index in range(0, len(list_mindwave_data)): try: datetime_from_mindwave = datetime.datetime.strptime( list_mindwave_data[index][1], "%Y-%m-%d %H:%M:%S.%f") except: datetime_from_mindwave = datetime.datetime.strptime( list_mindwave_data[index][1], "%Y-%m-%d %H:%M:%S") try: datetime_to_mindwave = datetime.datetime.strptime( list_mindwave_data[index][2], "%Y-%m-%d %H:%M:%S.%f") except: datetime_to_mindwave = datetime.datetime.strptime( list_mindwave_data[index][2], "%Y-%m-%d %H:%M:%S") for index_m_c in range(0, len(x_axis)): if datetime_from_mindwave >= x_axis[index_m_c][ 0] and datetime_from_mindwave < x_axis[index_m_c][1]: x_axis_converted.append(datetime_from_mindwave) attention_data_converted.append(attention_data[index_m_c]) meditation_data_converted.append( meditation_data[index_m_c]) mindwave_data_converted.append([ datetime_from_mindwave, datetime_to_mindwave, attention_data[index_m_c], meditation_data[index_m_c] ]) return mindwave_data_converted, x_axis_converted, attention_data_converted, meditation_data_converted
def test_convert_mindwave_data_to_RescueTime_intervals(self): list_dates_Rescuetime = [["2014-04-24 14:00:00"],["2014-04-24 14:05:00"],["2014-04-24 14:10:00"]] list_mindwave_data = [] list_mindwave_data.append([0,"2014-04-24 14:00:00",None,0.50,0.40,None,None]) list_mindwave_data.append([0,"2014-04-24 14:01:00",None,0.10,0.20,None,None]) list_mindwave_data.append([0,"2014-04-24 14:02:00",None,0.60,0.30,None,None]) list_mindwave_data.append([0,"2014-04-24 14:03:00",None,0.80,0.50,None,None]) list_mindwave_data.append([0,"2014-04-24 14:04:00",None,0.10,0.50,None,None]) list_mindwave_data.append([0,"2014-04-24 14:05:00",None,0.10,0.10,None,None]) list_mindwave_data.append([0,"2014-04-24 14:06:00",None,0.50,0.90,None,None]) list_mindwave_data.append([0,"2014-04-24 14:07:00",None,0.60,0.40,None,None]) list_mindwave_data.append([0,"2014-04-24 14:08:00",None,0.80,0.60,None,None]) list_mindwave_data.append([0,"2014-04-24 14:09:00",None,0.40,0.20,None,None]) list_mindwave_data.append([0,"2014-04-24 14:10:00",None,0.60,0.30,None,None]) list_mindwave_data.append([0,"2014-04-24 14:11:00",None,0.20,0.60,None,None]) list_mindwave_data.append([0,"2014-04-24 14:12:00",None,0.80,0.80,None,None]) list_mindwave_data.append([0,"2014-04-24 14:13:00",None,0.10,0.60,None,None]) list_mindwave_data.append([0,"2014-04-24 14:14:00",None,0.30,0.10,None,None]) list_mindwave_data.append([0,"2014-04-24 14:15:00",None,0.50,0.20,None,None]) attention_data_original = [] meditation_data_original = [] for item in list_mindwave_data: attention_data_original.append(item[3]) meditation_data_original.append(item[4]) x_axix,attention_data,meditation_data = Mindwave_data_processing.convert_mindwave_data_to_RescueTime_intervals(list_mindwave_data, list_dates_Rescuetime) self.assertEqual(round(attention_data[0],2),round(np.mean(attention_data_original[0:6]),2)) self.assertEqual(round(attention_data[1],2),round(np.mean(attention_data_original[6:11]),2)) self.assertEqual(round(attention_data[2],2),round(np.mean(attention_data_original[11:16]),2)) self.assertEqual(round(meditation_data[0],2),round(np.mean(meditation_data_original[0:6]),2)) self.assertEqual(round(meditation_data[1],2),round(np.mean(meditation_data_original[6:11]),2)) self.assertEqual(round(meditation_data[2],2),round(np.mean(meditation_data_original[11:16]),2))
def get_statistics_session_testpersoon_B(self): session_id = 41 datetime_from_session, datetime_to_session = self.dasession.get_dates_session( session_id) activities, manual_log_testpersoon_B = Manual_log.get_manual_logfile_Testpersoon_B_enkel_programmas_websites( ) datetime_from = manual_log_testpersoon_B[0][0] datetime_to = manual_log_testpersoon_B[len(manual_log_testpersoon_B) - 1][1] mindwave_data_list = Mindwave_data_processing.get_mindwave_data_filtered_smoothed_middle_moving_median( datetime_from, datetime_to, self.window_mindwave) list_dates = self.rescuetimeDataProcessing.get_dates_list( datetime_from_session, datetime_to_session) result_x_diff, result_y_diff = self.manualLogDataProcessing.get_list_concentration_differences_manual_log( manual_log_testpersoon_B, mindwave_data_list) result_x_amount_avg, result_y_amount_avg = self.manualLogDataProcessing.get_list_amount_used_programs_concentration_per_interval( mindwave_data_list, manual_log_testpersoon_B, list_dates, Calculate_statistics_enumeration.AVG) result_x_amount_std, result_y_amount_std = self.manualLogDataProcessing.get_list_amount_used_programs_concentration_per_interval( mindwave_data_list, manual_log_testpersoon_B, list_dates, Calculate_statistics_enumeration.STD) result_x_avg_rescuetime_amount, result_y_avg_rescuetime_amount = self.get_list_amount_activities_RescueTime_interval_with_mindwave( session_id, Calculate_statistics_enumeration.AVG) result_x_std_rescuetime_amount, result_y_std_rescuetime_amount = self.get_list_amount_activities_RescueTime_interval_with_mindwave( session_id, Calculate_statistics_enumeration.STD) activities_important = ["Wikipedia", "Latex"] result_x_avg, result_y_avg = self.manualLogDataProcessing.get_list_concentration_time_spent_activity( manual_log_testpersoon_B, mindwave_data_list, activities_important[0], Calculate_statistics_enumeration.AVG) result_x_std, result_y_std = self.manualLogDataProcessing.get_list_concentration_time_spent_activity( manual_log_testpersoon_B, mindwave_data_list, activities_important[0], Calculate_statistics_enumeration.STD) resultTuple_avg = ResultTuple(result_x_avg, result_y_avg) resultTuple_std = ResultTuple(result_x_std, result_y_std) for i in range(1, len(activities_important)): result_x_avg_temp, result_y_avg_temp = self.manualLogDataProcessing.get_list_concentration_time_spent_activity( manual_log_testpersoon_B, mindwave_data_list, activities_important[i], Calculate_statistics_enumeration.AVG) result_x_std_temp, result_y_std_temp = self.manualLogDataProcessing.get_list_concentration_time_spent_activity( manual_log_testpersoon_B, mindwave_data_list, activities_important[i], Calculate_statistics_enumeration.STD) resultTuple_avg.merge( ResultTuple(result_x_avg_temp, result_y_avg_temp)) resultTuple_std.merge( ResultTuple(result_x_std_temp, result_y_std_temp)) activity_from = "Latex" activity_to = "Wikipedia" result_x_diff_specific_switch, result_y_diff_specific_switch = self.manualLogDataProcessing.get_list_concentration_differences_manual_log_specific_switch( manual_log_testpersoon_B, mindwave_data_list, activity_from, activity_to) resultTuple_diff_specific_switch = ResultTuple( result_x_diff_specific_switch, result_y_diff_specific_switch) # //////////////////////////// # /// with all activities //// # //////////////////////////// result_x_avg_all_act, result_y_avg_all_act = self.manualLogDataProcessing.get_list_concentration_time_spent_activity( manual_log_testpersoon_B, mindwave_data_list, activities[0], Calculate_statistics_enumeration.AVG) result_x_std_all_act, result_y_std_all_act = self.manualLogDataProcessing.get_list_concentration_time_spent_activity( manual_log_testpersoon_B, mindwave_data_list, activities[0], Calculate_statistics_enumeration.STD) resultTuple_avg_all_act = ResultTuple(result_x_avg_all_act, result_y_avg_all_act) resultTuple_std_all_act = ResultTuple(result_x_std_all_act, result_y_std_all_act) for i in range(1, len(activities)): try: result_x_avg_temp, result_y_avg_temp = self.manualLogDataProcessing.get_list_concentration_time_spent_activity( manual_log_testpersoon_B, mindwave_data_list, activities[i], Calculate_statistics_enumeration.AVG) result_x_std_temp, result_y_std_temp = self.manualLogDataProcessing.get_list_concentration_time_spent_activity( manual_log_testpersoon_B, mindwave_data_list, activities[i], Calculate_statistics_enumeration.STD) resultTuple_avg_all_act.merge( ResultTuple(result_x_avg_temp, result_y_avg_temp)) resultTuple_std_all_act.merge( ResultTuple(result_x_std_temp, result_y_std_temp)) except: pass # //////////////////////////// resultTuple_diff = ResultTuple(result_x_diff, result_y_diff) resultTuple_amount_avg = ResultTuple(result_x_amount_avg, result_y_amount_avg) resultTuple_amount_std = ResultTuple(result_x_amount_std, result_y_amount_std) resultTuple_avg_rescuetime_amount = ResultTuple( result_x_avg_rescuetime_amount, result_y_avg_rescuetime_amount) resultTuple_std_rescuetime_amount = ResultTuple( result_x_std_rescuetime_amount, result_y_std_rescuetime_amount) filename = self.folder + "data_analysis_results/testpersoon_B/" # ////////////////////// # /// all activities /// # ////////////////////// self.generate_csv( "Time_spent_seconds", "Concentration avg", resultTuple_avg_all_act, filename + "comparison time_spent_sec against average concentration all activities" ) self.generate_csv( "Time_spent_seconds", "Concentration std", resultTuple_std_all_act, filename + "comparison time_spent_sec against std concentration all activities" ) # ////////////////////// self.generate_csv( "Time_spent_seconds", "Concentration avg", resultTuple_avg, filename + "comparison time_spent_sec against average concentration") self.generate_csv( "Time_spent_seconds", "Concentration std", resultTuple_std, filename + "comparison time_spent_sec against std concentration") self.generate_csv( "Switch ID", "Concentration avg", resultTuple_diff, filename + "comparison concentration difference when switch between activities" ) self.generate_csv( "Switch ID", "Concentration avg", resultTuple_diff_specific_switch, filename + "comparison concentration difference specific switch between activities" ) self.generate_csv( "Amount", "Concentration avg", resultTuple_amount_avg, filename + "comparison amount used programs with avg concentration") self.generate_csv( "Amount", "Concentration std", resultTuple_amount_std, filename + "comparison amount used programs with std concentration") self.generate_csv( "Amount", "Concentration avg", resultTuple_avg_rescuetime_amount, filename + "comparision RescueTime amount concentration avg") self.generate_csv( "Amount", "Concentration std", resultTuple_std_rescuetime_amount, filename + "comparision RescueTime amount concentration std") resultObject = ResultObject() resultObject.set_result_timeSpent_activity_avg(resultTuple_avg) resultObject.set_result_timeSpent_activity_std(resultTuple_std) resultObject.set_concentration_diff_activity_switch_avg( resultTuple_diff) resultObject.set_concentration_diff_specific_activity_switch_avg( resultTuple_diff_specific_switch) resultObject.set_result_amount_used_programs_avg( resultTuple_amount_avg) resultObject.set_result_amount_used_programs_std( resultTuple_amount_std) resultObject.set_amount_activities_RescueTime_interval_with_mindwave_avg( resultTuple_avg_rescuetime_amount) resultObject.set_amount_activities_RescueTime_interval_with_mindwave_std( resultTuple_std_rescuetime_amount) return resultObject
def get_statistics_session_testpersoon_D(self): session_id = 11 datetime_from_session, datetime_to_session = self.dasession.get_dates_session(session_id) activities,manual_log_testpersoon_D = Manual_log.get_manual_log_testpersoon_D_programms_and_extra_info() activities_userstate,manual_log_testpersoon_D_userstate = Manual_log.get_manual_log_testpersoon_D_userstates() datetime_from = manual_log_testpersoon_D[0][0] datetime_to = manual_log_testpersoon_D[len(manual_log_testpersoon_D) - 1][1] mindwave_data_list = Mindwave_data_processing.get_mindwave_data_filtered_smoothed_middle_moving_median(datetime_from,datetime_to,self.window_mindwave) list_dates = self.rescuetimeDataProcessing.get_dates_list(datetime_from_session, datetime_to_session) activities_important = ["pdf + toledovragen","powerpoint","wikipedia","toledovragen", "pdf"] # With important activities result_x_avg, result_y_avg = self.manualLogDataProcessing.get_list_concentration_time_spent_activity(manual_log_testpersoon_D,mindwave_data_list,activities_important[0],Calculate_statistics_enumeration.AVG) result_x_std, result_y_std = self.manualLogDataProcessing.get_list_concentration_time_spent_activity(manual_log_testpersoon_D,mindwave_data_list,activities_important[0],Calculate_statistics_enumeration.STD) resultTuple_avg = ResultTuple(result_x_avg, result_y_avg) resultTuple_std = ResultTuple(result_x_std, result_y_std) for i in range(1,len(activities_important)): result_x_avg_temp, result_y_avg_temp = self.manualLogDataProcessing.get_list_concentration_time_spent_activity(manual_log_testpersoon_D,mindwave_data_list,activities_important[i],Calculate_statistics_enumeration.AVG) result_x_std_temp, result_y_std_temp = self.manualLogDataProcessing.get_list_concentration_time_spent_activity(manual_log_testpersoon_D,mindwave_data_list,activities_important[i],Calculate_statistics_enumeration.STD) resultTuple_avg.merge(ResultTuple(result_x_avg_temp,result_y_avg_temp)) resultTuple_std.merge(ResultTuple(result_x_std_temp,result_y_std_temp)) result_x_diff, result_y_diff = self.manualLogDataProcessing.get_list_concentration_differences_manual_log(manual_log_testpersoon_D,mindwave_data_list) # //////////////////////////// # /// with all activities //// # //////////////////////////// result_x_avg_all_act, result_y_avg_all_act = self.manualLogDataProcessing.get_list_concentration_time_spent_activity(manual_log_testpersoon_D,mindwave_data_list,activities[0],Calculate_statistics_enumeration.AVG) result_x_std_all_act, result_y_std_all_act = self.manualLogDataProcessing.get_list_concentration_time_spent_activity(manual_log_testpersoon_D,mindwave_data_list,activities[0],Calculate_statistics_enumeration.STD) resultTuple_avg_all_act = ResultTuple(result_x_avg_all_act, result_y_avg_all_act) resultTuple_std_all_act = ResultTuple(result_x_std_all_act, result_y_std_all_act) for i in range(1,len(activities)): try: result_x_avg_temp, result_y_avg_temp = self.manualLogDataProcessing.get_list_concentration_time_spent_activity(manual_log_testpersoon_D,mindwave_data_list,activities[i],Calculate_statistics_enumeration.AVG) result_x_std_temp, result_y_std_temp = self.manualLogDataProcessing.get_list_concentration_time_spent_activity(manual_log_testpersoon_D,mindwave_data_list,activities[i],Calculate_statistics_enumeration.STD) resultTuple_avg_all_act.merge(ResultTuple(result_x_avg_temp,result_y_avg_temp)) resultTuple_std_all_act.merge(ResultTuple(result_x_std_temp,result_y_std_temp)) except: pass # //////////////////////////// result_x_amount_avg, result_y_amount_avg = self.manualLogDataProcessing.get_list_amount_used_programs_concentration_per_interval(mindwave_data_list,manual_log_testpersoon_D,list_dates,Calculate_statistics_enumeration.AVG) result_x_amount_std, result_y_amount_std = self.manualLogDataProcessing.get_list_amount_used_programs_concentration_per_interval(mindwave_data_list,manual_log_testpersoon_D,list_dates,Calculate_statistics_enumeration.STD) result_x_avg_rescuetime_amount, result_y_avg_rescuetime_amount = self.get_list_amount_activities_RescueTime_interval_with_mindwave(session_id,Calculate_statistics_enumeration.AVG) result_x_std_rescuetime_amount, result_y_std_rescuetime_amount = self.get_list_amount_activities_RescueTime_interval_with_mindwave(session_id,Calculate_statistics_enumeration.STD) result_x_avg_userstate, result_y_avg_userstate = self.manualLogDataProcessing.get_statistics_attention_userstates(activities_userstate,manual_log_testpersoon_D_userstate,mindwave_data_list,Calculate_statistics_enumeration.AVG) result_x_std_userstate, result_y_std_userstate = self.manualLogDataProcessing.get_statistics_attention_userstates(activities_userstate,manual_log_testpersoon_D_userstate,mindwave_data_list,Calculate_statistics_enumeration.STD) resultTuple_diff = ResultTuple(result_x_diff, result_y_diff) resultTuple_amount_avg = ResultTuple(result_x_amount_avg, result_y_amount_avg) resultTuple_amount_std = ResultTuple(result_x_amount_std, result_y_amount_std) resultTuple_avg_rescuetime_amount = ResultTuple(result_x_avg_rescuetime_amount, result_y_avg_rescuetime_amount) resultTuple_std_rescuetime_amount = ResultTuple(result_x_std_rescuetime_amount, result_y_std_rescuetime_amount) resultTuple_avg_userstate = ResultTuple(result_x_avg_userstate,result_y_avg_userstate) resultTuple_std_userstate = ResultTuple(result_x_std_userstate,result_y_std_userstate) filename = self.folder + "data_analysis_results/testpersoon_D/" self.generate_csv("Time_spent_seconds","Concentration avg",resultTuple_avg,filename + "comparison time_spent_sec against average concentration") self.generate_csv("Time_spent_seconds","Concentration std",resultTuple_std,filename + "comparison time_spent_sec against std concentration") # ////////////////////// # /// all activities /// # ////////////////////// self.generate_csv("Time_spent_seconds","Concentration avg",resultTuple_avg_all_act,filename + "comparison time_spent_sec against average concentration all activities") self.generate_csv("Time_spent_seconds","Concentration std",resultTuple_std_all_act,filename + "comparison time_spent_sec against std concentration all activities") # ////////////////////// self.generate_csv("Unknown","Concentration std",resultTuple_diff,filename + "comparison concentration difference when switch between activities") self.generate_csv("Amount","Concentration avg",resultTuple_amount_avg,filename + "comparison amount used programs with avg concentration") self.generate_csv("Amount","Concentration std",resultTuple_amount_std,filename + "comparison amount used programs with std concentration") self.generate_csv("Amount","Concentration avg",resultTuple_avg_rescuetime_amount,filename + "comparision RescueTime amount concentration avg") self.generate_csv("Amount","Concentration std",resultTuple_std_rescuetime_amount,filename + "comparision RescueTime amount concentration std") self.generate_csv("Userstate","Concentration avg",resultTuple_avg_userstate,filename + "comparision userstates concentration avg") self.generate_csv("Amount","Concentration std",resultTuple_std_userstate,filename + "comparision userstates concentration std") resultObject = ResultObject() resultObject.set_result_timeSpent_activity_avg(resultTuple_avg) resultObject.set_result_timeSpent_activity_std(resultTuple_std) resultObject.set_concentration_diff_activity_switch_avg(resultTuple_diff) resultObject.set_result_amount_used_programs_avg(resultTuple_amount_avg) resultObject.set_result_amount_used_programs_std(resultTuple_amount_std) resultObject.set_amount_activities_RescueTime_interval_with_mindwave_avg(resultTuple_avg_rescuetime_amount) resultObject.set_amount_activities_RescueTime_interval_with_mindwave_std(resultTuple_std_rescuetime_amount) return resultObject
def get_statistics_session_testpersoon_B(self): session_id = 41 datetime_from_session, datetime_to_session = self.dasession.get_dates_session(session_id) activities,manual_log_testpersoon_B = Manual_log.get_manual_logfile_Testpersoon_B_enkel_programmas_websites() datetime_from = manual_log_testpersoon_B[0][0] datetime_to = manual_log_testpersoon_B[len(manual_log_testpersoon_B) - 1][1] mindwave_data_list = Mindwave_data_processing.get_mindwave_data_filtered_smoothed_middle_moving_median(datetime_from,datetime_to,self.window_mindwave) list_dates = self.rescuetimeDataProcessing.get_dates_list(datetime_from_session, datetime_to_session) result_x_diff, result_y_diff = self.manualLogDataProcessing.get_list_concentration_differences_manual_log(manual_log_testpersoon_B,mindwave_data_list) result_x_amount_avg, result_y_amount_avg = self.manualLogDataProcessing.get_list_amount_used_programs_concentration_per_interval(mindwave_data_list,manual_log_testpersoon_B,list_dates,Calculate_statistics_enumeration.AVG) result_x_amount_std, result_y_amount_std = self.manualLogDataProcessing.get_list_amount_used_programs_concentration_per_interval(mindwave_data_list,manual_log_testpersoon_B,list_dates,Calculate_statistics_enumeration.STD) result_x_avg_rescuetime_amount, result_y_avg_rescuetime_amount = self.get_list_amount_activities_RescueTime_interval_with_mindwave(session_id,Calculate_statistics_enumeration.AVG) result_x_std_rescuetime_amount, result_y_std_rescuetime_amount = self.get_list_amount_activities_RescueTime_interval_with_mindwave(session_id,Calculate_statistics_enumeration.STD) activities_important = ["Wikipedia","Latex"] result_x_avg, result_y_avg = self.manualLogDataProcessing.get_list_concentration_time_spent_activity(manual_log_testpersoon_B,mindwave_data_list,activities_important[0],Calculate_statistics_enumeration.AVG) result_x_std, result_y_std = self.manualLogDataProcessing.get_list_concentration_time_spent_activity(manual_log_testpersoon_B,mindwave_data_list,activities_important[0],Calculate_statistics_enumeration.STD) resultTuple_avg = ResultTuple(result_x_avg, result_y_avg) resultTuple_std = ResultTuple(result_x_std, result_y_std) for i in range(1,len(activities_important)): result_x_avg_temp, result_y_avg_temp = self.manualLogDataProcessing.get_list_concentration_time_spent_activity(manual_log_testpersoon_B,mindwave_data_list,activities_important[i],Calculate_statistics_enumeration.AVG) result_x_std_temp, result_y_std_temp = self.manualLogDataProcessing.get_list_concentration_time_spent_activity(manual_log_testpersoon_B,mindwave_data_list,activities_important[i],Calculate_statistics_enumeration.STD) resultTuple_avg.merge(ResultTuple(result_x_avg_temp,result_y_avg_temp)) resultTuple_std.merge(ResultTuple(result_x_std_temp,result_y_std_temp)) activity_from = "Latex" activity_to = "Wikipedia" result_x_diff_specific_switch, result_y_diff_specific_switch = self.manualLogDataProcessing.get_list_concentration_differences_manual_log_specific_switch(manual_log_testpersoon_B,mindwave_data_list,activity_from,activity_to) resultTuple_diff_specific_switch = ResultTuple(result_x_diff_specific_switch,result_y_diff_specific_switch) # //////////////////////////// # /// with all activities //// # //////////////////////////// result_x_avg_all_act, result_y_avg_all_act = self.manualLogDataProcessing.get_list_concentration_time_spent_activity(manual_log_testpersoon_B,mindwave_data_list,activities[0],Calculate_statistics_enumeration.AVG) result_x_std_all_act, result_y_std_all_act = self.manualLogDataProcessing.get_list_concentration_time_spent_activity(manual_log_testpersoon_B,mindwave_data_list,activities[0],Calculate_statistics_enumeration.STD) resultTuple_avg_all_act = ResultTuple(result_x_avg_all_act, result_y_avg_all_act) resultTuple_std_all_act = ResultTuple(result_x_std_all_act, result_y_std_all_act) for i in range(1,len(activities)): try: result_x_avg_temp, result_y_avg_temp = self.manualLogDataProcessing.get_list_concentration_time_spent_activity(manual_log_testpersoon_B,mindwave_data_list,activities[i],Calculate_statistics_enumeration.AVG) result_x_std_temp, result_y_std_temp = self.manualLogDataProcessing.get_list_concentration_time_spent_activity(manual_log_testpersoon_B,mindwave_data_list,activities[i],Calculate_statistics_enumeration.STD) resultTuple_avg_all_act.merge(ResultTuple(result_x_avg_temp,result_y_avg_temp)) resultTuple_std_all_act.merge(ResultTuple(result_x_std_temp,result_y_std_temp)) except: pass # //////////////////////////// resultTuple_diff = ResultTuple(result_x_diff, result_y_diff) resultTuple_amount_avg = ResultTuple(result_x_amount_avg, result_y_amount_avg) resultTuple_amount_std = ResultTuple(result_x_amount_std, result_y_amount_std) resultTuple_avg_rescuetime_amount = ResultTuple(result_x_avg_rescuetime_amount, result_y_avg_rescuetime_amount) resultTuple_std_rescuetime_amount = ResultTuple(result_x_std_rescuetime_amount, result_y_std_rescuetime_amount) filename = self.folder + "data_analysis_results/testpersoon_B/" # ////////////////////// # /// all activities /// # ////////////////////// self.generate_csv("Time_spent_seconds","Concentration avg",resultTuple_avg_all_act,filename + "comparison time_spent_sec against average concentration all activities") self.generate_csv("Time_spent_seconds","Concentration std",resultTuple_std_all_act,filename + "comparison time_spent_sec against std concentration all activities") # ////////////////////// self.generate_csv("Time_spent_seconds","Concentration avg",resultTuple_avg,filename + "comparison time_spent_sec against average concentration") self.generate_csv("Time_spent_seconds","Concentration std",resultTuple_std,filename + "comparison time_spent_sec against std concentration") self.generate_csv("Switch ID","Concentration avg",resultTuple_diff,filename + "comparison concentration difference when switch between activities") self.generate_csv("Switch ID","Concentration avg",resultTuple_diff_specific_switch,filename + "comparison concentration difference specific switch between activities") self.generate_csv("Amount","Concentration avg",resultTuple_amount_avg,filename + "comparison amount used programs with avg concentration") self.generate_csv("Amount","Concentration std",resultTuple_amount_std,filename + "comparison amount used programs with std concentration") self.generate_csv("Amount","Concentration avg",resultTuple_avg_rescuetime_amount,filename + "comparision RescueTime amount concentration avg") self.generate_csv("Amount","Concentration std",resultTuple_std_rescuetime_amount,filename + "comparision RescueTime amount concentration std") resultObject = ResultObject() resultObject.set_result_timeSpent_activity_avg(resultTuple_avg) resultObject.set_result_timeSpent_activity_std(resultTuple_std) resultObject.set_concentration_diff_activity_switch_avg(resultTuple_diff) resultObject.set_concentration_diff_specific_activity_switch_avg(resultTuple_diff_specific_switch) resultObject.set_result_amount_used_programs_avg(resultTuple_amount_avg) resultObject.set_result_amount_used_programs_std(resultTuple_amount_std) resultObject.set_amount_activities_RescueTime_interval_with_mindwave_avg(resultTuple_avg_rescuetime_amount) resultObject.set_amount_activities_RescueTime_interval_with_mindwave_std(resultTuple_std_rescuetime_amount) return resultObject
def test_convert_mindwave_data_to_RescueTime_intervals(self): list_dates_Rescuetime = [["2014-04-24 14:00:00"], ["2014-04-24 14:05:00"], ["2014-04-24 14:10:00"]] list_mindwave_data = [] list_mindwave_data.append( [0, "2014-04-24 14:00:00", None, 0.50, 0.40, None, None]) list_mindwave_data.append( [0, "2014-04-24 14:01:00", None, 0.10, 0.20, None, None]) list_mindwave_data.append( [0, "2014-04-24 14:02:00", None, 0.60, 0.30, None, None]) list_mindwave_data.append( [0, "2014-04-24 14:03:00", None, 0.80, 0.50, None, None]) list_mindwave_data.append( [0, "2014-04-24 14:04:00", None, 0.10, 0.50, None, None]) list_mindwave_data.append( [0, "2014-04-24 14:05:00", None, 0.10, 0.10, None, None]) list_mindwave_data.append( [0, "2014-04-24 14:06:00", None, 0.50, 0.90, None, None]) list_mindwave_data.append( [0, "2014-04-24 14:07:00", None, 0.60, 0.40, None, None]) list_mindwave_data.append( [0, "2014-04-24 14:08:00", None, 0.80, 0.60, None, None]) list_mindwave_data.append( [0, "2014-04-24 14:09:00", None, 0.40, 0.20, None, None]) list_mindwave_data.append( [0, "2014-04-24 14:10:00", None, 0.60, 0.30, None, None]) list_mindwave_data.append( [0, "2014-04-24 14:11:00", None, 0.20, 0.60, None, None]) list_mindwave_data.append( [0, "2014-04-24 14:12:00", None, 0.80, 0.80, None, None]) list_mindwave_data.append( [0, "2014-04-24 14:13:00", None, 0.10, 0.60, None, None]) list_mindwave_data.append( [0, "2014-04-24 14:14:00", None, 0.30, 0.10, None, None]) list_mindwave_data.append( [0, "2014-04-24 14:15:00", None, 0.50, 0.20, None, None]) attention_data_original = [] meditation_data_original = [] for item in list_mindwave_data: attention_data_original.append(item[3]) meditation_data_original.append(item[4]) x_axix, attention_data, meditation_data = Mindwave_data_processing.convert_mindwave_data_to_RescueTime_intervals( list_mindwave_data, list_dates_Rescuetime) self.assertEqual(round(attention_data[0], 2), round(np.mean(attention_data_original[0:6]), 2)) self.assertEqual(round(attention_data[1], 2), round(np.mean(attention_data_original[6:11]), 2)) self.assertEqual(round(attention_data[2], 2), round(np.mean(attention_data_original[11:16]), 2)) self.assertEqual(round(meditation_data[0], 2), round(np.mean(meditation_data_original[0:6]), 2)) self.assertEqual(round(meditation_data[1], 2), round(np.mean(meditation_data_original[6:11]), 2)) self.assertEqual(round(meditation_data[2], 2), round(np.mean(meditation_data_original[11:16]), 2))
def test_get_attention_meditation_buckets(self): dates = [] dates.append( datetime.datetime.strptime("2013-12-28 08:00:00", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:01", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:02", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:03", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:04", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:05", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:06", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:07", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:08", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:09", "%Y-%m-%d %H:%M:%S")) dates.append( datetime.datetime.strptime("2013-12-28 08:00:10", "%Y-%m-%d %H:%M:%S")) mindwave_data = [] mindwave_data.append([dates[0], dates[1], 0.2, 0.2, 0, 0]) mindwave_data.append([dates[1], dates[2], 0.4, 0.5, 0, 0]) mindwave_data.append([dates[2], dates[3], 0.8, 0.2, 0, 0]) mindwave_data.append([dates[3], dates[4], 0.1, 0.5, 0, 0]) mindwave_data.append([dates[4], dates[5], 0.9, 0.1, 0, 0]) mindwave_data.append([dates[5], dates[6], 0.4, 0.8, 0, 0]) mindwave_data.append([dates[6], dates[7], 0.8, 0.3, 0, 0]) mindwave_data.append([dates[7], dates[8], 0.2, 0.6, 0, 0]) mindwave_data.append([dates[8], dates[9], 0.0, 1.0, 0, 0]) mindwave_data.append([dates[9], dates[10], 0.4, 0.5, 0, 0]) datetime_from = datetime.datetime.strptime("2013-12-28 08:00:00", "%Y-%m-%d %H:%M:%S") datetime_to = datetime.datetime.strptime("2013-12-28 08:30:00", "%Y-%m-%d %H:%M:%S") attention_bucket, meditation_bucket = Mindwave_data_processing.get_attention_meditation_buckets( datetime_from, datetime_to, mindwave_data) self.assertEqual(attention_bucket[0], 0.20) self.assertEqual(attention_bucket[1], 0.20) self.assertEqual(attention_bucket[2], 0.30) self.assertEqual(attention_bucket[3], 0.0) self.assertEqual(attention_bucket[4], 0.3) self.assertEqual(meditation_bucket[0], 0.1) self.assertEqual(meditation_bucket[1], 0.3) self.assertEqual(meditation_bucket[2], 0.3) self.assertEqual(meditation_bucket[3], 0.1) self.assertEqual(meditation_bucket[4], 0.2) print str("attention_bucket") print attention_bucket print str("meditation_bucket") print meditation_bucket
def mindwave_data_important_unimportant_activity(self, session_id): datetime_from, datetime_to = self.dasession.get_dates_session( session_id) attention_data, x, y_attention, y_meditation, y_userGoneNotStudying, y_userGoneStudying = Mindwave_data_processing.get_mindwave_dataa_important_unimportant_activity( datetime_from, datetime_to, self.window_RescueTime) title = "mindwave data important / unimportant activities" self.plot_data(attention_data, x, y_attention, y_meditation, None, y_userGoneNotStudying, y_userGoneStudying, title, self.x_label, self.y_label)
def mindwave_data_per_worksession(self, session_id): datetime_from, datetime_to = self.dasession.get_dates_session( session_id) attention_data, x, y_attention, y_meditation, y_userGoneNotStudying, y_userGoneStudying = Mindwave_data_processing.get_mindwave_worksession_data( datetime_from, datetime_to, self.window_other) title = "session_ID: " + str( session_id) + "mindwave data for worksession" self.plot_data(attention_data, x, y_attention, y_meditation, None, y_userGoneNotStudying, y_userGoneStudying, title, self.x_label, self.y_label)
result_html = add_table_workSession_gem_min_max(datetime_from,datetime_to,options_reason,treshold_important_unimportant,result_html) # tabel worksessies result_html = add_table_workSession(datetime_from,datetime_to,options_reason,treshold_important_unimportant,result_html) result_html += "<h2>Some additional information:</h2>" result_html += '<p>' + 'average eyes detected = ' + percentage_layout(User_gone_processing.get_eyes_detected_specific_period(datetime_from,datetime_to)) + '</p>' + '\n' try: avg_concentration_userfeedback = Userfeedback_processing.get_average_userfeedback_specific_period(datetime_from, datetime_to) except Exception.ListEmpty, e: avg_concentration_userfeedback = -1 avg_reading = Read_detection_processing.get_average_reading_specific_period(datetime_from, datetime_to) result_html += '<p>' + 'average concentration userfeedback = ' + percentage_layout(avg_concentration_userfeedback) + '</p>' + '\n' attention_mindwave, meditation_mindwave = Mindwave_data_processing.get_average_attention_meditation_specific_period(datetime_from,datetime_to) result_html += '<p>' + 'average concentration mindwave = ' + percentage_layout(attention_mindwave) + '\n' result_html += '<p>' + 'average meditation mindwave = ' + percentage_layout(meditation_mindwave) + '</p>' + '\n' result_html += '<p>' + 'average read = ' + percentage_layout(avg_reading) + '</p>' + '\n' #print df['Date'].unique() #df.to_csv('rt_data_interval_activity_20120901.csv', index=False) result_html += "</body>" + "\n" result_html += "</html>" + "\n" result_page = open("result_page.htm","wb") result_page.write(result_html) result_page.close()
def getListImportantActivities_V2_buckets(datetime_from, datetime_to,options_reason,link_to_main): daRescueTime = DARescueTime_SQLite.RescueTime(link_to_main) #result_rescueTime = DARescueTime_SQLite.get_data_important_activities_specific_period(datetime_from,datetime_to) important_activities_list = daRescueTime.get_data_important_activities_specific_period_group_by_activity(datetime_from,datetime_to) # hier komt het resultaat in per activity. Dus gemiddelde concentratie met tijd activiteit geopend result = [] # Itereren over elke belangrijke activitieit for activity in important_activities_list : #[DateTime, Time_sec,ActivityDetail, Category, isImportant, ActivityGeneral, Subject_ID] activity_details = daRescueTime.get_data_important_activities_specific_period_activity(datetime_from,datetime_to,activity[1]) # Dan per belangrijke activitieit, in die 5 minuten tijdspanne gaan kijken hoeveel de gebruiker naar het scherm keek mindwave_data_list = Mindwave_data_processing.get_mindwave_data_filtered_smoothed(datetime_from,datetime_to,10) attention_bucket_total = [] meditation_bucket_total = [] gemiddelde_concentratie_userfeedback = 0.0 totaal_userfeedback = 0 gemiddelde_eyes_detected = 0.0 totaal_eyes_detected = 0 gemiddelde_attention_mindwave = 0.0 totaal_attention_mindwave = 0 gemiddelde_meditation_mindwave = 0.0 totaal_meditation_mindwave = 0 gemiddelde_reading = 0.0 totaal_reading = 0.0 # Bijhouden dat, per keer de gebruiker niet naar het scherm keek, wat was die dan wel aan het doen? reason_array = [] for reason in options_reason: reason_array.append([reason[0],0.0]) for activity_detail in activity_details: start_datetime = datetime.datetime.strptime(activity_detail[1],"%Y-%m-%d %H:%M:%S") end_datetime = start_datetime + datetime.timedelta(minutes=5) # gemiddelde berekenen van de userfeedback gegevens voor de periodes van activity_detail try: concentratie = Userfeedback_processing.get_average_userfeedback_specific_period(start_datetime,end_datetime) gemiddelde_concentratie_userfeedback += concentratie totaal_userfeedback += 1 except Exception.ListEmpty, e: source = "data_processing, function: get_average_userfeedback_specific_period(" + str(start_datetime) + "," + str(end_datetime) + ")" DAErrorReport_SQLite.insert_row_action(datetime.datetime.today(),source,e.msg) gemiddelde_eyes_detected += float(User_gone_processing.get_eyes_detected_specific_period(start_datetime,end_datetime)) totaal_eyes_detected += 1 # Mindwave, gemiddelde berekenen attention_bucket, meditation_bucket = Mindwave_data_processing.get_attention_meditation_buckets(start_datetime,end_datetime,mindwave_data_list) attention_bucket_total.append(attention_bucket) meditation_bucket_total.append(meditation_bucket) # reason_array opvullen: teller_reason = 0 while(teller_reason < len(options_reason)): reason_array[teller_reason][1] += User_gone_processing.get_average_reason(start_datetime,end_datetime,options_reason[teller_reason][0]) teller_reason += 1 # reading reading_temp = Read_detection_processing.get_average_reading_specific_period(start_datetime,end_datetime) if reading_temp > 0: gemiddelde_reading += reading_temp totaal_reading += 1 teller_reason = 0 while (teller_reason < len(reason_array)): reason_array[teller_reason][1] = reason_array[teller_reason][1] / float(len(activity_details)) teller_reason += 1 if totaal_userfeedback > 0 : gemiddelde_concentratie_userfeedback = float((gemiddelde_concentratie_userfeedback / totaal_userfeedback)) else: gemiddelde_concentratie_userfeedback = -1 if totaal_eyes_detected > 0: gemiddelde_eyes_detected = float((gemiddelde_eyes_detected / totaal_eyes_detected)) else: gemiddelde_eyes_detected = 0 if len(attention_bucket_total) > 0: attention_bucket_avg, meditation_bucket_avg = Mindwave_data_processing.merge_buckets(attention_bucket_total, meditation_bucket_total) if totaal_reading > 0: gemiddelde_reading = float(gemiddelde_reading / totaal_reading) else: gemiddelde_reading = 0 result.append([activity[1],activity[0],gemiddelde_concentratie_userfeedback,gemiddelde_eyes_detected,reason_array,attention_bucket_avg, meditation_bucket_avg,gemiddelde_reading,activity[2]])
def get_statistics_session_testpersoon_D(self): session_id = 11 datetime_from_session, datetime_to_session = self.dasession.get_dates_session( session_id) activities, manual_log_testpersoon_D = Manual_log.get_manual_log_testpersoon_D_programms_and_extra_info( ) activities_userstate, manual_log_testpersoon_D_userstate = Manual_log.get_manual_log_testpersoon_D_userstates( ) datetime_from = manual_log_testpersoon_D[0][0] datetime_to = manual_log_testpersoon_D[len(manual_log_testpersoon_D) - 1][1] mindwave_data_list = Mindwave_data_processing.get_mindwave_data_filtered_smoothed_middle_moving_median( datetime_from, datetime_to, self.window_mindwave) list_dates = self.rescuetimeDataProcessing.get_dates_list( datetime_from_session, datetime_to_session) activities_important = [ "pdf + toledovragen", "powerpoint", "wikipedia", "toledovragen", "pdf" ] # With important activities result_x_avg, result_y_avg = self.manualLogDataProcessing.get_list_concentration_time_spent_activity( manual_log_testpersoon_D, mindwave_data_list, activities_important[0], Calculate_statistics_enumeration.AVG) result_x_std, result_y_std = self.manualLogDataProcessing.get_list_concentration_time_spent_activity( manual_log_testpersoon_D, mindwave_data_list, activities_important[0], Calculate_statistics_enumeration.STD) resultTuple_avg = ResultTuple(result_x_avg, result_y_avg) resultTuple_std = ResultTuple(result_x_std, result_y_std) for i in range(1, len(activities_important)): result_x_avg_temp, result_y_avg_temp = self.manualLogDataProcessing.get_list_concentration_time_spent_activity( manual_log_testpersoon_D, mindwave_data_list, activities_important[i], Calculate_statistics_enumeration.AVG) result_x_std_temp, result_y_std_temp = self.manualLogDataProcessing.get_list_concentration_time_spent_activity( manual_log_testpersoon_D, mindwave_data_list, activities_important[i], Calculate_statistics_enumeration.STD) resultTuple_avg.merge( ResultTuple(result_x_avg_temp, result_y_avg_temp)) resultTuple_std.merge( ResultTuple(result_x_std_temp, result_y_std_temp)) result_x_diff, result_y_diff = self.manualLogDataProcessing.get_list_concentration_differences_manual_log( manual_log_testpersoon_D, mindwave_data_list) # //////////////////////////// # /// with all activities //// # //////////////////////////// result_x_avg_all_act, result_y_avg_all_act = self.manualLogDataProcessing.get_list_concentration_time_spent_activity( manual_log_testpersoon_D, mindwave_data_list, activities[0], Calculate_statistics_enumeration.AVG) result_x_std_all_act, result_y_std_all_act = self.manualLogDataProcessing.get_list_concentration_time_spent_activity( manual_log_testpersoon_D, mindwave_data_list, activities[0], Calculate_statistics_enumeration.STD) resultTuple_avg_all_act = ResultTuple(result_x_avg_all_act, result_y_avg_all_act) resultTuple_std_all_act = ResultTuple(result_x_std_all_act, result_y_std_all_act) for i in range(1, len(activities)): try: result_x_avg_temp, result_y_avg_temp = self.manualLogDataProcessing.get_list_concentration_time_spent_activity( manual_log_testpersoon_D, mindwave_data_list, activities[i], Calculate_statistics_enumeration.AVG) result_x_std_temp, result_y_std_temp = self.manualLogDataProcessing.get_list_concentration_time_spent_activity( manual_log_testpersoon_D, mindwave_data_list, activities[i], Calculate_statistics_enumeration.STD) resultTuple_avg_all_act.merge( ResultTuple(result_x_avg_temp, result_y_avg_temp)) resultTuple_std_all_act.merge( ResultTuple(result_x_std_temp, result_y_std_temp)) except: pass # //////////////////////////// result_x_amount_avg, result_y_amount_avg = self.manualLogDataProcessing.get_list_amount_used_programs_concentration_per_interval( mindwave_data_list, manual_log_testpersoon_D, list_dates, Calculate_statistics_enumeration.AVG) result_x_amount_std, result_y_amount_std = self.manualLogDataProcessing.get_list_amount_used_programs_concentration_per_interval( mindwave_data_list, manual_log_testpersoon_D, list_dates, Calculate_statistics_enumeration.STD) result_x_avg_rescuetime_amount, result_y_avg_rescuetime_amount = self.get_list_amount_activities_RescueTime_interval_with_mindwave( session_id, Calculate_statistics_enumeration.AVG) result_x_std_rescuetime_amount, result_y_std_rescuetime_amount = self.get_list_amount_activities_RescueTime_interval_with_mindwave( session_id, Calculate_statistics_enumeration.STD) result_x_avg_userstate, result_y_avg_userstate = self.manualLogDataProcessing.get_statistics_attention_userstates( activities_userstate, manual_log_testpersoon_D_userstate, mindwave_data_list, Calculate_statistics_enumeration.AVG) result_x_std_userstate, result_y_std_userstate = self.manualLogDataProcessing.get_statistics_attention_userstates( activities_userstate, manual_log_testpersoon_D_userstate, mindwave_data_list, Calculate_statistics_enumeration.STD) resultTuple_diff = ResultTuple(result_x_diff, result_y_diff) resultTuple_amount_avg = ResultTuple(result_x_amount_avg, result_y_amount_avg) resultTuple_amount_std = ResultTuple(result_x_amount_std, result_y_amount_std) resultTuple_avg_rescuetime_amount = ResultTuple( result_x_avg_rescuetime_amount, result_y_avg_rescuetime_amount) resultTuple_std_rescuetime_amount = ResultTuple( result_x_std_rescuetime_amount, result_y_std_rescuetime_amount) resultTuple_avg_userstate = ResultTuple(result_x_avg_userstate, result_y_avg_userstate) resultTuple_std_userstate = ResultTuple(result_x_std_userstate, result_y_std_userstate) filename = self.folder + "data_analysis_results/testpersoon_D/" self.generate_csv( "Time_spent_seconds", "Concentration avg", resultTuple_avg, filename + "comparison time_spent_sec against average concentration") self.generate_csv( "Time_spent_seconds", "Concentration std", resultTuple_std, filename + "comparison time_spent_sec against std concentration") # ////////////////////// # /// all activities /// # ////////////////////// self.generate_csv( "Time_spent_seconds", "Concentration avg", resultTuple_avg_all_act, filename + "comparison time_spent_sec against average concentration all activities" ) self.generate_csv( "Time_spent_seconds", "Concentration std", resultTuple_std_all_act, filename + "comparison time_spent_sec against std concentration all activities" ) # ////////////////////// self.generate_csv( "Unknown", "Concentration std", resultTuple_diff, filename + "comparison concentration difference when switch between activities" ) self.generate_csv( "Amount", "Concentration avg", resultTuple_amount_avg, filename + "comparison amount used programs with avg concentration") self.generate_csv( "Amount", "Concentration std", resultTuple_amount_std, filename + "comparison amount used programs with std concentration") self.generate_csv( "Amount", "Concentration avg", resultTuple_avg_rescuetime_amount, filename + "comparision RescueTime amount concentration avg") self.generate_csv( "Amount", "Concentration std", resultTuple_std_rescuetime_amount, filename + "comparision RescueTime amount concentration std") self.generate_csv( "Userstate", "Concentration avg", resultTuple_avg_userstate, filename + "comparision userstates concentration avg") self.generate_csv( "Amount", "Concentration std", resultTuple_std_userstate, filename + "comparision userstates concentration std") resultObject = ResultObject() resultObject.set_result_timeSpent_activity_avg(resultTuple_avg) resultObject.set_result_timeSpent_activity_std(resultTuple_std) resultObject.set_concentration_diff_activity_switch_avg( resultTuple_diff) resultObject.set_result_amount_used_programs_avg( resultTuple_amount_avg) resultObject.set_result_amount_used_programs_std( resultTuple_amount_std) resultObject.set_amount_activities_RescueTime_interval_with_mindwave_avg( resultTuple_avg_rescuetime_amount) resultObject.set_amount_activities_RescueTime_interval_with_mindwave_std( resultTuple_std_rescuetime_amount) return resultObject