# Buggy code
def _get_microscope_name(self, ImageTags):
    try:
        if ImageTags.Session_Info.Microscope != "[]":
            return ImageTags.Session_Info.Microscope
    except AttributeError:
        return ImageTags.Microscope_Info.Name


# Traceback (AttributeError)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-6-98fa7e0685f8> in <module>()
----> 1 wedge = hs.load()

C:\Anaconda3\lib\site-packages\hyperspy-1.2+dev-py3.5.egg\hyperspy\io.py in load(filenames, signal_type, stack, stack_axis, new_axis_name, mmap, mmap_dir, **kwds)
219             objects = [load_single_file(filename,
220                                         **kwds)
--> 221                        for filename in filenames]
222
223         if hyperspy.defaults_parser.preferences.Plot.plot_on_load:

C:\Anaconda3\lib\site-packages\hyperspy-1.2+dev-py3.5.egg\hyperspy\io.py in <listcomp>(.0)
219             objects = [load_single_file(filename,
220                                         **kwds)
--> 221                        for filename in filenames]
222
223         if hyperspy.defaults_parser.preferences.Plot.plot_on_load:

C:\Anaconda3\lib\site-packages\hyperspy-1.2+dev-py3.5.egg\hyperspy\io.py in load_single_file(filename, signal_type, **kwds)
263                                 reader=reader,
264                                 signal_type=signal_type,
--> 265                                 **kwds)
266
267

C:\Anaconda3\lib\site-packages\hyperspy-1.2+dev-py3.5.egg\hyperspy\io.py in load_with_reader(filename, reader, signal_type, **kwds)
271                      **kwds):
272     file_data_list = reader.file_reader(filename,
--> 273                                         **kwds)
274     objects = []
275

C:\Anaconda3\lib\site-packages\hyperspy-1.2+dev-py3.5.egg\hyperspy\io_plugins\digital_micrograph.py in file_reader(filename, record_by, order)
991                  'original_metadata': dm.tags_dict,
992                  'post_process': post_process,
--> 993                  'mapping': image.get_mapping(),
994                  })
995

C:\Anaconda3\lib\site-packages\hyperspy-1.2+dev-py3.5.egg\hyperspy\io_plugins\digital_micrograph.py in get_mapping(self)
837         if "Microscope_Info" in self.imdict.ImageTags.keys():
838             is_TEM = (
--> 839                 'TEM' == self.imdict.ImageTags.Microscope_Info.Illumination_Mode)
840             is_diffraction = (
841                 'DIFFRACTION' == self.imdict.ImageTags.Microscope_Info.Imaging_Mode)

C:\Anaconda3\lib\site-packages\hyperspy-1.2+dev-py3.5.egg\hyperspy\misc\utils.py in __getattribute__(self, name)
333             name = name.decode()
334         name = slugify(name, valid_variable_name=True)
--> 335         item = super(DictionaryTreeBrowser, self).__getattribute__(name)
336         if isinstance(item, dict) and '_dtb_value_' in item and "key" in item:
337             return item['_dtb_value_']

AttributeError: 'DictionaryTreeBrowser' object has no attribute 'Illumination_Mode'

# Fixed code
def _get_microscope_name(self, ImageTags):
    try:
        if ImageTags.Session_Info.Microscope != "[]":
            return ImageTags.Session_Info.Microscope
    except AttributeError:
        if "Name" in ImageTags["Microscope_Info"].keys():
            return ImageTags.Microscope_Info.Name