diff --git a/brukerapi/dataset.py b/brukerapi/dataset.py index 0232022..f2ccbe8 100644 --- a/brukerapi/dataset.py +++ b/brukerapi/dataset.py @@ -244,7 +244,7 @@ "visu_series": (("VisuSeries",), ("VisuExperimentNumber", "VisuProcessingNumber")), "visu_equipment": ((), ("VisuManufacturer", "VisuAcqSoftwareVersion", "VisuInstitution", "VisuStation")), "visu_acq": (("VisuAcq", "VisuAcquisition"), ()), - "subject": (("SUBJECT_",), ()), + "subject": (("SUBJECT_", "CMN_study_"), ()), } # What "could not read this parameter file" looks like. FileNotFoundError is the diff --git a/test/test_api.py b/test/test_api.py index 4d52c4e..7cd2d43 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -69,6 +69,22 @@ def test_metadata_groups_follow_the_specification(tmp_path): assert "uisition_protocol" not in metadata["visu_acq"] +def test_subject_group_carries_the_pv360_study_level_cmn_parameters(tmp_path): + """PV360 writes two CMN_ parameters into `subject`, next to SUBJECT_study_*. + + `CMN_study_use_ats` says whether the Animal Transport System was in use, + which shifts the coordinate origin; selecting the group by `SUBJECT_` alone + dropped it and `CMN_study_bed` silently. + """ + root = tmp_path / "20200612_094625_study_1_1" + write_jcampdx(root / "subject", {"SUBJECT_id": [""], "SUBJECT_study_nr": 1, "CMN_study_use_ats": "Yes", "CMN_study_bed": [""]}) + dataset = Dataset(write_2dseq(root / "8" / "pdata" / "1"), add_parameters=["subject"], load=LOAD_STAGES["properties"]) + + assert dataset.metadata["subject"]["id"] == "phantom" + assert dataset.metadata["subject"]["use_ats"] == "Yes" + assert dataset.metadata["subject"]["bed"] == "Rat bed" + + def test_metadata_reports_the_same_string_as_the_property_that_reads_it(tmp_path): """`subj_id` and `metadata` read VisuSubjectName; they must agree.