cohere-core 4.2.2__tar.gz → 4.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. cohere_core-4.3/PKG-INFO +68 -0
  2. {cohere_core-4.2.2 → cohere_core-4.3}/README.md +2 -2
  3. cohere_core-4.3/pyproject.toml +44 -0
  4. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/controller/AI_guess.py +5 -3
  5. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/data/standard_preprocess.py +12 -2
  6. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/lib/cohlib.py +7 -0
  7. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/lib/cplib.py +9 -4
  8. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/lib/nplib.py +4 -0
  9. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/lib/torchlib.py +5 -0
  10. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/utilities/config_errors_dict.py +10 -0
  11. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/utilities/config_verifier.py +52 -1
  12. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/utilities/utils.py +18 -26
  13. cohere_core-4.3/src/cohere_core.egg-info/PKG-INFO +68 -0
  14. cohere_core-4.3/src/cohere_core.egg-info/SOURCES.txt +29 -0
  15. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core.egg-info/requires.txt +3 -0
  16. cohere_core-4.2.2/PKG-INFO +0 -22
  17. cohere_core-4.2.2/cohere_core/__init__.py +0 -1
  18. cohere_core-4.2.2/cohere_core.egg-info/PKG-INFO +0 -22
  19. cohere_core-4.2.2/cohere_core.egg-info/SOURCES.txt +0 -30
  20. cohere_core-4.2.2/setup.py +0 -24
  21. {cohere_core-4.2.2 → cohere_core-4.3}/LICENSE +0 -0
  22. {cohere_core-4.2.2 → cohere_core-4.3}/setup.cfg +0 -0
  23. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/controller/__init__.py +0 -0
  24. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/controller/features.py +0 -0
  25. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/controller/op_flow.py +0 -0
  26. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/controller/phasing.py +0 -0
  27. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/data/__init__.py +0 -0
  28. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/data/alien_tools.py +0 -0
  29. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/lib/__init__.py +0 -0
  30. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/lib/aflib.py +0 -0
  31. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/lib/check_libs.py +0 -0
  32. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/utilities/__init__.py +0 -0
  33. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/utilities/dvc_utils.py +0 -0
  34. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core/utilities/ga_utils.py +0 -0
  35. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core.egg-info/dependency_links.txt +0 -0
  36. {cohere_core-4.2.2 → cohere_core-4.3/src}/cohere_core.egg-info/top_level.txt +0 -0
