MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / _switch_lps_ras

Method _switch_lps_ras

monai/data/image_reader.py:1581–1595  ·  view source on GitHub ↗

For compatibility with nibabel, switch from LPS to RAS. Adapt affine matrix and `space` argument in header accordingly. If no information of space is given in the header, LPS is assumed and thus converted to RAS. If information about space is given, but is not LPS, t

(self, header: dict)

Source from the content-addressed store, hash-verified

1579 return affine
1580
1581 def _switch_lps_ras(self, header: dict) -> dict:
1582 """
1583 For compatibility with nibabel, switch from LPS to RAS. Adapt affine matrix and
1584 `space` argument in header accordingly. If no information of space is given in the header,
1585 LPS is assumed and thus converted to RAS. If information about space is given,
1586 but is not LPS, the unchanged header is returned.
1587
1588 Args:
1589 header: The image metadata as dict
1590
1591 """
1592 if "space" not in header or header["space"] == "left-posterior-superior":
1593 header[MetaKeys.ORIGINAL_AFFINE] = orientation_ras_lps(header[MetaKeys.ORIGINAL_AFFINE])
1594 header[MetaKeys.SPACE] = SpaceKeys.RAS
1595 return header
1596
1597 def _convert_f_to_c_order(self, header: dict) -> dict:
1598 """

Callers 1

get_dataMethod · 0.95

Calls 1

orientation_ras_lpsFunction · 0.90

Tested by

no test coverage detected