def load_model_dictionary(self):
        """
        Load the model dictionary from a saved one
        """
        import itertools

        sct.printv('\nLoading the model dictionary ...', self.param.verbose, 'normal')

        j = 0
        for subject_dir in os.listdir(self.model_dic_name):
            subject_path = self.model_dic_name + subject_dir
            if os.path.isdir(subject_path) and 'transformations' not in subject_path:
                subject_im = None
                im_mat = None
                subject_seg = None
                seg_mat = None
                subject_im_m = None
                im_m = None
                subject_seg_m = None
                seg_m = None

                for file_name in os.listdir(subject_path):
                    if '_im.nii' in file_name:
                        subject_im = file_name
                    if '_seg.nii' in file_name:
                        subject_seg = file_name
                    if '_im_model_space.nii' in file_name:
                        subject_im_m = file_name
                    if file_name in '_seg_model_space.nii':
                        subject_seg_m = file_name
                if subject_im is not None:
                    im = Image(subject_path + '/' + subject_im)
                    im_mat = im.data
                if subject_seg is not None:
                    seg = Image(subject_path + '/' + subject_seg)
                    seg_mat = seg.data
                if subject_im_m is not None:
                    im_m = Image(subject_path + '/' + subject_im_m)
                else:
                    sct.printv('WARNING: no dictionary image in model space for ' + subject_dir,
                               self.param.verbose, 'warning')
                if subject_seg_m is not None:
                    seg_m = Image(subject_path + '/' + subject_seg_m)
                else:
                    sct.printv('WARNING: no segmentation in model space for ' + subject_dir,
                               self.param.verbose, 'warning')
                if im_mat is None:
                    im_mat = itertools.repeat(None, im_m.data.shape[0])
                if seg_mat is None:
                    seg_mat = itertools.repeat(None, im_m.data.shape[0])

                for im_slice, seg_slice, im_m_slice, seg_m_slice in zip(im_mat, seg_mat, im_m.data, seg_m.data):
                    reg_list = ['transform_slice_' + str(j) + find_ants_transfo_name(transfo_type)[0]
                                for transfo_type in self.coregistration_transfos]
                    self.slices.append(Slice(slice_id=j, im=im_slice, seg=seg_slice, im_m=im_m_slice, seg_m=seg_m_slice,
                                             im_m_flat=im_m_slice.flatten(), seg_m_flat=seg_m_slice.flatten(),
                                             reg_to_m=reg_list))
                    j += 1

        # number of atlases in the dictionary
        self.J = len(self.slices)  # len([slice.im for slice in self.slices])

        # dimension of the data (flatten slices)
        self.N = len(self.slices[0].im_M.flatten())

        self.mean_image = Image(self.model_dic_name + 'mean_image.nii.gz').data
        self.mean_seg = Image(self.model_dic_name + 'mean_seg.nii.gz').data

    # ------------------------------------------------------------------------------------------------------------------
dataset/ETHPy150Open neuropoly/spinalcordtoolbox/dev/sct_segment_gray_matter_asman/sct_asman_old.py/ModelDictionary.load_model_dictionary/swapped operands of `in`