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_im = 0
        j_seg = 0
        j_im_m = 0
        j_seg_m = 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:

                for file_name in os.listdir(subject_path):
                    if '_im.nii' in file_name:
                        reg_list = ['transform_slice_' + str(j_im) + find_ants_transfo_name(transfo_type)[0]
                                    for transfo_type in self.coregistration_transfos]

                        slice_level = 0
                        name_list = file_name.split('_')
                        for word in name_list:
                            if word in self.level_label.values():
                                slice_level = get_key_from_val(self.level_label, word)

                        self.slices.append(Slice(slice_id=j_im, im=Image(subject_path + '/' + file_name).data,
                                                 level=slice_level, reg_to_m=reg_list))
                        j_im += 1

                    if file_name in '_seg.nii':
                        self.slices[j_seg].set(seg=Image(subject_path + '/' + file_name).data)
                        j_seg += 1

                    if '_im_model_space.nii' in file_name:
                        im_m_slice = Image(subject_path + '/' + file_name).data
                        self.slices[j_im_m].set(im_m=im_m_slice, im_m_flat=im_m_slice.flatten())
                        j_im_m += 1

                    if '_seg_model_space.nii' in file_name:
                        seg_m_slice = Image(subject_path + '/' + file_name).data
                        self.slices[j_seg_m].set(seg_m=seg_m_slice, seg_m_flat=seg_m_slice.flatten())
                        j_seg_m += 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/ModelDictionaryBySlice.load_model_dictionary/swapped operands of `in`