diff --git a/filter_functions.py b/filter_functions.py index 5a7c021..7fdb74f 100644 --- a/filter_functions.py +++ b/filter_functions.py @@ -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 diff --git a/segmentation.py b/segmentation.py index 957e17a..9a437eb 100644 --- a/segmentation.py +++ b/segmentation.py @@ -1,3 +1,8 @@ +""" +TODO: stor git_sha +""" + + import xarray as xr import pickle import os diff --git a/test_dask_framework_all_lazy.ipynb b/test_dask_framework_all_lazy.ipynb index 437513a..0b0a9d8 100644 --- a/test_dask_framework_all_lazy.ipynb +++ b/test_dask_framework_all_lazy.ipynb @@ -35,17 +35,18 @@ "name": "stdout", "output_type": "stream", "text": [ - "Dashboard at http://127.0.0.1:35154/status\n" + "Dashboard at http://127.0.0.1:35000/status\n" ] } ], "source": [ "# local cluster on current machine\n", - "tempfolder = '/mnt/nas_Uwrite/fische_r/tmp'\n", + "# tempfolder = '/mnt/nas_Uwrite/fische_r/tmp'\n", "# tempfolder = '/mpc/homes/fische_r/tmp'\n", + "tempfolder = '/mnt/SSD/fische_r/tmp'\n", "dask.config.config['temporary-directory'] = tempfolder\n", "\n", - "cluster = LocalCluster(dashboard_address=':35154', memory_limit = '160GB', n_workers=6, threads_per_worker=20) \n", + "cluster = LocalCluster(dashboard_address=':35000', memory_limit = '160GB', n_workers=6, threads_per_worker=20) \n", "client = Client(cluster)\n", "print('Dashboard at '+cluster.dashboard_link)" ] @@ -165,7 +166,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 27, "id": "6a59e105-1cce-4d75-a46a-b7998428e645", "metadata": {}, "outputs": [], @@ -175,7 +176,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 20, "id": "6f24fe3a-2fea-4fbe-8b2a-bcfd9891af75", "metadata": {}, "outputs": [], @@ -185,7 +186,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 21, "id": "2bc21c8d-4984-4a24-b3f8-1e1720a52d0e", "metadata": {}, "outputs": [], @@ -195,7 +196,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 32, "id": "0ebd826d-9c36-44f8-9c3c-9a6b55a78db0", "metadata": {}, "outputs": [ @@ -218,18 +219,18 @@ "
<xarray.Dataset>\n", - "Dimensions: (x: 1861, y: 169, z: 1140, time: 185, feature: 75)\n", - "Coordinates:\n", - " * x (x) int64 0 1 2 3 4 5 6 ... 1855 1856 1857 1858 1859 1860\n", - " * y (y) int64 0 1 2 3 4 5 6 7 ... 161 162 163 164 165 166 167 168\n", - " * z (z) int64 0 1 2 3 4 5 6 ... 1134 1135 1136 1137 1138 1139\n", - " * time (time) int64 0 1 2 3 4 5 6 7 ... 178 179 180 181 182 183 184\n", - " * feature (feature) <U27 'Gaussian_4D_Blur_0.0' ... 'median_dynamic_...\n", - "Data variables:\n", - " feature_stack (x, y, z, time, feature) float64 dask.array<chunksize=(364, 30, 190, 32, 1), meta=np.ndarray>