diff --git a/rec_to_nwb/processing/metadata/metadata_extractor.py b/rec_to_nwb/processing/metadata/metadata_extractor.py index 4dcea3b8..d1e78230 100644 --- a/rec_to_nwb/processing/metadata/metadata_extractor.py +++ b/rec_to_nwb/processing/metadata/metadata_extractor.py @@ -4,11 +4,15 @@ class MetadataExtractor: - @staticmethod def extract_metadata(metadata_path): - with open(metadata_path, 'r') as stream: - return json.loads( - json.dumps(yaml.safe_load(stream)), - parse_int=str, - parse_float=str) + with open(metadata_path, "r") as stream: + yaml_dict = yaml.safe_load(stream) + + # yaml automatically converts date_of_birth to a datetime object, need to convert back + yaml_dict["subject"]["date_of_birth"] = yaml_dict["subject"][ + "date_of_birth" + ].strftime("%Y-%m-%dT%H:%M:%S.%fZ") + + # for some reason they want to convert all ints, float to strings + return json.loads(json.dumps(yaml_dict), parse_int=str, parse_float=str)