def load_medical_data(f):
    """
    load data of different format into numpy array, return data is in xyz
    f: the complete path to the file that you want to load
    """
    filename = osp.basename(f).lower()

    if filename.endswith((".nii", ".nii.gz", ".dcm")):
        itkimage = sitk.ReadImage(f)
        if itkimage.GetDimension() == 4:
            slicer = sitk.ExtractImageFilter()
            s = list(itkimage.GetSize())
            s[-1] = 0
            slicer.SetSize(s)
            images = []
            for slice_idx in range(itkimage.GetSize()[-1]):
                slicer.SetIndex([0, 0, 0, slice_idx])
                sitk_volume = slicer.Execute(itkimage)
                images.append(sitk_volume)
            images = [sitk.DICOMOrient(img, "SLP") for img in images]
            f_nps = [sitk.GetArrayFromImage(img) for img in images]
        else:
            image = sitk.DICOMOrient(itkimage, "SLP")
            f_np = sitk.GetArrayFromImage(image)
            f_nps = [f_np]

    elif filename.endswith((".mha", ".mhd", "nrrd")):
        itkimage = sitk.DICOMOrient(sitk.ReadImage(f), "SLP")
        f_np = sitk.GetArrayFromImage(itkimage)
        if f_np.ndim == 4:
            f_nps = [f_np[:, :, :, idx] for idx in range(f_np.shape[3])]
        else:
            f_nps = [f_np]
    elif filename.endswith(".raw"):
        raise RuntimeError(
            f"Received {f}. Please only provide path to .mhd file, not to .raw file"
        )
    else:
        raise NotImplementedError

    return f_nps

    load data of different format into numpy array, return data is in xyz
    f: the complete path to the file that you want to load
    
EISeg/tool/medical2video.py