Skip to content

Commit cf96e82

Browse files
committed
Fix volume calculations in ACDC/MnMs
1 parent 6d74133 commit cf96e82

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

cinema/data/acdc/preprocess.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import SimpleITK as sitk # noqa: N813
1616
from tqdm import tqdm
1717

18-
from cinema import LV_LABEL
18+
from cinema import LV_LABEL, RV_LABEL
1919
from cinema.data.acdc import ACDC_LABEL_MAP, ACDC_SAX_SLICE_SIZE, ACDC_SPACING
2020
from cinema.data.sitk import (
2121
cast_to_uint8,
@@ -154,10 +154,13 @@ def preprocess_pid( # pylint:disable=too-many-statements
154154
es_image = sitk.Crop(es_image, crop_lower, crop_upper)
155155
es_label = sitk.Crop(es_label, crop_lower, crop_upper)
156156

157-
# calculate EDV, ESV, EF, HFrEF (EF < 40%)
158-
data["edv"] = sitk.GetArrayFromImage(ed_label).sum() * np.prod(ACDC_SPACING) / 1000.0 # ml = 1000 mm^3
159-
data["esv"] = sitk.GetArrayFromImage(es_label).sum() * np.prod(ACDC_SPACING) / 1000.0 # ml = 1000 mm^3
160-
data["ef"] = ejection_fraction(edv=data["edv"], esv=data["esv"])
157+
# calculate EDV, ESV, EF for LV and RV, ml = 1000 mm^3
158+
data["lv_edv"] = sitk.GetArrayFromImage(ed_label == LV_LABEL).sum() * np.prod(ACDC_SPACING) / 1000.0
159+
data["lv_esv"] = sitk.GetArrayFromImage(es_label == LV_LABEL).sum() * np.prod(ACDC_SPACING) / 1000.0
160+
data["lv_ef"] = ejection_fraction(edv=data["lv_edv"], esv=data["lv_esv"])
161+
data["rv_edv"] = sitk.GetArrayFromImage(ed_label == RV_LABEL).sum() * np.prod(ACDC_SPACING) / 1000.0
162+
data["rv_esv"] = sitk.GetArrayFromImage(es_label == RV_LABEL).sum() * np.prod(ACDC_SPACING) / 1000.0
163+
data["rv_ef"] = ejection_fraction(edv=data["rv_edv"], esv=data["rv_esv"])
161164

162165
# normalise intensity
163166
image = clip_and_normalise_intensity_4d(image, intensity_range=None)

cinema/data/mnms/preprocess.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import SimpleITK as sitk # noqa: N813
1717
from tqdm import tqdm
1818

19-
from cinema import LV_LABEL
19+
from cinema import LV_LABEL, RV_LABEL
2020
from cinema.data.mnms import MNMS_LABEL_MAP, MNMS_SAX_SLICE_SIZE, MNMS_SPACING
2121
from cinema.data.sitk import (
2222
cast_to_uint8,
@@ -108,10 +108,13 @@ def preprocess_pid( # pylint:disable=too-many-statements
108108
es_image = sitk.Crop(es_image, crop_lower, crop_upper)
109109
es_label = sitk.Crop(es_label, crop_lower, crop_upper)
110110

111-
# calculate EDV, ESV, EF, HFrEF (EF < 40%)
112-
data["edv"] = sitk.GetArrayFromImage(ed_label).sum() * np.prod(MNMS_SPACING) / 1000.0 # ml = 1000 mm^3
113-
data["esv"] = sitk.GetArrayFromImage(es_label).sum() * np.prod(MNMS_SPACING) / 1000.0 # ml = 1000 mm^3
114-
data["ef"] = ejection_fraction(edv=data["edv"], esv=data["esv"])
111+
# calculate EDV, ESV, EF for LV and RV, ml = 1000 mm^3
112+
data["lv_edv"] = sitk.GetArrayFromImage(ed_label == LV_LABEL).sum() * np.prod(MNMS_SPACING) / 1000.0
113+
data["lv_esv"] = sitk.GetArrayFromImage(es_label == LV_LABEL).sum() * np.prod(MNMS_SPACING) / 1000.0
114+
data["lv_ef"] = ejection_fraction(edv=data["lv_edv"], esv=data["lv_esv"])
115+
data["rv_edv"] = sitk.GetArrayFromImage(ed_label == RV_LABEL).sum() * np.prod(MNMS_SPACING) / 1000.0
116+
data["rv_esv"] = sitk.GetArrayFromImage(es_label == RV_LABEL).sum() * np.prod(MNMS_SPACING) / 1000.0
117+
data["rv_ef"] = ejection_fraction(edv=data["rv_edv"], esv=data["rv_esv"])
115118

116119
# normalise intensity
117120
ed_image = clip_and_normalise_intensity_3d(ed_image, intensity_range=None)

cinema/data/mnms2/preprocess.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import SimpleITK as sitk # noqa: N813
1717
from tqdm import tqdm
1818

19-
from cinema import LV_LABEL
19+
from cinema import LV_LABEL, RV_LABEL
2020
from cinema.data.mnms2 import MNMS2_LABEL_MAP, MNMS2_LAX_SLICE_SIZE, MNMS2_SAX_SLICE_SIZE, MNMS2_SPACING
2121
from cinema.data.sitk import (
2222
cast_to_uint8,
@@ -151,10 +151,13 @@ def preprocess_pid( # pylint:disable=too-many-statements
151151
sax_es_image = sitk.Crop(sax_es_image, crop_lower, crop_upper)
152152
sax_es_label = sitk.Crop(sax_es_label, crop_lower, crop_upper)
153153

154-
# calculate EDV, ESV, EF, HFrEF (EF < 40%)
155-
data["edv"] = sitk.GetArrayFromImage(sax_ed_label).sum() * np.prod(MNMS2_SPACING) / 1000.0 # ml = 1000 mm^3
156-
data["esv"] = sitk.GetArrayFromImage(sax_es_label).sum() * np.prod(MNMS2_SPACING) / 1000.0 # ml = 1000 mm^3
157-
data["ef"] = ejection_fraction(edv=data["edv"], esv=data["esv"])
154+
# calculate EDV, ESV, EF for LV and RV, ml = 1000 mm^3
155+
data["lv_edv"] = sitk.GetArrayFromImage(sax_ed_label == LV_LABEL).sum() * np.prod(MNMS2_SPACING) / 1000.0
156+
data["lv_esv"] = sitk.GetArrayFromImage(sax_es_label == LV_LABEL).sum() * np.prod(MNMS2_SPACING) / 1000.0
157+
data["lv_ef"] = ejection_fraction(edv=data["lv_edv"], esv=data["lv_esv"])
158+
data["rv_edv"] = sitk.GetArrayFromImage(sax_ed_label == RV_LABEL).sum() * np.prod(MNMS2_SPACING) / 1000.0
159+
data["rv_esv"] = sitk.GetArrayFromImage(sax_es_label == RV_LABEL).sum() * np.prod(MNMS2_SPACING) / 1000.0
160+
data["rv_ef"] = ejection_fraction(edv=data["rv_edv"], esv=data["rv_esv"])
158161

159162
# normalise intensity
160163
lax_4c_ed_image = clip_and_normalise_intensity_3d(lax_4c_ed_image, intensity_range=None)

0 commit comments

Comments
 (0)