Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

spatial.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import numpy as np
  2. from scipy import ndimage as spimage
  3. class SpatialNoFilter(object):
  4. def __init__(self):
  5. super().__init__()
  6. def filter_3D(self, data):
  7. return data
  8. def filter_2D(self, data):
  9. return data
  10. class SpatialFilterAbstract(SpatialNoFilter):
  11. def __init__(self):
  12. super().__init__()
  13. def filter_3D(self, data):
  14. filtered_data = np.empty_like(data)
  15. for index in range(data.shape[-1]):
  16. filtered_data[:, :, index] = self.filter_2D(data[:, :, index])
  17. return filtered_data
  18. class SpatialGaussianFilter(SpatialFilterAbstract):
  19. def __init__(self, Signal_FilterSpaceSize):
  20. super().__init__()
  21. self.filter_space_size = Signal_FilterSpaceSize
  22. def filter_2D(self, data):
  23. return spimage.gaussian_filter(data, self.filter_space_size)
  24. def get_spatial_processor(filter_space_flag, filter_space_size):
  25. if filter_space_flag and filter_space_size > 0:
  26. return SpatialGaussianFilter(filter_space_size)
  27. else:
  28. return SpatialNoFilter()