Closed Yugal0 closed 1 year ago
- TauFactor version: 1.0.0
- Python version: 3.10.6
- Operating System: Lubuntu 22
Description
I have seen friends using taufactor on MATLAB, there we need to provide a set of cross-section images to it, and we can get the tortuosity. I wanted to do the same, using this package in python, but seems it takes only one image ??. I have around 200 cross-section images of a porous structure available with me, need to find the tortuosity. What should I do? The introduction in documentation seems not helpful for me, maybe I am missing some understanding.
What I Did
I tried to running this code from the (official documentation) gave it a png file (this is the image ).( will it need jpg?)
import taufactor as tau import tifffile # load segmented image img = tifffile.imread('~/Downloads/tau1/image15.png') s = tau.Solver(img) s.solve() # tau s.tau # D_eff s.D_eff
The error that it gives on executing the above python code
Traceback (most recent call last): File "/home/yugal/.local/lib/python3.10/site-packages/tifffile/tifffile.py", line 4011, in __init__ byteorder = {b'II': '<', b'MM': '>', b'EP': '<'}[header[:2]] KeyError: b'\x89P' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/yugal/Documents/Codes/tau1.py", line 5, in <module> img = tifffile.imread('/home/yugal/Downloads/tau1/image15.png') File "/home/yugal/.local/lib/python3.10/site-packages/tifffile/tifffile.py", line 1062, in imread with TiffFile( File "/home/yugal/.local/lib/python3.10/site-packages/tifffile/tifffile.py", line 4013, in __init__ raise TiffFileError(f'not a TIFF file {header!r}') tifffile.tifffile.TiffFileError: not a TIFF file b'\x89PNG'
Oh its asking for tiff image file, I converted my png to tiff new tiff image
/home/yugal/.local/lib/python3.10/site-packages/taufactor/taufactor.py:40: UserWarning: CUDA not available, defaulting device to cpu. To avoid this warning, explicitly set the device when initialising the solver with device=torch.device('cpu')
warnings.warn(
Traceback (most recent call last):
File "/home/yugal/Documents/Codes/tau1.py", line 9, in <module>
s = tau.Solver(img)
File "/home/yugal/.local/lib/python3.10/site-packages/taufactor/taufactor.py", line 47, in __init__
raise ValueError(
ValueError: Input image must only contain 0s and 1s. Your image must be segmented to use this tool. If your image has been segmented, ensure your labels are 0 for non-conductive and 1 for conductive phase. Your image has the following labels: [ 0. 1. 4. 8. 12. 16. 20. 24. 28. 32. 36. 40. 44. 48.
52. 56. 60. 63. 64. 65. 68. 72. 76. 80. 84. 88. 92. 96.
100. 104. 108. 112. 116. 120. 124. 127. 128. 131. 135. 139. 143. 147.
151. 155. 159. 163. 167. 171. 175. 179. 183. 187. 191. 195. 199. 203.
207. 211. 215. 219. 223. 227. 231. 235. 239. 243. 247. 251. 255.]. If you have more than one conductive phase, use the multi-phase solver.
Seems it has be exactly black and white (0s and 1s), BUT STILL the main doubt remains will it take only one image, (hence only useful on 2D !?) How to I find tortuosity of a 3D structure?
- TauFactor version: 1.0.0
- Python version: 3.10.6
- Operating System: Lubuntu 22
Description
I have seen friends using taufactor on MATLAB, there we need to provide a set of cross-section images to it, and we can get the tortuosity. I wanted to do the same, using this package in python, but seems it takes only one image ??. I have around 200 cross-section images of a porous structure available with me, need to find the tortuosity. What should I do? The introduction in documentation seems not helpful for me, maybe I am missing some understanding.
What I Did
I tried to running this code from the (official documentation) gave it a png file (this is the image ).( will it need jpg?)
import taufactor as tau import tifffile # load segmented image img = tifffile.imread('~/Downloads/tau1/image15.png') s = tau.Solver(img) s.solve() # tau s.tau # D_eff s.D_eff
The error that it gives on executing the above python code
Traceback (most recent call last): File "/home/yugal/.local/lib/python3.10/site-packages/tifffile/tifffile.py", line 4011, in __init__ byteorder = {b'II': '<', b'MM': '>', b'EP': '<'}[header[:2]] KeyError: b'\x89P' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/yugal/Documents/Codes/tau1.py", line 5, in <module> img = tifffile.imread('/home/yugal/Downloads/tau1/image15.png') File "/home/yugal/.local/lib/python3.10/site-packages/tifffile/tifffile.py", line 1062, in imread with TiffFile( File "/home/yugal/.local/lib/python3.10/site-packages/tifffile/tifffile.py", line 4013, in __init__ raise TiffFileError(f'not a TIFF file {header!r}') tifffile.tifffile.TiffFileError: not a TIFF file b'\x89PNG'
Oh its asking for tiff image file, I converted my png to tiff new tiff image
/home/yugal/.local/lib/python3.10/site-packages/taufactor/taufactor.py:40: UserWarning: CUDA not available, defaulting device to cpu. To avoid this warning, explicitly set the device when initialising the solver with device=torch.device('cpu') warnings.warn( Traceback (most recent call last): File "/home/yugal/Documents/Codes/tau1.py", line 9, in <module> s = tau.Solver(img) File "/home/yugal/.local/lib/python3.10/site-packages/taufactor/taufactor.py", line 47, in __init__ raise ValueError( ValueError: Input image must only contain 0s and 1s. Your image must be segmented to use this tool. If your image has been segmented, ensure your labels are 0 for non-conductive and 1 for conductive phase. Your image has the following labels: [ 0. 1. 4. 8. 12. 16. 20. 24. 28. 32. 36. 40. 44. 48. 52. 56. 60. 63. 64. 65. 68. 72. 76. 80. 84. 88. 92. 96. 100. 104. 108. 112. 116. 120. 124. 127. 128. 131. 135. 139. 143. 147. 151. 155. 159. 163. 167. 171. 175. 179. 183. 187. 191. 195. 199. 203. 207. 211. 215. 219. 223. 227. 231. 235. 239. 243. 247. 251. 255.]. If you have more than one conductive phase, use the multi-phase solver.
Seems it has be exactly black and white (0s and 1s), BUT STILL the main doubt remains will it take only one image, (hence only useful on 2D !?) How to I find tortuosity of a 3D structure?
I tried using the 500x500...tiff file provided on github, but now its saying, I need to segment the image..
/home/yugal/.local/lib/python3.10/site-packages/taufactor/taufactor.py:40: UserWarning: CUDA not available, defaulting device to cpu. To avoid this warning, explicitly set the device when initialising the solver with device=torch.device('cpu')
warnings.warn(
Traceback (most recent call last):
File "/home/yugal/Documents/Codes/tau1.py", line 9, in <module>
s = tau.Solver(img)
File "/home/yugal/.local/lib/python3.10/site-packages/taufactor/taufactor.py", line 47, in __init__
raise ValueError(
ValueError: Input image must only contain 0s and 1s. Your image must be segmented to use this tool. If your image has been segmented, ensure your labels are 0 for non-conductive and 1 for conductive phase. Your image has the following labels: [ 0. 255.]. If you have more than one conductive phase, use the multi-phase solver.
Please explain. Other Question--> I suppose this single tiff file itself contains multiple crosssection images, is it?
Thank you for raising this issue. We are currently working on improving our documentation and adding some example scripts. You can follow that progress here #75. We have added a line to the examples explaining that to load in .png
images you must use plt.imread('filename.png')
. You must then concatenate your 2D images into a 3D volume using np.concatenate
. Then you must process your volume to ensure it contains 0s (non-conductive) and 1s (conductive) only. Our example.ipynb
will walk through an example of some of the common processing steps.
A tiff file can store 2D or 3D images, the example we have is a 3D image that contains multiple slices stacked together.
Description
I have seen friends using taufactor on MATLAB, there we need to provide a set of cross-section images to it, and we can get the tortuosity. I wanted to do the same, using this package in python, but seems it takes only one image ??. I have around 200 cross-section images of a porous structure available with me, need to find the tortuosity. What should I do? The introduction in documentation seems not helpful for me, maybe I am missing some understanding.
What I Did
I tried to running this code from the (official documentation) gave it a png file (this is the image ).( will it need jpg?)
The error that it gives on executing the above python code