Skip to content

Commit

Permalink
updated dm_reader
Browse files Browse the repository at this point in the history
  • Loading branch information
gduscher committed Jul 28, 2023
1 parent 54feacb commit 72e0eb6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions SciFiReaders/readers/microscopy/em/tem/dm_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def __init__(self, file_path, verbose=False):
# initialize variables ##
self.verbose = verbose
self.__filename = file_path
self.datasets = []
self.datasets = {}

# - open file for reading
try:
Expand Down Expand Up @@ -214,12 +214,13 @@ def read(self):
dataset.source = 'SciFiReaders.DMReader'
dataset.original_metadata['DM']['full_file_name'] = self.__filename

self.datasets.append(dataset)
self.extract_crucial_metadata(-1)
key = f'Channel_{image_number:03}'
self.datasets[key] = dataset
self.extract_crucial_metadata(key)

del self.__stored_tags['ImageList']
main_dataset_number = 0
for index, dataset in enumerate(self.datasets):
for index, dataset in self.datasets.items():
if 'urvey' in dataset.title:
main_dataset_number = index
self.datasets[main_dataset_number].original_metadata.update(self.__stored_tags)
Expand Down Expand Up @@ -318,7 +319,6 @@ def set_dimensions(self, dataset):
dimension_type=sidpy.DimensionType.RECIPROCAL))
reciprocal_name = chr(ord(reciprocal_name) + 1)
elif 'm' in units:
units = 'counts'
dataset.set_dimension(int(dim), sidpy.Dimension(values, name=spatial_name, units=units,
quantity='distance',
dimension_type=sidpy.DimensionType.SPATIAL))
Expand All @@ -332,8 +332,8 @@ def set_dimensions(self, dataset):

# For ill defined DM data
if dataset.data_type.name == 'IMAGE':
dataset.x.dimension_type = 'SPATiAL'
dataset.y.dimension_type = 'SPATiAL'
dataset.x.dimension_type = 'SPATIAL'
dataset.y.dimension_type = 'SPATIAL'

# utility functions

Expand Down Expand Up @@ -499,8 +499,8 @@ def get_raw(self, ImageDict):
ImageDict['ImageData']['Data'] = 'read'
return raw_data

def extract_crucial_metadata(self, dataset_index):
original_metadata = self.datasets[dataset_index].original_metadata
def extract_crucial_metadata(self, dataset_key):
original_metadata = self.datasets[dataset_key].original_metadata
"""Read essential parameter from original_metadata originating from a dm3 file"""
if not isinstance(original_metadata, dict):
raise TypeError('We need a dictionary to read')
Expand Down Expand Up @@ -552,7 +552,7 @@ def extract_crucial_metadata(self, dataset_index):
if 'Voltage' in exp_dictionary['Microscope Info']:
experiment['acceleration_voltage'] = exp_dictionary['Microscope Info']['Voltage']

self.datasets[dataset_index].metadata['experiment'] = experiment
self.datasets[dataset_key].metadata['experiment'] = experiment



Expand Down
Binary file not shown.

0 comments on commit 72e0eb6

Please sign in to comment.