@@ -0,0 +1,68 @@
1
+ Metadata-Version: 2.4
2
+ Name: cohere_core
3
+ Version: 4.3
4
+ Summary: cohere reconstruction tools
5
+ Author-email: Barbara Frosik <bfrosik@anl.gov>, Ross Harder <rharder@anl.gov>
6
+ License: Copyright © 2019, UChicago Argonne, LLC
7
+ All Rights Reserved
8
+ Software Name: CDI Reconstruction (cohere)
9
+ By: Argonne National Laboratory
10
+ OPEN SOURCE LICENSE
11
+
12
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
13
+
14
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
15
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
16
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
17
+
18
+
19
+ ******************************************************************************************************
20
+ DISCLAIMER
21
+
22
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ ***************************************************************************************************
24
+ Project-URL: Homepage, https://github.com/AdvancedPhotonSource/cohere
25
+ Classifier: Programming Language :: Python :: 3
26
+ Classifier: Operating System :: OS Independent
27
+ Requires-Python: >=3.11
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: numpy<2
31
+ Requires-Dist: scikit-learn
32
+ Requires-Dist: tifffile
33
+ Requires-Dist: psutil
34
+ Requires-Dist: tqdm
35
+ Requires-Dist: matplotlib
36
+ Requires-Dist: scipy==1.14.1
37
+ Requires-Dist: sphinx
38
+ Requires-Dist: sphinx-pyproject
39
+ Dynamic: license-file
40
+
41
+ [![Documentation Status](https://readthedocs.org/projects/cohere/badge/?version=latest)](http://cohere.readthedocs.io/en/latest/?badge=latest)
42
+
43
+ Project home page: [https://cohere.readthedocs.io/](https://cohere.readthedocs.io/)
44
+
45
+ The cohere package provides tools for reconstruction of image of a nanoscale structures from data obtained using Bragg Coherent Diffraction Imaging technique.
46
+
47
+ The reconstruction has very good performance, in particular when utilizing GPU. User has a choice to run on cpu or GPU by selecting Python library. Supported libraries: numpy, cupy, torch. The libraries cupy or torch are installed by user. The solution offers concurrent processing for fast reconstruction of multiple starting points.
48
+
49
+ Important features:
50
+ - Genetic Algorithm (GA) - powerful feature that can deliver good reconstruction result by using GA principles. Based on research "Three-dimensional imaging of dislocation propagation during crystal growth and dissolution, Supplementary Information" by Jesse N. Clark et. al.
51
+ - Artificial Intelligence initial guess for reconstruction - uses AI to find reconstructed object that is subsequently used as input to further reconstruction. The work is built on the research by Yudong Yao, et. al: "AutoPhaseNN: Unsupervised Physics-aware Deep Learning of 3D Nanoscale Bragg Coherent Diffraction Imaging".
52
+ A trained model must be provided when using this feature. User can download trained model by clicking the following link
53
+ https://g-29c18.fd635.8443.data.globus.org/cherukara/cohere-trained_model.hdf5
54
+ - AutoAlien1 algorithm - a method to remove aliens by automatic means during standard data preprocessing. Based on work "Removal of spurious data in Bragg coherent diffraction imaging: an algorithm for automated data preprocessing" by Kenley Pelzer et. al.
55
+ - Multipeak - support for an experiment where data is collected for adjacent peaks simultaneously and reconstructing this multipeak scenario. The research is in experimental stage. Implemented by Jason (Nick) Porter.
56
+ - chrono CDI - allows the oversampling requirement at each time step to be reduced. The increased time resolution will allow imaging of faster dynamics and of radiation-dose-sensitive samples. Based on work "Coherent diffractive imaging of time-evolving samples with improved temporal resolution" by A. Ulvestat et. al.
57
+
58
+ The tools offers a full solution for reading beamline specific experiment data, formatting the data, reconstruction, and visualization. Each of the components can be utilized independently. The project was implemented for the Advanced Photon Source beamline 34-ID-C.
59
+
60
+ Author(s)
61
+
62
+ Barbara Frosik - Principal Software Engineer at Argonne National Laboratory
63
+
64
+ Ross Harder - Scientist at Argonne National Laboratory
65
+
66
+ License
67
+
68
+ Copyright (c) UChicago Argonne, LLC. All rights reserved. See LICENSE file.
@@ -1,6 +1,6 @@
1
- [![Documentation Status](https://readthedocs.org/projects/cohere-dev/badge/?version=latest)](http://cohere-dev.readthedocs.io/en/latest/?badge=latest)
1
+ [![Documentation Status](https://readthedocs.org/projects/cohere/badge/?version=latest)](http://cohere.readthedocs.io/en/latest/?badge=latest)
2
2
 
3
- Project home page: [https://cohere-dev.readthedocs.io/](https://cohere-dev.readthedocs.io/)
3
+ Project home page: [https://cohere.readthedocs.io/](https://cohere.readthedocs.io/)
4
4
 
5
5
  The cohere package provides tools for reconstruction of image of a nanoscale structures from data obtained using Bragg Coherent Diffraction Imaging technique.
6
6
 
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 77.0.3"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "cohere_core"
7
+ version = "4.3"
8
+ authors = [
9
+ { name="Barbara Frosik", email="bfrosik@anl.gov" },
10
+ { name="Ross Harder", email="rharder@anl.gov" }
11
+ ]
12
+ description = "cohere reconstruction tools"
13
+ readme = "README.md"
14
+ requires-python = ">=3.11"
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+ license = { file = "LICENSE" }
20
+
21
+ dependencies = [
22
+ 'numpy<2',
23
+ 'scikit-learn',
24
+ 'tifffile',
25
+ 'psutil',
26
+ 'tqdm',
27
+ 'matplotlib',
28
+ 'scipy==1.14.1',
29
+ 'sphinx',
30
+ 'sphinx-pyproject'
31
+ ]
32
+
33
+ [tool.setuptools.packages.find]
34
+ where = ["src"]
35
+
36
+ [project.urls]
37
+ Homepage = "https://github.com/AdvancedPhotonSource/cohere"
38
+
39
+ [tool.sphinx-pyproject]
40
+ extensions = [
41
+ "sphinx.ext.autodoc",
42
+ "sphinx.ext.napoleon",
43
+ 'sphinx.ext.intersphinx',
44
+ ]
@@ -77,7 +77,7 @@ def match_oversample_diff(
77
77
  pad = [[pad_value1[0], pad_value2[0]], [pad_value1[1], pad_value2[1]],
78
78
  [pad_value1[2], pad_value2[2]]]
79
79
 
80
- output = ut.adjust_dimensions(diff, pad)
80
+ output = ut.adjust_dimensions(diff, pad, next_fast_len=False)
81
81
  return output, diff.shape
82
82
 
83
83
 
@@ -236,12 +236,14 @@ def run_AI(data, model_file, dir):
236
236
  pred_obj = preds_amp * np.exp(1j * preds_phi)
237
237
 
238
238
  # match object size with the input data
239
- pred_obj = ut.Resize(pred_obj, inshape)
239
+ pred_obj = ut.resample(pred_obj, inshape)
240
240
 
241
241
  pad_value = np.array(data.shape) // 2 - np.array(pred_obj.shape) // 2
242
242
  pad = [[pad_value[0], pad_value[0]], [pad_value[1], pad_value[1]],
243
243
  [pad_value[2], pad_value[2]]]
244
- guess = ut.adjust_dimensions(pred_obj, pad)
244
+ # not passing in 'next_fst_len' switch, so the dimensions will not be adjusted for fast processing of
245
+ # Fourier transforms
246
+ guess = ut.adjust_dimensions(pred_obj, pad, next_fast_len=False)
245
247
 
246
248
  np.save(ut.join(dir, 'image.npy'), guess)
247
249
 
@@ -65,8 +65,12 @@ def prep(beamline_full_datafile_name, **kwargs):
65
65
  Optional, enter center shift list the array maximum is centered before binning, and moved according to shift, [0,0,0] has no effect
66
66
  binning : list
67
67
  Optional, a list that defines binning values in respective dimensions, [1,1,1] has no effect.
68
- no_center_max : False
68
+ no_center_max : boolean, defaults to False
69
69
  True if the max is not centered
70
+ next_fast_len : boolean, defaults to False
71
+ Typically True, changes dimensions to numbers that allow fast fourier transform; depends on library
72
+ pkg : string
73
+ 'cp' for cupy, 'torch' for torch, 'np' for numpy
70
74
  """
71
75
  beamline_full_datafile_name = beamline_full_datafile_name.replace(os.sep, '/')
72
76
  # The data has been transposed when saved in tif format for the ImageJ to show the right orientation
@@ -117,7 +121,13 @@ def prep(beamline_full_datafile_name, **kwargs):
117
121
  pair = crops_pads[2 * i:2 * i + 2]
118
122
  pairs.append(pair)
119
123
 
120
- data = ut.adjust_dimensions(data, pairs)
124
+ # next_fast_len parameter should be always True. But it needs to be included
125
+ # when calling adjust_dimensions functions, as depending on the pkg, the result
126
+ # could be different. So for the sake of flexibility, the parameter next_fast_len
127
+ # was added as option in kwargs.
128
+ next_fast_len = kwargs.get('next_fast_len', True)
129
+ pkg = kwargs.get('pkg', 'np')
130
+ data = ut.adjust_dimensions(data, pairs, next_fast_len, pkg)
121
131
  if data is None:
122
132
  print('check "crop_pad" configuration')
123
133
  return
@@ -35,6 +35,8 @@ class cohlib(metaclass=abc.ABCMeta):
35
35
  callable(subclass.reshape) and
36
36
  hasattr(subclass, 'size') and
37
37
  callable(subclass.size) and
38
+ hasattr(subclass, 'next_fast_len') and
39
+ callable(subclass.next_fast_len) and
38
40
  hasattr(subclass, 'hasnan') and
39
41
  callable(subclass.hasnan) and
40
42
  hasattr(subclass, 'copy') and
@@ -240,6 +242,11 @@ class cohlib(metaclass=abc.ABCMeta):
240
242
  def size(arr):
241
243
  pass
242
244
 
245
+ @staticmethod
246
+ @abc.abstractmethod
247
+ def next_fast_len(target):
248
+ pass
249
+
243
250
  @staticmethod
244
251
  @abc.abstractmethod
245
252
  def hasnan(arr):
@@ -11,6 +11,7 @@ import cupyx.scipy.stats as stats
11
11
  import cupyx.scipy.ndimage as sc
12
12
  import cupyx.scipy.special as sp
13
13
  import cupyx.scipy.signal as sig
14
+ import cupyx.scipy.fft as fft
14
15
 
15
16
 
16
17
  class cplib(cohlib):
@@ -67,6 +68,10 @@ class cplib(cohlib):
67
68
  def size(arr):
68
69
  return arr.size
69
70
 
71
+ @staticmethod
72
+ def next_fast_len(target):
73
+ return fft.next_fast_len(target)
74
+
70
75
  @staticmethod
71
76
  def hasnan(arr):
72
77
  return cp.any(cp.isnan(arr))
@@ -103,19 +108,19 @@ class cplib(cohlib):
103
108
 
104
109
  @staticmethod
105
110
  def fftshift(arr):
106
- return cp.fft.fftshift(arr)
111
+ return fft.fftshift(arr)
107
112
 
108
113
  @staticmethod
109
114
  def ifftshift(arr):
110
- return cp.fft.ifftshift(arr)
115
+ return fft.ifftshift(arr)
111
116
 
112
117
  @staticmethod
113
118
  def fft(arr, norm='forward'):
114
- return cp.fft.fftn(arr, norm=norm)
119
+ return fft.fftn(arr, norm=norm)
115
120
 
116
121
  @staticmethod
117
122
  def ifft(arr, norm='forward'):
118
- return cp.fft.ifftn(arr, norm=norm)
123
+ return fft.ifftn(arr, norm=norm)
119
124
 
120
125
  @staticmethod
121
126
  def fftconvolve(arr1, kernel):
@@ -64,6 +64,10 @@ class nplib(cohlib):
64
64
  def size(arr):
65
65
  return arr.size
66
66
 
67
+ @staticmethod
68
+ def next_fast_len(target):
69
+ return fft.next_fast_len(target)
70
+
67
71
  @staticmethod
68
72
  def nan_to_num(arr, **kwargs):
69
73
  return np.nan_to_num(arr, **kwargs)
@@ -102,6 +102,11 @@ class torchlib(cohlib):
102
102
  def size(arr):
103
103
  return torch.numel(arr)
104
104
 
105
+ @staticmethod
106
+ def next_fast_len(target):
107
+ import scipy
108
+ return scipy.fft.next_fast_len(target)
109
+
105
110
  @staticmethod
106
111
  def hasnan(arr):
107
112
  return torch.any(torch.isnan(arr))
@@ -23,6 +23,15 @@ config_error = {'File':['File does not exist','Cannot Read File',
23
23
  'Separatescanranges':['separate_scan_ranges parameter should be True or False'],
24
24
  'Multipeak': ['multipeak parameter should be True or False']
25
25
  }
26
+ config_prep_error = {'File':['No configuration file',
27
+ 'cannot read configuration file',
28
+ 'Parsing error, check parenthesis,quotation syntax'],
29
+ 'Excludescans':['exclude_scans should be a list'],
30
+ 'MinFiles':['min_frames should be int',
31
+ 'min_frames parameter parsing error'],
32
+ 'Maxcrop':['max_crop should be a list',
33
+ 'max_crop parameter must have two values to crop 2D frame'],
34
+ }
26
35
  config_data_error = {'File':['No configuration file',
27
36
  'Cannot read configuration file',
28
37
  'Parsing error, check parenthesis,quotation syntax'],
@@ -140,6 +149,7 @@ config_disp_error = {'File':['No configuration file',
140
149
  'Rampups':['rampups should be int']}
141
150
 
142
151
  config_map_names = {'config_error_map_file':config_error,
152
+ 'config_prep_error_map_file':config_prep_error,
143
153
  'config_data_error_map_file':config_data_error,
144
154
  'config_rec_error_map_file':config_rec_error,
145
155
  'config_disp_error_map_file':config_disp_error}
@@ -69,7 +69,6 @@ def get_config_error_message(config_file_name, map_file, config_parameter, confi
69
69
  :return: An error string describing the error and where it was found
70
70
  """
71
71
  config_map_dic = config_map_names.get(map_file)
72
-
73
72
  error_string_message = config_map_dic.get(config_parameter)[config_error_no]
74
73
  # presented_message = "File=" + config_file_name, "Parameter=" + config_parameter, "Error=" + error_string_message
75
74
 
@@ -153,6 +152,56 @@ def ver_config(config_map):
153
152
  return ("")
154
153
 
155
154
 
155
+ def ver_config_prep(config_map):
156
+ """
157
+ This function verifies experiment config_prep file
158
+
159
+ Parameters
160
+ ----------
161
+ fname : str
162
+ configuration file name
163
+
164
+ Returns
165
+ -------
166
+ error_message : str
167
+ message describing parameter error or empty string if all parameters are verified
168
+ """
169
+ config_map_file = 'config_prep_error_map_file'
170
+ fname = 'config_prep'
171
+
172
+ config_parameter = 'Excludescans'
173
+ if 'exclude_scans' in config_map:
174
+ if not ver_list_int('exclude_scans', config_map['exclude_scans']):
175
+ config_error = 0
176
+ error_message = get_config_error_message(fname, config_map_file, config_parameter, config_error)
177
+ print(error_message)
178
+ return (error_message)
179
+
180
+ config_parameter = 'MinFiles'
181
+ if 'min_frames' in config_map:
182
+ min_frames = config_map['min_frames']
183
+ if type(min_frames) != int:
184
+ config_error = 0
185
+ error_message = get_config_error_message(fname, config_map_file, config_parameter, config_error)
186
+ print(error_message)
187
+ return (error_message)
188
+
189
+ config_parameter = 'Maxcrop'
190
+ if 'max_crop' in config_map:
191
+ if not ver_list_int('max_crop', config_map['max_crop']):
192
+ config_error = 0
193
+ error_message = get_config_error_message(fname, config_map_file, config_parameter, config_error)
194
+ print(error_message)
195
+ return (error_message)
196
+ elif len(config_map['max_crop']) < 2:
197
+ config_error = 1
198
+ error_message = get_config_error_message(fname, config_map_file, config_parameter, config_error)
199
+ print(error_message)
200
+ return (error_message)
201
+
202
+ return ("")
203
+
204
+
156
205
  def ver_config_rec(config_map):
157
206
  """
158
207
  This function verifies experiment config_rec file
@@ -1027,6 +1076,8 @@ def verify(config_name, conf_map):
1027
1076
  """
1028
1077
  if config_name == 'config':
1029
1078
  return ver_config(conf_map)
1079
+ if config_name == 'config_prep':
1080
+ return ver_config_prep(conf_map)
1030
1081
  elif config_name == 'config_data':
1031
1082
  return ver_config_data(conf_map)
1032
1083
  elif config_name == 'config_rec':
@@ -39,7 +39,7 @@ __all__ = [
39
39
  'pad_center',
40
40
  'read_config',
41
41
  'read_tif',
42
- 'Resize',
42
+ 'resample',
43
43
  'select_central_object',
44
44
  'save_tif',
45
45
  'save_metrics',
@@ -49,13 +49,14 @@ __all__ = [
49
49
  ]
50
50
 
51
51
 
52
- def adjust_dimensions(arr, pads):
52
+ def adjust_dimensions(arr, pads, next_fast_len=True, pkg='np'):
53
53
  """
54
54
  This function adds to or subtracts from each dimension of the array elements defined by pad. If the pad is positive, the array is padded in this dimension. If the pad is negative, the array is cropped.
55
- The dimensions of the new array is then adjusted to be supported by the opencl library.
56
55
 
57
56
  :param arr: ndarray, the array to pad/crop
58
57
  :param pad: list of pad values, a tuple of two int for each dimension. The values in each tuple will be added/subtracted to the sides of array in corresponding dimension.
58
+ :param next_fast_len: bool, whether or not to find the next fast length for each dimension
59
+ :param pkg: package acronym: 'cp' for cupy, 'torch' for torch, 'np' for numpy
59
60
  :return: the padded/cropped and adjusted to opencl compatible format array
60
61
  """
61
62
  # up the dimensions to 3D
@@ -75,8 +76,8 @@ def adjust_dimensions(arr, pads):
75
76
  pad = pads[i]
76
77
  # find a good dimension and find padding
77
78
  temp_dim = old_dims[i] + pad[0] + pad[1]
78
- if temp_dim > 1:
79
- new_dim = get_good_dim(temp_dim)
79
+ if next_fast_len and temp_dim > 1:
80
+ new_dim = get_good_dim(temp_dim, pkg)
80
81
  else:
81
82
  new_dim = temp_dim
82
83
  added = new_dim - temp_dim
@@ -170,28 +171,19 @@ def get_central_object_extent(fp: np.ndarray) -> list:
170
171
  return extent
171
172
 
172
173
 
173
- def get_good_dim(dim):
174
+ def get_good_dim(dim, pkg):
174
175
  """
175
- Calculates the dimension supported by opencl library (i.e. is multiplier of 2, 3, or 5) by increasing dimension and testing iteratively.
176
+ Returns the even dimension that the given package found to be good for fast Fourier transform and not smaller than given dimension. .
176
177
 
177
178
  :param dim: int, initial dimension
178
- :return: a smallest dimension that is supported by the opencl library and greater or equal original dimension
179
- """
180
- def is_correct(x):
181
- sub = x
182
- while sub % 3 == 0:
183
- sub = sub / 3
184
- while sub % 5 == 0:
185
- sub = sub / 5
186
- while sub % 2 == 0:
187
- sub = sub / 2
188
- return sub == 1
189
-
190
- new_dim = dim
191
- if new_dim % 2 == 1:
179
+ :param pck: python package that will be used for reconstruction: 'np' for numpy, 'cp' for cupy, 'torch' for torch.
180
+ :return: a new dimension
181
+ """
182
+ devlib = get_lib(pkg)
183
+ new_dim = devlib.next_fast_len(dim)
184
+ while new_dim % 2 == 1:
192
185
  new_dim += 1
193
- while not is_correct(new_dim):
194
- new_dim += 2
186
+ new_dim = devlib.next_fast_len(new_dim)
195
187
  return new_dim
196
188
 
197
189
 
@@ -355,15 +347,15 @@ def read_tif(filename):
355
347
  return tf.imread(filename.replace(os.sep, '/')).transpose()
356
348
 
357
349
 
358
- def Resize(IN, dim):
350
+ def resample(IN, dim):
359
351
  """
360
352
  Author: Yudong Yao
361
353
 
362
- Resizes to new dimensions and interpolates array.
354
+ Resamples to new dimensions.
363
355
 
364
356
  :param IN: ndarray
365
357
  :param dim: new dim
366
- :return: resized array
358
+ :return: resampled array
367
359
  """
368
360
  ft = np.fft.fftshift(np.fft.fftn(IN)) / np.prod(IN.shape)
369
361
 
@@ -0,0 +1,68 @@
1
+ Metadata-Version: 2.4
2
+ Name: cohere_core
3
+ Version: 4.3
4
+ Summary: cohere reconstruction tools
5
+ Author-email: Barbara Frosik <bfrosik@anl.gov>, Ross Harder <rharder@anl.gov>
6
+ License: Copyright © 2019, UChicago Argonne, LLC
7
+ All Rights Reserved
8
+ Software Name: CDI Reconstruction (cohere)
9
+ By: Argonne National Laboratory
10
+ OPEN SOURCE LICENSE
11
+
12
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
13
+
14
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
15
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
16
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
17
+
18
+
19
+ ******************************************************************************************************
20
+ DISCLAIMER
21
+
22
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ ***************************************************************************************************
24
+ Project-URL: Homepage, https://github.com/AdvancedPhotonSource/cohere
25
+ Classifier: Programming Language :: Python :: 3
26
+ Classifier: Operating System :: OS Independent
27
+ Requires-Python: >=3.11
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: numpy<2
31
+ Requires-Dist: scikit-learn
32
+ Requires-Dist: tifffile
33
+ Requires-Dist: psutil
34
+ Requires-Dist: tqdm
35
+ Requires-Dist: matplotlib
36
+ Requires-Dist: scipy==1.14.1
37
+ Requires-Dist: sphinx
38
+ Requires-Dist: sphinx-pyproject
39
+ Dynamic: license-file
40
+
41
+ [![Documentation Status](https://readthedocs.org/projects/cohere/badge/?version=latest)](http://cohere.readthedocs.io/en/latest/?badge=latest)
42
+
43
+ Project home page: [https://cohere.readthedocs.io/](https://cohere.readthedocs.io/)
44
+
45
+ The cohere package provides tools for reconstruction of image of a nanoscale structures from data obtained using Bragg Coherent Diffraction Imaging technique.
46
+
47
+ The reconstruction has very good performance, in particular when utilizing GPU. User has a choice to run on cpu or GPU by selecting Python library. Supported libraries: numpy, cupy, torch. The libraries cupy or torch are installed by user. The solution offers concurrent processing for fast reconstruction of multiple starting points.
48
+
49
+ Important features:
50
+ - Genetic Algorithm (GA) - powerful feature that can deliver good reconstruction result by using GA principles. Based on research "Three-dimensional imaging of dislocation propagation during crystal growth and dissolution, Supplementary Information" by Jesse N. Clark et. al.
51
+ - Artificial Intelligence initial guess for reconstruction - uses AI to find reconstructed object that is subsequently used as input to further reconstruction. The work is built on the research by Yudong Yao, et. al: "AutoPhaseNN: Unsupervised Physics-aware Deep Learning of 3D Nanoscale Bragg Coherent Diffraction Imaging".
52
+ A trained model must be provided when using this feature. User can download trained model by clicking the following link
53
+ https://g-29c18.fd635.8443.data.globus.org/cherukara/cohere-trained_model.hdf5
54
+ - AutoAlien1 algorithm - a method to remove aliens by automatic means during standard data preprocessing. Based on work "Removal of spurious data in Bragg coherent diffraction imaging: an algorithm for automated data preprocessing" by Kenley Pelzer et. al.
55
+ - Multipeak - support for an experiment where data is collected for adjacent peaks simultaneously and reconstructing this multipeak scenario. The research is in experimental stage. Implemented by Jason (Nick) Porter.
56
+ - chrono CDI - allows the oversampling requirement at each time step to be reduced. The increased time resolution will allow imaging of faster dynamics and of radiation-dose-sensitive samples. Based on work "Coherent diffractive imaging of time-evolving samples with improved temporal resolution" by A. Ulvestat et. al.
57
+
58
+ The tools offers a full solution for reading beamline specific experiment data, formatting the data, reconstruction, and visualization. Each of the components can be utilized independently. The project was implemented for the Advanced Photon Source beamline 34-ID-C.
59
+
60
+ Author(s)
61
+
62
+ Barbara Frosik - Principal Software Engineer at Argonne National Laboratory
63
+
64
+ Ross Harder - Scientist at Argonne National Laboratory
65
+
66
+ License
67
+
68
+ Copyright (c) UChicago Argonne, LLC. All rights reserved. See LICENSE file.
@@ -0,0 +1,29 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/cohere_core.egg-info/PKG-INFO
5
+ src/cohere_core.egg-info/SOURCES.txt
6
+ src/cohere_core.egg-info/dependency_links.txt
7
+ src/cohere_core.egg-info/requires.txt
8
+ src/cohere_core.egg-info/top_level.txt
9
+ src/cohere_core/controller/AI_guess.py
10
+ src/cohere_core/controller/__init__.py
11
+ src/cohere_core/controller/features.py
12
+ src/cohere_core/controller/op_flow.py
13
+ src/cohere_core/controller/phasing.py
14
+ src/cohere_core/data/__init__.py
15
+ src/cohere_core/data/alien_tools.py
16
+ src/cohere_core/data/standard_preprocess.py
17
+ src/cohere_core/lib/__init__.py
18
+ src/cohere_core/lib/aflib.py
19
+ src/cohere_core/lib/check_libs.py
20
+ src/cohere_core/lib/cohlib.py
21
+ src/cohere_core/lib/cplib.py
22
+ src/cohere_core/lib/nplib.py
23
+ src/cohere_core/lib/torchlib.py
24
+ src/cohere_core/utilities/__init__.py
25
+ src/cohere_core/utilities/config_errors_dict.py
26
+ src/cohere_core/utilities/config_verifier.py
27
+ src/cohere_core/utilities/dvc_utils.py
28
+ src/cohere_core/utilities/ga_utils.py
29
+ src/cohere_core/utilities/utils.py
@@ -4,3 +4,6 @@ tifffile
4
4
  psutil
5
5
  tqdm
6
6
  matplotlib
7
+ scipy==1.14.1
8
+ sphinx
9
+ sphinx-pyproject
@@ -1,22 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: cohere_core
3
- Version: 4.2.2
4
- Home-page: https://github.com/advancedPhotonSource/cohere
5
- Author: Barbara Frosik, Ross Harder
6
- Author-email: bfrosik@anl.gov
7
- Classifier: Intended Audience :: Science/Research
8
- Classifier: Programming Language :: Python :: 3.10
9
- Classifier: Programming Language :: Python :: 3.11
10
- License-File: LICENSE
11
- Requires-Dist: numpy<2
12
- Requires-Dist: scikit-learn
13
- Requires-Dist: tifffile
14
- Requires-Dist: psutil
15
- Requires-Dist: tqdm
16
- Requires-Dist: matplotlib
17
- Dynamic: author
18
- Dynamic: author-email
19
- Dynamic: classifier
20
- Dynamic: home-page
21
- Dynamic: license-file
22
- Dynamic: requires-dist
@@ -1 +0,0 @@
1
-
@@ -1,22 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: cohere_core
3
- Version: 4.2.2
4
- Home-page: https://github.com/advancedPhotonSource/cohere
5
- Author: Barbara Frosik, Ross Harder
6
- Author-email: bfrosik@anl.gov
7
- Classifier: Intended Audience :: Science/Research
8
- Classifier: Programming Language :: Python :: 3.10
9
- Classifier: Programming Language :: Python :: 3.11
10
- License-File: LICENSE
11
- Requires-Dist: numpy<2
12
- Requires-Dist: scikit-learn
13
- Requires-Dist: tifffile
14
- Requires-Dist: psutil
15
- Requires-Dist: tqdm
16
- Requires-Dist: matplotlib
17
- Dynamic: author
18
- Dynamic: author-email
19
- Dynamic: classifier
20
- Dynamic: home-page
21
- Dynamic: license-file
22
- Dynamic: requires-dist
@@ -1,30 +0,0 @@
1
- LICENSE
2
- README.md
3
- setup.py
4
- cohere_core/__init__.py
5
- cohere_core.egg-info/PKG-INFO
6
- cohere_core.egg-info/SOURCES.txt
7
- cohere_core.egg-info/dependency_links.txt
8
- cohere_core.egg-info/requires.txt
9
- cohere_core.egg-info/top_level.txt
10
- cohere_core/controller/AI_guess.py
11
- cohere_core/controller/__init__.py
12
- cohere_core/controller/features.py
13
- cohere_core/controller/op_flow.py
14
- cohere_core/controller/phasing.py
15
- cohere_core/data/__init__.py
16
- cohere_core/data/alien_tools.py
17
- cohere_core/data/standard_preprocess.py
18
- cohere_core/lib/__init__.py
19
- cohere_core/lib/aflib.py
20
- cohere_core/lib/check_libs.py
21
- cohere_core/lib/cohlib.py
22
- cohere_core/lib/cplib.py
23
- cohere_core/lib/nplib.py
24
- cohere_core/lib/torchlib.py
25
- cohere_core/utilities/__init__.py
26
- cohere_core/utilities/config_errors_dict.py
27
- cohere_core/utilities/config_verifier.py
28
- cohere_core/utilities/dvc_utils.py
29
- cohere_core/utilities/ga_utils.py
30
- cohere_core/utilities/utils.py
@@ -1,24 +0,0 @@
1
- import setuptools
2
-
3
- setuptools.setup(
4
- name='cohere_core',
5
- author='Barbara Frosik, Ross Harder',
6
- author_email='bfrosik@anl.gov',
7
- url='https://github.com/advancedPhotonSource/cohere',
8
- version='4.2.2',
9
- packages=setuptools.find_packages(),
10
- install_requires=[
11
- 'numpy<2',
12
- 'scikit-learn',
13
- 'tifffile',
14
- 'psutil',
15
- 'tqdm',
16
- 'matplotlib'
17
- ],
18
- classifiers=[
19
- 'Intended Audience :: Science/Research',
20
- 'Programming Language :: Python :: 3.10',
21
- 'Programming Language :: Python :: 3.11',
22
- ],
23
- )
24
-
File without changes
File without changes