How to get original DICOM CT Scan frame number from binary segmentation file?

Hi all – I am working on a deep learning framework for liver metastasis. I have the original DICOM CT of the abdomen and pelvis and a binary segmentation mask of the liver alone. I would like to pass axial images of JUST the liver segmentation to an LSTM network however I am having difficulty extracting frames of just the liver using the binary segmentation mask.

If there are tutorials available with a similar issue I would greatly appreciate the help. Thank you in advance.