我有1000帧的tiff图像堆栈,在这些图像堆栈中,我试图跟踪布朗运动中扩散的粒子。因此,我使用trackpy进行粒子跟踪:导入tiff堆栈,定位特征(粒子),然后绘制它们的轨迹。我使用了以下代码(来自trackpy演练页面):
import pims
import trackpy as tp
frames = pims.open("image.tif")
f = tp.locate(frames[0], 9, invert=False)但是最后一行(tp.locate)提供了一个回溯:
AttributeError Traceback (most recent call last)
<ipython-input-78-0fbce96715a7> in <module>
----> 1 f = tp.locate(frames[0], 9, invert=False)
~\anaconda3\lib\site-packages\slicerator\__init__.py in __getitem__(self, i)
186 indices, new_length = key_to_indices(i, len(self))
187 if new_length is None:
--> 188 return self._get(indices)
189 else:
190 return cls(self, indices, new_length, propagate_attrs)
~\anaconda3\lib\site-packages\pims\base_frames.py in __getitem__(self, key)
96 """__getitem__ is handled by Slicerator. In all pims readers, the data
97 returning function is get_frame."""
---> 98 return self.get_frame(key)
99
100 def __iter__(self):
~\anaconda3\lib\site-packages\pims\tiff_stack.py in get_frame(self, j)
119 t = self._tiff[j]
120 data = t.asarray()
--> 121 return Frame(data, frame_no=j, metadata=self._read_metadata(t))
122
123 def _read_metadata(self, tiff):
~\anaconda3\lib\site-packages\pims\tiff_stack.py in _read_metadata(self, tiff)
124 """Read metadata for current frame and return as dict"""
125 # tags are only stored as a TiffTags object on the parent TiffPage now
--> 126 tags = tiff.keyframe.tags
127 md = {}
128 for name in ('ImageDescription', 'image_description'):
~\anaconda3\lib\site-packages\skimage\external\tifffile\tifffile.py in __getattr__(self, name)
2752 setattr(self, name, value)
2753 return value
-> 2754 raise AttributeError(name)
2755
2756 def __str__(self):
AttributeError: keyframe我哪里错了?我还试着使用
imageio.imread("image.tif")导入图像,然后使用
f=tp.locate(frames[0], 9, invert=False)来定位粒子。但是这个函数的输出应该是x和y坐标的数据,如下所示

而我得到的只是x轴:

发布于 2021-04-13 04:49:11
我刚刚遇到了同样的问题,并通过在我的anaconda提示符中输入"conda install pims“来解决它。我以前做过"pip install pims“,我认为那把它搞砸了。
https://stackoverflow.com/questions/64296957
复制相似问题