示例#1
0
        public static MetadataObject FromMetadata(Dictionary <string, string> metadata)
        {
            MetadataObject metadataObject = new MetadataObject();
            string         s;

            s = null; metadata.TryGetValue("DeviceId", out s); metadataObject.DeviceId = s;
            s = null; metadata.TryGetValue("SessionId", out s); metadataObject.SessionId = s;

            s = null; metadata.TryGetValue("SamplingRate", out s); metadataObject.SamplingRate = s;
            s = null; metadata.TryGetValue("SamplingRange", out s); metadataObject.SamplingRange = s;

            s = null; metadata.TryGetValue("StartTime", out s); metadataObject.StartTime = s;
            s = null; metadata.TryGetValue("EndTime", out s); metadataObject.EndTime = s;

            s = null; metadata.TryGetValue("StudyCentre", out s); metadataObject.StudyCentre = s;
            s = null; metadata.TryGetValue("StudyCode", out s); metadataObject.StudyCode = s;
            s = null; metadata.TryGetValue("StudyInvestigator", out s); metadataObject.StudyInvestigator = s;
            s = null; metadata.TryGetValue("StudyExerciseType", out s); metadataObject.StudyExerciseType = s;
            s = null; metadata.TryGetValue("StudyOperator", out s); metadataObject.StudyOperator = s;
            s = null; metadata.TryGetValue("StudyNotes", out s); metadataObject.StudyNotes = s;

            s = null; metadata.TryGetValue("SubjectSite", out s); metadataObject.SubjectSite = s;
            s = null; metadata.TryGetValue("SubjectCode", out s); metadataObject.SubjectCode = s;
            s = null; metadata.TryGetValue("SubjectSex", out s); metadataObject.SubjectSex = s;
            s = null; metadata.TryGetValue("SubjectHeight", out s); metadataObject.SubjectHeight = s;
            s = null; metadata.TryGetValue("SubjectWeight", out s); metadataObject.SubjectWeight = s;
            s = null; metadata.TryGetValue("SubjectHandedness", out s); metadataObject.SubjectHandedness = s;
            s = null; metadata.TryGetValue("SubjectNotes", out s); metadataObject.SubjectNotes = s;

            // Fix up numeric references
            if (metadataObject.SubjectSex != null)
            {
                string[] values = { "", "male", "female" };
                int      i      = -1;
                int.TryParse(metadataObject.SubjectSex, out i);
                if (i >= 0 && i < values.Length)
                {
                    metadataObject.SubjectSex = values[i];
                }
            }
            if (metadataObject.SubjectHandedness != null)
            {
                string[] values = { "", "left", "right" };
                int      i      = -1;
                int.TryParse(metadataObject.SubjectHandedness, out i);
                if (i >= 0 && i < values.Length)
                {
                    metadataObject.SubjectHandedness = values[i];
                }
            }
            if (metadataObject.SubjectSite != null)
            {
                string[] values = { "", "left wrist", "right wrist", "waist", "left ankle", "right ankle", "left thigh", "right thigh", "left hip", "right hip", "left upper-arm", "right upper-arm", "chest", "sacrum", "neck", "head" };
                int      i      = -1;
                int.TryParse(metadataObject.SubjectSite, out i);
                if (i >= 0 && i < values.Length)
                {
                    metadataObject.SubjectSite = values[i];
                }
            }

            return(metadataObject);
        }