TODO: store git sha

This commit is contained in:
Fischer Robert
2022-10-13 15:13:18 +02:00
parent 13f6fbfa2a
commit 8c0cc68e57
4 changed files with 329 additions and 1034 deletions
+16 -4
View File
@@ -10,6 +10,7 @@ transient dimension, e.g. time, should be 4th dimension of input data
TODO: add GPU support (CUDA, cupy, cucim)
TODO: store git commit sha
"""
@@ -76,6 +77,10 @@ class image_filter:
self.chunks = chunksize
self.outchunks = outchunks
#wheter considering means for first and last time step
self.take_means = True
self.num_means = 7
# not sure if this is clever, does dask understand that this data is reused?
self.Gaussian_4D_dict = {}
self.Gaussian_space_dict = {}
@@ -209,10 +214,15 @@ class image_filter:
self.calculated_features.append(DG)
self.feature_names.append(name)
def diff_to_first_and_last(self):
def diff_to_first_and_last(self, take_mean, means):
# TODO: take temporal mean/median for first and last
DA = self.data
first = DA[...,0]
last = DA[...,-1]
if take_mean:
first = DA[...,:means].mean(axis=-1)
last = DA[...,-means:].mean(axis=-1)
else:
first = DA[...,0]
last = DA[...,-1]
if type(first) is not np.ndarray:
first = first.compute()
last = last.compute()
@@ -358,6 +368,7 @@ class image_filter:
# TODO: include feature selection either in compute (better) or save
# TODO: maybe add purge function
# TODO: maybe add iterative segmentation results, i.e. median filter of segmentation
def prepare(self):
self.Gaussian_4D_dict = {}
self.Gaussian_space_dict = {}
@@ -366,7 +377,7 @@ class image_filter:
self.calculated_features = []
self.feature_names = []
self.diff_to_first_and_last()
self.diff_to_first_and_last(self.take_means, self.num_means)
self.Gaussian_4D_stack()
self.diff_Gaussian('4D')
self.Gradients()
@@ -376,6 +387,7 @@ class image_filter:
self.Gaussian_space_stack()
self.diff_Gaussian('space')
# self.rank_filter_stack() #you have to load the entire raw data set for this filter --> not so good for many time steps
self.prepared = True
+5
View File
@@ -1,3 +1,8 @@
"""
TODO: stor git_sha
"""
import xarray as xr
import pickle
import os
File diff suppressed because one or more lines are too long
+6 -1
View File
@@ -4,7 +4,7 @@ Created on Wed Aug 17 16:04:34 2022
to be loaded in Jupyter
TODO: store git commit sha
@author: fische_r
"""
import xarray as xr
@@ -293,6 +293,9 @@ class train_segmentation:
plt.xticks(rotation=90)
plt.ylabel('importance')
def pickle_training_dict(self):
pickle.dump(self.training_dict, open(os.path.join(self.training_path, 'training_dict.p'),'wb'))
def pickle_classifier(self):
pickle.dump(self.clf, open(os.path.join(self.training_path, 'classifier.p'),'wb'))
@@ -303,6 +306,7 @@ class train_segmentation:
labelnames = os.listdir(path)
flag = True
for label_name in labelnames:
print(label_name)
X, y = training_set_per_image(label_name, path, feat_data, self.lazy)
training_dict[label_name] = X,y
if flag:
@@ -318,6 +322,7 @@ class train_segmentation:
self.clf = clf
self.training_dict = training_dict
def train_parallel(self):
#come up with a way to train() in parallel
# maybe with dask.delayed