Skip to content

Commit

Permalink
upgrade pf data storage
Browse files Browse the repository at this point in the history
  • Loading branch information
ophlariviere committed Jan 13, 2025
1 parent 9b1571c commit a9596ea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
8 changes: 6 additions & 2 deletions biosiglive/interfaces/qualisys_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,15 @@ async def get_force_plate_data(
nb_pf = len(forcesdata) # Nombre de plaques de force
collected_data = [] # Liste dynamique pour collecter les données valides
PFForce = forcesdata[0][1] # Données pour une plaque
nb_frames = len(PFForce) # Nombre de frames pour cette plaque


nb_frames = max(len(forcesdata[0][1]), len(forcesdata[1][1])) # Nombre de frames pour cette plaque
# Collecte des données
for platenum in range(nb_pf):
PFForce = forcesdata[platenum][1]
# Temporaire pour cette plaque
plate_data =np.empty((9, nb_frames))

plate_data[:]=np.nan
for frame_idx, data_tmp in enumerate(PFForce):
# Récupérer les données et remplir la matrice temporaire
plate_data[:, frame_idx] = [
Expand All @@ -298,6 +300,8 @@ async def get_force_plate_data(

# Concaténation des données valides uniquement pour obtenir [9 * nb_pf, nb_frame]
all_forces_data = np.concatenate(collected_data, axis=0)
print(all_forces_data)
print("newdata")
return all_forces_data


Expand Down
20 changes: 13 additions & 7 deletions examples/CompuServeetQual.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,27 @@ def load_marker_names(self):
# Chargement des noms des marqueurs à partir du fichier
tmp = load("walkAll_LAO01_Cond10.bio")
return tmp['markers_names'].data[0:self.nb_markers].tolist()
return tmp['markers_names'].data[0:self.nb_markers].tolist()

async def setup_interface(self):
self.interface = await QualisysClient.create(ip="192.168.0.2", system_rate=100, port=22224)
self.interface = await QualisysClient.create(ip="192.168.254.1", system_rate=100, port=22224)

# Configuration du jeu de marqueurs

await self.interface.add_marker_set(
nb_markers=self.nb_markers, data_buffer_size=1000, marker_data_file_key="markers", name="markers", rate=100,
nb_markers=self.nb_markers,
data_buffer_size=1000,
marker_data_file_key="markers",
name="markers",
rate=self.system_rate,
unit="mm"
)

await self.interface.add_device(
nb_channels=18,
device_type="force_plate",
name="force_plate",
data_buffer_size=2000,
data_buffer_size=20000,
rate=2000,
device_data_file_key="force_plate",
processing_method=None,
Expand All @@ -67,14 +72,14 @@ async def process_data(self):
packet = await self.interface.Connect.get_current_frame(components=self.interface.component)

# data recuperation
mark_tmp = self.interface.get_marker_set_data(packet=packet)

mark_tmp = await self.interface.get_marker_set_data(packet=packet)
dataforce = await self.interface.get_force_plate_data(packet=packet)

# Calcul de la force verticale moyenne actuelle
if dataforce is not []:
current_fz = np.mean(dataforce[2])
print(current_fz)
current_fz = np.nanmean(dataforce[2])
current_fz2 = np.nanmean(dataforce[11])
print(current_fz, current_fz2)
if not self.sending_started and detect_start(self.previous_fz, current_fz, self.threshold):
self.sending_started = True
print("Démarrage de l'envoi des données.")
Expand All @@ -90,6 +95,7 @@ async def process_data(self):

# Mettre à jour la valeur précédente de Fz
self.previous_fz = current_fz

loop_time = time.perf_counter() - tic
real_time_to_sleep = max(0, (1 / self.system_rate) - loop_time)
if real_time_to_sleep > 0:
Expand Down

0 comments on commit a9596ea

Please sign in to comment.