Commit 30e0ea12 authored by David GEISSBUHLER's avatar David GEISSBUHLER
Browse files

moved adjust in stream.py

parent 005f889d
......@@ -395,4 +395,50 @@ class StreamView(StreamFilter):
return super().process(data, indices)
def process_frame(self, data, data_index, stream_index):
return data[self.__bulk_view_full]
\ No newline at end of file
return data[self.__bulk_view_full]
################################################################################
### ajust ###
@stream_filter("adjust")
class StreamAdjust(StreamFilter):
def __init__(self, adjust_to, name, parent):
super().__init__(name=name, parent=parent)
self.adjust_to = adjust_to
def set_source(self, src):
super().set_source(src)
self.adjust_to.set_source(src)
@property
def shape(self):
return (self.adjust_to.shape[0], self.parent.shape[1], self.parent.shape[2], self.parent.shape[3])
@property
def timestamps(self):
return self.adjust_to.timestamps
def get_frame_indices(self, index):
return super().get_frame_indices(index)
def load(self, index):
# TODO load only relevant data if cropped
if isinstance(index, tuple):
index = index[0]
print("WARNING: cropping not yet implemented")
# original stream indices
old_indices = self.get_frame_indices(index)
selected_timestamps = [self.adjust_to.timestamps[i] for i in old_indices]
kdtree = cKDTree(self.parent.timestamps[:, np.newaxis])
def get_index(val, kdtree):
_, i = kdtree.query(val, k=1)
return i
new_indices = [get_index(ts[np.newaxis], kdtree) for ts in selected_timestamps]
if False:
print("DEBUG: indices alignement:")
print(old_indices)
print(new_indices)
print(self.parent.timestamps)
print(self.adjust_to.timestamps)
return super().load(new_indices)
\ No newline at end of file
......@@ -119,52 +119,6 @@ class StreamStacked(StreamFilter):
return np.concatenate((data, self.data2[data_index]), axis=0)
### ajust ###
@stream_filter("adjust")
class StreamAdjust(StreamFilter):
def __init__(self, adjust_to, name, parent):
super().__init__(name=name, parent=parent)
self.adjust_to = adjust_to
def set_source(self, src):
super().set_source(src)
self.adjust_to.set_source(src)
@property
def shape(self):
return (self.adjust_to.shape[0], self.parent.shape[1], self.parent.shape[2], self.parent.shape[3])
@property
def timestamps(self):
return self.adjust_to.timestamps
def get_frame_indices(self, index):
return super().get_frame_indices(index)
def load(self, index):
# TODO load only relevant data if cropped
if isinstance(index, tuple):
index = index[0]
print("WARNING: cropping not yet implemented")
# original stream indices
old_indices = self.get_frame_indices(index)
selected_timestamps = [self.adjust_to.timestamps[i] for i in old_indices]
kdtree = cKDTree(self.parent.timestamps[:, np.newaxis])
def get_index(val, kdtree):
_, i = kdtree.query(val, k=1)
return i
new_indices = [get_index(ts[np.newaxis], kdtree) for ts in selected_timestamps]
if False:
print("DEBUG: indices alignement:")
print(old_indices)
print(new_indices)
print(self.parent.timestamps)
print(self.adjust_to.timestamps)
return super().load(new_indices)
### warp_with ###
@stream_filter("warp")
class StreamWarp(StreamFilter):
......
Markdown is supported
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