@@ -84,7 +84,7 @@ def map_observation(metric_id,
8484 if metric_group == "CONTEXT" :
8585 return OBSERVATION_TEMPLATE_CONTEXT_DAHCC % (uuid ,
8686 uuid , source_id ,
87- uuid , metric_id ,
87+ uuid , uuid , metric_id ,
8888 uuid , str (timestamp_utc ),
8989 uuid , value
9090 )
@@ -93,10 +93,18 @@ def map_observation(metric_id,
9393 # patient_id, metric_id, uuid,
9494 # metric_id, time_str, str(timestamp_utc), value_str)
9595 elif metric_group == "WEARABLE" :
96- return OBSERVATION_TEMPLATE_WEARABLE % (source_id ,
97- patient_id , metric_id , uuid ,
98- patient_id , metric_id , uuid ,
99- metric_id , time_str , str (timestamp_utc ), value_str )
96+ return OBSERVATION_TEMPLATE_CONTEXT_DAHCC % (uuid ,
97+ uuid , source_id ,
98+ uuid , uuid , metric_id ,
99+ uuid , str (timestamp_utc ),
100+ uuid , value
101+ )
102+
103+
104+ # return OBSERVATION_TEMPLATE_WEARABLE % (source_id,
105+ # patient_id, metric_id, uuid,
106+ # patient_id, metric_id, uuid,
107+ # metric_id, time_str, str(timestamp_utc), value_str)
100108
101109
102110def map_value (value , metric_id ):
@@ -135,9 +143,10 @@ def update_source_id(source_id, metric_id):
135143OBSERVATION_TEMPLATE_CONTEXT_DAHCC = """
136144<https://dahcc.idlab.ugent.be/Protego/_participant1/obs%s> <http://rdfs.org/ns/void#inDataset> <https://dahcc.idlab.ugent.be/Protego/_participant1> .
137145<https://dahcc.idlab.ugent.be/Protego/_participant1/obs%s> <https://saref.etsi.org/core/measurementMadeBy> <https://dahcc.idlab.ugent.be/Homelab/SensorsAndActuators/%s> .
146+ <https://dahcc.idlab.ugent.be/Protego/_participant1/obs%s> <http://purl.org/dc/terms/isVersionOf> <https://saref.etsi.org/core/Measurement> .
138147<https://dahcc.idlab.ugent.be/Protego/_participant1/obs%s> <https://saref.etsi.org/core/relatesToProperty> <https://dahcc.idlab.ugent.be/Homelab/SensorsAndActuators/%s> .
139148<https://dahcc.idlab.ugent.be/Protego/_participant1/obs%s> <https://saref.etsi.org/core/hasTimestamp> "%s"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
140- <https://dahcc.idlab.ugent.be/Protego/_participant1/obs%s> <https://saref.etsi.org/core/hasValue> "%s"^^<http://www.w3.org/2001/XMLSchema#boolean > .
149+ <https://dahcc.idlab.ugent.be/Protego/_participant1/obs%s> <https://saref.etsi.org/core/hasValue> "%s"^^<http://www.w3.org/2001/XMLSchema#float > .
141150
142151"""
143152
@@ -283,7 +292,7 @@ def convert_timestamp_to_string(timestamp):
283292
284293
285294def generate_uuid (metric_id , patient_id ):
286- key = '%s.%s ' % (patient_id , metric_id )
295+ key = '%s' % (patient_id )
287296 if key not in uuid_map :
288297 uuid_map [key ] = 0
289298 result = uuid_map [key ]
@@ -297,21 +306,27 @@ def remove_whitespace(given_str):
297306
298307# MAIN FUNCTION FOR TESTING PURPOSES
299308
300- file = pandas .read_feather ('../data/dataset_participant1.feather' )
301- metric = 'people.presence.detected'
309+ file = pandas .read_feather ('data/dataset_participant3.feather' )
310+
311+ heartRateSensor = ['wearable.bvp' ];
312+ accelerationSensorNames = ['wearable.acceleration.x' , 'wearable.acceleration.y' , 'wearable.acceleration.z' ]
313+
314+ numberOfObservations = 500
302315
303- # print(file.head())
304- dataframe = file [file ['Metric' ] == 'people.presence.detected' ]
316+ dataframe_heart_rate = file [file ['Metric' ] == heartRateSensor [0 ]].head (numberOfObservations )
317+ dataframe_acc_x = file [file ['Metric' ] == accelerationSensorNames [0 ]].head (numberOfObservations )
318+ dataframe_acc_y = file [file ['Metric' ] == accelerationSensorNames [1 ]].head (numberOfObservations )
319+ dataframe_acc_z = file [file ['Metric' ] == accelerationSensorNames [2 ]].head (numberOfObservations )
320+
321+ dataframe_heart_rate_with_x = dataframe_heart_rate .append (dataframe_acc_x )
322+ dataframe_heart_rate_with_x_y = dataframe_heart_rate_with_x .append (dataframe_acc_y )
323+ dataframe = dataframe_heart_rate_with_x_y .append (dataframe_acc_z )
305324
306325if __name__ == '__main__' :
307326 for index in dataframe .index :
308327 source = dataframe ['Sensor' ][index ]
309328 metricId = dataframe ['Metric' ][index ]
310329 value = dataframe ['Value' ][index ]
311- if value == "1" :
312- newValue = "true"
313- else :
314- newValue = "false"
315330 datetimeValue = dataframe ['Timestamp' ][index ]
316331 datetimeValueString = str (datetimeValue )
317332 valueOfHour = datetimeValueString [0 :2 ]
@@ -321,7 +336,7 @@ def remove_whitespace(given_str):
321336 if (datetimeValueString [9 :12 ] == '' ):
322337 continue
323338 else :
324- valueOfMiliSeconds = datetimeValueString [9 :15 ]
339+ valueOfMiliSeconds = datetimeValueString [9 :13 ]
325340
326341 currentDate = datetime .now ()
327342 year = currentDate .strftime ("%Y" )
@@ -330,22 +345,19 @@ def remove_whitespace(given_str):
330345
331346 try :
332347 timeValue = str (year + '-' + month + '-' + day + 'T' + valueOfHour + ':' + valueOfMinute + ':' + valueOfSeconds + '.' + valueOfMiliSeconds )
333- # epoch = datetime(year=year, month=month, day=day, hour=valueOfHour, minute=valueOfMinute,
334- # second=valueOfSeconds, microsecond=valueOfMiliSeconds).strftime('%s')
335- # timeValue = epoch
336348 except Exception as e :
337349 print (e )
338350 finally :
339351 print ('Done' )
340352
341353 json_event = {
342354 "sourceId" : source ,
343- "metricId" : "people.presence.detected" ,
344- "value" : newValue ,
355+ "metricId" : metricId ,
356+ "value" : value ,
345357 "timestamp" : timeValue
346358 }
347359 _result = annotate_event (json_event )
348- with open ('/home/kush/Code/feather-RDF-mapper/data/rdfData/dataset_participant1 .nt' , 'a' ) as file :
360+ with open ('/home/kush/Code/feather-RDF-mapper/data/rdfData/dataset_participant3 .nt' , 'a' ) as file :
349361 pass
350362 file .write ('\n ' )
351363 file .write (_result )
0 commit comments