def test_parse_scans(self): root_path = os.path.join("path", "to") expected_contents = {"acqp": None, "method": None, "recons": None} with mock.patch.object( BrukerMetadata, "read_scans", return_value=expected_contents) as mock_read_scans: m = BrukerMetadata(root_path) m.parse_scans() assert m.scan_data == expected_contents mock_read_scans.assert_called_once()
def list_scans(pfo_study): study = BrukerMetadata(pfo_study) study.parse_subject() study.parse_scans() # Print study details to the console print() print("Subject: {}".format(study.subject_data["SUBJECT_name_string"])) print("Study Date: {:%Y-%m-%d %H:%M}".format( datetime.strptime(study.subject_data["SUBJECT_date"], "%Y-%m-%dT%H:%M:%S,%f%z"))) print("-------------------------------------------------------- ") print() for scan, value in study.scan_data.items(): print("Scan {}".format(scan)) print("Protocol: {}".format(value["acqp"]["ACQ_protocol_name"]).ljust( 30) + "Method: {}".format(value["acqp"]["ACQ_method"]).ljust(30) + "Scan Time: {}".format( timedelta( seconds=int(round(value["method"]["ScanTime"] / 1000)))).ljust(30)) print()