NSLS-II-CSX / csxtools

Useful python tools for CSX (23-ID)
http://nsls-ii-csx.github.io/csxtools
Other
4 stars 13 forks source link

get_fastccd_images() does not work with roi given as input #73

Open tankonst opened 3 years ago

tankonst commented 3 years ago

When roi coordinates are passed to
get_fastccd_images(h, (bgnd8, bgnd2, bgnd1), flat=ff, tag='fccd_image', roi = (0, 0, 50, 50))
the function returns an AttributeError.

AttributeError Traceback (most recent call last)

in /opt/conda_envs/analysis-2019-3.0-ml/lib/python3.7/site-packages/csxtools/utils.py in get_fastccd_images(light_header, dark_headers, flat, gain, tag, roi) 92 93 tt = ttime.time() ---> 94 b = get_images_to_3D(bgnd_events, dtype=np.uint16) 95 logger.info("Image conversion took %.3f seconds", 96 ttime.time() - tt) /opt/conda_envs/analysis-2019-3.0-ml/lib/python3.7/site-packages/csxtools/utils.py in get_images_to_3D(images, dtype) 173 174 """ --> 175 im = np.vstack([np.asarray(im, dtype=dtype) for im in images]) 176 return im 177 /opt/conda_envs/analysis-2019-3.0-ml/lib/python3.7/site-packages/csxtools/utils.py in (.0) 173 174 """ --> 175 im = np.vstack([np.asarray(im, dtype=dtype) for im in images]) 176 return im 177 /opt/conda_envs/analysis-2019-3.0-ml/lib/python3.7/site-packages/slicerator/__init__.py in (.0) 472 473 def __iter__(self): --> 474 return (self._get(i) for i in range(len(self))) 475 476 def __getitem__(self, i): /opt/conda_envs/analysis-2019-3.0-ml/lib/python3.7/site-packages/slicerator/__init__.py in _get(self, key) 459 # We need to copy here: else any _proc_func that acts inplace would 460 # change the ancestor value. --> 461 return self._proc_func(*(copy(a[key]) for a in self._ancestors)) 462 463 def __repr__(self): /opt/conda_envs/analysis-2019-3.0-ml/lib/python3.7/site-packages/slicerator/__init__.py in proc_func(*x) 683 if all_pipe: 684 def proc_func(*x): --> 685 return func(*(x + args), **kwargs) 686 687 return Pipeline(proc_func, *ancestors) /opt/conda_envs/analysis-2019-3.0-ml/lib/python3.7/site-packages/csxtools/utils.py in _crop_images(image, roi) 207 @pipeline 208 def _crop_images(image, roi): --> 209 return _crop(image, roi) 210 211 /opt/conda_envs/analysis-2019-3.0-ml/lib/python3.7/site-packages/csxtools/utils.py in _crop(image, roi) 214 # Assuming ROI is specified in the "rotated" (correct) orientation 215 roi = [image_shape[-2]-roi[3], roi[0], image_shape[-1]-roi[1], roi[2]] --> 216 return image.T[roi[1]:roi[3], roi[0]:roi[2]].T 217 218 AttributeError: 'ImageStack' object has no attribute 'T'
ambarb commented 3 years ago

@tankonst thanks for making it clear that this is an issue. see https://github.com/NSLS-II-CSX/csxtools/issues/68 for more discussion. I think we agreed first with DAMA that we would wait until the data handler was fixed for data broker catalogs worked. It does now. The next step is to implement catalogs instead of get_images.

It is probably worth planning on how were are going to do this and also roll in metadata from image concatenation (not associated with the roi functionality in this issue, but with the fccd settings to remove overscan and adjust for framestore versus non-framestore).

I think it is worth doing these first so that we only have to deal with this issue here one more time, instead of two times. Does that make sense, or do you need this functionality for the issue cited here now?

@danielballan @leofang I tag you because I know you also have interests at play.

tankonst commented 3 years ago

@ambarb yes, it makes sense. I was just thinking that it probably should be faster for for users to load only part of the image (aka 'area1' in the current notebook) for analysis of different scans in the same experiment. But this is not a top priority. I am closing it then since the issue was discussed in #68 (sorry, I haven't noticed before posting).

ambarb commented 3 years ago

@tankonst I don't mind leaving it open. It makes it clear to anyone else new to the repo. The discussion is reference, but hard to trek through.