Commit e1ad2f7c authored by Julia Garriga Ferrer's avatar Julia Garriga Ferrer
Browse files

[dataset] not using threading

parent 13d7cf49
lindick06
linkdick06
=========
The purpose of this API is to create a set of functions and classes to help the beamline 06 read a series of data images and apply the operations needed for the experiments.
......
......@@ -29,7 +29,6 @@ __license__ = "MIT"
__date__ = "26/07/2019"
import numpy
import threading
import fabio
......@@ -54,6 +53,11 @@ class Dataset():
def __init__(self, raw_filename=None, dark_filename=None, filenames=None,
data=None, dark_data=None, thread=False):
self._data = None
self.dark_frames = []
self.raw_filename = raw_filename
self.filenames = filenames
if data is not None:
if raw_filename is not None:
raise ValueError("'raw_filename' and 'data' are mutually exclusive")
......@@ -69,17 +73,8 @@ class Dataset():
self._data = data
self._data_has_changed = False
self.dark_frames = dark_data
# Load data
else:
self._data = None
self.dark_frames = []
self.data_urls = []
self.motors_positions = []
if thread:
thread = threading.Thread(target=self.startDataset,
args=(raw_filename, filenames)).start()
else:
self.startDataset(raw_filename, filenames)
elif not thread:
self.startDataset()
if dark_filename is not None:
......@@ -89,12 +84,11 @@ class Dataset():
# TODO: save only data, headers??
self.dark_frames.append(dark_frame.data)
def startDataset(self, raw_filename, filenames):
"""
Function that initializes the dataset. It goes through all the files to read
its headers.
"""
with fabio.open_series(first_filename=raw_filename, filenames=filenames) as series:
def startDataset(self):
self.data_urls = []
self.motors_positions = []
with fabio.open_series(first_filename=self.raw_filename, filenames=self.filenames) as series:
self.file_series = series
self.motors_mne = series.getframe(0).header["motor_mne"].split(" ")
......
......@@ -87,7 +87,8 @@ class BackgroundSubstractionWidget(qt.QWidget):
:param Dataset dataset: dataset
"""
self.dataset = dataset
self.setStack(dataset.data)
if len(dataset.data.shape) != 3:
self.setStack(dataset.data)
def setStack(self, *arg, **kwargs):
"""
......
......@@ -59,6 +59,7 @@ class DatasetSelectionWidget(qt.QTabWidget):
self.addTab(self._darkFilenameData, 'dark data')
def getDataset(self):
# Data files win over filename
if not self._rawFilesData.getFiles():
return Dataset(raw_filename=self._rawFilenameData.getFilename(),
......
......@@ -40,6 +40,7 @@ class OperationThread(qt.QThread):
def __init__(self, function):
qt.QThread.__init__(self)
self.func = function
self.args = []
def setArgs(self, *args):
"""
......
......@@ -98,7 +98,6 @@ class ROISelectionWidget(qt.QWidget):
Sets the data passed as aguments in the stack.
"""
first_frame_shape = self.dataset.data[0].shape
print(first_frame_shape)
self.setRoi(center=(first_frame_shape[0] / 2, first_frame_shape[1] / 2),
size=(first_frame_shape[0] / 5, first_frame_shape[1] / 5))
self._sv.setStack(*arg, **kwargs)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment