data_loader.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:segmentation_DLMI 作者: imatge-upc 项目源码 文件源码
def load_channels(self):
        flair = nib.load(self.FLAIR_FILE)
        t1 = nib.load(self.T1_FILE)
        t1c = nib.load(self.T1c_FILE)
        t2 = nib.load(self.T2_FILE)
        to_int = lambda b: 1 if b else 0
        num_input_modalities = to_int(self.booleanFLAIR) + to_int(self.booleanT1) + to_int(self.booleanT1c) + to_int(
            self.booleanT2)

        channels = np.zeros((num_input_modalities,) + flair.shape, dtype=np.float32)

        channels[0] = np.asarray(flair.dataobj) if self.booleanFLAIR is True else None
        channels[to_int(self.booleanFLAIR)] = np.asarray(t1.dataobj) if self.booleanT1 is True else None
        channels[to_int(self.booleanFLAIR) + to_int(self.booleanT1)] = np.asarray(
            t1c.dataobj) if self.booleanT1c is True else None
        channels[to_int(self.booleanFLAIR) + to_int(self.booleanT1) + to_int(self.booleanT1c)] = np.asarray(
            t2.dataobj) if self.booleanT2 is True else None

        return channels
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号