Closed rouzbeh closed 5 months ago
Good catch! This happens because your data identifier is only the subject id. In the examples that I tested, we always had "multi-level" identifier (e.g. cohort/participant id). In this case the identifier was always a tuple and taking the len
of that makes sense. If it is a string it doesn't. We need to differentiate between the "string" and the "tuple" case.
For now, there are two workarounds that you can do.
Option 1: Wrap subject id in a 1 element tuple:
from mobgap.consts import GRAV_MS2
from mobgap.data.base import ParticipantMetadata, RecordingMetadata
from mobgap.pipeline import MobilisedMetaPipeline, MobilisedPipelineHealthy
from mobgap.data import GaitDatasetFromData
gait_dataset = GaitDatasetFromData(
{
("18721", ): {
"accelerometer": acc
}
},
_sampling_rate_hz=frequency,
_participant_metadata={
("18721", ): ParticipantMetadata(cohort="HA", height_m=2, sensor_height_m=1),
},
single_sensor_name="accelerometer",
_recording_metadata={("18721", ): RecordingMetadata(
measurement_condition= "free_living"
)},
)
results = MobilisedPipelineHealthy().run(gait_dataset)
Or activly overwrite the index cols:
gait_dataset = GaitDatasetFromData(
{
"18721": {
"accelerometer": acc
}
},
_sampling_rate_hz=frequency,
_participant_metadata={
subject_meta.subject_id: ParticipantMetadata(cohort="HA", height_m=2, sensor_height_m=1),
},
single_sensor_name="accelerometer",
_recording_metadata={"18721": RecordingMetadata(
measurement_condition= "free_living"
)},
index_cols = ["participant_id"]
)
I also think there is a misunderstanding on how the data should be structured. The dictionary expected for data is {[identifier]:[sensor_pos]:data_as_df}
. And the data should then contain both the accelerometer and gyroscope data.
Let me know if that works and I will put a fix for your usecase in the next couple of days.
When generating a dataset from existing data and running the healthy pipeline, with something similar to
I get an error
I have traced this to the following line, which I think might be wrong.
https://github.com/mobilise-d/mobgap/blob/7ac4cb48689c530542e9d9cfc13f0524c737d902/mobgap/data/_dataset_from_data.py#L159
It seems like this should be changed to: